public static void CharAdded(ZeusScintillaControl scintilla, char ch) { AutoCompleteHelper ach = null; bool isTagged = (scintilla.ConfigurationLanguage == null) ? false : scintilla.ConfigurationLanguage.StartsWith("Tagged"); switch (scintilla.ConfigurationLanguage) { case "TaggedC#": case "C#": ach = _cSharpAutoCompleteHelper; break; case "TaggedVB.Net": case "VB.Net": ach = _vbNetAutoCompleteHelper; break; case "TaggedJScript": case "JScript": ach = _jScriptAutoCompleteHelper; break; case "TaggedVBScript": case "VBScript": ach = _vbScriptAutoCompleteHelper; break; } if (ach != null) { ach.HandleCharAdded(scintilla, isTagged, ch); } }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack <int> matches = new Stack <int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 86 || style == 7) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; int endWordIndex = m + word.Length; char c = scintilla.CharAt(++endWordIndex); List <string> words = new List <string>(); //skip whitespace while (Char.IsWhiteSpace(c)) { c = scintilla.CharAt(++endWordIndex); } // get "As" StringBuilder nextword = new StringBuilder(); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c)); if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase)) { //skip whitespace while (Char.IsWhiteSpace(c)) { c = scintilla.CharAt(++endWordIndex); } // get Type nextword.Remove(0, nextword.Length); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator))); string type = nextword.ToString(); List <Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } } return(isFound); }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack <int> matches = new Stack <int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 61 || style == 11) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; //scintilla. char c = scintilla.CharAt(--beginWordIndex); while (Char.IsWhiteSpace(c) && (beginWordIndex > 0)) { c = scintilla.CharAt(--beginWordIndex); } StringBuilder typeName = new StringBuilder(); while (this.IsValidIdentifierChar(c) || (c == MemberSeperator)) { if (typeName.Length == 0) { typeName.Append(c); } else { typeName.Insert(0, c); } c = scintilla.CharAt(--beginWordIndex); } string type = typeName.ToString(); List <Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } return(isFound); }