/// <summary> /// Sets a style for an Error annotation (reduced font + segoe ui) and for markers /// </summary> private void SetErrorStyles(byte errorLevel, StyleThemeItem styleItem) { int curFontSize = Sci.GetStyle(0).Size; Color bgColor = styleItem.BackColor; Color fgColor = styleItem.ForeColor; var normalStyle = Sci.GetStyle(OpenedFilesInfo.GetStyleOf((ErrorLevel)errorLevel, ErrorFontWeight.Normal)); normalStyle.Font = "Segoe ui"; normalStyle.Size = (int)(curFontSize * 0.9); normalStyle.ForeColor = fgColor; normalStyle.BackColor = bgColor; var boldStyle = Sci.GetStyle(OpenedFilesInfo.GetStyleOf((ErrorLevel)errorLevel, ErrorFontWeight.Bold)); boldStyle.Font = "Segoe ui"; boldStyle.Size = (int)(curFontSize * 0.9); boldStyle.Bold = true; boldStyle.ForeColor = fgColor; boldStyle.BackColor = bgColor; var italicStyle = Sci.GetStyle(OpenedFilesInfo.GetStyleOf((ErrorLevel)errorLevel, ErrorFontWeight.Italic)); italicStyle.Font = "Segoe ui"; italicStyle.Size = (int)(curFontSize * 0.9); italicStyle.Italic = true; italicStyle.ForeColor = fgColor; italicStyle.BackColor = bgColor; var markerStyle = Sci.GetMarker(errorLevel); markerStyle.Symbol = MarkerSymbol.SmallRect; markerStyle.SetBackColor(bgColor); markerStyle.SetForeColor(fgColor); }
private void BtGetHelpOnButtonPressed(object sender, EventArgs buttonPressedEventArgs) { Config.Instance.GlobalShowDetailedHelpForErrors = !Config.Instance.GlobalShowDetailedHelpForErrors; btGetHelp.UseGreyScale = !Config.Instance.GlobalShowDetailedHelpForErrors; OpenedFilesInfo.ClearAnnotationsAndMarkers(); OpenedFilesInfo.UpdateErrorsInScintilla(); Sci.GrabFocus(); }
/// <summary> /// Changing syntax theme /// </summary> private void CbSyntaxSelectedIndexChanged(object sender, EventArgs eventArgs) { ScintillaTheme.CurrentTheme = ScintillaTheme.GetThemesList[cbSyntax.SelectedIndex]; Config.Instance.SyntaxHighlightThemeId = cbSyntax.SelectedIndex; if (Npp.CurrentFileInfo.IsProgress) { ScintillaTheme.CurrentTheme.SetScintillaStyles(); Plug.ApplyOptionsForScintilla(); OpenedFilesInfo.UpdateFileStatus(); } }
/// <summary> /// When the user click on the margin /// </summary> public static void OnSciMarginClick(SCNotification nc) { if (!Npp.CurrentFileInfo.IsProgress) { return; } // click on the error margin if (nc.margin == OpenedFilesInfo.ErrorMarginNumber) { // if it's an error symbol that has been clicked, the error on the line will be cleared if (!OpenedFilesInfo.ClearLineErrors(Sci.LineFromPosition(nc.position.ToInt32()))) { // if nothing has been cleared, we go to the next error position OpenedFilesInfo.GoToNextError(Sci.LineFromPosition(nc.position.ToInt32())); } } }
/// <summary> /// Called when the user switches tab document /// You can use Npp.CurrentFile and Npp.PreviousFile in this method /// </summary> public static void DoNppBufferActivated(bool initiating = false) { // Apply options to npp and scintilla depending if we are on a progress file or not ApplyOptionsForScintilla(); // if the file has just been opened if (!_openedFileList.Contains(Npp.CurrentFileInfo.Path)) { _openedFileList.Add(Npp.CurrentFileInfo.Path); // need to auto change encoding? if (Config.Instance.AutoSwitchEncodingTo != NppEncodingFormat._Automatic_default && !string.IsNullOrEmpty(Config.Instance.AutoSwitchEncodingForFilePatterns)) { if (Npp.CurrentFileInfo.Path.TestAgainstListOfPatterns(Config.Instance.AutoSwitchEncodingForFilePatterns)) { NppMenuCmd cmd; if (Enum.TryParse(((int)Config.Instance.AutoSwitchEncodingTo).ToString(), true, out cmd)) { Npp.RunCommand(cmd); } } } } // activate show space for conf files / deactivate if coming from a conf file if (ShareExportConf.IsFileExportedConf(Npp.PreviousFileInfo.Path)) { if (Sci.ViewWhitespace != WhitespaceMode.Invisible && !Sci.ViewEol) { Sci.ViewWhitespace = _whitespaceMode; } } if (ShareExportConf.IsFileExportedConf(Npp.CurrentFileInfo.Path)) { Sci.ViewWhitespace = WhitespaceMode.VisibleAlways; } // close popups.. ClosePopups(); if (initiating) { // make sure to use the ProEnvironment and colorize the error counter OpenedFilesInfo.UpdateFileStatus(); } else { if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile) { CodeExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress); } if (Config.Instance.FileExplorerAutoHideOnNonProgressFile) { FileExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress); } } // Update info on the current file OpenedFilesInfo.UpdateErrorsInScintilla(); ProEnvironment.Current.ReComputeProPath(); AutoCompletion.SetStaticItems(); // Parse the document ParserHandler.ParseDocumentNow(); // publish the event if (OnDocumentChangedEnd != null) { OnDocumentChangedEnd(); } }
private void BtPrevErrorOnButtonPressed(object sender, EventArgs buttonPressedEventArgs) { OpenedFilesInfo.GoToPrevError(Sci.Line.CurrentLine - 1); }
private void BtClearAllErrorsOnButtonPressed(object sender, EventArgs buttonPressedEventArgs) { OpenedFilesInfo.ClearAllErrors(Npp.CurrentFileInfo.Path); Sci.GrabFocus(); }