private static void ScintillaNet_InsertCheck(object sender, InsertCheckEventArgs e) { DocumentView documentView = ((MainWindow)App.Current.MainWindow).ActiveDocument; if (documentView == null) { return; } ScintillaNET.WPF.ScintillaWPF scintilla = documentView.scintilla; var currentPos = scintilla.CurrentPosition; if (e.Text == "\u0013") { e.Text = string.Empty; return; } if ((e.Text.EndsWith("\r") || e.Text.EndsWith("\n"))) { var curLine = scintilla.LineFromPosition(e.Position); var curLineText = scintilla.Lines[curLine].Text.Replace("\r", "").Replace("\n", ""); var indent = Regex.Match(curLineText, @"^\s*"); e.Text += indent.Value; if (Regex.IsMatch(curLineText, @"{\s*$")) { e.Text += '\t'; } } }
private static void TextArea_MarginClick(object sender, MarginClickEventArgs e) { ScintillaNET.WPF.ScintillaWPF scintilla = ((MainWindow)App.Current.MainWindow).ActiveDocument.scintilla; if (e.Margin == ScintillaConstants.BREAKPOINT_MARGIN) { const uint mask = (1 << ScintillaConstants.BREAKPOINT_MARKER); Line line = scintilla.Lines[scintilla.LineFromPosition(e.Position)]; scintilla.IndicatorCurrent = ScintillaConstants.BREAKPOINT_INDICATOR; if ((line.MarkerGet() & mask) > 0) { line.MarkerDelete(ScintillaConstants.BREAKPOINT_MARKER); line.MarkerDelete(ScintillaConstants.BREAKPOINT_BG); scintilla.IndicatorClearRange(line.Position, line.Length); } else { int breakPointStartPosition, breakPointHighlightLength; if (ScintillaBreakPointValidator.IsBreakPointAllowed(scintilla, line, out breakPointStartPosition, out breakPointHighlightLength)) { line.MarkerAdd(ScintillaConstants.BREAKPOINT_MARKER); scintilla.IndicatorFillRange(breakPointStartPosition, breakPointHighlightLength); } } } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.saveFileDialog = ((Nevala.SaveFileDialog)(target)); return; case 2: this.scintilla = ((ScintillaNET.WPF.ScintillaWPF)(target)); return; } this._contentLoaded = true; }
private void TextArea_MarginClick(object sender, MarginClickEventArgs e) { ScintillaNET.WPF.ScintillaWPF TextArea = ActiveDocument.Scintilla; if (e.Margin == BOOKMARK_MARGIN) { // Do we have a marker for this line? const uint mask = (1 << BOOKMARK_MARKER); var line = TextArea.Lines[TextArea.LineFromPosition(e.Position)]; if ((line.MarkerGet() & mask) > 0) { // Remove existing bookmark line.MarkerDelete(BOOKMARK_MARKER); } else { // Add bookmark line.MarkerAdd(BOOKMARK_MARKER); } } }
private static void InsertMatchedChars(CharAddedEventArgs e) { ScintillaNET.WPF.ScintillaWPF scintilla = ((MainWindow)App.Current.MainWindow).ActiveDocument.scintilla; var caretPos = scintilla.CurrentPosition; var docStart = caretPos == 1; var docEnd = caretPos == scintilla.Text.Length; var charPrev = docStart ? scintilla.GetCharAt(caretPos) : scintilla.GetCharAt(caretPos - 2); var charNext = scintilla.GetCharAt(caretPos); var isCharPrevBlank = charPrev == ' ' || charPrev == '\t' || charPrev == '\n' || charPrev == '\r'; var isCharNextBlank = charNext == ' ' || charNext == '\t' || charNext == '\n' || charNext == '\r' || docEnd; var isEnclosed = (charPrev == '(' && charNext == ')') || (charPrev == '{' && charNext == '}') || (charPrev == '[' && charNext == ']'); var isSpaceEnclosed = (charPrev == '(' && isCharNextBlank) || (isCharPrevBlank && charNext == ')') || (charPrev == '{' && isCharNextBlank) || (isCharPrevBlank && charNext == '}') || (charPrev == '[' && isCharNextBlank) || (isCharPrevBlank && charNext == ']'); var isCharOrString = (isCharPrevBlank && isCharNextBlank) || isEnclosed || isSpaceEnclosed; var charNextIsCharOrString = charNext == '"' || charNext == '\''; switch (e.Char) { case '(': if (charNextIsCharOrString) { return; } scintilla.InsertText(caretPos, ")"); break; case '{': if (charNextIsCharOrString) { return; } scintilla.InsertText(caretPos, "}"); break; case '[': if (charNextIsCharOrString) { return; } scintilla.InsertText(caretPos, "]"); break; case '"': // 0x22 = " if (charPrev == 0x22 && charNext == 0x22) { scintilla.DeleteRange(caretPos, 1); scintilla.GotoPosition(caretPos); return; } if (isCharOrString) { scintilla.InsertText(caretPos, "\""); } break; case '\'': // 0x27 = ' if (charPrev == 0x27 && charNext == 0x27) { scintilla.DeleteRange(caretPos, 1); scintilla.GotoPosition(caretPos); return; } if (isCharOrString) { scintilla.InsertText(caretPos, "'"); } break; } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 10 "..\..\MainWindow.xaml" ((ide.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded); #line default #line hidden #line 10 "..\..\MainWindow.xaml" ((ide.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing); #line default #line hidden return; case 2: #line 29 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click); #line default #line hidden return; case 3: this.btnNewFile = ((System.Windows.Controls.MenuItem)(target)); #line 34 "..\..\MainWindow.xaml" this.btnNewFile.Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_4); #line default #line hidden return; case 4: #line 35 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_1); #line default #line hidden return; case 5: this.btnSave = ((System.Windows.Controls.MenuItem)(target)); #line 41 "..\..\MainWindow.xaml" this.btnSave.Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_2); #line default #line hidden return; case 6: #line 47 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_7); #line default #line hidden return; case 7: #line 48 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_8); #line default #line hidden return; case 8: #line 50 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_3); #line default #line hidden return; case 9: #line 58 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_5); #line default #line hidden return; case 10: #line 63 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click_6); #line default #line hidden return; case 11: this.richTextBox1 = ((System.Windows.Controls.RichTextBox)(target)); return; case 12: this.errorListView = ((System.Windows.Controls.ListView)(target)); #line 85 "..\..\MainWindow.xaml" this.errorListView.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.errorListView_MouseDoubleClick); #line default #line hidden return; case 13: #line 99 "..\..\MainWindow.xaml" ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.ClearChart); #line default #line hidden return; case 14: this.ramChart = ((LiveCharts.Wpf.CartesianChart)(target)); return; case 15: this.cpuChart = ((LiveCharts.Wpf.CartesianChart)(target)); return; case 16: this.editor = ((ScintillaNET.WPF.ScintillaWPF)(target)); #line 111 "..\..\MainWindow.xaml" this.editor.CharAdded += new System.EventHandler <ScintillaNET.CharAddedEventArgs>(this.editor_CharAdded); #line default #line hidden return; case 17: this.treeView1 = ((System.Windows.Controls.TreeView)(target)); #line 114 "..\..\MainWindow.xaml" this.treeView1.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.treeView1_MouseDoubleClick); #line default #line hidden return; } this._contentLoaded = true; }