From 3f1c3ee80e46f80d7f1642009c4f9dffa404d935 Mon Sep 17 00:00:00 2001 From: Max Schillinger Date: Mon, 18 Mar 2024 10:08:40 +0100 Subject: Add command completion with tab key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the command prompt, press to get a list of all available commands and pick one (using vis-menu). This works also after typing the first letters of a command (p.e. `:la`). Co-authored-by: Matěj Cepl --- vis-cmds.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'vis-cmds.c') diff --git a/vis-cmds.c b/vis-cmds.c index 482508f..b543683 100644 --- a/vis-cmds.c +++ b/vis-cmds.c @@ -693,6 +693,15 @@ static bool print_cmd(const char *key, void *value, void *data) { return text_appendf(data, " %-30s %s\n", usage, help ? help : ""); } +static bool print_cmd_name(const char *key, void *value, void *data) { + CommandDef *cmd = value; + return buffer_appendf(data, "%s\n", cmd->name); +} + +void vis_print_cmds(Vis *vis, Buffer *buf) { + map_iterate(vis->cmds, print_cmd_name, buf); +} + static bool print_option(const char *key, void *value, void *txt) { char desc[256]; const OptionDef *opt = value; -- cgit v1.2.3