예제 #1
0
        /// <summary>
        /// Scrolls the view to ensure the caret is visible.
        /// </summary>
        /// <param name="bufferPosition">The buffer position.</param>
        public void ScrollToCaret(TextPosition bufferPosition)
        {
            // Look to see if we are moving to a different position. If we are,
            // we tell the line buffer that we have exited the previous line.
            LinePosition linePosition = caret.Position.LinePosition;
            int          lineIndex    =
                linePosition.GetLineIndex(Controller.DisplayContext.LineBuffer);

            if (linePosition != bufferPosition.LinePosition)
            {
                // Send an operation to the line buffer that we left the line.
                LineBuffer.ExitLine(lineIndex);
            }

            // Call the base scrolling.
            caret.Position = bufferPosition;
            ScrollToCaret();
        }