/// <summary> /// Gets the comment start string /// </summary> public static String GetCommentStart(String lang) { Language obj = SciConfig.GetLanguage(lang); if (obj.commentstart != null) { return(obj.commentstart); } return(String.Empty); }
/// <summary> /// Gets the comment end string /// </summary> public static String GetCommentEnd(String lang) { Language obj = SciConfig.GetLanguage(lang); if (obj.commentend != null) { return(obj.commentend); } return(String.Empty); }
/// <summary> /// Gets the line comment string /// </summary> public static String GetLineComment(String lang) { Language obj = SciConfig.GetLanguage(lang); if (obj.linecomment != null) { return(obj.linecomment); } return(String.Empty); }
/// <summary> /// Scale the control area based on font size and DPI /// </summary> private static Int32 ScaleArea(ScintillaControl sci, Int32 size) { Int32 value = ScaleHelper.Scale(size); Language lang = SciConfig.GetLanguage(sci.ConfigurationLanguage); if (lang != null && lang.usestyles != null && lang.usestyles.Length > 0) { // Only larger fonts need scaling... if (lang.usestyles[0].FontSize < 11) { return(value); } Double multi = lang.usestyles[0].FontSize / 9f; Double adjusted = Convert.ToDouble(value) * (multi < 1 ? 1 : multi); value = Convert.ToInt32(Math.Floor(adjusted)); } return(value); }
public static void ApplySciSettings(ScintillaControl sci, Boolean hardUpdate) { try { ISettings settings = PluginBase.Settings; sci.CaretPeriod = settings.CaretPeriod; sci.CaretWidth = settings.CaretWidth; sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)settings.EOLMode); sci.IsBraceMatching = settings.BraceMatchingEnabled; sci.UseHighlightGuides = !settings.HighlightGuide; sci.Indent = settings.IndentSize; sci.SmartIndentType = settings.SmartIndentType; sci.IsBackSpaceUnIndents = settings.BackSpaceUnIndents; sci.IsCaretLineVisible = settings.CaretLineVisible; sci.IsIndentationGuides = settings.ViewIndentationGuides; sci.IndentView = settings.IndentView; sci.IsTabIndents = settings.TabIndents; sci.IsUseTabs = settings.UseTabs; sci.IsViewEOL = settings.ViewEOL; sci.ScrollWidth = Math.Max(settings.ScrollWidth, 1); sci.ScrollWidthTracking = settings.ScrollWidth == 0 || settings.ScrollWidth == 3000; sci.TabWidth = settings.TabWidth; sci.ViewWS = Convert.ToInt32(settings.ViewWhitespace); sci.WrapMode = Convert.ToInt32(settings.WrapText); sci.SetProperty("fold", Convert.ToInt32(settings.UseFolding).ToString()); sci.SetProperty("fold.comment", Convert.ToInt32(settings.FoldComment).ToString()); sci.SetProperty("fold.compact", Convert.ToInt32(settings.FoldCompact).ToString()); sci.SetProperty("fold.preprocessor", Convert.ToInt32(settings.FoldPreprocessor).ToString()); sci.SetProperty("fold.at.else", Convert.ToInt32(settings.FoldAtElse).ToString()); sci.SetProperty("fold.html", Convert.ToInt32(settings.FoldHtml).ToString()); sci.SetProperty("lexer.cpp.track.preprocessor", "0"); sci.SetVirtualSpaceOptions((Int32)settings.VirtualSpaceMode); sci.SetFoldFlags((Int32)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(BookmarksMargin, (Int32)MarginType.Fore); } else { sci.SetMarginTypeN(BookmarksMargin, (Int32)MarginType.Symbol); } } /** * Set correct line number margin width */ Boolean viewLineNumbers = settings.ViewLineNumbers; if (viewLineNumbers) { sci.SetMarginWidthN(LineMargin, ScaleArea(sci, 36)); } else { sci.SetMarginWidthN(LineMargin, 0); } /** * Set correct bookmark margin width */ Boolean viewBookmarks = settings.ViewBookmarks; if (viewBookmarks) { sci.SetMarginWidthN(BookmarksMargin, ScaleArea(sci, 14)); } else { sci.SetMarginWidthN(BookmarksMargin, 0); } /** * Set correct folding margin width */ Boolean useFolding = settings.UseFolding; if (!useFolding && !viewBookmarks && !viewLineNumbers) { sci.SetMarginWidthN(FoldingMargin, 0); } else if (useFolding) { sci.SetMarginWidthN(FoldingMargin, ScaleArea(sci, 15)); } else { sci.SetMarginWidthN(FoldingMargin, ScaleArea(sci, 2)); } sci.SetMarginWidthN(1, 0); //Inheritance Margin (see ASCompletion.PluginMain.Margin) /** * Adjust caret policy based on settings */ if (settings.KeepCaretCentered) { sci.SetXCaretPolicy((Int32)(CaretPolicy.Jumps | CaretPolicy.Even), 30); sci.SetYCaretPolicy((Int32)(CaretPolicy.Jumps | CaretPolicy.Even), 2); } else // Match edge... { sci.SetXCaretPolicy((Int32)CaretPolicy.Even, 0); sci.SetYCaretPolicy((Int32)CaretPolicy.Even, 0); } sci.SetVisiblePolicy((Int32)(CaretPolicy.Strict | CaretPolicy.Even), 0); /** * Set scroll range (if false, over-scroll mode is enabled) */ sci.EndAtLastLine = settings.EndAtLastLine ? 1 : 0; /** * Adjust the print margin */ sci.EdgeColumn = 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); } }