From 7ab551c54e7e5cca51bd0ad4554fc048a8fa21a6 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 26 Apr 2016 13:30:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=AD=97=E7=AC=A6=E8=BE=93?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 17_day/bootpack.c | 73 +++++++++++++++++++++++++++++++++++------------ 17_day/bootpack.h | 1 + 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/17_day/bootpack.c b/17_day/bootpack.c index f70e58c..cb34fbd 100644 --- a/17_day/bootpack.c +++ b/17_day/bootpack.c @@ -123,18 +123,29 @@ void HariMain(void) if (256 <= i && i <= 511) { /* 键盘数据*/ sprintf(s, "%02X", i - 256); putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); - if (i < 0x54 + 256) { - if (keytable[i - 256] != 0 && cursor_x < 128) { - s[0] = keytable[i - 256]; - s[1] = 0; - putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); - cursor_x += 8; + if (i < 0x54 + 256 && keytable[i - 256] != 0) { /*一般字符*/ + if (key_to == 0) { /*发送给任务A */ + if (cursor_x < 128) { + /*显示一个字符之后将光标后移一位*/ + s[0] = keytable[i - 256]; + s[1] = 0; + putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); + cursor_x += 8; + } + } else { /*发送给命令行窗口*/ + fifo32_put(&task_cons->fifo, keytable[i - 256] + 256); } } if (i == 256 + 0x0e && cursor_x > 8) { /* 退格键 */ - /* 用空格键把光标消去后,后移1次光标 */ - putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); - cursor_x -= 8; + if (key_to == 0) { /*发送给任务A */ + if (cursor_x > 8) { + /*用空白擦除光标后将光标前移一位*/ + putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); + cursor_x -= 8; + } + } else { /*发送给命令行窗口*/ + fifo32_put(&task_cons->fifo, 8 + 256); + } } if (i == 256 + 0x0f) { /* Tab键*/ if (key_to == 0) { @@ -291,36 +302,60 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c) void console_task(struct SHEET *sheet) { - struct FIFO32 fifo; struct TIMER *timer; struct TASK *task = task_now(); - int i, fifobuf[128], cursor_x = 8, cursor_c = COL8_000000; - fifo32_init(&fifo, 128, fifobuf, task); + int i, fifobuf[128], cursor_x = 16, cursor_c = COL8_000000; + char s[2]; + + fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); - timer_init(timer, &fifo, 1); + timer_init(timer, &task->fifo, 1); timer_settime(timer, 50); + /*显示提示符*/ + putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1); + for (;;) { io_cli(); - if (fifo32_status(&fifo) == 0) { + if (fifo32_status(&task->fifo) == 0) { task_sleep(task); io_sti(); } else { - i = fifo32_get(&fifo); + i = fifo32_get(&task->fifo); io_sti(); if (i <= 1) { /*光标用定时器*/ if (i != 0) { - timer_init(timer, &fifo, 0); /*下次置0 */ + timer_init(timer, &task->fifo, 0); /*下次置0 */ cursor_c = COL8_FFFFFF; } else { - timer_init(timer, &fifo, 1); /*下次置1 */ + timer_init(timer, &task->fifo, 1); /*下次置1 */ cursor_c = COL8_000000; } timer_settime(timer, 50); - boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); - sheet_refresh(sheet, cursor_x, 28, cursor_x + 8, 44); } + if (256 <= i && i <= 511) { /*键盘数据(通过任务A) */ + if (i == 8 + 256) { + /*退格键*/ + if (cursor_x > 16) { + /*用空白擦除光标后将光标前移一位*/ + putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, " ", 1); + cursor_x -= 8; + } + } else { + /*一般字符*/ + if (cursor_x < 240) { + /*显示一个字符之后将光标后移一位 */ + s[0] = i - 256; + s[1] = 0; + putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, s, 1); + cursor_x += 8; + } + } + } + /*重新显示光标*/ + boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); + sheet_refresh(sheet, cursor_x, 28, cursor_x + 8, 44); } } } diff --git a/17_day/bootpack.h b/17_day/bootpack.h index 86a2dd1..21188cb 100644 --- a/17_day/bootpack.h +++ b/17_day/bootpack.h @@ -199,6 +199,7 @@ struct TSS32 { struct TASK { int sel, flags; /* sel用来存放GDT的编号*/ int level, priority; /* 优先级 */ + struct FIFO32 fifo; struct TSS32 tss; }; struct TASKLEVEL {