mirror of
https://github.com/tmux/tmux.git
synced 2026-10-14 06:44:28 +00:00
Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master: Complete layout names and options again, GitHub issue 5731 from intertermux at gmail dot com.
This commit is contained in:
32
prompt.c
32
prompt.c
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: prompt.c,v 1.7 2026/09/09 07:53:03 nicm Exp $ */
|
/* $OpenBSD: prompt.c,v 1.8 2026/10/13 07:56:00 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2026 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2026 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -1555,14 +1555,25 @@ prompt_complete_add(char ***list, u_int *size, const char *s)
|
|||||||
|
|
||||||
/* Build completion list. */
|
/* Build completion list. */
|
||||||
static char **
|
static char **
|
||||||
prompt_complete_commands(u_int *size, const char *s)
|
prompt_complete_commands(u_int *size, const char *s, int at_start)
|
||||||
{
|
{
|
||||||
char **list = NULL, *tmp;
|
char **list = NULL, *tmp;
|
||||||
const char *value, *cp;
|
const char **layout, *value, *cp;
|
||||||
const struct cmd_entry **cmdent;
|
const struct cmd_entry **cmdent;
|
||||||
|
const struct options_table_entry *oe;
|
||||||
size_t slen = strlen(s), valuelen;
|
size_t slen = strlen(s), valuelen;
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
struct options_array_item *a;
|
struct options_array_item *a;
|
||||||
|
const char *layouts[] = {
|
||||||
|
"even-horizontal",
|
||||||
|
"even-vertical",
|
||||||
|
"main-horizontal",
|
||||||
|
"main-horizontal-mirrored",
|
||||||
|
"main-vertical",
|
||||||
|
"main-vertical-mirrored",
|
||||||
|
"tiled",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
*size = 0;
|
*size = 0;
|
||||||
for (cmdent = cmd_table; *cmdent != NULL; cmdent++) {
|
for (cmdent = cmd_table; *cmdent != NULL; cmdent++) {
|
||||||
@@ -1588,6 +1599,16 @@ prompt_complete_commands(u_int *size, const char *s)
|
|||||||
a = options_array_next(a);
|
a = options_array_next(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (at_start)
|
||||||
|
return (list);
|
||||||
|
for (oe = options_table; oe->name != NULL; oe++) {
|
||||||
|
if (strncmp(oe->name, s, slen) == 0)
|
||||||
|
prompt_complete_add(&list, size, oe->name);
|
||||||
|
}
|
||||||
|
for (layout = layouts; *layout != NULL; layout++) {
|
||||||
|
if (strncmp(*layout, s, slen) == 0)
|
||||||
|
prompt_complete_add(&list, size, *layout);
|
||||||
|
}
|
||||||
return (list);
|
return (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1671,11 +1692,10 @@ prompt_complete(struct prompt *pr, const char *word, u_int offset)
|
|||||||
char **list = NULL, *out = NULL;
|
char **list = NULL, *out = NULL;
|
||||||
u_int size = 0, i;
|
u_int size = 0, i;
|
||||||
|
|
||||||
if (pr->type != PROMPT_TYPE_COMMAND || offset != 0 ||
|
if (pr->type != PROMPT_TYPE_COMMAND || *word == '\0')
|
||||||
*word == '\0')
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
list = prompt_complete_commands(&size, word);
|
list = prompt_complete_commands(&size, word, offset == 0);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
free(list);
|
free(list);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user