protected virtual void CharAdded(object sender, CharAddedEventArgs e) { if (e.Ch == '(') { this._sca.CallTip.Show("TODO: parameters",_sca.CurrentPos); } else { this._sca.CallTip.Cancel(); try { string entry = GetSentenceAt(_sca.CurrentPos); this._sca.CallTip.Show(entry, _sca.CurrentPos); var autocomplete = EvaluationHelper.GetCompletions(entry, _sca.Text); if (autocomplete.Count > 0) { if (entry.Length == 1 || entry.Length > 2 && entry[entry.Length - 2] == '.') { _sca.AutoComplete.Show(_sca.GetWordFromPosition(_sca.CurrentPos).Length, autocomplete); } _sca.AutoComplete.List = autocomplete; } } catch (Exception ex) { this._sca.CallTip.Show(ex.Message, _sca.CurrentPos); } } }
void scintilla_CharAdded(object sender, CharAddedEventArgs e) { if (this.IsActive) { int le = getLengthEntered(); // We need to make sure we aren't affecting the main list later on. // and so we create a new SkipList from the one we're given. SkipList usableList = new SkipList(_list.GetList()); StringBuilder strb = new StringBuilder(); int cop = 1; while (le > (cop - 1)) { strb.Append(NativeScintilla.GetCharAt(NativeScintilla.GetCurrentPos() - cop)); cop++; } char[] arr = strb.ToString().ToCharArray(); Array.Reverse(arr); String tmp = new string(arr); SkipList srList = usableList.RemoveNonMatchingStartString(tmp); String rList = getListString(srList); NativeScintilla.AutoCSetCurList(rList); } else { if (this.List[0] != "") { if (ShouldTrigger(e.Ch)) { this.Show(); } } } }
/// <summary> /// Raises the <see cref="CharAdded"/> event. /// </summary> /// <param name="e">An <see cref="CharAddedEventArgs"/> that contains the event data.</param> protected virtual void OnCharAdded(CharAddedEventArgs e) { EventHandler<CharAddedEventArgs> handler = Events[_charAddedEventKey] as EventHandler<CharAddedEventArgs>; if (handler != null) handler(this, e); if (_indentation.SmartIndentType != SmartIndent.None) _indentation.CheckSmartIndent(e.Ch); }
void Scintilla_CharAdded(object sender, CharAddedEventArgs e) { if (e.Ch == '\n') { int pos = scintillaWrapper.CurrentPos; Line line = scintillaWrapper.Lines.FromPosition(pos); int indent = line.Previous.Indentation; if (indent > 0) { line.Indentation = indent; scintillaWrapper.GoTo.Position(pos + indent); } } else { if (!scintillaWrapper.AutoComplete.IsActive) { //doShowAutocomplete = true; } } }
private void sciDocument_CharAdded(object sender, CharAddedEventArgs e) { Scintilla sci = (Scintilla)sender; string text = sci.Text; char lastChar = e.Ch; bool res = sci.Snippets.DoSnippetCheck(); if (res == false) { AutoCompletionEngine.IsActive = true; AutoCompletionEngine.checkForAutoCompletion(lastChar); } else { //ActiveDocument.Scintilla.Indentation.SmartIndentType = } if(this.luaSyntaxCheckerBt.Checked == true) checkLuaSyntax(); //if (sci.GetWordFromPosition(sci.CurrentPos).Equals("end")) // this.formatCodeCurrentDocument(); }
/// <summary> /// Registers characters added to the control for controlling auto-indentation and autocomplete /// </summary> private void Scintilla_CharAdded(object sender, CharAddedEventArgs e) { Scintilla scintilla = (Scintilla)sender; // Update AutoIndent depending on words typed if (Settings.AutoIndent && e.Ch == '\n') { // Correct previous line indent string prevText = scintilla.Lines.Current.Previous.Text.Trim(); int prevIndent = -1; if (prevText == "=begin" || prevText == "=end") scintilla.Lines.Current.Previous.Indentation = 0; else prevIndent = GetLineIndent(scintilla.Lines.Current.Previous); if (prevIndent != -1) scintilla.Lines.Current.Previous.Indentation = prevIndent * scintilla.Indentation.TabWidth; // Indent new line string indentStr = ""; int indent = GetLineIndent(scintilla.Lines.Current); for (int i = 0; i < indent; i++) indentStr += "\t"; _scintilla.InsertText(indentStr); } // Update AutoComplete depending on the words typed if (Settings.AutoComplete) { int pos = scintilla.CurrentPos; // Prevents auto-complete for comments and strings int style = _scintilla.Styles.GetStyleAt(pos - 2); if (style == 2 || style == 3 || style == 6 || style == 7 || style == 12 || style == 18) return; // Prevents certain characters from raising the auto-complete window string word = scintilla.GetWordFromPosition(pos).ToLower(); if (_suppressedChars.Contains(e.Ch) || word.Length < Settings.AutoCompleteLength) return; // Select the matched words (we assume that Settings.AutoCompleteWords is already sorted) scintilla.AutoComplete.List = Settings.AutoCompleteWords.FindAll( delegate (string listWord) { return (listWord.ToLower().Contains(word)); }); if (scintilla.AutoComplete.List.Count > 0) scintilla.AutoComplete.Show(); else scintilla.AutoComplete.Cancel(); } }
private void scint_CharAdded(object sender, CharAddedEventArgs e) { if (SettingsManagement.AutocompleteEnable == false) return; if (scint.AutoComplete.IsActive == false && "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#".Contains(e.Ch) && scint.PositionIsOnComment(scint.CurrentPos) == false) { string line = scint.Lines.Current.Text; int lineLen = scint.Caret.Position - scint.Lines.Current.StartPosition; line = Environment.NewLine + line + Environment.NewLine; bool inString = false; bool inChar = false; for (int i = 2; i < lineLen + 2; i++) { if (line[i] == '\\' && line[i + 1] == '\\' && (inString || inChar)) { line = line.Remove(i, 2); line = line.Insert(i, " "); } else if (line[i] == '"' && line[i - 1] != '\\' && inChar == false) { inString = !inString; } else if (line[i] == '\'' && line[i - 1] != '\\' && inString == false) { inChar = !inChar; } } if (inString == false && inChar == false) { if (e.Ch == '#') { lastAutocompleteList = KeywordScanner.GetPreprocKeywords(); string w = scint.GetWordFromPosition(scint.CurrentPos); bool found = false; foreach (string i in lastAutocompleteList) { if (i.StartsWith(w)) { found = true; break; } } if (found) scint.AutoComplete.Show(lastAutocompleteList); } else { lastAutocompleteList = KeywordScanner.GetKeywordsUpTo(file, scint.Text.Substring(0, scint.NativeInterface.WordStartPosition(scint.CurrentPos, true))); string w = scint.GetWordFromPosition(scint.CurrentPos); bool found = false; foreach (string i in lastAutocompleteList) { if (i.StartsWith(w)) { found = true; break; } } if (found) scint.AutoComplete.Show(lastAutocompleteList); } } } }