/// <summary> /// Adds or removes a marker /// </summary> public static void ToggleMarker(ScintillaControl sci, Int32 marker, Int32 line) { Int32 lineMask = sci.MarkerGet(line); if ((lineMask & GetMarkerMask(marker)) == 0) sci.MarkerAdd(line, marker); else sci.MarkerDelete(line, marker); UITools.Manager.MarkerChanged(sci, line); }
/// <summary> /// Bookmarks a search match /// </summary> public static void BookmarkMatches(ScintillaControl sci, List<SearchMatch> matches) { for (Int32 i = 0; i < matches.Count; i++) { Int32 line = matches[i].Line - 1; sci.EnsureVisible(line); sci.MarkerAdd(line, 0); } }
/// <summary> /// Applies the state object to a scintilla control /// </summary> private static void ApplyStateObject(ScintillaControl sci, StateObject so, Boolean restorePosition) { if (so.LineCount != sci.LineCount) return; sci.Refresh(); // Update the scintilla control state for (Int32 i = 0; i < so.FoldedLines.Count; i++) { Int32 foldedLine = so.FoldedLines[i]; sci.ToggleFold(foldedLine); } if (so.BookmarkedLines != null) { for (Int32 i = 0; i < so.BookmarkedLines.Count; i++) { Int32 bookmarkedLine = so.BookmarkedLines[i]; sci.MarkerAdd(bookmarkedLine, 0); } sci.Refresh(); // Update again } if (restorePosition) { sci.FirstVisibleLine = so.LineScroll; Int32 line = sci.LineFromPosition(so.Position); sci.SetSel(so.Position, so.Position); sci.EnsureVisible(line); } }
/// <summary> /// Handles the modified event /// </summary> public void OnScintillaControlModified(ScintillaControl sender, Int32 pos, Int32 modType, String text, Int32 length, Int32 lAdded, Int32 line, Int32 fLevelNow, Int32 fLevelPrev) { ITabbedDocument document = DocumentManager.FindDocument(sender); if (document != null && document.IsEditable) { this.OnDocumentModify(document); if (this.appSettings.ViewModifiedLines) { Int32 flags = sender.ModEventMask; sender.ModEventMask = flags & ~(Int32)ScintillaNet.Enums.ModificationFlags.ChangeMarker; Int32 modLine = sender.LineFromPosition(pos); sender.MarkerAdd(modLine, 2); for (Int32 i = 0; i <= lAdded; i++) { sender.MarkerAdd(modLine + i, 2); } sender.ModEventMask = flags; } } }
/// <summary> /// /// </summary> static public void SciControl_MarginClick(ScintillaControl sender, int modifiers, int position, int margin) { if (margin != 0) return; //if (PluginMain.debugManager.FlashInterface.isDebuggerStarted && !PluginMain.debugManager.FlashInterface.isDebuggerSuspended) return; int line = sender.LineFromPosition(position); if (IsMarkerSet(sender, markerBPEnabled, line)) { sender.MarkerDelete(line, markerBPEnabled); } else { if (IsMarkerSet(sender, markerBPDisabled, line)) sender.MarkerDelete(line, markerBPDisabled); sender.MarkerAdd(line, markerBPEnabled); } }
/// <summary> /// Adds or removes a marker /// </summary> public static void ToggleMarker(ScintillaControl sci, Int32 marker, Int32 line) { if (!HasMarker(sci, marker, line)) sci.MarkerAdd(line, marker); else sci.MarkerDelete(line, marker); UITools.Manager.MarkerChanged(sci, line); }
/// <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> /// 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; }