Пример #1
0
        public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max(StartCol, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 0 ? LineSegment.Length : EndCol);

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            int @from;
            int to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos = layout.IndexToPos(start - startOffset).X;
                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(end - startOffset).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            using (Cairo.Context cr = Gdk.CairoHelper.Create(win)) {
                int height = editor.LineHeight / 5;
                cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor(ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition(ColorName));
                Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }

            /*
             *              using (Gdk.GC gc = new Gdk.GC(win)) {
             *                      gc.RgbFgColor = ;
             *                      const int length = 6;
             *                      const int height = 2;
             *                      if (Wave) {
             *                              startXPos = System.Math.Max (startXPos, editor.TextViewMargin.XOffset);
             *                              for (int height = @from; height < to; height += length) {
             *                                      win.DrawLine (gc, height, drawY, height + length / 2, drawY - height);
             *                                      win.DrawLine (gc, height + length / 2, drawY - height, height + length, drawY);
             *                              }
             *                      } else {
             *                              win.DrawLine (gc, @from, drawY, to, drawY);
             *                      }
             *              }	*/
        }
Пример #2
0
        void InternalDraw(int markerStart, int markerEnd, MonoTextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (markerStart >= markerEnd)
            {
                return;
            }
            double @from;
            double to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos = layout.IndexToPos(System.Math.Max(0, start - startOffset)).X;
                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(System.Math.Max(0, end - startOffset)).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            double height = editor.LineHeight / 5;

            if (selected)
            {
                cr.SetSourceColor(editor.ColorStyle.SelectedText.Foreground);
            }
            else
            {
                cr.SetSourceColor(ColorName == null ? Color : editor.ColorStyle.GetChunkStyle(ColorName).Foreground);
            }
            if (Wave)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }
            else
            {
                cr.LineWidth = 1;
                cr.MoveTo(@from, y + editor.LineHeight - 1.5);
                cr.LineTo(to, y + editor.LineHeight - 1.5);
                cr.Stroke();
            }
        }
Пример #3
0
            public override void Draw(
                TextEditor editor,
                Cairo.Context cr,
                Pango.Layout layout,
                bool selected,
                int startOffset,
                int endOffset,
                double y,
                double startXPos,
                double endXPos)
            {
                int markerStart = line.Offset + startColumn - 1;
                int markerEnd   = line.Offset + startColumn - 1 + text.Length;

                if (markerEnd < startOffset || markerStart > endOffset)
                {
                    return;
                }

                double @from;
                double to;

                if (markerStart < startOffset && endOffset < markerEnd)
                {
                    @from = startXPos;
                    to    = endXPos;
                }
                else
                {
                    int start = startOffset < markerStart ? markerStart : startOffset;
                    int end   = endOffset < markerEnd ? endOffset : markerEnd;
                    int x_pos = layout.IndexToPos(start - startOffset).X;

                    @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                    x_pos = layout.IndexToPos(end - startOffset).X;

                    to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                }

                @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
                to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
                if (@from < to)
                {
                    cr.DrawLine(editor.ColorStyle.GetChunkStyle(style).CairoColor,
                                @from,
                                y + editor.LineHeight,
                                to,
                                y + editor.LineHeight);
                }
            }
Пример #4
0
        public override void Draw(TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max(StartCol - 1, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 1 ? LineSegment.EditableLength : EndCol - 1);

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            double @from;
            double to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos = layout.IndexToPos(start - startOffset).X;
                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(end - startOffset).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            double height = editor.LineHeight / 5;

            cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition(ColorName);
            if (Wave)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }
            else
            {
                cr.MoveTo(@from, y + editor.LineHeight - 1);
                cr.LineTo(to, y + editor.LineHeight - 1);
                cr.Stroke();
            }
        }
Пример #5
0
        public Point TextPositionToPoint(Position p)
        {
            int index = PositionToIndex(p);

            var rect = layout.IndexToPos(index);

            int x = Pango.Units.ToPixels(rect.X) + origin.X;
            int y = Pango.Units.ToPixels(rect.Y) + origin.Y;

            return(new Point(x, y));
        }
Пример #6
0
        public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
        {
            int markerStart = line.Offset + startColumn;
            int markerEnd   = line.Offset + endColumn;

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            int @from;
            int to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int start = startOffset < markerStart ? markerStart : startOffset;
                int end   = endOffset < markerEnd ? endOffset : markerEnd;
                int x_pos = layout.IndexToPos(start - startOffset).X;

                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(end - startOffset).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from < to)
            {
                using (Gdk.GC gc = new Gdk.GC(win)) {
                    gc.RgbFgColor = selected ? editor.ColorStyle.Selection.Color : editor.ColorStyle.GetChunkStyle(style).Color;
                    win.DrawLine(gc, @from, y + editor.LineHeight - 1, to, y + editor.LineHeight - 1);
                }
            }
        }
Пример #7
0
        public override void Draw(TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (Debugger.DebuggingService.IsDebugging)
            {
                return;
            }
            int markerStart = Segment.Offset;
            int markerEnd   = Segment.EndOffset;

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            bool drawOverlay = result.InspectionMark == IssueMarker.GrayOut;

            if (drawOverlay && editor.IsSomethingSelected)
            {
                var selectionRange = editor.SelectionRange;
                if (selectionRange.Contains(markerStart) && selectionRange.Contains(markerEnd))
                {
                    return;
                }
                if (selectionRange.Contains(markerEnd))
                {
                    markerEnd = selectionRange.Offset;
                }
                if (selectionRange.Contains(markerStart))
                {
                    markerStart = selectionRange.EndOffset;
                }
                if (markerEnd <= markerStart)
                {
                    return;
                }
            }

            double drawFrom;
            double drawTo;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                drawFrom = startXPos;
                drawTo   = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos    = layout.IndexToPos(start - startOffset).X;
                drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                x_pos    = layout.IndexToPos(end - startOffset).X;

                drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            drawFrom = System.Math.Max(drawFrom, editor.TextViewMargin.XOffset);
            drawTo   = System.Math.Max(drawTo, editor.TextViewMargin.XOffset);
            if (drawFrom >= drawTo)
            {
                return;
            }

            double height = editor.LineHeight / 5;

            cr.Color = GetColor(editor, Result);
            if (drawOverlay)
            {
                cr.Rectangle(drawFrom, y, drawTo - drawFrom, editor.LineHeight);
                var color = editor.ColorStyle.PlainText.Background;
                color.A  = 0.6;
                cr.Color = color;
                cr.Fill();
            }
            else if (Wave)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
            }
            else
            {
                cr.MoveTo(drawFrom, y + editor.LineHeight - 1);
                cr.LineTo(drawTo, y + editor.LineHeight - 1);
                cr.Stroke();
            }
        }
Пример #8
0
        public override void Draw(TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            int markerStart = LineSegment.Offset + System.Math.Max(StartCol - 1, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 1 ? LineSegment.EditableLength : EndCol - 1);

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            bool drawOverlay = result.Level == QuickTaskSeverity.Warning && result.Importance == ResultImportance.Low;

            if (drawOverlay && editor.IsSomethingSelected)
            {
                var selectionRange = editor.SelectionRange;
                if (selectionRange.Contains(markerStart) && selectionRange.Contains(markerEnd))
                {
                    return;
                }
                if (selectionRange.Contains(markerEnd))
                {
                    markerEnd = selectionRange.Offset;
                }
                if (selectionRange.Contains(markerStart))
                {
                    markerStart = selectionRange.EndOffset;
                }
                if (markerEnd <= markerStart)
                {
                    return;
                }
            }

            double drawFrom;
            double drawTo;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                drawFrom = startXPos;
                drawTo   = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos    = layout.IndexToPos(start - startOffset).X;
                drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                x_pos    = layout.IndexToPos(end - startOffset).X;

                drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            drawFrom = System.Math.Max(drawFrom, editor.TextViewMargin.XOffset);
            drawTo   = System.Math.Max(drawTo, editor.TextViewMargin.XOffset);
            if (drawFrom >= drawTo)
            {
                return;
            }

            double height = editor.LineHeight / 5;

            cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition(ColorName);
            if (drawOverlay)
            {
                cr.Rectangle(drawFrom, y, drawTo - drawFrom, editor.LineHeight);
                var color = editor.ColorStyle.Default.CairoBackgroundColor;
                color.A  = 0.6;
                cr.Color = color;
                cr.Fill();
            }
            else if (Wave)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
            }
            else
            {
                cr.MoveTo(drawFrom, y + editor.LineHeight - 1);
                cr.LineTo(drawTo, y + editor.LineHeight - 1);
                cr.Stroke();
            }
        }
Пример #9
0
        public override void Draw(TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (Debugger.DebuggingService.IsDebugging)
            {
                return;
            }
            int markerStart = Segment.Offset;
            int markerEnd   = Segment.EndOffset;

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            bool drawOverlay = result.InspectionMark == IssueMarker.GrayOut;

            if (drawOverlay && editor.IsSomethingSelected)
            {
                var selectionRange = editor.SelectionRange;
                if (selectionRange.Contains(markerStart) && selectionRange.Contains(markerEnd))
                {
                    return;
                }
                if (selectionRange.Contains(markerEnd))
                {
                    markerEnd = selectionRange.Offset;
                }
                if (selectionRange.Contains(markerStart))
                {
                    markerStart = selectionRange.EndOffset;
                }
                if (markerEnd <= markerStart)
                {
                    return;
                }
            }

            double drawFrom;
            double drawTo;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                drawTo = endXPos;
                var line   = editor.GetLineByOffset(startOffset);
                int offset = line.GetIndentation(editor.Document).Length;
                drawFrom = startXPos + (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.IndexToPos(start - startOffset).X;
                drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                x_pos    = layout.IndexToPos(end - startOffset).X;

                drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            drawFrom = System.Math.Max(drawFrom, editor.TextViewMargin.XOffset);
            drawTo   = System.Math.Max(drawTo, editor.TextViewMargin.XOffset);
            if (drawFrom >= drawTo)
            {
                return;
            }

            double height = editor.LineHeight / 5;

            cr.SetSourceColor(GetColor(editor, Result));
            if (drawOverlay)
            {
                cr.Rectangle(drawFrom, y, drawTo - drawFrom, editor.LineHeight);
                var color = editor.ColorStyle.PlainText.Background;
                color.A = 0.6;
                cr.SetSourceColor(color);
                cr.Fill();
            }
            else if (result.InspectionMark == IssueMarker.WavedLine)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
            }
            else if (result.InspectionMark == IssueMarker.DottedLine)
            {
                cr.Save();
                cr.LineWidth = 1;
                cr.MoveTo(drawFrom + 1, y + editor.LineHeight - 1 + 0.5);
                cr.RelLineTo(System.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();
            }
        }
Пример #10
0
 public Pango.Rectangle IndexToPos(int index_)
 {
     return(layout.IndexToPos(index_));
 }
Пример #11
0
        void InternalDraw(int markerStart, int markerEnd, MonoTextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (markerStart > markerEnd)
            {
                return;
            }
            double @from;
            double to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = startOffset < markerStart ? markerStart : startOffset;
                int             end   = endOffset < markerEnd ? endOffset : markerEnd;
                int /*lineNr,*/ x_pos;

                x_pos = layout.IndexToPos(System.Math.Max(0, start - startOffset)).X;
                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                x_pos = layout.IndexToPos(System.Math.Max(0, end - startOffset)).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                var line = editor.GetLineByOffset(endOffset);
                if (markerEnd > endOffset || @from == to)
                {
                    to += editor.TextViewMargin.CharWidth;
                    if (@from >= to)
                    {
                        @from = to - editor.TextViewMargin.CharWidth;
                    }
                }
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            double height = editor.LineHeight / 5;

            // TODO : EditorTheme does that look ok ?

            // if (selected) {
            //	cr.SetSourceColor (editor.EditorTheme.SelectedText.Foreground);
            // } else

            if (ColorName == null)
            {
                cr.SetSourceColor(Color);
            }
            else
            {
                HslColor color;
                editor.EditorTheme.TryGetColor(ColorName, out color);
                cr.SetSourceColor(color);
            }
            // }
            if (Wave)
            {
                Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }
            else
            {
                cr.LineWidth = 1;
                cr.MoveTo(@from, y + editor.LineHeight - 1.5);
                cr.LineTo(to, y + editor.LineHeight - 1.5);
                cr.Stroke();
            }
        }