Esempio n. 1
0
        protected internal override void DrawBackground(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height)
        {
            if (line == null)
            {
                return;
            }

            if (lineNumber == editor.Caret.Line)
            {
                cr.SetColor(editor.Options.ColorScheme.LineMarker.Color);
                cr.Rectangle(x, y, editor.GetWidth(), height);
                cr.Fill();
            }

            var style          = SyntaxModeService.DefaultColorStyle;
            var selectionStyle = editor.HasFocus ? style.SelectedText : style.SelectedInactiveText;

            var selectionSegment = GetSegmentForLine(editor.Selection, line);

            if (selectionSegment != null)
            {
                int logicalStartColumn = selectionSegment.Value.Offset - line.Offset;
                int visualStartColumn  = line.GetVisualColumn(editor, logicalStartColumn);

                if (selectionSegment.Value.Offset == line.Offset)
                {
                    visualStartColumn = 0;
                }

                int logicalEndColumn = selectionSegment.Value.EndOffset - line.Offset;
                int visualEndColumn  = line.GetVisualColumn(editor, logicalEndColumn);

                if (editor.Selection.EndOffset != selectionSegment.Value.EndOffset && visualEndColumn > 0)
                {
                    visualEndColumn--;
                }

                if (editor.Selection.Contains(line.EndOffset))
                {
                    ++visualEndColumn;
                }

                cr.SetColor(selectionStyle.Background);
                double startX = x + visualStartColumn * CharWidth;
                double endX   = x + visualEndColumn * CharWidth;
                cr.Rectangle(startX, y, endX - startX, LineHeight);
                cr.Fill();
            }
        }
Esempio n. 2
0
        int DrawLinePortion(Context cr, ChunkStyle style, TextLayout layout, DocumentLine line, int visualOffset, int logicalLength)
        {
            int logicalColumn    = line.GetLogicalColumn(editor, visualOffset);
            int logicalEndColumn = logicalColumn + logicalLength;
            int visualEndOffset  = line.GetVisualColumn(editor, logicalEndColumn);

            int visualLength = visualEndOffset - visualOffset;

            int indexOffset = visualOffset - 1;

            layout.SetFontStyle(style.FontStyle, indexOffset, visualLength);
            layout.SetFontWeight(style.FontWeight, indexOffset, visualLength);
            if (style.Underline)
            {
                layout.SetUnderline(indexOffset, visualLength);
            }
            layout.SetForeground(style.Foreground, indexOffset, visualLength);

            return(visualEndOffset);
        }
Esempio n. 3
0
        public double ColumnToX(DocumentLine line, int column)
        {
            int visualColumn = line.GetVisualColumn(editor, column);

            return((visualColumn - 1) * CharWidth);
        }