diff --git a/kernel/chr_drv/console.c b/kernel/chr_drv/console.c index 47533981187dd1718b8dae1b20dc46bbcad38edb..c67c45ae1dad0297611e58d431b4fd30a4a7fa7e 100644 --- a/kernel/chr_drv/console.c +++ b/kernel/chr_drv/console.c @@ -36,6 +36,7 @@ static unsigned long origin; static unsigned long scr_end; static unsigned long pos; static unsigned long x, y; +static unsigned long state = 0; static unsigned long top, bottom; static unsigned long attr = 0x07; @@ -66,6 +67,32 @@ static inline void set_cursor() { sti(); } +static void scrdown() { + if (bottom <= top) + return; + + __asm__("std\n\t" + "rep\n\t" + "movsl\n\t" + "addl $2,%%edi\n\t" + "movl video_num_columns,%%ecx\n\t" + "rep\n\t" + "stosw" + ::"a" (video_erase_char), + "c" ((bottom-top-1)*video_num_columns>>1), + "D" (origin+video_size_row*bottom-4), + "S" (origin+video_size_row*(bottom-1)-4):); +} + +static void ri() { + if (y>top) { + y--; + pos -= video_size_row; + return; + } + scrdown(); +} + static void scrup() { if (video_type == VIDEO_TYPE_EGAC || video_type == VIDEO_TYPE_EGAM) { if (!top && bottom == video_num_lines) { @@ -220,30 +247,45 @@ void con_write(struct tty_struct* tty) { while(nr--) { GETCH(tty->write_q, c); - if (c > 31 && c < 127) { - if (x >= video_num_columns) { - x -= video_num_columns; - pos -= video_size_row; + switch (state) { + case 0: + if (c > 31 && c < 127) { + if (x >= video_num_columns) { + x -= video_num_columns; + pos -= video_size_row; + lf(); + } + + *(char *)pos = c; + *(((char*)pos) + 1) = attr; + pos += 2; + x++; + } + else if (c == 27) { + state = 1; + } + else if (c == 10 || c == 11 || c == 12) lf(); + else if (c == 13) + cr(); + else if (c == 127) { + del(); } - - *(char *)pos = c; - *(((char*)pos) + 1) = attr; - pos += 2; - x++; - } - else if (c == 10 || c == 11 || c == 12) - lf(); - else if (c == 13) - cr(); - else if (c == 127) { - del(); - } - else if (c == 8) { - if (x) { - x--; - pos -= 2; + else if (c == 8) { + if (x) { + x--; + pos -= 2; + } + } + break; + case 1: + if (c == '[') { + state = 2; + } + else if (c == 'M') { + ri(); } + break; } } diff --git a/kernel/chr_drv/kboard.c b/kernel/chr_drv/kboard.c index 4eb6e35b668ade579465631bf143b357e1cde85d..d03cc8bb37f5cf75faee3d510a9c805055a09254 100644 --- a/kernel/chr_drv/kboard.c +++ b/kernel/chr_drv/kboard.c @@ -10,7 +10,7 @@ void do_self(); void ctrl() {} void func() {} -void cursor() {} +void cursor(); void lshift(); void rshift(); @@ -128,6 +128,8 @@ static char shift_map[0x7f] = { '>', 0,0,0,0,0,0,0,0,0,0}; +const char* cur_table = "HA5 DGC YB623"; + unsigned char scan_code, leds, mode, e0; void keyboard_handler(void) @@ -151,9 +153,8 @@ void keyboard_handler(void) key_fn func = key_table[scan_code]; if (func) func(); + do_tty_interrupt(0); } - - do_tty_interrupt(0); } void do_self() { @@ -176,6 +177,23 @@ void do_self() { PUTCH(c, tty_table[0].read_q); } +void cursor() { + scan_code -= 0x47; + if (scan_code < 0 || scan_code > 12) + return; + + if (scan_code != 12) { + if (e0 == 1) { + if (cur_table[scan_code] > '9') { + PUTCH(0x1b, tty_table[0].read_q); + PUTCH('M', tty_table[0].read_q); + //PUTCH(0x5b, tty_table[0].read_q); + //PUTCH(scan_code, tty_table[0].read_q); + } + } + } +} + void lshift() { mode |= 0x1; } diff --git a/kernel/chr_drv/tty_io.c b/kernel/chr_drv/tty_io.c index 48b24587ef37a9dd4db801d98c15add5f09caf01..2b545dbbbb740a2779e13a902f538fbaad535f73 100644 --- a/kernel/chr_drv/tty_io.c +++ b/kernel/chr_drv/tty_io.c @@ -28,7 +28,7 @@ struct tty_struct tty_table[] = { ICRNL, OPOST | ONLCR, 0, - ISIG | ICANON | ECHO | ECHOCTL | ECHOKE, + ISIG | ICANON | ECHO | ECHOKE, 0, INIT_C_CC }, @@ -157,6 +157,9 @@ void copy_to_cooked(struct tty_struct * tty) { PUTCH('^', tty->write_q); PUTCH(c + 64, tty->write_q); } + else { + PUTCH(c, tty->write_q); + } } else PUTCH(c, tty->write_q);