From 47513bd32c256c4f35e3a8ced7d9fd7e15903530 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 20:38:53 -0500 Subject: terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program --- src/user/highway/line.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/user/highway/line.c') diff --git a/src/user/highway/line.c b/src/user/highway/line.c index bf171e5..cefdf92 100644 --- a/src/user/highway/line.c +++ b/src/user/highway/line.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -20,7 +20,7 @@ void ensure_color() { const struct no_null_sn *fg = get_var((struct no_null_sn){.data = "_color_fg", .length = 9}); const struct no_null_sn *bg = get_var((struct no_null_sn){.data = "_color_bg", .length = 9}); if (fg && bg) - set_color( + term_set_color( (hex_to_int(fg->data[0]) << 4) | hex_to_int(fg->data[1]), (hex_to_int(bg->data[0]) << 4) | hex_to_int(bg->data[1]) ); @@ -32,6 +32,7 @@ static void line_replace(const char *from) { while (*fi) { if (ti == line + LINE_SIZE) { term_add_sz("Line too long.\n"); + term_paint(); line[0] = '\0'; return; } @@ -49,11 +50,13 @@ static void line_replace(const char *from) { term_addf("Unterminated variable at\"%10s...\".\n", fi); else term_addf("Unterminated variable at \"%s\".\n", fi); + term_paint(); line[0] = '\0'; return; } if (ti + (var_end - var_start) >= line + LINE_SIZE) { term_add_sz("Line too long.\n"); + term_paint(); line[0] = '\0'; return; } @@ -87,16 +90,17 @@ void run_line(const char *original_line) { else if (blockequ(line, "echo ", 5)) { term_add_sz(space + 1); term_add_char('\n'); + term_paint(); } else if (blockequ(line, "vars", 5)) dump_vars(); - else if (blockequ(line, "quit", 5)) { - del_term(active_term); + else if (blockequ(line, "quit", 5)) __pcrt_quit(); + else if (blockequ(line, "clear", 6)) { + term_clear(); + term_paint(); } - else if (blockequ(line, "clear", 6)) - clear_term(); - else if (blockequ(line, "help", 5)) + else if (blockequ(line, "help", 5)) { term_add_sz("Highway is a command shell for Portland OS. It includes variable support and a couple of pseudo-commands. Variables are addressed by surrounding with \"$\". The following list shows each of the pseudo-commands.\n\n" " source FILE\t" "run each command in FILE\n" " clear\t\t\t" "clear the screen\n" @@ -105,10 +109,13 @@ void run_line(const char *original_line) { " vars\t\t\t" "dump variables\n" " quit\t\t\t" "exit highway\n" " help\t\t\t" "show this\n"); + term_paint(); + } else if (!try_run_command_blocking(line, stdio_task)) { const struct no_null_sn *path = get_var((struct no_null_sn){.data = "_path", .length = 5}); if (!path->length) { term_add_sz("Could not run command.\n"); + term_paint(); return; } for (uint16_t to_i = LINE_SIZE - 1; to_i >= path->length; --to_i) @@ -116,14 +123,17 @@ void run_line(const char *original_line) { blockcpy(line, path->data, path->length); if (!try_run_command_blocking(line, stdio_task)) { term_add_sz("Could not run command.\n"); + term_paint(); return; } else { + _yield_task(); + term_add_char('\n'); ensure_color(); - if (active_term->cursor_x) - term_newline(); } } - else + else { + _yield_task(); ensure_color(); + } } \ No newline at end of file -- cgit v1.2.3