Esempio n. 1
0
/*
 * Set the current cursor position.
 * Params:
 *   state->ebx - new row value
 *   state->ecx - new column value
 * Returns: 0 if successful, -1 otherwise
 */
static int Sys_PutCursor(struct Interrupt_State* state)
{
    if (Put_Cursor(state->ebx, state->ecx))
        return 0;
    else
        return -1;
}
Esempio n. 2
0
/*
 * The workhorse output function.
 * Depending on the current console output state,
 * does literal character output or processes part of
 * an escape sequence.
 */
static void Put_Char_Imp(int c) {
  again:
    switch (s_cons.state) {
        case S_NORMAL:
            if(c == ESC)
                Start_Escape();
            else
                Output_Literal_Character(c);
            break;

        case S_ESC:
            if(c == '[')
                s_cons.state = S_ESC2;
            else
                Reset();
            break;

        case S_ESC2:
            if(ISDIGIT(c)) {
                Start_Arg(0);
                goto again;
            } else if(c == ';') {
                /* Special case: for "n;m" commands, "n" is implicitly 1 if omitted */
                Start_Arg(0);
                Add_Digit('1');
                Start_Arg(1);
            } else {
                s_cons.state = S_CMD;
                goto again;
            }
            break;

        case S_ARG:
            if(ISDIGIT(c))
                Add_Digit(c);
            else if(c == ';')
                Start_Arg(s_cons.numArgs);
            else {
                s_cons.state = S_CMD;
                goto again;
            }
            break;

        case S_CMD:
            switch (c) {
                case 'K':
                    Clear_To_EOL();
                    break;
                case 's':
                    Save_Cursor();
                    break;
                case 'u':
                    Restore_Cursor();
                    break;
                case 'A':
                    Move_Cursor(s_cons.row - Get_Arg(0), s_cons.col);
                    break;
                case 'B':
                    Move_Cursor(s_cons.row + Get_Arg(0), s_cons.col);
                    break;
                case 'C':
                    Move_Cursor(s_cons.row, s_cons.col + Get_Arg(0));
                    break;
                case 'D':
                    Move_Cursor(s_cons.row, s_cons.col - Get_Arg(0));
                    break;
                case 'm':
                    Update_Attributes();
                    break;
                case 'f':
                case 'H':
                    if(s_cons.numArgs == 2)
                        Move_Cursor(Get_Arg(0) - 1, Get_Arg(1) - 1);
                    break;
                case 'J':
                    if(s_cons.numArgs == 1 && Get_Arg(0) == 2) {
                        Clear_Screen();
                        Put_Cursor(0, 0);
                    }
                    break;
                default:
                    break;
            }
            Reset();
            break;

        default:
            KASSERT(false);
    }
}
Esempio n. 3
0
/*
 * Set the current cursor position.
 * Params:
 *   state->ebx - new row value
 *   state->ecx - new column value
 * Returns: 0 if successful, -1 otherwise
 */
static int Sys_PutCursor(struct Interrupt_State *state) {
    return Put_Cursor(state->ebx, state->ecx) ? 0 : -1;
}