From 4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Sat, 8 Jun 2013 23:09:52 +0200 Subject: All FWIK is deleted. YOSH is now pure C. Not-working KBASIC included. --- src/kernel/ui/vt.cpp | 41 +++++++++-------------------------------- src/kernel/ui/vt.h | 2 +- 2 files changed, 10 insertions(+), 33 deletions(-) (limited to 'src/kernel/ui') diff --git a/src/kernel/ui/vt.cpp b/src/kernel/ui/vt.cpp index 3bed897..6876806 100644 --- a/src/kernel/ui/vt.cpp +++ b/src/kernel/ui/vt.cpp @@ -18,7 +18,6 @@ vt::vt(node* parent, int ww, int hh) : node(parent, FT_TERMINAL) { bgcolor = TC_BLACK; output = 0; cursor_visible = true; - keyboard_echo = false; csr_l = csr_c = 0; kbd_buffer_filled = 0; @@ -194,9 +193,12 @@ void vt::keyboardInput(keypress kp, keyboard* from) { if ((kp.command == 0 || kp.command == KB_ENTER || kp.command == KB_TAB || kp.command == KB_BACKSPACE) && kp.character != 0 && kp.pressed) { b[n++] = (char)kp.character; - } else if (kp.command == KB_CMD_ALT && kp.character >= 64 && kp.character <= 126 && kp.pressed) { + } else if ((kp.command & KB_CMD_ALT) && kp.character >= 64 && kp.character <= 126 && kp.pressed) { b[n++] = 27; b[n++] = kp.character; + } else if ((kp.command & KB_CMD_CTRL) && kp.character >= 'A' && kp.character <= 'z' && kp.pressed) { + if (kp.character >= 'A' && kp.character <= 'Z') b[n++] = 1 + kp.character - 'A'; + if (kp.character >= 'a' && kp.character <= 'z') b[n++] = 1 + kp.character - 'a'; } else if (kb_cmd_esc[kp.command & 0x3F] != 0 && kp.pressed) { int i; for (i = 0; kb_cmd_esc[kp.command & 0x3F][i] != 0; i++) { @@ -330,10 +332,6 @@ int vt::write(size_t offset, size_t len, char* buffer) { } else if (buffer[i] == 'p') { // restore cursor position csr_l = save_csr_l; csr_c = save_csr_c; - } else if (buffer[i] == 'e') { // CUSTOM : enable keyboard echo - keyboard_echo = true; - } else if (buffer[i] == 'h') { // CUSTOM : disable keyboard echo - keyboard_echo = false; } else if (buffer[i] == '?') { if (buffer[++i] == '2' && buffer[++i] == '5') { if (buffer[++i] == 'l') cursor_visible = false; @@ -361,38 +359,17 @@ int vt::read(size_t offset, size_t len, char* buffer) { unsigned c = 0; while (true) { - bool end = false; if (kbd_buffer_filled > 0) { int r = 0; - if (keyboard_echo) { - for (; r < kbd_buffer_filled; r++) { - if (kbd_buffer[r] == '\b') { - if (c > 0) { - c--; - put('\b'); - } - } else if (kbd_buffer[r] == '\n') { - buffer[c++] = '\n'; - c++; - put('\n'); - end = true; - break; - } else if (kbd_buffer[r] >= ' ') { - buffer[c++] = kbd_buffer[r]; - put(buffer[c]); - } - if (c == len) break; - } - } else { - while (r < kbd_buffer_filled && c < len) { - buffer[c++] = kbd_buffer[r++]; - } - end = true; + while (r < kbd_buffer_filled && c < len) { + buffer[c++] = kbd_buffer[r++]; } + memcpy(kbd_buffer + r, kbd_buffer, (kbd_buffer_filled - r)); kbd_buffer_filled -= r; + + return c; } - if (end || c == len) return c; if (kbd_waiter != 0) return c; kbd_waiter = current_thread; diff --git a/src/kernel/ui/vt.h b/src/kernel/ui/vt.h index a29716f..8a169b4 100644 --- a/src/kernel/ui/vt.h +++ b/src/kernel/ui/vt.h @@ -19,7 +19,7 @@ class vt : public node { vt_char *text; void put_at(int l, int c, int ch); - bool cursor_visible, keyboard_echo; + bool cursor_visible; int kbd_buffer_filled; char kbd_buffer[KBD_BUFFER_SIZE]; -- cgit v1.2.3