/// <summary> /// Get the object, which was inserted under the keyword (line, at offset, with length length), /// returns null, if no such keyword was inserted. /// </summary> public object this[IDocument document, LineSegment line, int offset, int length] { get { if (length == 0) { return(null); } Node next = root; int wordOffset = line.Offset + offset; if (casesensitive) { for (int i = 0; i < length; ++i) { int index = document.GetCharAt(wordOffset + i) % 256; next = next[index]; if (next == null) { return(null); } if (next.color != null && TextUtility.RegionMatches(document, wordOffset, length, next.word)) { return(next.color); } } } else { for (int i = 0; i < length; ++i) { int index = char.ToUpper(document.GetCharAt(wordOffset + i)) % 256; next = next[index]; if (next == null) { return(null); } if (next.color != null && TextUtility.RegionMatches(document, casesensitive, wordOffset, length, next.word)) { return(next.color); } } } return(null); } }
public object this[IDocument document, LineSegment line, int offset, int length] { get { if (length == 0) { return(null); } LookupTable.Node item = this.root; int num = line.Offset + offset; if (!this.casesensitive) { for (int i = 0; i < length; i++) { int upper = char.ToUpper(document.GetCharAt(num + i)) % 'Ā'; item = item[upper]; if (item == null) { return(null); } if (item.color != null && TextUtility.RegionMatches(document, this.casesensitive, num, length, item.word)) { return(item.color); } } } else { for (int j = 0; j < length; j++) { int charAt = document.GetCharAt(num + j) % 'Ā'; item = item[charAt]; if (item == null) { return(null); } if (item.color != null && TextUtility.RegionMatches(document, num, length, item.word)) { return(item.color); } } } return(null); } }
public static bool RegionMatches(IDocument document, bool casesensitive, int offset, int length, char[] word) { if (casesensitive) { return(TextUtility.RegionMatches(document, offset, length, word)); } if (length != (int)word.Length || document.TextLength < offset + length) { return(false); } for (int i = 0; i < length; i++) { if (char.ToUpper(document.GetCharAt(offset + i)) != char.ToUpper(word[i])) { return(false); } } return(true); }