add command history in repl

This commit is contained in:
ValKmjolnir
2023-09-19 00:24:45 +08:00
parent e811965629
commit 0a94e8d2dd
4 changed files with 43 additions and 25 deletions

View File

@@ -51,7 +51,7 @@ public:
return 1;
}
int flag = fcntl(0, F_GETFL);
fcntl(0, F_SETFL,flag|O_NONBLOCK);
fcntl(0, F_SETFL, flag|O_NONBLOCK);
nread = read(0, &ch, 1);
fcntl(0, F_SETFL, flag);
if (nread==1) {
@@ -83,25 +83,25 @@ public:
noecho_input this_window;
var nas_getch(var* args, usize size, gc* ngc) {
return var::num((double)this_window.noecho_getch());
return var::num(static_cast<double>(this_window.noecho_getch()));
}
var nas_kbhit(var* args, usize size, gc* ngc) {
return var::num((double)this_window.noecho_kbhit());
return var::num(static_cast<double>(this_window.noecho_kbhit()));
}
var nas_noblock(var* args, usize size, gc* ngc) {
if (this_window.noecho_kbhit()) {
return var::num((double)this_window.noecho_getch());
return var::num(static_cast<double>(this_window.noecho_getch()));
}
return nil;
}
module_func_info func_tbl[] = {
{"nas_getch",nas_getch},
{"nas_kbhit",nas_kbhit},
{"nas_noblock",nas_noblock},
{nullptr,nullptr}
{"nas_getch", nas_getch},
{"nas_kbhit", nas_kbhit},
{"nas_noblock", nas_noblock},
{nullptr, nullptr}
};
extern "C" module_func_info* get() {