public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos) { var line = editor.GetLine (loc.Line); var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition; cr.Rectangle (Math.Floor (x) + 0.5, Math.Floor (y) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth); if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) { cr.SetSourceRGBA (0.8, 0.8, 1, 0.9); } else { cr.SetSourceRGBA (0.2, 0.2, 1, 0.9); } cr.Stroke (); }
void IActionTextLineMarker.MouseHover (TextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result) { if (args.Button != 0) return; var line = editor.GetLine (loc.Line); if (line == null) return; var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.TextStartPosition; var y = editor.LineToY (line.LineNumber + 1) - editor.VAdjustment.Value; if (args.X - x >= 0 * editor.Options.Zoom && args.X - x < tagMarkerWidth * editor.Options.Zoom && args.Y - y < (editor.LineHeight / 2) * editor.Options.Zoom) { result.Cursor = null; Popup (); } else { codeActionEditorExtension.CancelSmartTagPopupTimeout (); } }
static IEnumerable<IDocumentLine> GetSelectedLines (TextEditor textEditor) { if (!textEditor.IsSomethingSelected) { yield return textEditor.GetLine (textEditor.CaretLine); yield break; } var selection = textEditor.SelectionRegion; var line = textEditor.GetLine(selection.EndLine); if (selection.EndColumn == 1 && textEditor.SelectionLeadOffset < textEditor.SelectionAnchorOffset) line = line.PreviousLine; while (line != null && line.LineNumber >= selection.BeginLine) { yield return line; line = line.PreviousLine; } }