Пример #1
0
        /// <summary>
        /// Draws a character to the screen while no connection is established.
        /// </summary>
        /// <param name="ch">The character to draw.</param>
        /// <param name="modifier">The existing screen modifier.</param>
        /// <param name="echo">A value indicating whether to draw the character to the terminal in plain text (<see cref="false"/> for password input with * characters).</param>
        private void DrawLocalModeChar(char ch, IScreenModifier modifier, bool echo)
        {
            ScreenCellFormat defaultFormat = new ScreenCellFormat();

            switch (ch)
            {
            case '\r':
                modifier.CursorColumn = 0;
                break;

            case '\n':
                modifier.CursorRowIncreaseWithScroll(null, null);
                break;

            default:
                modifier.CursorCharacter = echo ? ch : '*';
                modifier.ApplyFormatToCursor(defaultFormat);
                if (modifier.CursorColumn + 1 >= this.Screen.ColumnCount)
                {
                    modifier.CursorColumn = 0;
                    modifier.CursorRowIncreaseWithScroll(scrollTop: null, scrollBottom: null);
                }
                else
                {
                    modifier.CursorColumn++;
                }

                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Saves or restores the cursor.
        /// </summary>
        /// <param name="cursorRow">When <paramref name="save"/> is true: the cursor row to save; else it is set to the restored cursor row.</param>
        /// <param name="cursorColumn">When <paramref name="save"/> is true: the cursor column to save; else it is set to the restored cursor row.</param>
        /// <param name="save">A value indicating whether to save the cursor (true), or restore it (false).</param>
        private void SaveOrRestoreCursor(ref int cursorRow, ref int cursorColumn, bool save)
        {
            if (save)
            {
                this.savedCursor = new SavedCursor(cursorRow, cursorColumn, this.currentFormat);
            }
            else
            {
                if (this.savedCursor == null)
                {
                    return;
                }

                cursorRow          = this.savedCursor.CursorRow;
                cursorColumn       = this.savedCursor.CursorColumn;
                this.currentFormat = this.savedCursor.Format.Clone();
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SavedCursor"/> class.
 /// </summary>
 /// <param name="cursorRow">The cursor row to save.</param>
 /// <param name="cursorColumn">The cursor column to save.</param>
 /// <param name="currentFormat">The current format to save.</param>
 public SavedCursor(int cursorRow, int cursorColumn, ScreenCellFormat currentFormat)
 {
     this.CursorRow    = cursorRow;
     this.CursorColumn = cursorColumn;
     this.Format       = currentFormat.Clone();
 }