CeDOS - Commit b05d8653

VGA console: Implemented more ANSI escape codes CSI n G (Cursor Horizontal Absolute) CSI n ; m H (Cursor Position) CSI n J (Erase in Display)
Celina Sophie Kalus
Wed, 06 Dec 2023 01:18:24 +0100
1 files changed, 26 insertions(+), 1 deletions(-)
M kernel/drivers/vga_console.ckernel/drivers/vga_console.c

@@ -121,7 +121,7 @@ ESCAPE_C = 4

} state; static int n, m; - if (c == '\e') { + if (state == NORMAL && c == '\e') { // beginning of escape sequence state = ESCAPE_START; n = 0;

@@ -130,6 +130,31 @@ } else if (state == ESCAPE_START && c == '[') {

state = ESCAPE_N; } else if (state == ESCAPE_N && c >= '0' && c <= '9') { n = n * 10 + (c - '0'); + } else if (state == ESCAPE_M && c >= '0' && c <= '9') { + m = m * 10 + (c - '0'); + } else if (state == ESCAPE_N && c == ';') { + state = ESCAPE_M; + } else if (state == ESCAPE_N && c == 'G') { + column = n; + set_cursor(line, column); + state = NORMAL; + } else if (state == ESCAPE_M && c == 'H') { + line = n; + column = m; + set_cursor(line, column); + state = NORMAL; + } else if (state == ESCAPE_N && c == 'J') { + switch (n) { + default: + case 0: + // clear from cursor to end of screen + case 1: + // clear from beginning of screen to cursor + case 2: + // clear whole display + vga_con_clear(); + } + state = NORMAL; } else if (state == ESCAPE_N && c == 'm') { if (n < 38) { color = n - 30;