private void OnZoomChanged(object sender, EventArgs e) { int newMaxRowCharLength = ScintillaEditor.Lines.Count.ToString().Length; ScintillaEditor.Margins[0].Width = ScintillaEditor.TextWidth(ScintillaNET.Style.LineNumber, new string('9', newMaxRowCharLength + 1)); _maxRowCharLength = newMaxRowCharLength; }
// code Folding ( after Lexer changed ) private void ScintillaFolding() { ScintillaEditor.SetProperty("fold", "1"); ScintillaEditor.SetProperty("fold.compact", "1"); // Configure a margin to display folding symbols ScintillaEditor.Margins[2].Type = MarginType.Symbol; ScintillaEditor.Margins[2].Mask = Marker.MaskFolders; ScintillaEditor.Margins[2].Sensitive = true; ScintillaEditor.Margins[2].Width = 20; // Set colors for all folding markers for (var i = 25; i <= 31; i++) { ScintillaEditor.Markers[i].SetForeColor(System.Drawing.ColorTranslator.FromHtml("#FFFFFF")); ScintillaEditor.Markers[i].SetBackColor(System.Drawing.ColorTranslator.FromHtml("#AAAAAA")); } // Configure folding markers with respective symbols ScintillaEditor.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus; ScintillaEditor.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus; ScintillaEditor.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected; ScintillaEditor.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; ScintillaEditor.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected; ScintillaEditor.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; ScintillaEditor.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; // Enable automatic folding ScintillaEditor.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change; }
public EditorControl() { InitializeComponent(); ScintillaEditor.Margins[0].Width = 32; ScintillaEditor.IndentationGuides = IndentView.LookBoth; ScintillaEditor.StyleResetDefault(); ScintillaEditor.Styles[0].Font = "Consolas"; ScintillaEditor.Styles[0].Size = 12; }
public void Goto(int row, int column) { ScintillaEditor.Lines[row - 1].Goto(); ScintillaEditor.GotoPosition(ScintillaEditor.CurrentPosition + column); EditorFocus(); ScintillaEditor.UpdateUI += OnCursorChanged; _isGotoHappenned = true; _errorLine = row - 1; ScintillaEditor.CaretLineBackColor = Color.Red; ScintillaEditor.CaretLineBackColorAlpha = 50; }
private void OnTextChanged(object sender, System.EventArgs e) { IsDirty = true; IsDirtyChanged?.Invoke(true); int newMaxRowCharLength = ScintillaEditor.Lines.Count.ToString().Length; if (_maxRowCharLength == newMaxRowCharLength) { return; } ScintillaEditor.Margins[0].Width = ScintillaEditor.TextWidth(ScintillaNET.Style.LineNumber, new string('9', newMaxRowCharLength + 1)); _maxRowCharLength = newMaxRowCharLength; }
// reload lexer ( After Lexer changed ) private void ReloadLexer() { ScintillaEditor.Lexer = Lexer; // Scintilla keywords for highlighting new language if (_keyWord1.ContainsKey(ScintillaEditor.Lexer)) { ScintillaEditor.SetKeywords(0, _keyWord1[ScintillaEditor.Lexer]); } if (_keyWord2.ContainsKey(ScintillaEditor.Lexer)) { ScintillaEditor.SetKeywords(1, _keyWord2[ScintillaEditor.Lexer]); } // Autocomplete suggestions for new language ReloadAutocompleteMenu(); ScintillaFolding(); }
public void EditorFocus() { ScintillaEditor.Focus(); }
// Load color scheme ( after ResourcesDirectory changed ) private void LoadColorScheme(string colorScheme) { if (!Directory.Exists($"{ResourcesDirectory}\\{ColorSchemesDirectoryName}\\{colorScheme}")) { return; } // Cpp if (File.Exists($"{ResourcesDirectory}\\{ColorSchemesDirectoryName}\\{colorScheme}\\Cpp.json")) { var cppColorScheme = Newtonsoft.Json.JsonConvert.DeserializeObject <ColorScheme>( File.ReadAllText($"{ResourcesDirectory}\\{ColorSchemesDirectoryName}\\{colorScheme}\\Cpp.json")); ScintillaEditor.Styles[ScintillaNET.Style.Default].BackColor = System.Drawing.Color.FromArgb(cppColorScheme.DFBackColor.R, cppColorScheme.DFBackColor.G, cppColorScheme.DFBackColor.B); ScintillaEditor.Styles[ScintillaNET.Style.Default].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.DFForeColor.R, cppColorScheme.DFForeColor.G, cppColorScheme.DFForeColor.B); ScintillaEditor.StyleClearAll(); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Identifier].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Identifier.R, cppColorScheme.Identifier.G, cppColorScheme.Identifier.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Comment].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Comment.R, cppColorScheme.Comment.G, cppColorScheme.Comment.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.CommentLine].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.CommentLine.R, cppColorScheme.CommentLine.G, cppColorScheme.CommentLine.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.CommentDoc].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.CommentDoc.R, cppColorScheme.CommentDoc.G, cppColorScheme.CommentDoc.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Number].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Number.R, cppColorScheme.Number.G, cppColorScheme.Number.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.String].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.String.R, cppColorScheme.String.G, cppColorScheme.String.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Character].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Character.R, cppColorScheme.Character.G, cppColorScheme.Character.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Preprocessor].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Preprocessor.R, cppColorScheme.Preprocessor.G, cppColorScheme.Preprocessor.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Operator].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Operator.R, cppColorScheme.Operator.G, cppColorScheme.Operator.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Regex].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Regex.R, cppColorScheme.Regex.G, cppColorScheme.Regex.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.CommentLineDoc].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.CommentLineDoc.R, cppColorScheme.CommentLineDoc.G, cppColorScheme.CommentLineDoc.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Word].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Word.R, cppColorScheme.Word.G, cppColorScheme.Word.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.Word2].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.Word2.R, cppColorScheme.Word2.G, cppColorScheme.Word2.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.CommentDocKeyword].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.CommentDocKeyword.R, cppColorScheme.CommentDocKeyword.G, cppColorScheme.CommentDocKeyword.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.CommentDocKeywordError].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.CommentDocKeywordError.R, cppColorScheme.CommentDocKeywordError.G, cppColorScheme.CommentDocKeywordError.B); ScintillaEditor.Styles[ScintillaNET.Style.Cpp.GlobalClass].ForeColor = System.Drawing.Color.FromArgb(cppColorScheme.GlobalClass.R, cppColorScheme.GlobalClass.G, cppColorScheme.GlobalClass.B); if (_keyWord1.ContainsKey(Lexer.Cpp)) { _keyWord1[Lexer.Cpp] = cppColorScheme.KeyWord1; } else { _keyWord1.Add(Lexer.Cpp, cppColorScheme.KeyWord1); } if (_keyWord2.ContainsKey(Lexer.Cpp)) { _keyWord2[Lexer.Cpp] = cppColorScheme.KeyWord2; } else { _keyWord2.Add(Lexer.Cpp, cppColorScheme.KeyWord2); } } // Lua if (File.Exists($"{ResourcesDirectory}\\{ColorSchemesDirectoryName}\\{colorScheme}\\Lua.json")) { } }