private bool TestIfComments(int pos, bool checkStr) { var st = sci.GetStyleAt(pos); //exclude autocomplete in comments and strings var b = st == TextStyle.MultilineStyle1 || st == TextStyle.MultilineStyle2 || st == TextStyle.Style6 || st == TextStyle.Style7; if (st == TextStyle.None && checkStr) { var lnn = sci.GetLineFromPosition(pos); var ln = sci.GetLine(lnn); var col = sci.GetColumnFromPosition(pos); for (var i = col; i > -1; i--) { if (sci.CharAt(sci.GetPositionByColumn(lnn, i)) == '"') { return(true); } } } return(b); }
int GetDisplayPosition() { var pos = Expr.Position; switch (CompilerService) { case HaxeCompilerService.COMPLETION: // locate a . or ( while (pos > 1 && Sci.CharAt(pos - 1) != '.' && Sci.CharAt(pos - 1) != '(') { pos--; } break; case HaxeCompilerService.POSITION: case HaxeCompilerService.USAGE: pos = Sci.WordEndPosition(Sci.CurrentPos, true); // necessary to get results with older versions due to a compiler bug if (haxeVersion < "3.3.0") { pos++; } break; case HaxeCompilerService.GLOBAL_DIAGNOSTICS: case HaxeCompilerService.DIAGNOSTICS: pos = 0; break; } // account for BOM characters pos += FileHelper.GetEncodingFileInfo(FileName).BomLength; return(pos); }
static private bool HandleBoxCompletion(ScintillaControl Sci, int position) { // is the block before a function declaration? int len = Sci.TextLength - 1; char c; StringBuilder sb = new StringBuilder(); while (position < len) { c = (char)Sci.CharAt(position); sb.Append(c); if (c == '(' || c == ';' || c == '{' || c == '}') { break; } position++; } string signature = sb.ToString(); if (re_functionDeclaration.IsMatch(signature)) { // get method signature position++; while (position < len) { c = (char)Sci.CharAt(position); sb.Append(c); if (c == ';' || c == '{') { break; } position++; } signature = sb.ToString(); } else { signature = null; } // build templates list List <ICompletionListItem> templates = new List <ICompletionListItem>(); if (signature != null) { boxMethodParams.Context = signature; templates.Add(boxMethodParams); } templates.Add(boxSimpleClose); // show CompletionList.Show(templates, true, ""); return(true); }
int GetDisplayPosition() { var pos = Expr.Position; // locate a . or ( while (pos > 1 && Sci.CharAt(pos - 1) != '.' && Sci.CharAt(pos - 1) != '(') { pos--; } // account for BOM characters pos += FileHelper.GetEncodingFileInfo(FileName).BomLength; return(pos); }
public virtual ASResult GetCollectionOfForeachStatement(ScintillaControl sci, int startPosition) { var result = new ASResult(); var parCount = 0; var endPosition = sci.TextLength; var pos = startPosition; while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (c > ' ') { if (c == '(') { parCount++; } else if (c == ')') { parCount--; if (parCount == 0) { result = ASComplete.GetExpressionType(sci, pos); break; } } } } pos++; } return(result); }
public virtual int GetStartOfBody(ScintillaControl sci, int startPosition) { var result = -1; var parCount = 0; var pos = startPosition; var endPosition = sci.TextLength; while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (c == '(') { parCount++; } else if (c == ')') { parCount--; if (parCount == 0) { result = pos + 1; break; } } } pos++; } return(result); }
void OnTextChanged(ScintillaControl sender, int position, int length, int linesAdded) { String added = ""; Int32 start = position; if (String.IsNullOrEmpty(this.pathSoFar)) { this.pathSoFar = ""; } while (start < position + length) { added += (Char)(sender.CharAt(start)); start++; } if (length > 0) { if (this.notAllowed.IsMatch(added)) { this.FinishFileCompletion(sender, null); return; } this.pathSoFar += added; } else { this.pathSoFar = this.pathSoFar.Substring(0, Math.Max(0, this.pathSoFar.Length + length)); } }
/// <summary> /// Shows the completion list automaticly after typing three chars /// </summary> private void SciControlCharAdded(ScintillaControl sci, Int32 value) { String language = sci.ConfigurationLanguage.ToLower(); if (this.IsSupported(language)) { Language config = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage); String characters = config.characterclass.Characters; // Do not autocomplete in word Char c = (char)sci.CharAt(sci.CurrentPos); if (characters.IndexOf(c) >= 0) { return; } // Autocomplete after typing word chars only if (characters.IndexOf((char)value) < 0) { return; } String curWord = sci.GetWordLeft(sci.CurrentPos - 1, false); if (curWord == null || curWord.Length < 3) { return; } List <ICompletionListItem> items = this.GetCompletionListItems(language, sci.FileName); if (items != null && items.Count > 0) { items.Sort(); CompletionList.Show(items, true, curWord); CompletionList.DisableAutoInsertion(); } } }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { int insideBrackets = 0; Char c; System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (c == ')') { insideBrackets++; } else if (c == '(' && insideBrackets > 0) { insideBrackets--; } else if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.') && insideBrackets == 0) { break; } sb.Insert(0, c); } return(sb.ToString()); }
public new ASResult GetVarOfForeachStatement(ScintillaControl sci, int startPosition) { var result = new ASResult(); var parCount = 0; var characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters; var endPosition = sci.TextLength; var pos = startPosition; while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (c > ' ') { if (parCount == 0 && c == '(') { parCount++; } else if (parCount == 1 && characterClass.IndexOf(c) != -1) { pos = sci.WordEndPosition(pos, true); result = ASComplete.GetExpressionType(sci, pos); break; } } } pos++; } return(result); }
private string ReadAttribute(ScintillaControl sci, int i) { bool inWord = false; string word = ""; while (i > 1) { char c = (char)sci.CharAt(i--); if (wordChars.IndexOf(c) >= 0) { inWord = true; word = c + word; } else if (c > 32) { return(""); } else if (inWord) { break; } } if (word.Length > 0 && word[0] == '-') { Match m = reNavPrefix.Match(word); if (m.Success) { word = m.Groups[1].Value; } } return(word); }
internal void OnInsert(ScintillaControl sci, int position, string text, char trigger, ICompletionListItem item) { if (!(item is CompletionItem)) { return; } CompletionItem it = item as CompletionItem; if (trigger == ':') { lastColonInsert = position + text.Length + 1; } else if (it.Kind == ItemKind.Property && !settings.DisableInsertColon) { int pos = position + text.Length; char c = (char)sci.CharAt(pos); if (c != ':') { sci.InsertText(pos, ":"); } sci.SetSel(pos + 1, pos + 1); lastColonInsert = pos + 1; } else { lastColonInsert = -1; } }
public virtual int GetStartOfIfStatement(ScintillaControl sci, int startPosition) { var characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters; var endPosition = sci.TextLength; var pos = GetStartOfBody(sci, startPosition); while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (c > ' ' && (characterClass.IndexOf(c) != -1 || c == '{')) { if (c != '{') { var word = sci.GetWordRight(pos, true); switch (word) { case "for": case "while": case "do": case "switch": case "try": return(GetEndOfStatement(sci, pos + word.Length)); } } pos = Reflector.ASGenerator.GetEndOfStatement(pos - 1, endPosition, sci); if (pos == endPosition) { return(pos); } var p = pos; while (p < endPosition) { if (!sci.PositionIsOnComment(p) && characterClass.IndexOf((char)sci.CharAt(p)) != -1) { var word = sci.GetWordRight(p, false); if (word == "else") { pos = p + word.Length; word = sci.GetWordRight(pos, true); if (word == "if") { pos = sci.WordStartPosition(pos + word.Length, false); return(GetStartOfIfStatement(sci, pos)); } break; } return(pos); } p++; } } } pos++; } return(-1); }
static private XMLContextTag GetXMLContextTag(ScintillaControl sci, int position) { XMLContextTag xtag = new XMLContextTag(); if ((position == 0) || (sci == null)) { return(xtag); } StringBuilder tag = new StringBuilder(); char c = (char)sci.CharAt(position - 1); position -= 2; tag.Append(c); while (position >= 0) { c = (char)sci.CharAt(position); tag.Insert(0, c); if (c == '>') { return(xtag); } if (c == '<') { break; } position--; } // xtag.Position = position; xtag.Tag = tag.ToString(); Match mTag = re_TagName.Match(xtag.Tag + " "); if (mTag.Success) { xtag.Name = mTag.Groups["name"].Value; if (xtag.Name.IndexOf(':') > 0) { xtag.NameSpace = xtag.Name.Substring(0, xtag.Name.IndexOf(':')); } } return(xtag); }
public static Int32 GetWordEndPositionByWordChar(ScintillaControl sci, Int32 position) { if (IsWordChar((byte)sci.CharAt(position)) == false) { return(position); } Int32 pos = position; Int32 aft = sci.PositionAfter(pos); while (IsWordChar((byte)sci.CharAt(aft)) == true) { pos = aft; aft = sci.PositionAfter(pos); if (aft == pos) { return(aft); } } return(aft); }
private void OnUpdateCallTip(ScintillaControl sci, int position) { if (ASComplete.HasCalltip()) { int pos = sci.CurrentPos - 1; char c = (char)sci.CharAt(pos); if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0) { sci.Colourise(0, -1); } ASComplete.HandleFunctionCompletion(sci, false, true); } }
static public bool OnChar(ScintillaControl Sci, int Value, int position, int style) { if (style == 3 || style == 124) { switch (Value) { // documentation tag case '@': return(HandleDocTagCompletion(Sci)); // documentation bloc case '*': if ((position > 2) && (Sci.CharAt(position - 3) == '/') && (Sci.CharAt(position - 2) == '*') && ((position == 3) || (Sci.BaseStyleAt(position - 4) != 3))) { HandleBoxCompletion(Sci, position); } break; } } return(false); }
public static Boolean NextNonWhiteCharIsOpenBrace(ScintillaControl sci, Int32 position) { Int32 pos = NextNonWhiteCharPosition(sci, position); if (pos > -1) { return(sci.CharAt(pos) == 123); } else { return(false); } }
private static bool IsEscapedCharacter(ScintillaControl sci, int position, char escapeChar = '\\') { var escaped = false; for (var i = position - 1; i >= 0; i--) { if (sci.CharAt(i) != escapeChar) { break; } escaped = !escaped; } return(escaped); }
int GetDisplayPosition() { var pos = Expr.Position; switch (CompilerService) { case HaxeCompilerService.COMPLETION: // locate a . or ( while (pos > 1 && Sci.CharAt(pos - 1) != '.' && Sci.CharAt(pos - 1) != '(') { pos--; } break; case HaxeCompilerService.POSITION: pos = Sci.WordEndPosition(Sci.CurrentPos, true) + 1; break; } // account for BOM characters pos += FileHelper.GetEncodingFileInfo(FileName).BomLength; return(pos); }
public override int GetStartOfStatement(ScintillaControl sci, int startPosition) { var result = -1; var pos = startPosition; if (sci.GetWordFromPosition(pos) == "for") { var parCount = 0; var dots = string.Empty; var endPosition = sci.TextLength; while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (c > ' ') { if (c == '(') { parCount++; } else if (c == ')') { parCount--; if (parCount == 0) { result = sci.WordStartPosition(startPosition, true); break; } } else if (c == '.') { dots += '.'; if (dots.Length == 3) { result = -1; break; } } else { dots = string.Empty; } } } pos++; } } return(result); }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { Char c; System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.')) { break; } sb.Insert(0, c); } return(sb.ToString()); }
public static Int32 GetWordStartPositionByWordChar(ScintillaControl sci, Int32 position) { Int32 pos = position; Int32 bef = sci.PositionBefore(pos); while (IsWordChar((byte)sci.CharAt(bef)) == true) { pos = bef; bef = sci.PositionBefore(pos); if (bef == pos) { return(bef); } } return(pos); }
public static Int32 NextCharPosition(ScintillaControl sci, Int32 position, String c) { Int32 curPos = sci.CurrentPos; sci.GotoPos(position); char currentChar = (char)sci.CharAt(sci.CurrentPos); if (currentChar.ToString().Equals(c)) { sci.CharRight(); } sci.SearchAnchor(); Int32 next = sci.SearchNext(0, c); sci.GotoPos(curPos); return(next); }
private string ReadWordLeft(ScintillaControl sci, int i) { bool inWord = false; string word = ""; while (i > 1) { char c = (char)sci.CharAt(i--); if (wordChars.IndexOf(c) >= 0) { inWord = true; word = c + word; } else if (inWord) { break; } } return(word); }
public static Int32 PreviousNonWhiteCharPosition(ScintillaControl sci, Int32 position) { Int32 pos = position; Int32 bef = sci.PositionBefore(pos); if (bef == pos) { return(-1); } while (IsWhiteChar(sci.CharAt(bef)) == true) { pos = bef; bef = sci.PositionBefore(pos); if (bef == pos) { return(-1); } } return(bef); }
public static Int32 NextNonWhiteCharPosition(ScintillaControl sci, Int32 position) { Int32 pos = position; Int32 aft = sci.PositionAfter(pos); if (aft == pos) { return(-1); } while (IsWhiteChar(sci.CharAt(aft)) == true) { pos = aft; aft = sci.PositionAfter(pos); if (aft == pos) { return(-1); } } return(aft); }
/// <summary> /// Shows the completion list automaticly after typing three chars /// </summary> private void SciControlCharAdded(ScintillaControl sci, Int32 value) { ITabbedDocument doc = DocumentManager.FindDocument(sci); if (this.isSupported && !settingObject.DisableAutoCompletion) { String lang = sci.ConfigurationLanguage; AutoInsert insert = settingObject.AutoInsertType; Language config = ScintillaControl.Configuration.GetLanguage(lang); String characters = config.characterclass.Characters; // Do not autocomplete in word Char c = (char)sci.CharAt(sci.CurrentPos); if (characters.IndexOf(c) >= 0) { return; } // Autocomplete after typing word chars only if (characters.IndexOf((char)value) < 0) { return; } String curWord = sci.GetWordLeft(sci.CurrentPos - 1, false); if (curWord == null || curWord.Length < 3) { return; } List <ICompletionListItem> items = this.GetCompletionListItems(lang, sci.FileName); if (items != null && items.Count > 0) { items.Sort(); CompletionList.Show(items, true, curWord); if (insert == AutoInsert.Never || (insert == AutoInsert.CPP && sci.Lexer != 3 /*CPP*/) || lang == "text") { CompletionList.DisableAutoInsertion(); } } } }
/// <summary> /// Gets the word from the specified position /// </summary> private static string GetWordLeft(ScintillaControl sci, ref Int32 position) { Char c; String word = ""; String exclude = "(){};,+///\\=:.%\"<>"; while (position >= 0) { c = (Char)sci.CharAt(position); if (c <= ' ') { break; } else if (exclude.IndexOf(c) >= 0) { break; } else { word = c + word; } position--; } return(word); }
public virtual int GetEndOfStatement(ScintillaControl sci, int startPosition) { var parCount = 0; var parseBody = false; var characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters; var word = string.Empty; var endPosition = sci.TextLength; var pos = startPosition; while (pos < endPosition) { if (!sci.PositionIsOnComment(pos)) { var c = (char)sci.CharAt(pos); if (parseBody) { if (c == '{') { if (word == "catch") { pos = Reflector.ASGenerator.GetEndOfStatement(pos - 1, endPosition, sci); return(pos == endPosition ? pos : GetEndOfStatement(sci, pos)); } return(Reflector.ASGenerator.GetEndOfStatement(pos - 1, endPosition, sci)); } if (c > ' ') { if (characterClass.IndexOf(c) != -1) { word = sci.GetWordRight(pos, false); switch (word) { case "if": return(GetStartOfIfStatement(sci, pos + word.Length)); case "for": case "while": case "switch": pos += word.Length; return(GetEndOfStatement(sci, pos)); case "do": case "try": pos += word.Length; pos = Reflector.ASGenerator.GetEndOfStatement(pos, endPosition, sci); return(pos == endPosition ? pos : GetEndOfStatement(sci, pos)); default: pos += word.Length; return(Reflector.ASGenerator.GetEndOfStatement(pos, endPosition, sci)); } } if (c == ';') { return(pos + 1); } } } else if (characterClass.IndexOf(c) != -1) { if (string.IsNullOrEmpty(word)) { word = sci.GetWordRight(pos, false); } if (word == "finally") { pos += word.Length; parseBody = true; } } else if (c == '(') { parCount++; } else if (c == ')') { parCount--; if (parCount == 0) { parseBody = true; } } } pos++; } return(-1); }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { int insideBrackets = 0; Char c; StringBuilder sb = new StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (c == ')') { insideBrackets++; } else if (c == '(' && insideBrackets > 0) { insideBrackets--; } else if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.') && insideBrackets == 0) { break; } sb.Insert(0, c); } return sb.ToString(); }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { Char c; System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.')) { break; } sb.Insert(0, c); } return sb.ToString(); }