Beispiel #1
0
 public void SaveToFile()
 {
     if (Filepath != null && !string.IsNullOrEmpty(Filepath))
     {
         string[] lines = contentBuffer.ToArray();
         File.WriteAllLines(Filepath, lines, FileEncoding);
         FileIsSaved = true;
     }
     else
     {
         // Ask where to save the file
         SaveFileDialog sfd = new SaveFileDialog();
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             Filepath = sfd.FileName;
             Filename = ParentWindow.ParseFileName(sfd.FileName);
             SaveToFile(); // Save with the new values
             SyntaxHighlighting.LanguageSyntax prevLanSyntax = LanguageSyntax;
             LanguageSyntax = DetectLanguageSyntax();
             if (LanguageSyntax != prevLanSyntax)
             {
                 Parent.Draw();
                 DrawAllLines();
             }
         }
         else
         {
             _fileIsSaved = false;
         }
     }
 }
Beispiel #2
0
        public void NewFileEditor(string filename, string filepath, SyntaxHighlighting.LanguageSyntax language)
        {
            Editor newFile = new Editor(filename, filepath, language);

            newFile.AddNewLine();
            newFile.FileIsSaved = false;
            AddEditor(newFile, true);
        }
Beispiel #3
0
 /// <summary>
 /// This class is meant to manage file
 /// editing, syntax highlighting, code completion,
 /// line indexes, text typing/moving around in file/console,
 /// mid level input handeling (onSave, onDiscard events etc...),
 /// etc...
 /// </summary>
 public Editor(string filename, string filepath, SyntaxHighlighting.LanguageSyntax languageSyntax)
 {
     ID             = (new Random()).Next();
     Filename       = filename;
     Filepath       = filepath;
     LanguageSyntax = languageSyntax;
     contentBuffer  = new List <string>();
     FileEncoding   = languageSyntax.PreferredEncoding;
     FileIsSaved    = true;
     CursorLeft     = 0;
     CursorTop      = 0;
 }