SetWhiteSpaceColor() публичный статический Метод

sets the fore/background color of the whitespaces, overriding the lexer's
public static SetWhiteSpaceColor ( bool use, Color bg, Color fg ) : void
use bool
bg Color
fg Color
Результат void
Пример #1
0
        internal static void ApplyPluginOptionsForScintilla()
        {
            if (!_hasBeenInit || !IsPreviousFileProgress)
            {
                // read default options
                _tabWidth       = Npp.TabWidth;
                _indentWithTabs = Npp.UseTabs;
                _whitespaceMode = Npp.ViewWhitespace;
                AnnotationMode  = Npp.AnnotationVisible;
            }
            _hasBeenInit = true;

            // need to do this stuff uniquely for both scintilla
            var curScintilla = Npp.CurrentScintilla; // 0 or 1

            if (_initiatedScintilla[curScintilla] == 0)
            {
                // Extra settings at the start
                Npp.MouseDwellTime = Config.Instance.ToolTipmsBeforeShowing;
                Npp.EndAtLastLine  = false;
                Npp.EventMask      = (int)(SciMsg.SC_MOD_INSERTTEXT | SciMsg.SC_MOD_DELETETEXT | SciMsg.SC_PERFORMED_USER | SciMsg.SC_PERFORMED_UNDO | SciMsg.SC_PERFORMED_REDO);
                _initiatedScintilla[curScintilla] = 1;
            }

            Npp.TabWidth = Config.Instance.CodeTabSpaceNb;
            Npp.UseTabs  = false;
            if (Config.Instance.CodeShowSpaces)
            {
                Npp.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }

            // apply style
            Style.SetSyntaxStyles();
            var currentStyle = Style.Current;

            Npp.SetIndentGuideColor(currentStyle.WhiteSpace.BackColor, currentStyle.WhiteSpace.ForeColor);
            Npp.SetWhiteSpaceColor(true, Color.Transparent, currentStyle.WhiteSpace.ForeColor);
            Npp.SetSelectionColor(true, currentStyle.Selection.BackColor, Color.Transparent);
            Npp.CaretLineBackColor = currentStyle.CaretLine.BackColor;
            Npp.CaretColor         = currentStyle.CaretColor.ForeColor;
            Npp.SetFoldMarginColors(true, currentStyle.FoldMargin.BackColor, currentStyle.FoldMargin.BackColor);
            Npp.SetFoldMarginMarkersColor(currentStyle.FoldMargin.ForeColor, currentStyle.FoldMargin.BackColor, currentStyle.FoldActiveMarker.ForeColor);

            // we want the default auto-completion to not show
            // we block on a scintilla level (pretty bad solution because it slows down npp on big documents)
            Npp.AutoCStops(@"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_");
            // and we also block it in Npp (pull request on going for v6.9.?)
            if (Config.IsDevelopper)
            {
                WinApi.SendMessage(Npp.HandleNpp, NppMsg.NPPM_SETAUTOCOMPLETIONDISABLEDONCHARADDED, 0, 1);
            }
        }
Пример #2
0
        internal static void ApplyDefaultOptionsForScintilla()
        {
            // nothing has been done yet, no need to reset anything! same if we already were on a non progress file
            if (!_hasBeenInit || !IsPreviousFileProgress)
            {
                return;
            }

            // apply default options
            Npp.TabWidth          = _tabWidth;
            Npp.UseTabs           = _indentWithTabs;
            Npp.AnnotationVisible = AnnotationMode;

            if (Npp.ViewWhitespace != WhitespaceMode.Invisible && !Npp.ViewEol)
            {
                Npp.ViewWhitespace = _whitespaceMode;
            }

            // apply default style...
            try {
                // read npp's stylers.xml file
                var widgetStyle = XDocument.Load(Config.FileNppStylersXml).Descendants("WidgetStyle");
                var xElements   = widgetStyle as XElement[] ?? widgetStyle.ToArray();
                var wsFore      = GetColorInStylers(xElements, "White space symbol", "fgColor");
                Npp.SetIndentGuideColor(GetColorInStylers(xElements, "Indent guideline style", "bgColor"), GetColorInStylers(xElements, "Indent guideline style", "fgColor"));
                Npp.SetWhiteSpaceColor(true, Color.Transparent, wsFore);
                Npp.SetSelectionColor(true, GetColorInStylers(xElements, "Selected text colour", "bgColor"), Color.Transparent);
                Npp.CaretLineBackColor = GetColorInStylers(xElements, "Current line background colour", "bgColor");
                Npp.CaretColor         = GetColorInStylers(xElements, "Caret colour", "fgColor");
                Npp.SetFoldMarginColors(true, GetColorInStylers(xElements, "Fold margin", "bgColor"), GetColorInStylers(xElements, "Fold margin", "fgColor"));
                Npp.SetFoldMarginMarkersColor(GetColorInStylers(xElements, "Fold", "fgColor"), GetColorInStylers(xElements, "Fold", "bgColor"), GetColorInStylers(xElements, "Fold active", "fgColor"));
            } catch (Exception e) {
                ErrorHandler.LogError(e);
                if (!_warnedAboutFailStylers)
                {
                    _warnedAboutFailStylers = true;
                    UserCommunication.Notify("Error while reading one of Notepad++ file :<div>" + Config.FileNppStylersXml.ToHtmlLink() + "</div>", MessageImg.MsgError, "Error reading stylers.xml", "Xml read error");
                }
            }

            // we wanted the default auto-completion to not show, but no more
            Npp.AutoCStops("");
            if (Config.IsDevelopper)
            {
                WinApi.SendMessage(Npp.HandleNpp, NppMsg.NPPM_SETAUTOCOMPLETIONDISABLEDONCHARADDED, 0, 0);
            }
        }