summaryrefslogtreecommitdiff
path: root/src/user/highway
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-02-16 20:38:53 -0500
committerBenji Dial <benji6283@gmail.com>2021-02-16 20:38:53 -0500
commit47513bd32c256c4f35e3a8ced7d9fd7e15903530 (patch)
treecafdf75d52a954814726e07445063c41bb6599f9 /src/user/highway
parentbd7facc4b5f53481dc85a15ba123361b2758655b (diff)
downloadportland-os-47513bd32c256c4f35e3a8ced7d9fd7e15903530.tar.gz
terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program
Diffstat (limited to 'src/user/highway')
-rw-r--r--src/user/highway/cmds.c2
-rw-r--r--src/user/highway/line.c30
-rw-r--r--src/user/highway/main.c23
-rw-r--r--src/user/highway/vars.c5
4 files changed, 30 insertions, 30 deletions
diff --git a/src/user/highway/cmds.c b/src/user/highway/cmds.c
index 0420ae1..53198df 100644
--- a/src/user/highway/cmds.c
+++ b/src/user/highway/cmds.c
@@ -1,4 +1,4 @@
-#include <terminal/terminal.h>
+#include <libterm/terminal.h>
#include <knob/file.h>
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 <terminal/terminal.h>
+#include <libterm/terminal.h>
#include <knob/block.h>
#include <knob/task.h>
@@ -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
diff --git a/src/user/highway/main.c b/src/user/highway/main.c
index 60d5a69..c9ceee2 100644
--- a/src/user/highway/main.c
+++ b/src/user/highway/main.c
@@ -1,32 +1,21 @@
-#include <terminal/terminal.h>
-#include <terminal/readline.h>
+#include <libterm/terminal.h>
+#include <libterm/readline.h>
-#include <libfont/fonts.h>
-
-#include <knob/format.h>
-#include <knob/heap.h>
#include <knob/task.h>
#include "cmds.h"
#include "line.h"
-#define FONT_NAME "berry"
-
void main(const char *arg) {
- struct font_info *f = get_font(FONT_NAME);
-
- if (!f)
- return;
-
- active_term = make_term(f, 50, 18);
- if (!active_term)
- return;
+//syslogf(" this task: 0x%2h", this_task);
+//syslogf(" stdio task: 0x%2h", stdio_task);
+//syslogf("calling task: 0x%2h", calling_task);
source(*arg ? arg : "user/default.rc");
ensure_color();
term_add_sz("Portland Highway\nType \"help\" for help.\n");
- paint_term();
+ term_paint();
char cmd_buf[128];
while (1) {
diff --git a/src/user/highway/vars.c b/src/user/highway/vars.c
index 5f56621..82062c4 100644
--- a/src/user/highway/vars.c
+++ b/src/user/highway/vars.c
@@ -1,4 +1,4 @@
-#include <terminal/terminal.h>
+#include <libterm/terminal.h>
#include <knob/format.h>
#include <knob/block.h>
@@ -77,6 +77,7 @@ void del_var(struct no_null_sn name) {
void dump_vars() {
for (struct var_dict_node *node = var_dict_start; node; node = node->next) {
- term_addf_no_ww("$%ns$ = %ns\n", node->name.length, node->name.data, node->value.length, node->value.data);
+ term_addf_no_ww("$%ns$\t= %ns\n", node->name.length, node->name.data, node->value.length, node->value.data);
+ term_paint();
}
} \ No newline at end of file