Ejemplo n.º 1
0
        public MdTextViewLineCollection(MonoTextEditor textEditor) : base(64)
        {
            this.textView = textEditor;
            this.version  = this.textView.Document.Version;

            int    startLine = textEditor.TextArea.YToLine(textEditor.VAdjustment.Value);
            double startY    = textEditor.TextArea.LineToY(startLine);
            double curY      = startY;
            double lastY     = textEditor.VAdjustment.Value + textEditor.Allocation.Height;

            for (int visualLineNumber = textEditor.GetTextEditorData().LogicalToVisualLine(startLine); ; visualLineNumber++)
            {
                int logicalLineNumber = textEditor.GetTextEditorData().VisualToLogicalLine(visualLineNumber);
                var line = textEditor.GetLine(logicalLineNumber);

                if (line == null)
                {
                    break;
                }

                Add(new MdTextViewLine(this, textEditor, line, textEditor.TextViewMargin.GetLayout(line)));

                curY += textEditor.TextArea.GetLineHeight(line);
                if (curY >= lastY)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 void EditorCarethandlePositionChanged(object sender, DocumentLocationEventArgs e)
 {
     if (!editor.GetTextEditorData().HighlightCaretLine || e.Location.Line == editor.Caret.Line)
     {
         return;
     }
     editor.RedrawMarginLine(this, e.Location.Line);
     editor.RedrawMarginLine(this, editor.Caret.Line);
 }
        public void SetSegment(ISegment segment, bool removeIndent)
        {
            int startLine = editor.Document.OffsetToLineNumber(segment.Offset);
            int endLine   = editor.Document.OffsetToLineNumber(segment.EndOffset);

            bool pushedLineLimit = endLine - startLine > maxLines;

            if (pushedLineLimit)
            {
                segment = new TextSegment(segment.Offset, editor.Document.GetLine(startLine + maxLines).Offset - segment.Offset);
            }
            layout.Ellipsize = Pango.EllipsizeMode.End;
            layout.SetMarkup(editor.GetTextEditorData().GetMarkup(segment.Offset, segment.Length, removeIndent) + (pushedLineLimit ? Environment.NewLine + "..." : ""));
            QueueDraw();
        }
Ejemplo n.º 4
0
        public void SetSegment(ISegment segment, bool removeIndent)
        {
            this.Segment = segment;

            // no need to markup thousands of lines for a preview window
            int startLine = editor.Document.OffsetToLineNumber(segment.Offset);
            int endLine   = editor.Document.OffsetToLineNumber(segment.EndOffset);

            bool pushedLineLimit = endLine - startLine > MaximumLineCount;

            if (pushedLineLimit)
            {
                segment = new TextSegment(segment.Offset, editor.Document.GetLine(startLine + MaximumLineCount).Offset - segment.Offset);
            }
            Markup = editor.GetTextEditorData().GetMarkup(segment.Offset, segment.Length, removeIndent) + (pushedLineLimit ? Environment.NewLine + "..." : "");
        }
Ejemplo n.º 5
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            if (args.Button != 1 || args.LineNumber < DocumentLocation.MinLine)
            {
                return;
            }
            editor.LockedMargin = this;
            int  lineNumber      = args.LineNumber;
            bool extendSelection = (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;

            if (lineNumber <= editor.Document.LineCount)
            {
                DocumentLocation loc  = new DocumentLocation(lineNumber, DocumentLocation.MinColumn);
                DocumentLine     line = args.LineSegment;
                if (args.Type == EventType.TwoButtonPress)
                {
                    if (line != null)
                    {
                        editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber));
                    }
                }
                else if (extendSelection)
                {
                    if (!editor.IsSomethingSelected)
                    {
                        editor.MainSelection = new Selection(loc, loc);
                    }
                    else
                    {
                        editor.MainSelection = editor.MainSelection.WithLead(loc);
                    }
                }
                else
                {
                    anchorLocation = loc;
                    editor.ClearSelection();
                }
                editor.Caret.PreserveSelection = true;
                editor.Caret.Location          = loc;
                editor.Caret.PreserveSelection = false;
            }
        }