public void MouseHover (TextEditor editor, MarginMouseEventArgs args, TextMarkerHoverResult result) { bool isOver = MouseIsOverMarker (editor, args); if (isOver != oldIsOver) editor.Document.CommitLineUpdate (this.LineSegment); oldIsOver = isOver; int errorNumber = MouseIsOverError (editor, args); if (errorNumber >= 0) { result.Cursor = arrowCursor; if (!isOver) // don't show tooltip when hovering over error counter layout. result.TooltipMarkup = GLib.Markup.EscapeText (errors[errorNumber].ErrorMessage); } }
protected internal override void MouseHover (MarginMouseEventArgs args) { base.MouseHover (args); var loc = PointToLocation (args.X, args.Y); if (loc.Line < DocumentLocation.MinLine || loc.Column < DocumentLocation.MinColumn) return; var line = Document.GetLine (loc.Line); var oldHoveredLine = HoveredLine; HoveredLine = line; OnHoveredLineChanged (new LineEventArgs (oldHoveredLine)); var hoverResult = new TextMarkerHoverResult (); oldMarkers.ForEach (m => m.MouseHover (this.textEditor, args, hoverResult)); if (line != null) { newMarkers.Clear (); newMarkers.AddRange (line.Markers.Where (m => m is IActionTextMarker).Cast <IActionTextMarker> ()); var extraMarker = Document.GetExtendingTextMarker (loc.Line) as IActionTextMarker; if (extraMarker != null && !oldMarkers.Contains (extraMarker)) newMarkers.Add (extraMarker); foreach (var marker in newMarkers.Where (m => !oldMarkers.Contains (m))) { marker.MouseHover (this.textEditor, args, hoverResult); } oldMarkers.Clear (); var tmp = oldMarkers; oldMarkers = newMarkers; newMarkers = tmp; } else { oldMarkers.Clear (); } base.cursor = hoverResult.Cursor ?? xtermCursor; if (textEditor.TooltipMarkup != hoverResult.TooltipMarkup) { textEditor.TooltipMarkup = null; textEditor.TriggerTooltipQuery (); } textEditor.TooltipMarkup = hoverResult.TooltipMarkup; if (args.Button != 1 && args.Y >= 0 && args.Y <= this.textEditor.Allocation.Height) { // folding marker int lineNr = args.LineNumber; foreach (KeyValuePair<Rectangle, FoldSegment> shownFolding in GetFoldRectangles (lineNr)) { if (shownFolding.Key.Contains ((int)(args.X + this.XOffset), (int)args.Y)) { ShowTooltip (shownFolding.Value.Segment, shownFolding.Key); return; } } ShowTooltip (TextSegment.Invalid, Gdk.Rectangle.Zero); string link = GetLink != null ? GetLink (args) : null; if (!String.IsNullOrEmpty (link)) { base.cursor = textLinkCursor; } else { base.cursor = hoverResult.Cursor ?? xtermCursor; } return; } if (inDrag) return; Caret.PreserveSelection = true; switch (this.mouseSelectionMode) { case MouseSelectionMode.SingleChar: if (!inSelectionDrag) { textEditor.SetSelection (loc, loc); } else { textEditor.ExtendSelectionTo (loc); } Caret.Location = loc; break; case MouseSelectionMode.Word: int offset = textEditor.Document.LocationToOffset (loc); int start; int end; var data = textEditor.GetTextEditorData (); if (offset < textEditor.SelectionAnchor) { start = data.FindCurrentWordStart (offset); end = data.FindCurrentWordEnd (textEditor.SelectionAnchor); Caret.Offset = start; } else { start = data.FindCurrentWordStart (textEditor.SelectionAnchor); end = data.FindCurrentWordEnd (offset); Caret.Offset = end; } if (textEditor.MainSelection != null) { textEditor.MainSelection.Lead = Caret.Location; if (Caret.Offset < mouseWordStart) { textEditor.MainSelection.Anchor = Document.OffsetToLocation (mouseWordEnd); } else { textEditor.MainSelection.Anchor = Document.OffsetToLocation (mouseWordStart); } } break; case MouseSelectionMode.WholeLine: //textEditor.SetSelectLines (loc.Line, textEditor.MainSelection.Anchor.Line); LineSegment line1 = textEditor.Document.GetLine (loc.Line); LineSegment line2 = textEditor.Document.GetLineByOffset (textEditor.SelectionAnchor); Caret.Offset = line1.Offset < line2.Offset ? line1.Offset : line1.EndOffsetIncludingDelimiter; if (textEditor.MainSelection != null) textEditor.MainSelection.Lead = Caret.Location; break; } Caret.PreserveSelection = false; //HACK: use cmd as Mac block select modifier because GTK currently makes it impossible to access alt/mod1 //NOTE: Mac cmd seems to be mapped as ControlMask from mouse events on older GTK, mod1 on newer var blockSelModifier = !Platform.IsMac? ModifierType.Mod1Mask : (ModifierType.ControlMask | ModifierType.Mod1Mask); //NOTE: also allow super for block select on X11 because most window managers use the alt modifier already if (Platform.IsX11) blockSelModifier |= (ModifierType.SuperMask | ModifierType.Mod4Mask); if ((args.ModifierState & blockSelModifier) != 0) { textEditor.SelectionMode = SelectionMode.Block; } else { if (textEditor.SelectionMode == SelectionMode.Block) Document.CommitMultipleLineUpdate (textEditor.MainSelection.MinLine, textEditor.MainSelection.MaxLine); textEditor.SelectionMode = SelectionMode.Normal; } inSelectionDrag = true; }