mirror of
https://github.com/tmux/tmux.git
synced 2025-04-01 05:08:46 +00:00
Add -F to list-commands.
This commit is contained in:
parent
17e4744459
commit
068b8b03ad
@ -27,10 +27,10 @@
|
|||||||
* List key bindings.
|
* List key bindings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
|
static enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
|
||||||
enum cmd_retval cmd_list_keys_commands(struct cmd_q *);
|
static enum cmd_retval cmd_list_keys_commands(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
.name = "list-keys",
|
.name = "list-keys",
|
||||||
@ -47,14 +47,14 @@ const struct cmd_entry cmd_list_commands_entry = {
|
|||||||
.name = "list-commands",
|
.name = "list-commands",
|
||||||
.alias = "lscm",
|
.alias = "lscm",
|
||||||
|
|
||||||
.args = { "", 0, 0 },
|
.args = { "F:", 0, 0 },
|
||||||
.usage = "",
|
.usage = "[-F format]",
|
||||||
|
|
||||||
.flags = CMD_STARTSERVER,
|
.flags = CMD_STARTSERVER,
|
||||||
.exec = cmd_list_keys_exec
|
.exec = cmd_list_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -65,7 +65,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
int repeat, width, tablewidth, keywidth;
|
int repeat, width, tablewidth, keywidth;
|
||||||
|
|
||||||
if (self->entry == &cmd_list_commands_entry)
|
if (self->entry == &cmd_list_commands_entry)
|
||||||
return (cmd_list_keys_commands(cmdq));
|
return (cmd_list_keys_commands(self, cmdq));
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
return (cmd_list_keys_table(self, cmdq));
|
return (cmd_list_keys_table(self, cmdq));
|
||||||
@ -131,7 +131,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -180,21 +180,44 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
static enum cmd_retval
|
||||||
cmd_list_keys_commands(struct cmd_q *cmdq)
|
cmd_list_keys_commands(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
|
struct args *args = self->args;
|
||||||
const struct cmd_entry **entryp;
|
const struct cmd_entry **entryp;
|
||||||
const struct cmd_entry *entry;
|
const struct cmd_entry *entry;
|
||||||
|
struct format_tree *ft;
|
||||||
|
const char *template;
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
if ((template = args_get(args, 'F')) == NULL) {
|
||||||
|
template = "#{command_list_name}"
|
||||||
|
"#{?command_list_alias, (#{command_list_alias}),} "
|
||||||
|
"#{command_list_usage}";
|
||||||
|
}
|
||||||
|
|
||||||
|
ft = format_create(cmdq, 0);
|
||||||
|
format_defaults(ft, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
for (entryp = cmd_table; *entryp != NULL; entryp++) {
|
||||||
entry = *entryp;
|
entry = *entryp;
|
||||||
if (entry->alias == NULL) {
|
|
||||||
cmdq_print(cmdq, "%s %s", entry->name, entry->usage);
|
format_add(ft, "command_list_name", "%s", entry->name);
|
||||||
continue;
|
if (entry->alias != NULL) {
|
||||||
|
format_add(ft, "command_list_alias", "%s",
|
||||||
|
entry->alias);
|
||||||
}
|
}
|
||||||
cmdq_print(cmdq, "%s (%s) %s", entry->name, entry->alias,
|
if (entry->alias != NULL) {
|
||||||
entry->usage);
|
format_add(ft, "command_list_usage", "%s",
|
||||||
|
entry->usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
line = format_expand(ft, template);
|
||||||
|
if (*line != '\0')
|
||||||
|
cmdq_print(cmdq, "%s", line);
|
||||||
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
format_free(ft);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
7
tmux.1
7
tmux.1
@ -773,7 +773,9 @@ section.
|
|||||||
If
|
If
|
||||||
.Ar target-session
|
.Ar target-session
|
||||||
is specified, list only clients connected to that session.
|
is specified, list only clients connected to that session.
|
||||||
.It Ic list-commands
|
.It Xo Ic list-commands
|
||||||
|
.Op Fl F Ar format
|
||||||
|
.Xc
|
||||||
.D1 (alias: Ic lscm )
|
.D1 (alias: Ic lscm )
|
||||||
List the syntax of all commands supported by
|
List the syntax of all commands supported by
|
||||||
.Nm .
|
.Nm .
|
||||||
@ -3492,6 +3494,9 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "client_width" Ta "" Ta "Width of client"
|
.It Li "client_width" Ta "" Ta "Width of client"
|
||||||
.It Li "command_hooked" Ta "" Ta "Name of command hooked, if any"
|
.It Li "command_hooked" Ta "" Ta "Name of command hooked, if any"
|
||||||
.It Li "command_name" Ta "" Ta "Name of command in use, if any"
|
.It Li "command_name" Ta "" Ta "Name of command in use, if any"
|
||||||
|
.It Li "command_list_name" Ta "" Ta "Command name if listing commands"
|
||||||
|
.It Li "command_list_alias" Ta "" Ta "Command alias if listing commands"
|
||||||
|
.It Li "command_list_usage" Ta "" Ta "Command usage if listing commands"
|
||||||
.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
|
.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
|
||||||
.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"
|
.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"
|
||||||
.It Li "cursor_y" Ta "" Ta "Cursor Y position in pane"
|
.It Li "cursor_y" Ta "" Ta "Cursor Y position in pane"
|
||||||
|
Loading…
Reference in New Issue
Block a user