private void EditControl_CharAdded(object sender,ScintillaNET.CharAddedEventArgs e) { if( e.Char == '\n' ) { this.Lines[this.CurrentLine].Indentation = this.Lines[this.CurrentLine - 1].Indentation; this.CurrentPosition = this.CurrentPosition + ( this.Lines[this.CurrentLine].Indentation / this.TabWidth ); this.SelectionStart = this.CurrentPosition; } }
private static void SetList(ScintillaNET.Scintilla text_box, List<String> methods) { text_box.AutoComplete.MaxHeight = 10; if (methods.Count == 1) { text_box.InsertText(methods[0]); return; } text_box.AutoComplete.Show(methods); }
private void tbxCode_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { /*if (e.Ch == '.') { System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); t.Interval = 10; t.Tag = tbxCode; t.Tick += new EventHandler((obj, ev) => { List<string> s = new List<string>(); s.Add("UnAbort"); s.Add("Abort"); s.Add("CheckAbort"); s.Add("tabnew"); s.Add("tabclose"); s.Add("tabcloseall"); s.Add("go"); s.Add("sleep"); s.Add("exit"); s.Add("click"); s.Add("log"); s.Add("clearlog"); s.Add("extract"); s.Add("fill"); s.Add("filldropdown"); s.Add("toObject"); s.Add("browser"); s.Add("resetlistwebsite"); s.Add("takesnapshot"); s.Add("imagetotext"); s.Add("fileupload"); s.Add("createfolder"); s.Add("download"); s.Add("getfiles"); s.Add("getfolders"); s.Add("read"); s.Add("save"); s.Add("remove"); s.Add("removefolder"); s.Add("explorer"); s.Add("excute"); s.Add("logoff"); s.Add("lockworkstation"); s.Add("forcelogoff"); s.Add("reboot"); s.Add("shutdown"); s.Add("hibernate"); s.Add("standby"); s.Add("runcommand"); s.Add("createtask"); s.Add("removetask"); s.Add("generatekeys"); s.Add("encrypt"); s.Add("decrypt"); s.Add("showpicture"); s.Add("savefilterimage"); s.Add("writetextimage"); s.Add("getcurrenturl"); s.Add("scrollto"); s.Add("getheight"); s.Add("gettitle"); s.Add("getlinks"); s.Add("getCurrentContent"); s.Add("getCurrentPath"); s.Add("checkelement"); s.Add("readCellExcel"); s.Add("writeCellExcel"); s.Add("replaceMsWord"); s.Add("loadHTML"); s.Add("textToJSON"); s.Add("login"); s.Add("register"); s.Add("getAccount"); s.Add("ocr"); s.Add("captchaborder"); s.Add("saveImageFromElement"); s.Add("getControlText"); s.Add("setControlText"); s.Add("clickControl"); s.Add("getCurrentMouseX"); s.Add("getCurrentMouseY"); s.Add("MouseDown"); s.Add("MouseUp"); s.Add("MouseClick"); s.Add("MouseDoubleClick"); s.Add("MouseMove"); s.Add("MouseWheel"); s.Add("KeyDown"); s.Add("KeyUp"); s.Add("Reload"); s.Add("getConnection"); s.Add("getEmailAccount"); s.Add("sendEmail"); s.Add("locdau"); s.Sort(); // don't forget to sort it tbxCode.AutoComplete.ShowUserList(0, s); t.Stop(); t.Enabled = false; t.Dispose(); }); t.Start(); }*/ }
private void ConfigureScintillaStyle(ScintillaNET.Scintilla scintilla) { var selectionColor = Color.FromArgb(255, 192, 192, 192); // Reset the styles scintilla.StyleResetDefault(); scintilla.StyleClearAll(); // Set the XML Lexer scintilla.Lexer = Lexer.Container; scintilla.StyleNeeded += scintilla_StyleNeeded; scintilla.Styles[(int)RdlScriptLexer.Style.Default].ForeColor = Color.Black; scintilla.Styles[(int)RdlScriptLexer.Style.Identifier].ForeColor = Color.Black; scintilla.Styles[(int)RdlScriptLexer.Style.Error].ForeColor = Color.Red; scintilla.Styles[(int)RdlScriptLexer.Style.Error].Underline = true; scintilla.Styles[(int)RdlScriptLexer.Style.Number].ForeColor = Color.OrangeRed; scintilla.Styles[(int)RdlScriptLexer.Style.String].ForeColor = Color.Brown; scintilla.Styles[(int)RdlScriptLexer.Style.Method].ForeColor = Color.Blue; scintilla.Styles[(int)RdlScriptLexer.Style.AggrMethod].ForeColor = Color.Blue; scintilla.Styles[(int)RdlScriptLexer.Style.AggrMethod].Bold = true; scintilla.Styles[(int)RdlScriptLexer.Style.UserInfo].ForeColor = Color.BlueViolet; scintilla.Styles[(int)RdlScriptLexer.Style.Globals].ForeColor = Color.BlueViolet; scintilla.Styles[(int)RdlScriptLexer.Style.Parameter].ForeColor = Color.Violet; scintilla.Styles[(int)RdlScriptLexer.Style.Field].ForeColor = Color.DodgerBlue; }
void ToggleBreakpoint(ScintillaNET.Scintilla sc, int position) { var line = sc.Lines.FromPosition(position); while (line != null && line.StartPosition >= 0) { var trimmed = line.Text.Trim(); int colon = trimmed.IndexOf(":"); if (colon >= 0) { string start = trimmed.Substring(0, colon); int lineNum = -1; if (int.TryParse(start, out lineNum)) { if (line.GetMarkers().Contains(sc.Markers[BREAKPOINT_MARKER])) { line.DeleteMarkerSet(BreakpointMarkers); m_Breakpoints.Remove(lineNum); } else { line.AddMarkerSet(BreakpointMarkers); m_Breakpoints.Add(lineNum); } sc.Invalidate(); return; } } line = line.Next; } }
private void scintilla2_TextInserted(object sender, ScintillaNET.TextModifiedEventArgs e) { }
private void _source_UpdateUI(object sender, ScintillaNET.UpdateUIEventArgs e) { pb.Trace.WriteLine("_source.SelectionStart {0} _source.SelectionEnd {1}", _source.SelectionStart, _source.SelectionEnd); }
private void intellua_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { //ShowCalltip(); const string brackets = "()[]{}"; const string newline = "\r\n"; if (newline.Contains(e.Ch)) { if (e.Ch == '\n') { InsertText(string.Concat(Enumerable.Repeat("\t", Lines.Current.Previous.Indentation / Indentation.TabWidth))); if (Lines.Current.FoldParent != null && Lines.Current.FoldParent.StartPosition == Lines.Current.Previous.StartPosition) { InsertText("\t"); } } return; } if (!Parse) return; if (brackets.Contains(e.Ch)) return; MemberChain chain = MemberChain.ParseBackward(m_source); if (chain.Elements.Count == 1) { string word = chain.Elements[0].Name; if (char.IsLetterOrDigit(e.Ch) && word.Length >= 3) { List<IAutoCompleteItem> list = m_autoCompleteData.Variables.getList(word,CurrentPos); m_autoCompleteData.Types.appendList(list, word); m_autoCompleteData.Keywords.appendList(list, word); list.Sort(); if (list.Count > 0) { ShowAutoComplete(word.Length, list); } } } else { Type t = chain.getType(m_autoCompleteData); if (t != null) { List<IAutoCompleteItem> list = t.getList(chain.IsNamespace); if (list.Count > 0) { ShowAutoComplete(chain.getLastElement().Length, list); } } } if (!AutoComplete.IsActive) { m_tooltip.Hide(); } }
public static void RunMongo(ScintillaNET.Scintilla text_box, bool debug = false) { var methods = Query.AutoComplete.QueryExecuter.Main (text_box.TextBeforeCursor(), text_box.TextAfterCursor()); SetList(text_box, methods); }
// Functions public void UnIndentScintillaText(ScintillaNET.Scintilla scintilla) { try { string text = null; bool streamcomment = false; int ind = 0; for (int lineind = 0; lineind < scintilla.Lines.Count; lineind++) { text = scintilla.Lines[lineind].Text; if (text.Length > 0) { // Fixes for comments. if (text.StartsWith("//")) { continue; } if (text.IndexOf("/*") != -1 && text.IndexOf("*/") == -1) { streamcomment = true; } else if (text.IndexOf("*/") != -1 && text.IndexOf("/*") == -1) { streamcomment = false; } // The unindenting. if (!streamcomment) { // Remove new lines for the local variable. if (text.EndsWith("\r\n")) text = text.Substring(0, text.Length - 2); if (text.EndsWith("\n")) text = text.Substring(0, text.Length - 1); // Unindent. ind = 0; foreach (char ch in text) { if (text.Length > ind + 1) { if (text.Substring(ind, 2).CompareTo("//") == 0) { break; } } if (text.Length > 0) { if (ch != '\t' && ch != ' ') break; text = text.Remove(0, 1); } ind++; } // Set the line. scintilla.Lines[lineind].Text = text; } } } } catch (Exception ex) { CaughtException(ex); } }
public void IndentScintillaText(ScintillaNET.Scintilla scintilla) { try { // First let's unindent. UnIndentScintillaText(scintilla); // Then indent. string text = null; int tabind = 0; int tabincdec = 0; bool streamcomment = false; bool instring = false; int ind = 0; for (int lineind = 0; lineind < scintilla.Lines.Count; lineind++) { text = scintilla.Lines[lineind].Text; if (text.Length > 0) { // Fixes for comments. if (text.StartsWith("//")) { continue; } if (text.IndexOf("/*") != -1 && text.IndexOf("*/") == -1) { streamcomment = true; } else if (text.IndexOf("*/") != -1 && text.IndexOf("/*") == -1) { streamcomment = false; } // The indenting. if (!streamcomment) { // Remove excess spaces and new lines for the local variable. if (text.EndsWith("\r\n")) text = text.Substring(0, text.Length - 2); if (text.EndsWith("\n")) text = text.Substring(0, text.Length - 1); while (text.EndsWith(" ") || text.EndsWith("\t")) { if (text.Length < 1) break; text = text.Substring(0, text.Length - 1); } // If the tab index is below 0, set it to 0. if (tabind < 0) tabind = 0; // Add the current tab index. for (int i = 0; i < tabind; i++) { text = text.Insert(0, "\t"); } // Indent. tabincdec = 0; ind = 0; foreach (char ch in text) { if (ch == '\"') { if (instring) { instring = false; } else { instring = true; } } if (text.Length > ind + 1) { if (text.Substring(ind, 2).CompareTo("//") == 0) { break; } } if (!instring) { if (ch == '{') { tabincdec++; } else if (ch == '}') { tabincdec--; } } ind++; } // A (failed) attempt to fix indentation for code like this // if(1 == 1) // int i = 0; // else // int i = 1; /*if (lineind < scintilla.Lines.Count) { if (text.IndexOf("if") != -1 || text.IndexOf("else") != -1) { text2 = scintilla.Lines[lineind + 1].Text; if (text2.EndsWith("\r\n")) text2 = text2.Substring(0, text2.Length - 2); if (text2.EndsWith("\n")) text2 = text2.Substring(0, text2.Length - 1); bool inc = true; // increment or no foreach (char ch in text2) { if (ch == '{') { inc = false; } if (ch == '}') { inc = true; } } foreach (char ch in text) { if (ch == '{') { inc = false; } if (ch == '}') { inc = true; } } if (inc) { MessageBox.Show("line: " + lineind + " " + text2); text2 = text2.Insert(0, "\t"); scintilla.Lines[lineind + 1].Text = text2; MessageBox.Show("line2: " + lineind + " " + text2); } } }*/ // Set the new tab index. tabind += tabincdec; // Remove wrong tabs on closing braces (assuming there was one on this line) if (tabincdec < 0) { bool removetab = true; foreach (char ch in text) { if (ch != '\t' && ch != '}') { removetab = false; break; } else if (ch == '}') { removetab = true; break; } } if (removetab && text.IndexOf("\t") >= 0) { text = text.Remove(text.IndexOf("\t"), 1); } } // Set the line. scintilla.Lines[lineind].Text = text; } } } } catch (Exception ex) { CaughtException(ex); } }
private void txtSql_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { var charArray = ",()'.".ToCharArray(); var lastWords = string.Empty; if (!charArray.Contains(e.Ch)) { var str = txtSql.GetCurrentLine().TrimEnd(); var index = str.LastIndexOf(' '); index ++; lastWords = str.Substring(index).TrimEnd(); if (string.IsNullOrEmpty(lastWords)) txtSql.AutoComplete.List = new List<string>(); else { lastWords = lastWords.Split(charArray).Last(); var list = allWords.Where(x => x.IndexOf(lastWords, StringComparison.OrdinalIgnoreCase) > -1).ToList(); txtSql.AutoComplete.List = list; } } else txtSql.AutoComplete.List = allWords; if (txtSql.AutoComplete.List != null && txtSql.AutoComplete.List.Count> 0) this.txtSql.AutoComplete.Show(); }
void Scintilla_FoldChanged(object sender, ScintillaNET.FoldChangedEventArgs e) { if ((e.NewFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) != 0) { if ((e.PreviousFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) == 0) { // Adding a fold point. this.Lines[e.Line].FoldExpanded = true; if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) Expand(e.Line, true, false, 0, e.PreviousFoldLevel); } } else if ((e.PreviousFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) != 0) { if (!this.Lines[e.Line].FoldExpanded) { // Removing the fold from one that has been contracted so should expand // otherwise lines are left invisible with no way to make them visible this.Lines[e.Line].FoldExpanded = true; if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) Expand(e.Line, true, false, 0, e.PreviousFoldLevel); } } if ((e.NewFoldLevel & 0x1000/*SC_FOLDLEVELWHITEFLAG*/) == 0 && ((e.PreviousFoldLevel & 0x0FFF /*SC_FOLDLEVELNUMBERMASK*/) > (e.NewFoldLevel & 0x0FFF /*SC_FOLDLEVELNUMBERMASK*/))) { if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) { // See if should still be hidden ScintillaNET.Line parentLine = this.Lines[e.Line].FoldParent; if (parentLine == null) { this.Lines[e.Line].IsVisible = true; } else if (parentLine.FoldExpanded && parentLine.IsVisible) { this.Lines[e.Line].IsVisible = true; } } } }
private void scintilla1_StyleNeeded(object sender, ScintillaNET.StyleNeededEventArgs e) { //textBox1.Text += e.Range.Start.ToString() + " - " + e.Range.End.ToString() + "\r\n"; //try //{ // var stringIterator = new EtcScriptLib.StringIterator(e.Range.Text); // var tokenIterator = new EtcScriptLib.TokenStream(stringIterator, ScriptEnvironment.Context); // SyntaxLex.Style(tokenIterator); //} //catch (Exception ex) { } //scintilla1.Folding.IsEnabled = true; //e.Range.SetStyle(1); //e.Range.StartingLine.IsFoldPoint = true; //e.Range.StartingLine.FoldLevel = e.Range.StartingLine.VisibleLineNumber; }
private void ConfigureScintillaStyle(ScintillaNET.Scintilla scintilla) { // Reset the styles scintilla.StyleResetDefault(); scintilla.Styles[Style.Default].Font = "Consolas"; scintilla.Styles[Style.Default].Size = 10; scintilla.StyleClearAll(); // Set the XML Lexer scintilla.Lexer = Lexer.Xml; // Show line numbers scintilla.Margins[0].Width = 40; // Enable folding scintilla.SetProperty("fold", "1"); scintilla.SetProperty("fold.compact", "1"); scintilla.SetProperty("fold.html", "1"); // Use Margin 2 for fold markers scintilla.Margins[2].Type = MarginType.Symbol; scintilla.Margins[2].Mask = Marker.MaskFolders; scintilla.Margins[2].Sensitive = true; scintilla.Margins[2].Width = 20; // Reset folder markers for (int i = Marker.FolderEnd; i <= Marker.FolderOpen; i++) { scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight); scintilla.Markers[i].SetBackColor(SystemColors.ControlDark); } // Style the folder markers scintilla.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus; scintilla.Markers[Marker.Folder].SetBackColor(SystemColors.ControlText); scintilla.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus; scintilla.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected; scintilla.Markers[Marker.FolderEnd].SetBackColor(SystemColors.ControlText); scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected; scintilla.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; scintilla.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; // Enable automatic folding scintilla.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change; // Set the Styles scintilla.StyleResetDefault(); // I like fixed font for XML scintilla.Styles[Style.Default].Font = "Courier"; scintilla.Styles[Style.Default].Size = 10; scintilla.StyleClearAll(); scintilla.Styles[Style.Xml.Attribute].ForeColor = Color.Red; scintilla.Styles[Style.Xml.Entity].ForeColor = Color.Red; scintilla.Styles[Style.Xml.Comment].ForeColor = Color.Green; scintilla.Styles[Style.Xml.Tag].ForeColor = Color.Blue; scintilla.Styles[Style.Xml.TagEnd].ForeColor = Color.Blue; scintilla.Styles[Style.Xml.DoubleString].ForeColor = Color.DeepPink; scintilla.Styles[Style.Xml.SingleString].ForeColor = Color.DeepPink; }
private void scintilla1_HotspotClick(object sender, ScintillaNET.HotspotClickEventArgs e) { move_caret_to_line = keywords[scintilla1.GetWordFromPosition(e.Position)]; move_sci_to_line(move_caret_to_line); }
void codeBox_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { if (Char.IsLetter(e.Ch)) codeBox.AutoComplete.Show(); }
void editor_TextInserted(object sender, ScintillaNET.TextModifiedEventArgs e) { this.File.MakeDirty(); }
private void intellua_CallTipClick(object sender, ScintillaNET.CallTipClickEventArgs e) { Function func = m_calltipFuncion.Func; func.CurrentOverloadIndex++; if (func.CurrentOverloadIndex == func.Param.Count) { func.CurrentOverloadIndex = 0; } m_calltipFuncion.update(); CallTip.Show(m_calltipFuncion.CalltipString, m_calltipFuncion.HighLightStart, m_calltipFuncion.HighLightEnd); }
private void sctEditor_TextInserted(object sender, ScintillaNET.TextModifiedEventArgs e) { m_dirty = true; }
private void intellua_TextInserted(object sender, ScintillaNET.TextModifiedEventArgs e) { queueParseFile(); }
public static extern bool GetUpdateRect( IntPtr hWnd, out ScintillaNET.RECT lpRect, bool bErase);
private void scintilla_StyleNeeded(object sender, ScintillaNET.StyleNeededEventArgs e) { // Style the _text if (_iniLexer) global::GenusIDE.IniLexer.StyleNeeded((Scintilla) sender, e.Range); }
void editor_MarginClick(object sender, ScintillaNET.MarginClickEventArgs e) { var editor = (sender as ScintillaNET.Scintilla); if (editor != null) { ScintillaNET.Marker m = editor.Markers[0]; m.Symbol = ScintillaNET.MarkerSymbol.Circle; var markers = e.Line.GetMarkers(); if (markers != null && markers.Count > 0) { e.Line.DeleteAllMarkers(); } else { e.Line.AddMarker(m); } } }