Exemplo n.º 1
0
 /// <summary>
 /// Applies the state object to a scintilla control
 /// </summary>
 private static void ApplyStateObject(ScintillaControl sci, StateObject so, Boolean restorePosition)
 {
     if (so.LineCount != sci.LineCount) return;
     sci.Refresh(); // Update the scintilla control state
     for (Int32 i = 0; i < so.FoldedLines.Count; i++)
     {
         Int32 foldedLine = so.FoldedLines[i];
         sci.ToggleFold(foldedLine);
     }
     if (so.BookmarkedLines != null)
     {
         for (Int32 i = 0; i < so.BookmarkedLines.Count; i++)
         {
             Int32 bookmarkedLine = so.BookmarkedLines[i];
             sci.MarkerAdd(bookmarkedLine, 0);
         }
         sci.Refresh(); // Update again
     }
     if (restorePosition)
     {
         sci.FirstVisibleLine = so.LineScroll;
         Int32 line = sci.LineFromPosition(so.Position);
         sci.SetSel(so.Position, so.Position);
         sci.EnsureVisible(line);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Changes the current document's language
 /// </summary>
 public static void ChangeSyntax(String lang, ScintillaControl sci)
 {
     sci.StyleClearAll();
     sci.StyleResetDefault();
     sci.ClearDocumentStyle();
     sci.ConfigurationLanguage = lang;
     sci.Colourise(0, -1);
     sci.Refresh();
     ButtonManager.UpdateFlaggedButtons();
     Globals.MainForm.OnSyntaxChange(lang);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates editor Globals.Settings to the specified ScintillaControl
 /// </summary>
 public static void ApplySciSettings(ScintillaControl sci)
 {
     try
     {
         sci.CaretPeriod = Globals.Settings.CaretPeriod;
         sci.CaretWidth = Globals.Settings.CaretWidth;
         sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)Globals.Settings.EOLMode);
         sci.IsBraceMatching = Globals.Settings.BraceMatchingEnabled;
         sci.UseHighlightGuides = !Globals.Settings.HighlightGuide;
         sci.Indent = Globals.Settings.IndentSize;
         sci.SmartIndentType = Globals.Settings.SmartIndentType;
         sci.IsBackSpaceUnIndents = Globals.Settings.BackSpaceUnIndents;
         sci.IsCaretLineVisible = Globals.Settings.CaretLineVisible;
         sci.IsIndentationGuides = Globals.Settings.ViewIndentationGuides;
         sci.IsTabIndents = Globals.Settings.TabIndents;
         sci.IsUseTabs = Globals.Settings.UseTabs;
         sci.IsViewEOL = Globals.Settings.ViewEOL;
         sci.ScrollWidth = Globals.Settings.ScrollWidth;
         sci.TabWidth = Globals.Settings.TabWidth;
         sci.ViewWS = Convert.ToInt32(Globals.Settings.ViewWhitespace);
         sci.WrapMode = Convert.ToInt32(Globals.Settings.WrapText);
         sci.SetProperty("fold", Convert.ToInt32(Globals.Settings.UseFolding).ToString());
         sci.SetProperty("fold.comment", Convert.ToInt32(Globals.Settings.FoldComment).ToString());
         sci.SetProperty("fold.compact", Convert.ToInt32(Globals.Settings.FoldCompact).ToString());
         sci.SetProperty("fold.preprocessor", Convert.ToInt32(Globals.Settings.FoldPreprocessor).ToString());
         sci.SetProperty("fold.at.else", Convert.ToInt32(Globals.Settings.FoldAtElse).ToString());
         sci.SetProperty("fold.html", Convert.ToInt32(Globals.Settings.FoldHtml).ToString());
         sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
         /** 
         * Set correct line number margin width
         */
         Boolean viewLineNumbers = Globals.Settings.ViewLineNumbers;
         if (viewLineNumbers) sci.SetMarginWidthN(1, 31);
         else sci.SetMarginWidthN(1, 0);
         /**
         * Set correct bookmark margin width
         */
         Boolean viewBookmarks = Globals.Settings.ViewBookmarks;
         if (viewBookmarks) sci.SetMarginWidthN(0, 14);
         else sci.SetMarginWidthN(0, 0);
         /**
         * Set correct folding margin width
         */
         Boolean useFolding = Globals.Settings.UseFolding;
         if (!useFolding && !viewBookmarks && !viewLineNumbers) sci.SetMarginWidthN(2, 0);
         else if (useFolding) sci.SetMarginWidthN(2, 15);
         else sci.SetMarginWidthN(2, 2);
         /**
         * Adjust the print margin
         */
         sci.EdgeColumn = Globals.Settings.PrintMarginColumn;
         if (sci.EdgeColumn > 0) sci.EdgeMode = 1;
         else sci.EdgeMode = 0;
         /**
         * Add missing ignored keys
         */
         Int32 count = Globals.MainForm.IgnoredKeys.Count;
         for (Int32 i = 0; i < count; i++)
         {
             Keys keys = (Keys)Globals.MainForm.IgnoredKeys[i];
             if (!sci.ContainsIgnoredKeys(keys))
             {
                 sci.AddIgnoredKeys(keys);
             }
         }
         String lang = sci.ConfigurationLanguage;
         sci.ConfigurationLanguage = lang;
         sci.Colourise(0, -1);
         sci.Refresh();
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
Exemplo n.º 4
0
 public static void ApplySciSettings(ScintillaControl sci, Boolean hardUpdate)
 {
     try
     {
         sci.CaretPeriod = Globals.Settings.CaretPeriod;
         sci.CaretWidth = Globals.Settings.CaretWidth;
         sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)Globals.Settings.EOLMode);
         sci.IsBraceMatching = Globals.Settings.BraceMatchingEnabled;
         sci.UseHighlightGuides = !Globals.Settings.HighlightGuide;
         sci.Indent = Globals.Settings.IndentSize;
         sci.SmartIndentType = Globals.Settings.SmartIndentType;
         sci.IsBackSpaceUnIndents = Globals.Settings.BackSpaceUnIndents;
         sci.IsCaretLineVisible = Globals.Settings.CaretLineVisible;
         sci.IsIndentationGuides = Globals.Settings.ViewIndentationGuides;
         sci.IndentView = Globals.Settings.IndentView;
         sci.IsTabIndents = Globals.Settings.TabIndents;
         sci.IsUseTabs = Globals.Settings.UseTabs;
         sci.IsViewEOL = Globals.Settings.ViewEOL;
         sci.ScrollWidth = Globals.Settings.ScrollWidth;
         sci.TabWidth = Globals.Settings.TabWidth;
         sci.ViewWS = Convert.ToInt32(Globals.Settings.ViewWhitespace);
         sci.WrapMode = Convert.ToInt32(Globals.Settings.WrapText);
         sci.SetProperty("fold", Convert.ToInt32(Globals.Settings.UseFolding).ToString());
         sci.SetProperty("fold.comment", Convert.ToInt32(Globals.Settings.FoldComment).ToString());
         sci.SetProperty("fold.compact", Convert.ToInt32(Globals.Settings.FoldCompact).ToString());
         sci.SetProperty("fold.preprocessor", Convert.ToInt32(Globals.Settings.FoldPreprocessor).ToString());
         sci.SetProperty("fold.at.else", Convert.ToInt32(Globals.Settings.FoldAtElse).ToString());
         sci.SetProperty("fold.html", Convert.ToInt32(Globals.Settings.FoldHtml).ToString());
         sci.SetProperty("lexer.cpp.track.preprocessor", "0");
         sci.SetVirtualSpaceOptions((Int32)Globals.Settings.VirtualSpaceMode);
         sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
         /**
         * Set if themes should colorize the first margin
         */
         Language language = SciConfig.GetLanguage(sci.ConfigurationLanguage);
         if (language != null && language.editorstyle != null)
         {
             Boolean colorizeMarkerBack = language.editorstyle.ColorizeMarkerBack;
             if (colorizeMarkerBack) sci.SetMarginTypeN(0, (Int32)MarginType.Fore);
             else sci.SetMarginTypeN(0, (Int32)MarginType.Symbol);
         }
         /**
         * Set correct line number margin width
         */
         Boolean viewLineNumbers = Globals.Settings.ViewLineNumbers;
         if (viewLineNumbers) sci.SetMarginWidthN(1, ScaleArea(sci, 36));
         else sci.SetMarginWidthN(1, 0);
         /**
         * Set correct bookmark margin width
         */
         Boolean viewBookmarks = Globals.Settings.ViewBookmarks;
         if (viewBookmarks) sci.SetMarginWidthN(0, ScaleArea(sci, 14));
         else sci.SetMarginWidthN(0, 0);
         /**
         * Set correct folding margin width
         */
         Boolean useFolding = Globals.Settings.UseFolding;
         if (!useFolding && !viewBookmarks && !viewLineNumbers) sci.SetMarginWidthN(2, 0);
         else if (useFolding) sci.SetMarginWidthN(2, ScaleArea(sci, 15));
         else sci.SetMarginWidthN(2, ScaleArea(sci, 2));
         /**
         * Adjust the print margin
         */
         sci.EdgeColumn = Globals.Settings.PrintMarginColumn;
         if (sci.EdgeColumn > 0) sci.EdgeMode = 1;
         else sci.EdgeMode = 0;
         /**
         * Add missing ignored keys
         */
         foreach (Keys keys in ShortcutManager.AllShortcuts)
         {
             if (keys != Keys.None && !sci.ContainsIgnoredKeys(keys))
             {
                 sci.AddIgnoredKeys(keys);
             }
         }
         if (hardUpdate)
         {
             String lang = sci.ConfigurationLanguage;
             sci.ConfigurationLanguage = lang;
         }
         sci.Colourise(0, -1);
         sci.Refresh();
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }