コード例 #1
0
            public override void Draw(Gdk.Drawable drawable, Gdk.Rectangle area)
            {
                TextEditor editor = mode.editor;
                int        y      = editor.LineToVisualY(mode.CurrentInsertionPoint.Line) - (int)editor.VAdjustment.Value;

                using (var g = Gdk.CairoHelper.Create(drawable)) {
                    g.LineWidth = System.Math.Min(1, editor.Options.Zoom);
                    LineSegment lineAbove = editor.Document.GetLine(mode.CurrentInsertionPoint.Line - 1);
                    LineSegment lineBelow = editor.Document.GetLine(mode.CurrentInsertionPoint.Line);

                    int aboveStart = 0, aboveEnd = editor.TextViewMargin.XOffset;
                    int belowStart = 0, belowEnd = editor.TextViewMargin.XOffset;
                    int l = 0;
                    if (lineAbove != null)
                    {
                        var wrapper = editor.TextViewMargin.GetLayout(lineAbove);
                        wrapper.Layout.IndexToLineX(lineAbove.GetIndentation(editor.Document).Length, true, out l, out aboveStart);
                        aboveStart = (int)(aboveStart / Pango.Scale.PangoScale);
                        aboveEnd   = (int)(wrapper.PangoWidth / Pango.Scale.PangoScale);

                        if (wrapper.IsUncached)
                        {
                            wrapper.Dispose();
                        }
                    }
                    if (lineBelow != null)
                    {
                        var wrapper = editor.TextViewMargin.GetLayout(lineBelow);
                        int index   = lineAbove.GetIndentation(editor.Document).Length;
                        if (index == 0)
                        {
                            belowStart = 0;
                        }
                        else if (index >= lineBelow.EditableLength)
                        {
                            belowStart = wrapper.PangoWidth;
                        }
                        else
                        {
                            wrapper.Layout.IndexToLineX(index, true, out l, out belowStart);
                        }

                        belowStart = (int)(belowStart / Pango.Scale.PangoScale);
                        belowEnd   = (int)(wrapper.PangoWidth / Pango.Scale.PangoScale);
                        if (wrapper.IsUncached)
                        {
                            wrapper.Dispose();
                        }
                    }

                    int d  = editor.LineHeight / 3;
                    int x1 = editor.TextViewMargin.XOffset - (int)editor.HAdjustment.Value;
                    int x2 = x1;
                    if (aboveStart < belowEnd)
                    {
                        x1 += aboveStart;
                        x2 += belowEnd;
                    }
                    else if (aboveStart > belowEnd)
                    {
                        d  *= -1;
                        x1 += belowEnd;
                        x2 += aboveStart;
                    }
                    else
                    {
                        x1 += System.Math.Min(aboveStart, belowStart);
                        x2 += System.Math.Max(aboveEnd, belowEnd);
                        if (x1 == x2)
                        {
                            x2 += 50;
                        }
                    }

                    g.MoveTo(x1, y + d);
                    g.LineTo(x1, y);
                    g.LineTo(x2, y);
                    g.LineTo(x2, y - d);

                    g.Color = new Cairo.Color(1.0, 0, 0);
                    g.Stroke();

                    DrawArrow(g, x1 - 4, y);
                }
            }