diff options
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/main.c | 2 | ||||
-rw-r--r-- | src/user/app/shell.c | 31 |
2 files changed, 8 insertions, 25 deletions
diff --git a/src/user/app/main.c b/src/user/app/main.c index f87133e..ff47d4e 100644 --- a/src/user/app/main.c +++ b/src/user/app/main.c @@ -63,6 +63,7 @@ int main(void) { printf("couldn't open /kdev/com1\n"); _syscall_exit(1); } + termcook(); shell_loop(); _syscall_exit(1); @@ -78,6 +79,7 @@ int main(void) { printf("couldn't open /keyboard\n"); _syscall_exit(1); } + termcook(); shell_loop(); _syscall_exit(1); diff --git a/src/user/app/shell.c b/src/user/app/shell.c index 4f062d9..3a08af4 100644 --- a/src/user/app/shell.c +++ b/src/user/app/shell.c @@ -31,33 +31,14 @@ static char *strtrim(char *s) { } +// TODO fgets static int readline(char *buf, size_t max) { - char c; + char c = '\0'; size_t pos = 0; - while (file_read(stdin, &c, 1)) { - switch (c) { - case '\b': - case 0x7f: - /* for some reason backspace outputs 0x7f (DEL) */ - if (pos != 0) { - printf("\b \b"); - pos--; - } - break; - case '\n': - case '\r': - printf("\n"); - buf[pos++] = '\0'; - return pos; - default: - if (pos < max) { - printf("%c", c); - buf[pos] = c; - pos++; - } - } - } - return -1; // error + while (pos < (max-1) && c != '\n' && file_read(stdin, &c, 1)) + buf[pos++] = c; + buf[pos++] = '\0'; + return pos; } static void cmd_cat_ls(const char *args, bool ls) { |