diff options
-rw-r--r-- | src/pOS/arch/x86/kernel/shell/shell.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/pOS/arch/x86/kernel/shell/shell.cpp b/src/pOS/arch/x86/kernel/shell/shell.cpp index 16ca129..5e8d896 100644 --- a/src/pOS/arch/x86/kernel/shell/shell.cpp +++ b/src/pOS/arch/x86/kernel/shell/shell.cpp @@ -1,6 +1,8 @@ #include <kernel/shell/shell.h> char Shell::prefix[10]; +static int indx = 0; +static char cmd[20]; /* Mem management */ void signal_handler(Signal_Type signal) { @@ -9,10 +11,17 @@ void signal_handler(Signal_Type signal) case ESC_SIG: break; case LEFT_ARROW_SIG: - TTY::tty_cursor_move(-1, 0); + if(indx - 1 >= 0) + { + TTY::tty_cursor_move(-1, 0); + indx--; + } break; case RIGHT_ARROW_SIG: TTY::tty_cursor_move(+1, 0); + if(cmd[indx] == 0) + cmd[indx] = ' '; + indx++; break; case UP_ARROW_SIG: /* TODO: implement history */ @@ -35,18 +44,17 @@ int Shell::run(void) { char c; int return_code = 0; - int indx = 0; - char cmd[20]; /* Mem management */ printf("%s ", Shell::prefix); while((c = getc()) && c != EOF) { putc(c); if(c == '\b') - indx--; + { + cmd[indx] = c; + } else if(c == '\n') { - cmd[indx] = '\0'; indx = 0; return_code = CMD_MANAGER::execute(cmd); @@ -55,10 +63,14 @@ int Shell::run(void) sprintf(retstr, "(%d)", return_code); if(!return_code) retstr[0] = '\0'; + printf("%s%s ", retstr, Shell::prefix); + memset(cmd, 0, 20); } else + { cmd[indx++] = c; + } } ASSERT(c == EOF); |