mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-24 19:34:01 +00:00
Stage 28
This commit is contained in:
@@ -398,12 +398,16 @@ static int ush_cmd_exit(ush_state *sh, const char *arg) {
|
||||
}
|
||||
|
||||
static int ush_cmd_clear(void) {
|
||||
u64 i;
|
||||
|
||||
for (i = 0ULL; i < USH_CLEAR_LINES; i++) {
|
||||
ush_write_char('\n');
|
||||
}
|
||||
ush_write("\x1B[2J\x1B[H");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ush_cmd_ansi(void) {
|
||||
ush_writeln("\x1B[1;36mansi color demo\x1B[0m");
|
||||
ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m");
|
||||
ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m");
|
||||
ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m \x1B[93mbright-yellow\x1B[0m");
|
||||
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m \x1B[97mbright-white\x1B[0m");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -874,6 +878,8 @@ void ush_execute_line(ush_state *sh, const char *line) {
|
||||
success = ush_cmd_exit(sh, arg);
|
||||
} else if (ush_streq(cmd, "clear") != 0 || ush_streq(cmd, "cls") != 0) {
|
||||
success = ush_cmd_clear();
|
||||
} else if (ush_streq(cmd, "ansi") != 0 || ush_streq(cmd, "color") != 0) {
|
||||
success = ush_cmd_ansi();
|
||||
} else if (ush_streq(cmd, "memstat") != 0) {
|
||||
success = ush_cmd_memstat();
|
||||
} else if (ush_streq(cmd, "fsstat") != 0) {
|
||||
@@ -925,4 +931,4 @@ void ush_execute_line(ush_state *sh, const char *line) {
|
||||
if (known == 0) {
|
||||
sh->cmd_unknown++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,13 +246,14 @@ void ush_writeln(const char *text) {
|
||||
|
||||
void ush_prompt(const ush_state *sh) {
|
||||
if (sh == (const ush_state *)0) {
|
||||
ush_write("cleonos(user)> ");
|
||||
ush_write("\x1B[96mcleonos\x1B[0m(\x1B[92muser\x1B[0m)> ");
|
||||
return;
|
||||
}
|
||||
|
||||
ush_write("cleonos(user:");
|
||||
ush_write("\x1B[96mcleonos\x1B[0m(\x1B[92muser\x1B[0m:");
|
||||
ush_write("\x1B[93m");
|
||||
ush_write(sh->cwd);
|
||||
ush_write(")> ");
|
||||
ush_write("\x1B[0m)> ");
|
||||
}
|
||||
|
||||
void ush_write_hex_u64(u64 value) {
|
||||
@@ -272,4 +273,4 @@ void ush_print_kv_hex(const char *label, u64 value) {
|
||||
ush_write(": ");
|
||||
ush_write_hex_u64(value);
|
||||
ush_write_char('\n');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ int cleonos_app_main(void) {
|
||||
char line[USH_LINE_MAX];
|
||||
|
||||
ush_init_state(&sh);
|
||||
ush_writeln("[USER][SHELL] interactive framework online");
|
||||
ush_writeln("\x1B[92m[USER][SHELL]\x1B[0m interactive framework online");
|
||||
|
||||
if (ush_run_script_file(&sh, "/shell/init.cmd") == 0) {
|
||||
ush_writeln("[USER][SHELL] /shell/init.cmd missing");
|
||||
if (ush_run_script_file(&sh, "/shell/init.cmd") == 0 &&
|
||||
ush_run_script_file(&sh, "/shell/INIT.CMD") == 0 &&
|
||||
ush_run_script_file(&sh, "/SHELL/INIT.CMD") == 0) {
|
||||
ush_writeln("\x1B[33m[USER][SHELL]\x1B[0m init script not found, continue interactive mode");
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
@@ -19,4 +21,4 @@ int cleonos_app_main(void) {
|
||||
return (int)(sh.exit_code & 0x7FFFFFFFULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user