feat: complete command completion in shell
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 108
|
#define MONTAUK_BUILD_NUMBER 110
|
||||||
|
|||||||
@@ -441,6 +441,15 @@ extern "C" void _start() {
|
|||||||
char* table[128] = { };
|
char* table[128] = { };
|
||||||
int n = get_completions(line, table, 128, cwd, current_drive);
|
int n = get_completions(line, table, 128, cwd, current_drive);
|
||||||
|
|
||||||
|
// Command completion if there is only 1 match
|
||||||
|
if (n == 1) {
|
||||||
|
size_t chars_already_typed = pos;
|
||||||
|
pos = 0;
|
||||||
|
|
||||||
|
montauk::strncpy(line, table[0], 256);
|
||||||
|
pos = montauk::slen(table[0]);
|
||||||
|
montauk::print(table[0] + chars_already_typed);
|
||||||
|
} else { // If more than one result, print multiple results
|
||||||
montauk::print("\n");
|
montauk::print("\n");
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
montauk::print(" ");
|
montauk::print(" ");
|
||||||
@@ -450,6 +459,7 @@ extern "C" void _start() {
|
|||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
prompt();
|
prompt();
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user