public double GetLineHeight (MonoTextEditor editor) { return editor.LineHeight; /* if (!IsVisible || DebuggingService.IsDebugging) return editor.LineHeight; if (editorAllocHeight == editor.Allocation.Width && lastLineLength == lineSegment.EditableLength) return lastHeight; CalculateLineFit (editor, lineSegment); double height; if (CollapseExtendedErrors) { height = editor.LineHeight; } else { // TODO: Insert virtual lines, if required height = UseVirtualLines ? editor.LineHeight * errors.Count : editor.LineHeight; } if (!fitsInSameLine) height += editor.LineHeight; editorAllocHeight = editor.Allocation.Height; lastLineLength = lineSegment.EditableLength; lastHeight = height; return height;*/ }
public override async Task<TooltipItem> GetItem (MonoTextEditor editor, int offset, CancellationToken token = default(CancellationToken)) { var wrappedEditor = WrapEditor (editor); if (wrappedEditor == null) return null; var doc = IdeApp.Workbench.ActiveDocument; if (doc == null) return null; var task = provider.GetItem (wrappedEditor, doc, offset, token); if (task == null) { LoggingService.LogWarning ("Tooltip provider " + provider + " gave back null on GetItem (should always return a non null task)."); return null; } var item = await task; if (item == null) return null; if (lastUnwrappedItem != null) { if (lastUnwrappedItem.Offset == item.Offset && lastUnwrappedItem.Length == item.Length && lastUnwrappedItem.Item.Equals (item.Item)) { return lastWrappedItem; } } lastUnwrappedItem = item; return lastWrappedItem = new TooltipItem (item.Item, item.Offset, item.Length); }
static void DrawIcon (MonoTextEditor editor, Cairo.Context cr, DocumentLine lineSegment, double x, double y, double width, double height) { if (lineSegment.IsBookmarked) { var color1 = editor.ColorStyle.Bookmarks.Color; var color2 = editor.ColorStyle.Bookmarks.SecondColor; DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4); // FIXME: VV: Remove gradient features using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) { pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.SetSource (pat); cr.FillPreserve (); } // FIXME: VV: Remove gradient features using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) { pat.AddColorStop (0, color2); //pat.AddColorStop (1, color1); cr.SetSource (pat); cr.Stroke (); } } }
public ColorShemeEditor (HighlightingPanel panel) { this.panel = panel; this.Build (); textEditor = new MonoTextEditor (); textEditor.Options = new StyledSourceEditorOptions (MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance); this.scrolledwindowTextEditor.Child = textEditor; textEditor.ShowAll (); this.treeviewColors.AppendColumn (GettextCatalog.GetString ("Name"), new Gtk.CellRendererText (), new CellLayoutDataFunc (SyntaxCellRenderer)); this.treeviewColors.HeadersVisible = false; this.treeviewColors.Model = colorStore; this.treeviewColors.SearchColumn = -1; // disable the interactive search this.treeviewColors.Selection.Changed += HandleTreeviewColorsSelectionChanged; this.hpaned1.Position = 250; this.SetSizeRequest (1024, 768); this.colorbuttonFg.ColorSet += Stylechanged; this.colorbuttonBg.ColorSet += Stylechanged; this.colorbuttonPrimary.ColorSet += Stylechanged; this.colorbuttonSecondary.ColorSet += Stylechanged; this.colorbuttonBorder.ColorSet += Stylechanged; colorbuttonBg.UseAlpha = true; this.checkbuttonBold.Toggled += Stylechanged; this.checkbuttonItalic.Toggled += Stylechanged; this.buttonOk.Clicked += HandleButtonOkClicked; HandleTreeviewColorsSelectionChanged (null, null); notebookColorChooser.ShowTabs = false; }
public virtual Gtk.Window ShowTooltipWindow (MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item) { int ox = 0, oy = 0; if (editor.GdkWindow != null) editor.GdkWindow.GetOrigin (out ox, out oy); int w; double xalign; GetRequiredPosition (editor, tipWindow, out w, out xalign); w += 10; int x = mouseX + ox + editor.Allocation.X; int y = mouseY + oy + editor.Allocation.Y; Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry (editor.Screen.GetMonitorAtPoint (x, y)); x -= (int) ((double) w * xalign); y += 10; if (x + w >= geometry.X + geometry.Width) x = geometry.X + geometry.Width - w; if (x < geometry.Left) x = geometry.Left; int h = tipWindow.SizeRequest ().Height; if (y + h >= geometry.Y + geometry.Height) y = geometry.Y + geometry.Height - h; if (y < geometry.Top) y = geometry.Top; tipWindow.Move (x, y); tipWindow.ShowAll (); return tipWindow; }
public BounceFadePopupWindow (MonoTextEditor editor) : base (Gtk.WindowType.Popup) { if (!IsComposited) throw new InvalidOperationException ("Only works with composited screen. Check Widget.IsComposited."); if (editor == null) throw new ArgumentNullException ("Editor"); DoubleBuffered = true; Decorated = false; BorderWidth = 0; HasFrame = true; this.editor = editor; Events = Gdk.EventMask.ExposureMask; Duration = 500; ExpandWidth = 12; ExpandHeight = 2; BounceEasing = Easing.Sine; var rgbaColormap = Screen.RgbaColormap; if (rgbaColormap == null) return; Colormap = rgbaColormap; stage.ActorStep += OnAnimationActorStep; stage.Iteration += OnAnimationIteration; stage.UpdateFrequency = 10; }
public GutterMargin (MonoTextEditor editor) { this.editor = editor; this.editor.Document.LineChanged += UpdateWidth; this.editor.Document.TextSet += HandleEditorDocumenthandleTextSet; this.editor.Caret.PositionChanged += EditorCarethandlePositionChanged; }
public FoldMarkerMargin (MonoTextEditor editor) { this.editor = editor; layout = PangoUtil.CreateLayout (editor); editor.Caret.PositionChanged += HandleEditorCaretPositionChanged; editor.Document.FoldTreeUpdated += HandleEditorDocumentFoldTreeUpdated; editor.Caret.PositionChanged += EditorCarethandlePositionChanged; }
static MonoDevelop.Ide.Editor.TextEditor WrapEditor (MonoTextEditor editor) { foreach (var doc in IdeApp.Workbench.Documents) { if (doc.FileName == editor.FileName) return doc.Editor; } return null; }
public ActionMargin (MonoTextEditor editor) { if (editor == null) throw new ArgumentNullException ("editor"); this.editor = editor; marginWidth = 20; IsVisible = false; this.editor.Caret.PositionChanged += HandlePositionChanged;; }
void IActionTextLineMarker.MouseHover (MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result) { MouseHover?.Invoke (this, new TextEventArgsWrapper (args)); result.Cursor = textLinkCursor; if (OnlyShowLinkOnHover) { editor.GetTextEditorData ().Document.CommitLineUpdate (args.LineSegment); editor.TextViewMargin.HoveredLineChanged += new UpdateOldLine (editor, args.LineSegment).TextViewMargin_HoveredLineChanged; } }
public override bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics) { if (metrics.SelectionStart > 0) return true; cr.SetSourceColor (color); cr.Rectangle (metrics.TextRenderStartPosition, metrics.LineYRenderStartPosition, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight); cr.Fill (); return true; }
public ViStatusArea (MonoTextEditor editor) { this.editor = editor; editor.TextViewMargin.CaretBlink += HandleCaretBlink; editor.Caret.PositionChanged += HandlePositionChanged; editor.AddTopLevelWidget (this, 0, 0); ((MonoTextEditor.EditorContainerChild)editor[this]).FixedPosition = true; Show (); }
bool IActionTextLineMarker.MouseReleased (MonoTextEditor editor, MarginMouseEventArgs args) { if ((Platform.IsMac && (args.ModifierState & Gdk.ModifierType.Mod2Mask) == Gdk.ModifierType.Mod2Mask) || (!Platform.IsMac && (args.ModifierState & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask)) activateLink?.Invoke (LinkRequest.RequestNewView); else activateLink?.Invoke (LinkRequest.SameView); return false; }
public GotoLineNumberWidget (MonoTextEditor textEditor, Widget frame) { this.textEditor = textEditor; this.frame = frame; this.Build (); StoreWidgetState (); textEditor.Parent.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; //HACK: GTK rendering issue on Mac, images don't repaint unless we put them in visible eventboxes if (MonoDevelop.Core.Platform.IsMac) { foreach (var eb in new [] { eventbox1, eventbox2 }) { eb.VisibleWindow = true; eb.ModifyBg (StateType.Normal, new Gdk.Color (230, 230, 230)); } } this.closeButton.Clicked += delegate { RestoreWidgetState (); CloseWidget (); }; this.buttonGoToLine.Clicked += delegate { cleanExit = true; GotoLine (); CloseWidget (); }; foreach (Gtk.Widget child in this.Children) { child.KeyPressEvent += delegate (object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) { RestoreWidgetState (); CloseWidget (); } }; } Gtk.Widget oldWidget = null; this.FocusChildSet += delegate (object sender, Gtk.FocusChildSetArgs args) { // only store state when the focus comes from a non child widget if (args.Widget != null && oldWidget == null) StoreWidgetState (); oldWidget = args.Widget; }; this.entryLineNumber.Changed += delegate { PreviewLine (); }; this.entryLineNumber.Activated += delegate { cleanExit = true; GotoLine (); CloseWidget (); }; }
// string status; public void InternalHandleKeypress (MonoTextEditor editor, TextEditorData data, Gdk.Key key, uint unicodeChar, Gdk.ModifierType modifier) { this.editor = editor; this.textEditorData = data; HandleKeypress (key, unicodeChar, modifier); //make sure that nothing funny goes on when the mode should have finished this.textEditorData = null; this.editor = null; }
internal void InternalCaretPositionChanged (MonoTextEditor editor, TextEditorData data) { // only trigger CaretPositionChanged when event is a result of external stimuli, i.e. when // not already running HandleKeypress if (this.editor == null) { this.editor = editor; this.textEditorData = data; CaretPositionChanged (); this.textEditorData = null; this.editor = null; } }
public FoldingScreenbackgroundRenderer (MonoTextEditor editor, IEnumerable<FoldSegment> foldSegments) { this.editor = editor; this.foldSegments = new List<FoldSegment> (foldSegments); startTime = DateTime.Now; timeout = GLib.Timeout.Add (30, delegate { editor.QueueDraw (); var cont = (DateTime.Now - startTime).TotalMilliseconds < animationLength; if (!cont) timeout = 0; return cont; }); }
public override void DrawForeground (MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics) { double size = metrics.Margin.Width; double borderLineWidth = cr.LineWidth; double x = Math.Floor (metrics.Margin.XOffset - borderLineWidth / 2); double y = Math.Floor (metrics.Y + (metrics.Height - size) / 2); var deltaX = size / 2 - DebugIcon.Width / 2 + 0.5f; var deltaY = size / 2 - DebugIcon.Height / 2 + 0.5f; cr.DrawImage (editor, DebugIcon, Math.Round (x + deltaX), Math.Round (y + deltaY)); }
public override void Update (MonoTextEditor editor) { var startLine = editor.GetLine (start); if (start == end) { editor.TextViewMargin.RemoveCachedLine (startLine); editor.RedrawLine (start); } else { for (int i = 0; startLine != null && i < end - start; i++) { editor.TextViewMargin.RemoveCachedLine (startLine); startLine = startLine.NextLine; } editor.RedrawLines (start, end); } }
public MessageBubbleCache (MonoTextEditor editor) { this.editor = editor; editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged; editor.TextArea.LeaveNotifyEvent += HandleLeaveNotifyEvent; editor.TextArea.MotionNotifyEvent += HandleMotionNotifyEvent; editor.TextArea.BeginHover += HandleBeginHover; editor.VAdjustment.ValueChanged += HandleValueChanged; editor.HAdjustment.ValueChanged += HandleValueChanged; fontDescription = FontService.GetFontDescription ("Pad"); tooltipFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold); errorCountFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold); }
public override void InformMouseHover (MonoTextEditor editor, Margin margin, MarginMouseEventArgs args) { base.InformMouseHover (editor, margin, args); if (!string.IsNullOrEmpty (Tooltip)) { if (CanDrawForeground (margin)) // update tooltip during the next ui loop run, // otherwise Gtk will not update the position of the tooltip Gtk.Application.Invoke (delegate { args.Editor.TooltipText = Tooltip; }); else if (args.Editor.TooltipText == Tooltip) args.Editor.TooltipText = null; } }
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { this.editor = editor; int markerStart = base.Offset; int markerEnd = base.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max (@from, editor.TextViewMargin.XOffset); to = Math.Max (to, editor.TextViewMargin.XOffset); if (@from < to) { cr.SetSourceColor (background(editor).Color); cr.RoundedRectangle (@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2); // 2.5 to make space for the column guideline if (background(editor).HasBorderColor) { cr.FillPreserve (); cr.SetSourceColor (background(editor).BorderColor); cr.Stroke (); } else { cr.Fill (); } } }
void IChunkMarker.ChangeForeColor (MonoTextEditor editor, Chunk chunk, ref Cairo.Color color) { if (Debugger.DebuggingService.IsDebugging) return; int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (chunk.EndOffset <= markerStart || markerEnd <= chunk.Offset) return; var bgc = editor.ColorStyle.PlainText.Background; double alpha = 0.6; color = new Cairo.Color ( color.R * alpha + bgc.R * (1.0 - alpha), color.G * alpha + bgc.G * (1.0 - alpha), color.B * alpha + bgc.B * (1.0 - alpha) ); }
public MessageBubbleCache (MonoTextEditor editor) { this.editor = editor; errorPixbuf = Xwt.Drawing.Image.FromResource ("gutter-error-15.png"); warningPixbuf = Xwt.Drawing.Image.FromResource ("gutter-warning-15.png"); editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged; editor.TextArea.LeaveNotifyEvent += HandleLeaveNotifyEvent; editor.TextArea.MotionNotifyEvent += HandleMotionNotifyEvent; editor.TextArea.BeginHover += HandleBeginHover; editor.VAdjustment.ValueChanged += HandleValueChanged; editor.HAdjustment.ValueChanged += HandleValueChanged; fontDescription = FontService.GetFontDescription ("Pad"); tooltipFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold); errorCountFontDescription = FontService.GetFontDescription ("Pad").CopyModified (weight: Pango.Weight.Bold); }
public GotoLineNumberWidget (MonoTextEditor textEditor, Widget frame) { this.textEditor = textEditor; this.frame = frame; this.Build (); StoreWidgetState (); textEditor.Parent.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; this.closeButton.Clicked += delegate { RestoreWidgetState (); CloseWidget (); }; this.buttonGoToLine.Clicked += delegate { cleanExit = true; GotoLine (); CloseWidget (); }; foreach (Gtk.Widget child in this.Children) { child.KeyPressEvent += delegate (object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) { RestoreWidgetState (); CloseWidget (); } }; } Gtk.Widget oldWidget = null; this.FocusChildSet += delegate (object sender, Gtk.FocusChildSetArgs args) { // only store state when the focus comes from a non child widget if (args.Widget != null && oldWidget == null) StoreWidgetState (); oldWidget = args.Widget; }; this.entryLineNumber.Changed += delegate { PreviewLine (); }; this.entryLineNumber.Activated += delegate { cleanExit = true; GotoLine (); CloseWidget (); }; }
public static ICollection <Cairo.Rectangle> GetDiffRectangles(MonoTextEditor editor, int startOffset, int endOffset) { ICollection <Cairo.Rectangle> rectangles = new List <Cairo.Rectangle> (); var startLine = editor.GetLineByOffset(startOffset); var endLine = editor.GetLineByOffset(endOffset); int lineCount = endLine.LineNumber - startLine.LineNumber; var line = startLine; for (int i = 0; i <= lineCount; i++) { Cairo.Point point = editor.LocationToPoint(editor.Document.OffsetToLocation(Math.Max(startOffset, line.Offset)), true); Cairo.Point point2 = editor.LocationToPoint(editor.Document.OffsetToLocation(Math.Min(line.EndOffset, endOffset)), true); rectangles.Add(new Cairo.Rectangle(point.X - editor.TextViewMargin.XOffset, point.Y, point2.X - point.X, editor.LineHeight)); line = line.NextLine; } return(rectangles); }
public void MouseHover(MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result) { if (!IsVisible) { return; } if (base.LineSegment == null) { return; } if (bubbleDrawX < args.X && args.X < bubbleDrawX + bubbleWidth) { editor.HideTooltip(); result.Cursor = null; cache.StartHover(this, bubbleDrawX, bubbleDrawY, bubbleWidth, bubbleIsReduced); } }
void DrawIconMarginBackground(MonoTextEditor ed, Cairo.Context cr, MarginDrawMetrics metrics) { cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height); cr.SetSourceColor(IconMarginColor); cr.Fill(); cr.MoveTo(metrics.Right - 0.5, metrics.Y); cr.LineTo(metrics.Right - 0.5, metrics.Bottom); cr.SetSourceColor(IconMarginBorderColor); cr.Stroke(); if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) { cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height); var color = (Cairo.Color)IconMarginColor; cr.SetSourceRGBA(color.R, color.G, color.B, 0.5); cr.Fill(); } }
void Change(MonoTextEditor textEditor, int n) { if (n == 0) { SetLocal(textEditor.GetTextEditorData()); return; } RemoveLocal(textEditor.GetTextEditorData()); textEditor.Document.IsReadOnly = true; if (n == 1) { if (textEditor == editors [0]) { diffRevision = null; } else { originalRevision = null; } Task.Run(async() => { try { return(await info.Item.Repository.GetBaseTextAsync(info.Item.Path)); } catch (Exception ex) { var text = string.Format(GettextCatalog.GetString("Error while getting the base text of {0}:\n{1}"), info.Item.Path, ex.ToString()); await Runtime.RunInMainThread(() => MessageService.ShowError(text)); return(text); } }).ContinueWith(t => { var editor = textEditor; if (editor.IsDisposed) { return; } editor.Document.Text = t.Result; CreateDiff(); }, Runtime.MainTaskScheduler); return; } var rev = info.History [n - 2]; SetRevision(textEditor, rev); }
protected override void UndoChange (MonoTextEditor fromEditor, MonoTextEditor toEditor, Hunk hunk) { base.UndoChange (fromEditor, toEditor, hunk); int i = leftConflicts.IndexOf (hunk); if (i < 0) i = rightConflicts.IndexOf (hunk); // no conflicting change if (i < 0) return; currentConflicts.RemoveAt (i); /* var startLine = MainEditor.Document.GetLineByOffset (hunk.InsertStart); var endline = MainEditor.Document.GetLineByOffset (hunk.InsertStart + hunk.Inserted); currentConflicts[i].StartSegment.Offset = startLine.EndOffset; currentConflicts[i].EndSegment.Offset = endline.EndOffset; */ UpdateDiff (); }
public override void InformMouseHover(MonoTextEditor editor, Margin margin, MarginMouseEventArgs args) { base.InformMouseHover(editor, margin, args); if (!string.IsNullOrEmpty(Tooltip)) { if (CanDrawForeground(margin)) { // update tooltip during the next ui loop run, // otherwise Gtk will not update the position of the tooltip Gtk.Application.Invoke(delegate { args.Editor.TooltipText = Tooltip; }); } else if (args.Editor.TooltipText == Tooltip) { args.Editor.TooltipText = null; } } }
void ShowPopup(MonoTextEditor editor, EventButton evt) { CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet("/MonoDevelop/VersionControl/DiffView/ContextMenu"); Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset); menu.Destroyed += delegate { this.QueueDraw(); }; if (evt != null) { GtkWorkarounds.ShowContextMenu(menu, this, evt); } else { var pt = editor.LocationToPoint(editor.Caret.Location); GtkWorkarounds.ShowContextMenu(menu, editor, new Gdk.Rectangle(pt.X, pt.Y, 1, (int)editor.LineHeight)); } }
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { int markerStart = Offset; int markerEnd = EndOffset; double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max (@from, editor.TextViewMargin.XOffset); to = Math.Max (to, editor.TextViewMargin.XOffset); if (@from <= to) { if (metrics.TextEndOffset < markerEnd) to = metrics.WholeLineWidth + metrics.TextRenderStartPosition; var c1 = editor.Options.GetColorStyle ().PlainText.Background; var c2 = editor.Options.GetColorStyle ().SelectedText.Background; cr.SetSourceRGB ((c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2); cr.Rectangle (@from, y, to - @from, metrics.LineHeight); cr.Fill (); } }
internal void EnsureLayoutCreated(MonoTextEditor editor) { if (layouts != null) { return; } layouts = new List <MessageBubbleCache.LayoutDescriptor> (); foreach (ErrorText errorText in errors) { layouts.Add(cache.CreateLayoutDescriptor(errorText)); } if (errorCountLayout == null && errors.Count > 1) { errorCountLayout = new Pango.Layout(editor.PangoContext); errorCountLayout.FontDescription = cache.errorCountFontDescription; errorCountLayout.SetText(errors.Count.ToString()); } }
public void SetRevision(MonoTextEditor toEditor, Revision rev) { IdeApp.Workbench.StatusBar.BeginProgress(string.Format(GettextCatalog.GetString("Retrieving revision {0}..."), rev.ToString())); IdeApp.Workbench.StatusBar.AutoPulse = true; if (toEditor == editors[0]) { diffRevision = rev; } else { originalRevision = rev; } var box2 = toEditor == editors[0] ? diffComboBox : originalComboBox; box2.Sensitive = false; Task.Run(async delegate { string text = null; try { text = await info.Item.Repository.GetTextAtRevisionAsync((await info.Item.GetVersionInfoAsync()).LocalPath, rev); } catch (Exception ex) { text = string.Format(GettextCatalog.GetString("Error while getting the text of revision {0}:\n{1}"), rev, ex.ToString()); MessageService.ShowError(text); return; } Runtime.RunInMainThread(() => { var box = toEditor == editors [0] ? diffComboBox : originalComboBox; RemoveLocal(toEditor.GetTextEditorData()); box.SetItem(string.Format(GettextCatalog.GetString("Revision {0}\t{1}\t{2}"), rev, rev.Time, rev.Author), null, rev); toEditor.Text = text; IdeApp.Workbench.StatusBar.AutoPulse = false; IdeApp.Workbench.StatusBar.EndProgress(); IdeApp.Workbench.StatusBar.ShowReady(); box.Sensitive = true; UpdateDiff(); }).Ignore(); }).Ignore(); }
public CodeSegmentPreviewWindow (MonoTextEditor editor, bool hideCodeSegmentPreviewInformString, TextSegment segment, int width, int height, bool removeIndent = true) : base (Gtk.WindowType.Popup) { this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString; this.Segment = segment; this.editor = editor; this.AppPaintable = true; this.SkipPagerHint = this.SkipTaskbarHint = true; this.TypeHint = WindowTypeHint.Menu; layout = PangoUtil.CreateLayout (this); informLayout = PangoUtil.CreateLayout (this); informLayout.SetText (CodeSegmentPreviewInformString); fontDescription = Pango.FontDescription.FromString (editor.Options.FontName); fontDescription.Size = (int)(fontDescription.Size * 0.8f); layout.FontDescription = fontDescription; layout.Ellipsize = Pango.EllipsizeMode.End; // setting a max size for the segment (40 lines should be enough), // no need to markup thousands of lines for a preview window SetSegment (segment, removeIndent); CalculateSize (width); }
void IChunkMarker.ChangeForeColor(MonoTextEditor editor, MonoDevelop.Ide.Editor.Highlighting.ColoredSegment chunk, ref Cairo.Color color) { if (Debugger.DebuggingService.IsDebugging) { return; } int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (chunk.EndOffset <= markerStart || markerEnd <= chunk.Offset) { return; } color = new Cairo.Color( color.R, color.G, color.B, 0.6 ); }
public override async Task <MonoDevelop.Ide.Editor.TooltipItem> GetItem(MonoTextEditor editor, int offset, CancellationToken token = default(CancellationToken)) { var wrappedEditor = WrapEditor(editor); if (wrappedEditor == null) { return(null); } var doc = IdeApp.Workbench.ActiveDocument; if (doc == null) { return(null); } var task = provider.GetItem(wrappedEditor, doc, offset, token); if (task == null) { LoggingService.LogWarning("Tooltip provider " + provider + " gave back null on GetItem (should always return a non null task)."); return(null); } var item = await task; if (item == null) { return(null); } if (lastItem != null) { if (lastItem.Offset == item.Offset && lastItem.Length == item.Length && lastItem.Item.Equals(item.Item)) { return(lastItem); } } lastItem = item; return(item); }
public PinnedWatchWidget(MonoTextEditor editor, PinnedWatch watch) { objectValue = watch.Value; Editor = editor; Watch = watch; valueTree = new ObjectValueTreeView(); valueTree.AllowAdding = false; valueTree.AllowEditing = true; valueTree.AllowPinning = true; valueTree.HeadersVisible = false; valueTree.CompactView = true; valueTree.PinnedWatch = watch; if (objectValue != null) { valueTree.AddValue(objectValue); } valueTree.ButtonPressEvent += HandleValueTreeButtonPressEvent; valueTree.ButtonReleaseEvent += HandleValueTreeButtonReleaseEvent; valueTree.MotionNotifyEvent += HandleValueTreeMotionNotifyEvent; valueTree.SizeAllocated += OnTreeSizeChanged; sw = new ScrolledWindow(); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Never; sw.Add(valueTree); Frame fr = new Frame(); fr.ShadowType = ShadowType.Out; fr.Add(sw); Add(fr); ShowAll(); DebuggingService.PausedEvent += HandleDebuggingServicePausedEvent; DebuggingService.ResumedEvent += HandleDebuggingServiceResumedEvent; }
void IChunkMarker.ChangeForeColor(MonoTextEditor editor, Chunk chunk, ref Cairo.Color color) { if (Debugger.DebuggingService.IsDebugging) { return; } int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (chunk.EndOffset <= markerStart || markerEnd <= chunk.Offset) { return; } var bgc = editor.ColorStyle.PlainText.Background; double alpha = 0.6; color = new Cairo.Color( color.R * alpha + bgc.R * (1.0 - alpha), color.G * alpha + bgc.G * (1.0 - alpha), color.B * alpha + bgc.B * (1.0 - alpha) ); }
public CodeSegmentEditorWindow (MonoTextEditor editor) : base (Gtk.WindowType.Toplevel) { Gtk.ScrolledWindow scrolledWindow = new Gtk.ScrolledWindow (); scrolledWindow.Child = codeSegmentEditor; scrolledWindow.ShadowType = Gtk.ShadowType.In; Child = scrolledWindow; codeSegmentEditor.Realize (); ((SimpleEditMode)codeSegmentEditor.CurrentMode).AddBinding (Gdk.Key.Escape, Close, true); TextEditorOptions options = new TextEditorOptions (true); options.FontName = editor.Options.FontName; options.ColorScheme = editor.Options.ColorScheme; options.ShowRuler = false; options.ShowLineNumberMargin = false; options.ShowFoldMargin = false; options.ShowIconMargin = false; options.Zoom = 0.8; codeSegmentEditor.Document.MimeType = editor.MimeType; codeSegmentEditor.Document.ReadOnly = true; codeSegmentEditor.Options = options; codeSegmentEditor.KeyPressEvent += delegate(object o, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) Destroy (); }; Gtk.Widget parent = editor.Parent; while (parent != null && !(parent is Gtk.Window)) parent = parent.Parent; if (parent is Gtk.Window) this.TransientFor = (Gtk.Window)parent; this.SkipTaskbarHint = true; this.Decorated = false; Gdk.Pointer.Grab (this.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask, null, null, Gtk.Global.CurrentEventTime); Gtk.Grab.Add (this); GrabBrokenEvent += delegate { Destroy (); }; codeSegmentEditor.GrabFocus (); }
void IChunkMarker.ChangeForeColor(MonoTextEditor editor, MonoDevelop.Ide.Editor.Highlighting.ColoredSegment chunk, ref Cairo.Color color) { if (Debugger.DebuggingService.IsDebugging) { return; } int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (chunk.EndOffset <= markerStart || markerEnd <= chunk.Offset) { return; } var bgc = (Cairo.Color)SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.Background); double alpha = 0.6; color = new Cairo.Color( color.R * alpha + bgc.R * (1.0 - alpha), color.G * alpha + bgc.G * (1.0 - alpha), color.B * alpha + bgc.B * (1.0 - alpha) ); }
void DrawErrorMarkers(MonoTextEditor editor, Cairo.Context g, LineMetrics metrics, double y) { uint curIndex = 0, byteIndex = 0; var o = metrics.LineSegment.Offset; foreach (var task in errors.Select(t => t.Task)) { try { var column = (uint)(Math.Min(Math.Max(0, task.Column - 1), metrics.Layout.LineChars.Length)); var line = editor.GetLine(task.Line); // skip possible white space locations while (column < line.Length && char.IsWhiteSpace(editor.GetCharAt(line.Offset + (int)column))) { column++; } if (column >= metrics.Layout.LineChars.Length) { continue; } int index = (int)metrics.Layout.TranslateToUTF8Index(column, ref curIndex, ref byteIndex); var pos = metrics.Layout.Layout.IndexToPos(index); var co = o + task.Column - 1; g.SetSourceColor(GetMarkerColor(false, metrics.SelectionStart <= co && co < metrics.SelectionEnd)); g.MoveTo( metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale, y + editor.LineHeight - 3 ); g.RelLineTo(3, 3); g.RelLineTo(-6, 0); g.ClosePath(); g.Fill(); } catch (Exception e) { LoggingService.LogError("Error while drawing task marker " + task, e); } } }
public static SearchResult FindPrevious(MonoTextEditor textEditor) { textEditor.SearchPattern = SearchAndReplaceOptions.SearchPattern; SearchResult result = textEditor.FindPrevious(true); if (result == null) { return(null); } textEditor.CenterToCaret(); if (result.SearchWrapped) { IdeApp.Workbench.StatusBar.ShowMessage( Stock.Find, GettextCatalog.GetString("Reached top, continued from bottom") ); } else { IdeApp.Workbench.StatusBar.ShowReady(); } return(result); }
internal override void UndoChange(MonoTextEditor fromEditor, MonoTextEditor toEditor, Hunk hunk) { base.UndoChange(fromEditor, toEditor, hunk); int i = leftConflicts.IndexOf(hunk); if (i < 0) { i = rightConflicts.IndexOf(hunk); } // no conflicting change if (i < 0) { return; } currentConflicts.RemoveAt(i); /* var startLine = MainEditor.Document.GetLineByOffset (hunk.InsertStart); * var endline = MainEditor.Document.GetLineByOffset (hunk.InsertStart + hunk.Inserted); * * currentConflicts[i].StartSegment.Offset = startLine.EndOffset; * currentConflicts[i].EndSegment.Offset = endline.EndOffset; */ UpdateDiff(); }
public override void Draw(MonoTextEditor editor, Cairo.Context g, LineMetrics metrics) { }
public override void Draw(MonoTextEditor editor, Cairo.Context cr, LineMetrics layout, int startOffset, int endOffset) { if (DebuggingService.IsDebugging) { return; } int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) { return; } double drawFrom; double drawTo; double y = layout.LineYRenderStartPosition; double startXPos = layout.TextRenderStartPosition; double endXPos = layout.TextRenderEndPosition; if (markerStart < startOffset && endOffset < markerEnd) { drawTo = endXPos; var line = editor.GetLineByOffset(startOffset); int offset = line.GetIndentation(editor.Document).Length; drawFrom = startXPos + (layout.Layout.IndexToPos(offset).X / Pango.Scale.PangoScale); } else { int start; if (startOffset < markerStart) { start = markerStart; } else { var line = editor.GetLineByOffset(startOffset); int offset = line.GetIndentation(editor.Document).Length; start = startOffset + offset; } int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos; x_pos = layout.Layout.IndexToPos(start - startOffset).X; drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.Layout.IndexToPos(end - startOffset).X; drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } drawFrom = Math.Max(drawFrom, editor.TextViewMargin.XOffset); drawTo = Math.Max(drawTo, editor.TextViewMargin.XOffset); if (drawFrom >= drawTo) { return; } double height = editor.LineHeight / 5; cr.SetSourceColor(Color); if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine) { Pango.CairoHelper.ShowErrorUnderline(cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height); } else if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine) { cr.Save(); cr.LineWidth = 1; cr.MoveTo(drawFrom + 1, y + editor.LineHeight - 1 + 0.5); cr.RelLineTo(Math.Min(drawTo - drawFrom, 4 * 3), 0); cr.SetDash(new double[] { 2, 2 }, 0); cr.Stroke(); cr.Restore(); } else { cr.MoveTo(drawFrom, y + editor.LineHeight - 1); cr.LineTo(drawTo, y + editor.LineHeight - 1); cr.Stroke(); } }
/// <summary> /// Breaks the lines into words in the form of a list of <see cref="TextSegment">TextSegments</see>. A 'word' is defined as an identifier (a series of letters, digits or underscores) /// or a single non-identifier character (including white space characters) /// </summary> /// <returns> /// The list of segments representing the 'words' in the lines /// </returns> /// <param name='editor'> /// The text editor to get the words from /// </param> /// <param name='startLine'> /// The first line in the editor's documents to get the words from /// </param> /// <param name='lineCount'> /// The number of lines to get words from /// </param> public static List <ISegment> BreakLinesIntoWords(MonoTextEditor editor, int startLine, int lineCount, bool includeDelimiter = true) { return(BreakLinesIntoWords(editor.Document, startLine, lineCount, includeDelimiter)); }
internal SearchAndReplaceWidget(MonoTextEditor textEditor, Widget frame) { if (textEditor == null) { throw new ArgumentNullException("textEditor"); } this.textEditor = textEditor; this.frame = frame; textEditor.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; textEditor.TextViewMargin.SearchRegionsUpdated += HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated; textEditor.Caret.PositionChanged += HandleWidgetTextEditorCaretPositionChanged; SizeAllocated += HandleViewTextEditorhandleSizeAllocated; Name = "SearchAndReplaceWidget"; Events = Gdk.EventMask.AllEventsMask; DisableAutomaticSearchPatternCaseMatch = false; Build(); buttonReplace.TooltipText = GettextCatalog.GetString("Replace"); buttonSearchForward.TooltipText = GettextCatalog.GetString("Find next {0}", GetShortcut(SearchCommands.FindNext)); buttonSearchBackward.TooltipText = GettextCatalog.GetString("Find previous {0}", GetShortcut(SearchCommands.FindPrevious)); buttonSearchMode.TooltipText = GettextCatalog.GetString("Toggle between search and replace mode"); searchEntry.Ready = true; searchEntry.Visible = true; searchEntry.WidthRequest = textEditor.Allocation.Width / 3; searchEntry.ForceFilterButtonVisible = true; replaceWidgets = new Widget [] { // labelReplace, entryReplace, buttonReplace, buttonReplaceAll }; FocusChain = new Widget [] { searchEntry, buttonSearchForward, buttonSearchBackward, entryReplace, buttonReplace, buttonReplaceAll }; FilterHistory(seachHistoryProperty); FilterHistory(replaceHistoryProperty); if (String.IsNullOrEmpty(textEditor.SearchPattern)) { textEditor.SearchPattern = SearchAndReplaceOptions.SearchPattern; } else if (textEditor.SearchPattern != SearchAndReplaceOptions.SearchPattern) { SearchAndReplaceOptions.SearchPattern = textEditor.SearchPattern; //FireSearchPatternChanged (); } UpdateSearchPattern(); SetSearchOptions(); //searchEntry.Model = searchHistory; searchEntry.Entry.KeyReleaseEvent += delegate { CheckSearchPatternCasing(SearchPattern); /* widget.SetSearchPattern (SearchPattern); * searchPattern = SearchPattern; * UpdateSearchEntry ();*/ }; searchEntry.Entry.Changed += delegate { SetSearchPattern(SearchPattern); string oldPattern = SearchAndReplaceOptions.SearchPattern; SearchAndReplaceOptions.SearchPattern = SearchPattern; if (oldPattern != SearchAndReplaceOptions.SearchPattern) { UpdateSearchEntry(); } var history = GetHistory(seachHistoryProperty); // Don't do anything to the history if we have a blank search if (string.IsNullOrWhiteSpace(SearchPattern)) { return; } if (history.Count > 0 && history [0] == oldPattern) { // Only update the current history item if we're adding to the search string if (!oldPattern.StartsWith(SearchPattern)) { ChangeHistory(seachHistoryProperty, SearchAndReplaceOptions.SearchPattern); } } else { UpdateSearchHistory(SearchAndReplaceOptions.SearchPattern); } }; entryReplace.Text = SearchAndReplaceOptions.ReplacePattern ?? ""; // entryReplace.Model = replaceHistory; // RestoreReplaceHistory (); foreach (Gtk.Widget child in Children) { child.KeyPressEvent += delegate(object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) { RemoveSearchWidget(); } }; } closeButton.Clicked += delegate { RemoveSearchWidget(); }; buttonSearchMode.Clicked += delegate { IsReplaceMode = !IsReplaceMode; }; // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Text")); // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Regular Expressions")); // comboboxSearchAs.Active = 0; // ReplacePatternChanged += UpdateReplacePattern; //SearchPatternChanged += UpdateSearchPattern; FocusChildSet += delegate { StoreWidgetState(); }; searchEntry.Entry.Activated += delegate { UpdateSearchHistory(SearchPattern); FindNext(textEditor); }; buttonSearchForward.Clicked += delegate { UpdateSearchHistory(SearchPattern); FindNext(textEditor); }; buttonSearchBackward.Clicked += delegate { UpdateSearchHistory(SearchPattern); FindPrevious(textEditor); }; // optionsButton.Label = MonoDevelop.Core.GettextCatalog.GetString ("Options"); this.searchEntry.RequestMenu += HandleSearchEntryhandleRequestMenu; entryReplace.Changed += delegate { SearchAndReplaceOptions.ReplacePattern = ReplacePattern; if (!inReplaceUpdate) { FireReplacePatternChanged(); } }; entryReplace.Activated += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); Replace(); entryReplace.GrabFocus(); }; buttonReplace.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); Replace(); }; buttonReplaceAll.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); ReplaceAll(); }; buttonSearchForward.KeyPressEvent += OnNavigateKeyPressEvent; buttonSearchBackward.KeyPressEvent += OnNavigateKeyPressEvent; searchEntry.Entry.KeyPressEvent += OnNavigateKeyPressEvent; entryReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplaceAll.KeyPressEvent += OnNavigateKeyPressEvent; resultInformLabelEventBox = this.searchEntry.AddLabelWidget(resultInformLabel); resultInformLabelEventBox.BorderWidth = 2; resultInformLabel.Xpad = 2; resultInformLabel.Show(); searchEntry.FilterButtonPixbuf = SearchEntryFilterImage; if (textEditor.IsSomethingSelected) { if (textEditor.MainSelection.MinLine == textEditor.MainSelection.MaxLine || ClipboardContainsSelection()) { SetSearchPattern(); } else { SelectionSegment = textEditor.SelectionRange; IsInSelectionSearchMode = true; SetSearchOptions(); } } SetSearchPattern(SearchAndReplaceOptions.SearchPattern); textEditor.HighlightSearchPattern = true; textEditor.TextViewMargin.RefreshSearchMarker(); if (textEditor.Document.IsReadOnly) { buttonSearchMode.Visible = false; IsReplaceMode = false; } SearchAndReplaceOptions.SearchPatternChanged += HandleSearchPatternChanged; SearchAndReplaceOptions.ReplacePatternChanged += HandleReplacePatternChanged; }
public CurrentDebugLineTextMarker(MonoTextEditor editor, int offset, int length) { IconMarker = new DebugIconMarker(currentLine); TextMarker = new DebugTextMarker(offset, length, e => e.ColorStyle.DebuggerCurrentLineMarker, e => e.ColorStyle.DebuggerCurrentLine); }
internal static void EditorFocusIn(object sender, FocusInEventArgs args) { MonoTextEditor editor = (MonoTextEditor)sender; UpdateCaretPosition(editor.Caret); }
public MiddleArea(EditorCompareWidgetBase widget, MonoTextEditor fromEditor, MonoTextEditor toEditor, bool useLeft) { this.widget = widget; this.Events |= EventMask.PointerMotionMask | EventMask.ButtonPressMask; this.fromEditor = fromEditor; this.toEditor = toEditor; this.useLeft = useLeft; this.toEditor.EditorOptionsChanged += HandleToEditorhandleEditorOptionsChanged; }
static List <ISegment> BreakTextInWords(MonoTextEditor editor, int start, int count) { return(TextBreaker.BreakLinesIntoWords(editor, start, count)); }
Tuple <List <Cairo.Rectangle>, List <Cairo.Rectangle> > GetDiffPaths(List <Hunk> diff, MonoTextEditor editor, Hunk hunk) { if (!diffCache.ContainsKey(diff)) { diffCache[diff] = new Dictionary <Hunk, Tuple <List <Cairo.Rectangle>, List <Cairo.Rectangle> > > (); } var pathCache = diffCache[diff]; Tuple <List <Cairo.Rectangle>, List <Cairo.Rectangle> > result; if (pathCache.TryGetValue(hunk, out result)) { return(result); } var words = BreakTextInWords(editor, hunk.RemoveStart, hunk.Removed); var cmpWords = BreakTextInWords(MainEditor, hunk.InsertStart, hunk.Inserted); var wordDiff = new List <Hunk> (Diff.GetDiff(words.Select(editor.GetTextAt).ToArray(), cmpWords.Select(MainEditor.GetTextAt).ToArray())); result = Tuple.Create(CalculateChunkPath(editor, wordDiff, words, true), CalculateChunkPath(MainEditor, wordDiff, cmpWords, false)); pathCache[hunk] = result; return(result); }
bool IActionTextLineMarker.MouseReleased(MonoTextEditor editor, MarginMouseEventArgs args) { return(false); }
public override void DrawAfterEol(MonoTextEditor textEditor, Cairo.Context g, EndOfLineMetrics metrics) { if (!IsVisible) { return; } EnsureLayoutCreated(editor); int errorCounterWidth = 0, eh = 0; if (errorCountLayout != null) { errorCountLayout.GetPixelSize(out errorCounterWidth, out eh); errorCounterWidth = Math.Max(15, Math.Max(errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4))); } var sx = metrics.TextRenderEndPosition; var width = LayoutWidth + errorCounterWidth + editor.LineHeight; var drawLayout = layouts[0].Layout; var y = metrics.LineYRenderStartPosition; bool customLayout = true; //sx + width > editor.Allocation.Width; bool hideText = false; bubbleIsReduced = customLayout; var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null; double roundingRadius = editor.LineHeight / 2 - 1; if (customLayout) { width = editor.Allocation.Width - sx; string text = layouts[0].Layout.Text; drawLayout = new Pango.Layout(editor.PangoContext); drawLayout.FontDescription = cache.fontDescription; var paintWidth = (width - errorCounterWidth - editor.LineHeight + 4); var minWidth = Math.Max(25, errorCounterWidth) * editor.Options.Zoom; if (paintWidth < minWidth) { hideText = true; showErrorCount = false; // drawLayout.SetMarkup ("<span weight='heavy'>···</span>"); width = minWidth; //roundingRadius = 10 * editor.Options.Zoom; sx = Math.Min(sx, editor.Allocation.Width - width); } else { drawLayout.Ellipsize = Pango.EllipsizeMode.End; drawLayout.Width = (int)(paintWidth * Pango.Scale.PangoScale); drawLayout.SetText(text); int w2, h2; drawLayout.GetPixelSize(out w2, out h2); width = w2 + errorCounterWidth + editor.LineHeight - 2; } } bubbleDrawX = sx - editor.TextViewMargin.XOffset; bubbleDrawY = y + 2; bubbleWidth = width; var bubbleHeight = editor.LineHeight; g.RoundedRectangle(sx, y, width, bubbleHeight, roundingRadius); g.SetSourceColor(TagColor.Color); g.Fill(); // Draw error count icon if (showErrorCount) { var errorCounterHeight = bubbleHeight - 2; var errorCounterX = sx + width - errorCounterWidth - 1; var errorCounterY = Math.Round(y + (bubbleHeight - errorCounterHeight) / 2); g.RoundedRectangle( errorCounterX, errorCounterY, errorCounterWidth, errorCounterHeight, editor.LineHeight / 2 - 2 ); // FIXME: VV: Remove gradient features using (var lg = new Cairo.LinearGradient(errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) { lg.AddColorStop(0, CounterColor.Color); lg.AddColorStop(1, CounterColor.Color.AddLight(-0.1)); g.SetSource(lg); g.Fill(); } g.Save(); int ew; errorCountLayout.GetPixelSize(out ew, out eh); var tx = Math.Round(errorCounterX + (2 + errorCounterWidth - ew) / 2); var ty = Math.Round(errorCounterY + (-1 + errorCounterHeight - eh) / 2); g.Translate(tx, ty); g.SetSourceColor(CounterColor.SecondColor); g.ShowLayout(errorCountLayout); g.Restore(); } if (hideText) { // Draw dots double radius = 2 * editor.Options.Zoom; double spacing = 1 * editor.Options.Zoom; sx += 1 * editor.Options.Zoom + Math.Ceiling((bubbleWidth - 3 * (radius * 2) - 2 * spacing) / 2); for (int i = 0; i < 3; i++) { g.Arc(sx, y + bubbleHeight / 2, radius, 0, Math.PI * 2); g.SetSourceColor(TagColor.SecondColor); g.Fill(); sx += radius * 2 + spacing; } } else { // Draw label text var tx = Math.Round(sx + editor.LineHeight / 2); var ty = Math.Round(y + (editor.LineHeight - layouts [0].Height) / 2) - 1; g.Save(); g.Translate(tx, ty); g.SetSourceColor(TagColor.SecondColor); g.ShowLayout(drawLayout); g.Restore(); } if (customLayout) { drawLayout.Dispose(); } }
public override bool DrawBackground(MonoTextEditor editor, Cairo.Context g, LineMetrics metrics) { if (!IsVisible) { return(false); } bool markerShouldDrawnAsHidden = cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this; if (editor.Document.GetTextSegmentMarkersAt(metrics.LineSegment).Any(m => m is DebugTextMarker)) { return(false); } EnsureLayoutCreated(editor); double x = editor.TextViewMargin.XOffset; int right = editor.Allocation.Width; bool isCaretInLine = metrics.TextStartOffset <= editor.Caret.Offset && editor.Caret.Offset <= metrics.TextEndOffset; int errorCounterWidth = GetErrorCountBounds(metrics).Item1; var min = right - LayoutWidth - border - (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) - errorCounterWidth; var max = Math.Round(editor.TextViewMargin.XOffset + editor.LineHeight / 2); double x2 = Math.Max(min, max); bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != Mono.TextEditor.SelectionMode.Block ? editor.SelectionRange.Contains(LineSegment.Offset + LineSegment.Length) : false; int active = 0; bool highlighted = active == 0 && isCaretInLine; var y = metrics.LineYRenderStartPosition; // draw background if (!markerShouldDrawnAsHidden) { DrawRectangle(g, x, y, right, editor.LineHeight); g.SetSourceColor(LineColor.Color); g.Fill(); if (metrics.Layout.StartSet || metrics.SelectionStart == metrics.TextEndOffset) { double startX; double endX; if (metrics.SelectionStart != metrics.TextEndOffset) { var start = metrics.Layout.Layout.IndexToPos((int)metrics.Layout.SelectionStartIndex); startX = (int)(start.X / Pango.Scale.PangoScale); var end = metrics.Layout.Layout.IndexToPos((int)metrics.Layout.SelectionEndIndex); endX = (int)(end.X / Pango.Scale.PangoScale); } else { startX = x2; endX = startX; } if (editor.MainSelection.SelectionMode == Mono.TextEditor.SelectionMode.Block && startX == endX) { endX = startX + 2; } startX += metrics.TextRenderStartPosition; endX += metrics.TextRenderStartPosition; startX = Math.Max(editor.TextViewMargin.XOffset, startX); // clip region to textviewmargin start if (isEolSelected) { endX = editor.Allocation.Width + (int)editor.HAdjustment.Value; } if (startX < endX) { DrawRectangle(g, startX, y, endX - startX, editor.LineHeight); g.SetSourceColor(GetLineColor(highlighted, true)); g.Fill(); } } DrawErrorMarkers(editor, g, metrics, y); } double y2 = y + 0.5; double y2Bottom = y2 + editor.LineHeight - 1; var selected = isEolSelected; var lineTextPx = editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition + metrics.Layout.Width; if (x2 < lineTextPx) { x2 = lineTextPx; } if (editor.Options.ShowRuler) { double divider = Math.Max(editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX); if (divider >= x2) { g.MoveTo(new Cairo.PointD(divider + 0.5, y2)); g.LineTo(new Cairo.PointD(divider + 0.5, y2Bottom)); g.SetSourceColor(GetLineColorBorder(highlighted, selected)); g.Stroke(); } } return(true); }
public InvalidBreakpointTextMarker(MonoTextEditor editor, int offset, int length, bool isTracepoint) { IconMarker = new DebugIconMarker(isTracepoint ? tracepoint : breakpoint); TextMarker = new DebugTextMarker(offset, length, e => SyntaxHighlightingService.GetColor(e.EditorTheme, EditorThemeColors.BreakpointMarkerInvalid)); }
public CurrentDebugLineTextMarker(MonoTextEditor editor, int offset, int length) { IconMarker = new DebugIconMarker(currentLine); TextMarker = new DebugTextMarker(offset, length, e => SyntaxHighlightingService.GetColor(e.EditorTheme, EditorThemeColors.DebuggerCurrentLineMarker), e => SyntaxHighlightingService.GetChunkStyle(e.EditorTheme, EditorThemeColors.DebuggerCurrentLine)); }