Ejemplo n.º 1
0
    public void KeyDownProcessor(char key)
    {
        if (key == 13)
        {
            return;
        }
        CursorController cursor = Typer.Cursor;

        if (key == '\b')
        {
            if (_command.Length + 1 == Typer.PositionX)
            {
                Typer.MoveCursor(true);
                _screen.TypeChar(0, cursor.x, cursor.y);
                _screen.Apply();
                if (!string.IsNullOrEmpty(_command))
                {
                    DeleteLastChar();
                }
            }
            else
            {
                Typer.MoveCursor(true);
                _command = _command.Substring(0, Typer.PositionX - 1) + _command.Substring(Typer.PositionX);
                int x = cursor.x;
                cursor.SetPosition(Typer.borderWidth, cursor.y);
                Typer.Print(">" + _command + " ");
                cursor.SetPosition(x, cursor.y);
                _screen.Apply();
            }
        }
        else if (_command.Length + 1 == Typer.PositionX)
        {
            if (cursor.x == DisplaySystem.COLS - 1 - Typer.borderWidth)
            {
                return;
            }
            _screen.TypeChar(Utils.GetCharNumber(key), cursor.x, cursor.y);
            cursor.Next();
            _command = _command + key;
            _screen.Apply();
        }
        else if (!string.IsNullOrEmpty(_command))
        {
            if (_command.Length > DisplaySystem.COLS - 3 - Typer.borderWidth)
            {
                return;
            }
            InsertToString(key);
        }
    }
Ejemplo n.º 2
0
 public void Print(string text)
 {
     if (text.Length > DisplaySystem.COLS - borderWidth * 2)
     {
         string[] lines = Utils.Split(text, DisplaySystem.COLS - borderWidth * 2);
         foreach (string line in lines)
         {
             Print(line);
         }
     }
     else
     {
         foreach (char i in text)
         {
             if (i == '\n')
             {
                 Cursor.NextLine();
                 continue;
             }
             Screen.TypeChar(Utils.GetCharNumber(i), Cursor.x, Cursor.y);
             Cursor.Next();
         }
     }
 }