Beispiel #1
0
        /// <summary>
        /// Gets the Pango markup for a given line.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public string GetSelectionMarkup(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Get the line markup from the underlying buffer.
            string markup = LineBuffer.GetLineMarkup(lineIndex, lineContexts);

            // Check to see if we are in the selection.
            CharacterPosition beginCharacterPosition;
            CharacterPosition endCharacterPosition;
            bool containsLine = DisplayContext.Caret.Selection.ContainsLine(
                LineBuffer, lineIndex, out beginCharacterPosition, out endCharacterPosition);

            if (containsLine)
            {
                // Apply the markup to the line.
                var linePosition        = new LinePosition(lineIndex);
                var singleLineTextRange = new SingleLineTextRange(
                    linePosition, beginCharacterPosition, endCharacterPosition);
                return(SelectionRenderer.GetSelectionMarkup(markup, singleLineTextRange));
            }

            // Return the resulting markup.
            return(markup);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorViewRenderer"/> class.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        /// <param name="lineBuffer">The line buffer.</param>
        public LineBufferRenderer(
            IDisplayContext displayContext,
            LineBuffer lineBuffer)
            : base(displayContext)
        {
            // Save the buffer in a property.
            SetLineBuffer(lineBuffer);

            // Set up the selection.
            selectionRenderer = new SelectionRenderer();
        }