diff options
| author | Albert Cervin <albert@acervin.com> | 2024-04-03 11:43:49 +0200 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2024-04-03 11:43:49 +0200 |
| commit | 1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6 (patch) | |
| tree | dff73302ddb932b1355df8cff4fcb2557a748a8e /src/main/cmds.c | |
| parent | 80e6ab5ec9fdb0f4a3b3fa35e4ea502a54b85e1a (diff) | |
| download | dged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.tar.gz dged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.tar.xz dged-1ed6000dd2a995bcd67e99b1c89aa1e2c4a6f1e6.zip | |
Add completion to execute
Completes on the command, not on following arguments if written
directly at the prompt.
Diffstat (limited to 'src/main/cmds.c')
| -rw-r--r-- | src/main/cmds.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/cmds.c b/src/main/cmds.c index d28924b..4dc84ed 100644 --- a/src/main/cmds.c +++ b/src/main/cmds.c @@ -54,11 +54,23 @@ int32_t write_file(struct command_ctx ctx, int argc, const char *argv[]) { return 0; } +static void run_interactive_comp_inserted() { minibuffer_execute(); } + int32_t run_interactive(struct command_ctx ctx, int argc, const char *argv[]) { if (argc == 0) { + struct completion_provider providers[] = {commands_provider()}; + enable_completion(minibuffer_buffer(), + ((struct completion_trigger){ + .kind = CompletionTrigger_Input, + .input = + (struct completion_trigger_input){ + .nchars = 0, .trigger_initially = false}}), + providers, 1, run_interactive_comp_inserted); + return minibuffer_prompt(ctx, "execute: "); } + disable_completion(minibuffer_buffer()); struct command *cmd = lookup_command(ctx.commands, argv[0]); if (cmd != NULL) { return execute_command(cmd, ctx.commands, ctx.active_window, ctx.buffers, |
