feat: add rudimentary tab completion for executables to shell
This commit is contained in:
@@ -39,8 +39,6 @@ void sync_cwd() {
|
||||
// ---- Session info (read once at startup) ----
|
||||
|
||||
void read_session() {
|
||||
// TODO Why is getuser treated as not defined in VSCode intellisense?
|
||||
|
||||
montauk::getuser(
|
||||
(char *)&session_user, // Buffer
|
||||
32 // Buffer max size
|
||||
@@ -352,6 +350,10 @@ static constexpr uint8_t SC_DOWN = 0x50;
|
||||
static constexpr uint8_t SC_LEFT = 0x4B;
|
||||
static constexpr uint8_t SC_RIGHT = 0x4D;
|
||||
|
||||
// ---- Tab key scancode ----
|
||||
|
||||
static constexpr uint8_t SC_TAB = 0x0F;
|
||||
|
||||
static bool empty_key_event(const montauk::abi::KeyEvent& ev) {
|
||||
return ev.scancode == 0 && ev.ascii == 0 && !ev.pressed &&
|
||||
!ev.shift && !ev.ctrl && !ev.alt;
|
||||
@@ -427,6 +429,26 @@ extern "C" void _start() {
|
||||
line[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ev.scancode == SC_TAB) {
|
||||
line[pos] = '\0';
|
||||
|
||||
char* table[128] = { };
|
||||
int n = get_completions(line, table, 128);
|
||||
|
||||
montauk::print("\n");
|
||||
for (int i = 0; i < n; i++) {
|
||||
montauk::print(" ");
|
||||
montauk::print(table[i]);
|
||||
montauk::print("\n");
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
prompt();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user