コード例 #1
0
        /// <summary>
        /// Handler for Return keyboard event.
        /// </summary>
        /// <param name="down">Indicates whether the key was pressed or released.</param>
        /// <returns>
        /// True if handled.
        /// </returns>
        protected override bool OnKeyReturn(bool down)
        {
            if (down)
            {
                return(true);
            }

            //Split current string, putting the rhs on a new line
            string CurrentLine = m_TextLines[m_CursorPos.Y];
            string lhs         = CurrentLine.Substring(0, CursorPosition.X);
            string rhs         = CurrentLine.Substring(CursorPosition.X);

            m_TextLines[m_CursorPos.Y] = lhs;
            m_TextLines.Insert(m_CursorPos.Y + 1, rhs);

            OnKeyDown(true);
            OnKeyHome(true);

            if (m_CursorPos.Y == TotalLines - 1)
            {
                m_ScrollControl.ScrollToBottom();
            }

            Invalidate();
            RefreshCursorBounds();

            return(true);
        }