/// <summary> /// Selects the text specified in the action point /// </summary> public static void ExecuteActionPoint(ActionPoint point, ScintillaControl sci) { if (point.EntryPosition != -1 && point.ExitPosition != -1) { Int32 start = sci.MBSafePosition(point.EntryPosition); Int32 end = sci.MBSafePosition(point.ExitPosition); sci.SetSel(start, end); } else if (point.EntryPosition != -1 && point.ExitPosition == -1) { Int32 start = sci.MBSafePosition(point.EntryPosition); sci.SetSel(start, start); } }
/// <summary> /// Selects a search match /// </summary> public static void SelectMatch(ScintillaControl sci, SearchMatch match) { Int32 start = sci.MBSafePosition(match.Index); // wchar to byte position Int32 end = start + sci.MBSafeTextLength(match.Value); // wchar to byte text length Int32 line = sci.LineFromPosition(start); sci.EnsureVisible(line); sci.SetSel(start, end); }
/// <summary> /// Checks if the given match actually is the declaration. /// </summary> public static bool IsMatchTheTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target) { if (Sci == null || target == null || target.InFile == null || target.Member == null) { return(false); } String originalFile = Sci.FileName; // get type at match position ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)); return((declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)))); }
/// <summary> /// Checks if a given search match actually points to the given target source /// </summary /// <returns>True if the SearchMatch does point to the target source.</returns> static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper) { if (Sci == null || target == null) { return(false); } bool matchMember = target.InFile != null && target.Member != null; bool matchType = target.Member == null && target.IsStatic && target.Type != null; if (!matchMember && !matchType) { return(false); } ASResult result = null; // get type at match position if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported { result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)); if (associatedDocumentHelper != null) { // because the declaration lookup opens a document, we should register it with the document helper to be closed later associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument); } } // check if the result matches the target if (result == null || (result.InFile == null && result.Type == null)) { return(false); } if (matchMember) { if (result.Member == null) { return(false); } return(result.InFile.BasePath == target.InFile.BasePath && result.InFile.FileName == target.InFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name); } else // type { if (result.Type == null) { return(false); } if (result.Type.QualifiedName == target.Type.QualifiedName) { return(true); } return(false); } }
/// <summary> /// Processes the snippet and template arguments /// </summary> public static Int32 PostProcessSnippets(ScintillaControl sci, Int32 currentPosition) { Int32 delta = 0; while (sci.SelectText(BOUNDARY, 0) != -1) { sci.ReplaceSel(""); delta -= BOUNDARY.Length; } String text = sci.Text; // Store text temporarily Int32 entryPosition = sci.MBSafePosition(text.IndexOfOrdinal(ENTRYPOINT)); Int32 exitPosition = sci.MBSafePosition(text.IndexOfOrdinal(EXITPOINT)); if (entryPosition != -1 && exitPosition != -1) { sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length; sci.SelectText(EXITPOINT, 0); sci.ReplaceSel(""); delta -= EXITPOINT.Length; sci.SetSel(entryPosition, exitPosition - ENTRYPOINT.Length); } else if (entryPosition != -1 && exitPosition == -1) { sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length; sci.SetSel(entryPosition, entryPosition); } else sci.SetSel(currentPosition, currentPosition); return delta; }
/// <summary> /// Checks if a given search match actually points to the given target source /// </summary /// <returns>True if the SearchMatch does point to the target source.</returns> static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper) { if (Sci == null || target == null || target.inFile == null || target.Member == null) { return(false); } // get type at match position ASResult result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)); if (associatedDocumentHelper != null) { // because the declaration lookup opens a document, we should register it with the document helper to be closed later associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument); } // check if the result matches the target // TODO: this method of checking their equality seems pretty crude -- is there a better way? if (result == null || result.inFile == null || result.Member == null) { return(false); } Boolean doesMatch = result.inFile.BasePath == target.inFile.BasePath && result.inFile.FileName == target.inFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name; return(doesMatch); }
/// <summary> /// Replaces only the matches in the current sci control /// </summary> public static void ReplaceMatches(IList<SearchMatch> matches, ScintillaControl sci, String replacement, String src) { if (sci == null || matches == null || matches.Count == 0) return; sci.BeginUndoAction(); try { for (Int32 i = 0; i < matches.Count; i++) { SelectMatch(sci, matches[i]); FRSearch.PadIndexes((List<SearchMatch>)matches, i, matches[i].Value, replacement); sci.EnsureVisible(sci.LineFromPosition(sci.MBSafePosition(matches[i].Index))); sci.ReplaceSel(replacement); } } finally { sci.EndUndoAction(); } }
/// <summary> /// Adds highlights to the correct sci control /// </summary> private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches) { ITabbedDocument doc = DocumentManager.FindDocument(sci); Language language = MainForm.Instance.SciConfig.GetLanguage(sci.ConfigurationLanguage); foreach (SearchMatch match in matches) { Int32 start = sci.MBSafePosition(match.Index); Int32 end = start + sci.MBSafeTextLength(match.Value); Int32 line = sci.LineFromPosition(start); Int32 position = start; Int32 es = sci.EndStyled; Int32 mask = 1 << sci.StyleBits; // Define indics in both controls... doc.SplitSci1.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox); doc.SplitSci1.SetIndicFore(0, language.editorstyle.HighlightBackColor); doc.SplitSci2.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox); doc.SplitSci2.SetIndicFore(0, language.editorstyle.HighlightBackColor); sci.StartStyling(position, mask); sci.SetStyling(end - start, mask); sci.StartStyling(es, mask - 1); } }
/// <summary> /// Move the document position /// </summary> private void MoveToPosition(ScintillaControl sci, Int32 position) { try { position = sci.MBSafePosition(position); // scintilla indexes are in 8bits Int32 line = sci.LineFromPosition(position); sci.EnsureVisible(line); sci.GotoPos(position); sci.SetSel(position, sci.LineEndPosition(line)); sci.Focus(); } catch { String message = TextHelper.GetString("Info.InvalidItem"); ErrorManager.ShowInfo(message); this.RemoveInvalidItems(); this.RefreshProject(); } }
/// <summary> /// Highlight a regexp match group /// </summary> /// <param name="sci"></param> /// <param name="matches"></param> private void AddHighlight(ScintillaControl sci, SearchMatch match) { Int32 start = sci.MBSafePosition(match.Index); // wchar to byte position Int32 end = start + sci.MBSafeTextLength(match.Value); // wchar to byte text length Int32 line = sci.LineFromPosition(start); Int32 position = start; Int32 es = sci.EndStyled; Int32 mask = 1 << sci.StyleBits; sci.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.Max); sci.SetIndicFore(0, 0xff0000); sci.StartStyling(position, mask); sci.SetStyling(end - start, mask); sci.StartStyling(es, mask - 1); }
/// <summary> /// Handles the incoming character /// </summary> public static void OnChar(ScintillaControl sci, Int32 value) { if (cType == XMLType.Invalid || (sci.ConfigurationLanguage != "xml" && sci.ConfigurationLanguage != "html")) return; XMLContextTag ctag; Int32 position = sci.CurrentPos; if (sci.BaseStyleAt(position) == 6 && value != '"') return; // in XML attribute Char c = ' '; DataEvent de; switch (value) { case 10: // Shift+Enter to insert <BR/> Int32 line = sci.LineFromPosition(position); if (Control.ModifierKeys == Keys.Shift) { ctag = GetXMLContextTag(sci, position); if (ctag.Tag == null || ctag.Tag.EndsWith(">")) { int start = sci.PositionFromLine(line)-((sci.EOLMode == 0)? 2:1); sci.SetSel(start, position); sci.ReplaceSel((PluginSettings.UpperCaseHtmlTags) ? "<BR/>" : "<br/>"); sci.SetSel(start+5, start+5); return; } } if (PluginSettings.SmartIndenter) { // There is no standard for XML formatting, although most IDEs have similarities. We are mostly going with Visual Studio style with slight differences. // Get last non-empty line. String text = ""; Int32 line2 = line - 1; while (line2 >= 0 && text.Length == 0) { text = sci.GetLine(line2).TrimEnd(); line2--; } if ((text.EndsWith(">") && !text.EndsWith("?>") && !text.EndsWith("%>")) || text.EndsWith("<!--") || text.EndsWith("<![CDATA[")) { // Get the previous tag. do { position--; c = (Char)sci.CharAt(position); } while (position > 0 && c != '>'); ctag = GetXMLContextTag(sci, c == '>' ? position + 1 : position); // Line indentation. Int32 indent = sci.GetLineIndentation(line2 + 1); String checkStart = null; bool subIndent = true; if (text.EndsWith("<!--")) { checkStart = "-->"; subIndent = false; } else if (text.EndsWith("<![CDATA[")) { checkStart = "]]>"; subIndent = false; } else if (ctag.Closed || ctag.Closing) { //Closed tag. Look for the nearest open and not closed tag for proper indentation subIndent = false; if (ctag.Name != null) { var tmpTags = new Stack<XMLContextTag>(); var tmpTag = ctag; if (!tmpTag.Closed) tmpTags.Push(tmpTag); while (tmpTag.Position != 0) { tmpTag = GetXMLContextTag(sci, tmpTag.Position); if (tmpTag.Tag != null && tmpTag.Name != null) { if (tmpTag.Closed) continue; else if (tmpTag.Closing) { tmpTags.Push(tmpTag); } else { if (tmpTags.Count > 0 && tmpTags.Peek().Name == tmpTag.Name) tmpTags.Pop(); else break; } } } if (tmpTags.Count > 0) indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTags.Pop().Position)); else if (tmpTag.Name != null) { subIndent = true; checkStart = "</" + tmpTag.Name; indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTag.Position)); } else { indent = sci.GetLineIndentation(sci.LineFromPosition(tmpTag.Position)); } } } else if (ctag.Name != null) { // Indentation. Some IDEs use the tag position, VS uses the tag start line indentation. indent = sci.GetLineIndentation(sci.LineFromPosition(ctag.Position)); checkStart = "</" + ctag.Name; if (ctag.Name.ToLower() == "script" || ctag.Name.ToLower() == "style") subIndent = false; } try { sci.BeginUndoAction(); if (checkStart != null) { text = sci.GetLine(line).TrimStart(); if (text.StartsWith(checkStart)) { sci.SetLineIndentation(line, indent); sci.InsertText(sci.PositionFromLine(line), LineEndDetector.GetNewLineMarker(sci.EOLMode)); } } // Indent the code if (subIndent) indent += sci.Indent; sci.SetLineIndentation(line, indent); position = sci.LineIndentPosition(line); sci.SetSel(position, position); } finally { sci.EndUndoAction(); } return; } else if (!text.EndsWith(">")) { ctag = GetXMLContextTag(sci, sci.CurrentPos); if (ctag.Tag == null || ctag.Name == null) return; // We're inside a tag. Visual Studio indents with regards to the first line, other IDEs indent using the indentation of the last line with text. int indent; string tag = (ctag.Tag.IndexOf('\r') > 0 || ctag.Tag.IndexOf('\n') > 0) ? ctag.Tag.Substring(0, ctag.Tag.IndexOfAny(new[] {'\r', '\n'})).TrimEnd() : ctag.Tag.TrimEnd(); if (tag.EndsWith("\"")) { int i; int l = tag.Length; for (i = ctag.Name.Length + 1; i < l; i++) { if (!char.IsWhiteSpace(tag[i])) break; } indent = sci.Column(ctag.Position) + sci.MBSafePosition(i); } else { indent = sci.GetLineIndentation(sci.LineFromPosition(ctag.Position)) + sci.Indent; } sci.SetLineIndentation(line, indent); position = sci.LineIndentPosition(line); sci.SetSel(position, position); return; } } break; case '<': case '/': if (value == '/') { if ((position < 2) || ((Char)sci.CharAt(position-2) != '<')) return; ctag = new XMLContextTag(); ctag.Position = position - 2; ctag.Closing = true; } else { ctag = GetXMLContextTag(sci, position); if (ctag.Tag != null) return; } // Allow another plugin to handle this de = new DataEvent(EventType.Command, "XMLCompletion.Element", ctag); EventManager.DispatchEvent(PluginBase.MainForm, de); if (de.Handled) return; // New tag if (PluginSettings.EnableXMLCompletion && cType == XMLType.Known) { List<ICompletionListItem> items = new List<ICompletionListItem>(); String previous = null; foreach (string ns in namespaces) { items.Add(new NamespaceItem(ns)); } foreach (HTMLTag tag in knownTags) if (tag.Name != previous && (tag.NS == "" || tag.NS == defaultNS)) { items.Add( new HtmlTagItem(tag.Name, tag.Tag)); previous = tag.Name; } items.Sort(new ListItemComparer()); CompletionList.Show(items, true); } return; case ':': ctag = GetXMLContextTag(sci, position); if (ctag.NameSpace == null || position - ctag.Position > ctag.Name.Length + 2) return; // Allow another plugin to handle this de = new DataEvent(EventType.Command, "XMLCompletion.Namespace", ctag); EventManager.DispatchEvent(PluginBase.MainForm, de); if (de.Handled) return; // Show namespace's tags if (PluginSettings.EnableXMLCompletion && cType == XMLType.Known) { List<ICompletionListItem> items = new List<ICompletionListItem>(); String previous = null; foreach (HTMLTag tag in knownTags) if (tag.Name != previous && tag.NS == ctag.NameSpace) { items.Add(new HtmlTagItem(tag.Name, tag.Name)); previous = tag.Name; } CompletionList.Show(items, true); } return; case '>': if (PluginSettings.CloseTags) { ctag = GetXMLContextTag(sci, position); if (ctag.Name != null && !ctag.Closed) { // Allow another plugin to handle this de = new DataEvent(EventType.Command, "XMLCompletion.CloseElement", ctag); EventManager.DispatchEvent(PluginBase.MainForm, de); if (de.Handled) return; if (ctag.Closing) return; Boolean isLeaf = false; if (cType == XMLType.Known) foreach(HTMLTag tag in knownTags) { if (String.Compare(tag.Tag, ctag.Name, true) == 0) { isLeaf = tag.IsLeaf; break; } } if (isLeaf) { sci.SetSel(position-1,position); sci.ReplaceSel("/>"); sci.SetSel(position+1, position+1); } else { String closeTag = "</"+ctag.Name+">"; sci.ReplaceSel(closeTag); sci.SetSel(position, position); } } } return; case ' ': c = (char)sci.CharAt(position); if (c > 32 && c != '/' && c != '>' && c != '<') return; ctag = GetXMLContextTag(sci, position); if (ctag.Tag != null) { if (InQuotes(ctag.Tag) || ctag.Tag.LastIndexOf('"') < ctag.Tag.LastIndexOf('=')) return; // Allow another plugin to handle this Object[] obj = new Object[] { ctag, "" }; de = new DataEvent(EventType.Command, "XMLCompletion.Attribute", obj); EventManager.DispatchEvent(PluginBase.MainForm, de); if (de.Handled) return; if (PluginSettings.EnableXMLCompletion && cType == XMLType.Known) { foreach (HTMLTag tag in knownTags) if (String.Compare(tag.Tag, ctag.Name, true) == 0) { List<ICompletionListItem> items = new List<ICompletionListItem>(); String previous = null; foreach (String attr in tag.Attributes) if (attr != previous) { items.Add(new HtmlAttributeItem(attr)); previous = attr; } CompletionList.Show(items, true); return; } } } /*else { if (Control.ModifierKeys == Keys.Shift) { sci.SetSel(position - 1, position); sci.ReplaceSel(" "); } }*/ return; case '=': if (PluginSettings.InsertQuotes) { ctag = GetXMLContextTag(sci, position); position = sci.CurrentPos-2; if (ctag.Tag != null && !String.IsNullOrEmpty(ctag.Name) && Char.IsLetter(ctag.Name[0]) && !InQuotes(ctag.Tag) && (GetWordLeft(sci, ref position).Length > 0)) { position = sci.CurrentPos; c = (Char)sci.CharAt(position); if (c > 32 && c != '>') sci.ReplaceSel("\"\" "); else sci.ReplaceSel("\"\""); sci.SetSel(position+1, position+1); justInsertedQuotesAt = position+1; // Allow another plugin to handle this de = new DataEvent(EventType.Command, "XMLCompletion.AttributeValue", new Object[] { ctag, string.Empty }); EventManager.DispatchEvent(PluginBase.MainForm, de); } } return; case '"': ctag = GetXMLContextTag(sci, position); if (position > 1 && ctag.Tag != null && !ctag.Tag.StartsWith("<!")) { // TODO Colorize text change to highlight what's been done if (justInsertedQuotesAt == position - 1) { justInsertedQuotesAt = -1; c = (Char)sci.CharAt(position - 2); if (c == '"' && (Char)sci.CharAt(position-2) == '"') { sci.SetSel(position - 2, position); sci.ReplaceSel("\""); } // Allow another plugin to handle this de = new DataEvent(EventType.Command, "XMLCompletion.AttributeValue", new Object[] {ctag, string.Empty}); EventManager.DispatchEvent(PluginBase.MainForm, de); } else { c = (Char)sci.CharAt(position - 1); if (c == '"' && (Char)sci.CharAt(position) == '"') { sci.SetSel(position - 1, position + 1); sci.ReplaceSel("\""); } } } break; case '?': case '%': if (PluginSettings.CloseTags && position > 1) { ctag = GetXMLContextTag(sci, position-2); if (ctag.Tag == null || ctag.Tag.EndsWith(">")) { if ((Char)sci.CharAt(position-2) == '<') { sci.ReplaceSel((Char)value + ">"); sci.SetSel(position, position); } } } break; case '!': if (PluginSettings.CloseTags && position > 1) { ctag = GetXMLContextTag(sci, position-2); if (ctag.Tag == null || ctag.Tag.EndsWith(">")) { if ((Char)sci.CharAt(position-2) == '<') { CompletionList.Show(xmlBlocks, true); } } } break; } }
/// <summary> /// Checks if a given search match actually points to the given target source /// </summary> /// <returns>True if the SearchMatch does point to the target source.</returns> public static bool DoesMatchPointToTarget(ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper) { if (Sci == null || target == null) return false; FileModel targetInFile = null; if (target.InFile != null) targetInFile = target.InFile; else if (target.Member != null && target.InClass == null) targetInFile = target.Member.InFile; Boolean matchMember = targetInFile != null && target.Member != null; Boolean matchType = target.Member == null && target.IsStatic && target.Type != null; if (!matchMember && !matchType) return false; ASResult result = null; // get type at match position if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported { result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)); if (associatedDocumentHelper != null) { // because the declaration lookup opens a document, we should register it with the document helper to be closed later associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument); } } // check if the result matches the target if (result == null || (result.InFile == null && result.Type == null)) return false; if (matchMember) { if (result.Member == null) return false; var resultInFile = result.InClass != null ? result.InFile : result.Member.InFile; return resultInFile.BasePath == targetInFile.BasePath && resultInFile.FileName == targetInFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name; } else // type { if (result.Type == null) return false; if (result.Type.QualifiedName == target.Type.QualifiedName) return true; return false; } }
/// <summary> /// Checks if the given match actually is the declaration. /// </summary> public static bool IsMatchTheTarget(ScintillaControl Sci, SearchMatch match, ASResult target) { if (Sci == null || target == null || target.InFile == null || target.Member == null) { return false; } String originalFile = Sci.FileName; // get type at match position ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)); return (declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value))); }
/// <summary> /// Adds highlights to the correct sci control /// </summary> private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches) { if (matches == null) { return; } foreach (SearchMatch match in matches) { Int32 start = sci.MBSafePosition(match.Index); Int32 end = start + sci.MBSafeTextLength(match.Value); Int32 line = sci.LineFromPosition(start); Int32 position = start; Int32 es = sci.EndStyled; Int32 mask = 1 << sci.StyleBits; sci.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox); sci.SetIndicFore(0, DataConverter.ColorToInt32(this.settingObject.highlightColor)); sci.StartStyling(position, mask); sci.SetStyling(end - start, mask); sci.StartStyling(es, mask - 1); if (this.settingObject.addLineMarker) { sci.MarkerAdd(line, 2); sci.MarkerSetBack(2, DataConverter.ColorToInt32(this.settingObject.highlightColor)); } } }
/// <summary> /// TODO slavara: IMPLEMENT ME /// </summary> /// <param name="matches"></param> /// <param name="exprType"></param> /// <param name="sci"></param> /// <returns></returns> private List<SearchMatch> FilterResults(List<SearchMatch> matches, ASResult exprType, ScintillaControl sci) { if (matches == null || matches.Count == 0) return null; MemberModel contextMember = null; int lineFrom = 0; int lineTo = sci.LineCount; FlagType localVarMask = FlagType.LocalVar | FlagType.ParameterVar; bool isLocalVar = false; if (exprType.Member != null) { if ((exprType.Member.Flags & localVarMask) > 0) { contextMember = exprType.Context.ContextFunction; lineFrom = contextMember.LineFrom; lineTo = contextMember.LineTo; isLocalVar = true; } } List<SearchMatch> newMatches = new List<SearchMatch>(); foreach (SearchMatch m in matches) { if (m.Line < lineFrom || m.Line > lineTo) continue; int pos = sci.MBSafePosition(m.Index); exprType = ASComplete.GetExpressionType(sci, sci.WordEndPosition(pos, true)); if (exprType != null) { MemberModel member = exprType.Member; if (!isLocalVar) { if ((exprType.Type != null && member == null) || (member != null && (member.Flags & localVarMask) == 0)) newMatches.Add(m); } else if (member != null && (member.Flags & localVarMask) > 0) newMatches.Add(m); } } return newMatches; }
/// <summary> /// Adds highlights to the correct sci control /// </summary> private void AddHighlights(ScintillaControl sci, List<SearchMatch> matches) { if (matches == null) return; int style = (int)settings.HighlightStyle; int color = DataConverter.ColorToInt32(settings.HighlightColor); if (settings.HighlightUnderCursorEnabled && prevResult != null) { if (prevResult.IsPackage) color = DataConverter.ColorToInt32(settings.PackageColor); else { FlagType flags; if (prevResult.Type != null && prevResult.Member == null) { flags = prevResult.Type.Flags; if ((flags & FlagType.Abstract) > 0) color = DataConverter.ColorToInt32(settings.AbstractColor); else if ((flags & FlagType.TypeDef) > 0) color = DataConverter.ColorToInt32(settings.TypeDefColor); else if ((flags & FlagType.Enum) > 0) color = DataConverter.ColorToInt32(settings.EnumColor); else if ((flags & FlagType.Class) > 0) color = DataConverter.ColorToInt32(settings.ClassColor); } else if (prevResult.Member != null) { flags = prevResult.Member.Flags; if ((flags & FlagType.Constant) > 0) color = DataConverter.ColorToInt32(settings.ConstantColor); else if ((flags & FlagType.ParameterVar) > 0) color = DataConverter.ColorToInt32(settings.MemberFunctionColor); else if ((flags & FlagType.LocalVar) > 0) color = DataConverter.ColorToInt32(settings.LocalVariableColor); else if ((flags & FlagType.Static) == 0) { if ((flags & FlagType.Variable) > 0) color = DataConverter.ColorToInt32(settings.VariableColor); else if ((flags & (FlagType.Setter | FlagType.Getter)) > 0) color = DataConverter.ColorToInt32(settings.AccessorColor); else if ((flags & FlagType.Function) > 0) color = DataConverter.ColorToInt32(settings.MethodColor); } else { if ((flags & FlagType.Variable) > 0) color = DataConverter.ColorToInt32(settings.StaticVariableColor); else if ((flags & (FlagType.Setter | FlagType.Getter)) > 0) color = DataConverter.ColorToInt32(settings.StaticAccessorColor); else if ((flags & FlagType.Function) > 0) color = DataConverter.ColorToInt32(settings.StaticMethodColor); } } } } int es = sci.EndStyled; int mask = 1 << sci.StyleBits; bool addLineMarker = settings.AddLineMarker; foreach (SearchMatch match in matches) { int start = sci.MBSafePosition(match.Index); int end = start + sci.MBSafeTextLength(match.Value); int line = sci.LineFromPosition(start); int position = start; sci.SetIndicStyle(0, style); sci.SetIndicFore(0, color); sci.StartStyling(position, mask); sci.SetStyling(end - start, mask); sci.StartStyling(es, mask - 1); if (addLineMarker) { sci.MarkerAdd(line, MARKER_NUMBER); sci.MarkerSetBack(MARKER_NUMBER, color); } } prevPos = sci.CurrentPos; }