예제 #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);
        }