summaryrefslogtreecommitdiff
path: root/src/user/highway
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-20 14:50:12 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-20 14:50:12 -0400
commitfadd46012c9974931add6c36e69636d3cbc6906f (patch)
treed1af6084772830074be18cf7a9dd93c2ec3d3f59 /src/user/highway
parentde20d7430df08731d9108acb83e1234ba7f1fe16 (diff)
downloadportland-os-fadd46012c9974931add6c36e69636d3cbc6906f.tar.gz
history when getting line from user in knob
Diffstat (limited to 'src/user/highway')
-rw-r--r--src/user/highway/line.c17
-rw-r--r--src/user/highway/main.c3
2 files changed, 12 insertions, 8 deletions
diff --git a/src/user/highway/line.c b/src/user/highway/line.c
index 40dccfa..b5a54c5 100644
--- a/src/user/highway/line.c
+++ b/src/user/highway/line.c
@@ -57,25 +57,28 @@ void run_line(const char *original_line) {
const char *space;
for (space = line; *space && (*space != ' '); ++space)
;
- if (blockequ(line, "source", space - line))
+ if (blockequ(line, "source ", 7))
source(space + 1);
- else if (blockequ(line, "set", space - line))
+ else if (blockequ(line, "set ", 4))
set(space + 1);
- else if (blockequ(line, "echo", space - line)) {
+ else if (blockequ(line, "echo ", 5)) {
tell_user_sz(space + 1);
tell_user_sz("\n");
}
- else if (blockequ(line, "vars", space - line))
+ else if (blockequ(line, "vars", 5))
dump_vars();
- else if (blockequ(line, "quit", space - line))
+ else if (blockequ(line, "quit", 5))
__pcrt_quit();
- else if (blockequ(line, "help", space - line))
+ else if (blockequ(line, "clear", 6))
+ _clear_screen();
+ else if (blockequ(line, "help", 5))
tell_user_sz("Highway is a command shell for Portland OS. It includes variables and a couple\n"
"of pseudo-commands. Variables are addressed by surrounding with \"$\". The\n"
"following list shows each of the pseudo-commands.\n\n"
" source FILE run each command in FILE\n"
- " set VAR VALUE set $VAR$ to VALUE\n"
+ " clear clear the screen\n"
" echo STRING print STRING\n"
+ " set VAR VALUE set $VAR$ to VALUE\n"
" vars dump variables\n"
" quit exit highway\n"
" help show this\n");
diff --git a/src/user/highway/main.c b/src/user/highway/main.c
index 61f736e..4599315 100644
--- a/src/user/highway/main.c
+++ b/src/user/highway/main.c
@@ -7,10 +7,11 @@ void main(const char *arg) {
source(*arg ? arg : "user/default.rc");
char cmd_buf[128];
yield_task();
+ struct history *cmd_hs = new_history(128);
tell_user_sz("Portland Highway\nType \"help\" for help.\n");
while (1) {
tell_user_sz("\n> ");
- ask_user_line_sz(cmd_buf, 127);
+ ask_user_line_sz_with_history(cmd_buf, 127, cmd_hs);
run_line(cmd_buf);
}
} \ No newline at end of file