aboutsummaryrefslogtreecommitdiff
path: root/vis-cmds.c
diff options
context:
space:
mode:
authorMax Schillinger <maxschillinger@web.de>2024-03-18 10:08:40 +0100
committerRandy Palamar <randy@rnpnr.xyz>2025-11-28 07:41:12 -0700
commit3f1c3ee80e46f80d7f1642009c4f9dffa404d935 (patch)
tree08e3ab9011bcb4396ffca5f51d20c079d44da901 /vis-cmds.c
parent12fc09a442939d0af09d700c7a8074cca9b1694e (diff)
downloadvis-3f1c3ee80e46f80d7f1642009c4f9dffa404d935.tar.gz
vis-3f1c3ee80e46f80d7f1642009c4f9dffa404d935.tar.xz
Add command completion with tab key
In the command prompt, press <tab> 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<tab>`). Co-authored-by: Matěj Cepl <mcepl@cepl.eu>
Diffstat (limited to 'vis-cmds.c')
-rw-r--r--vis-cmds.c9
1 files changed, 9 insertions, 0 deletions
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;