Add format variables for the default formats for the various modes

(tree_mode_format and so on) and add a -a flag to display-message to
list variables with values.
This commit is contained in:
nicm
2019-03-18 14:10:25 +00:00
parent ce6be7afd4
commit 2628af573d
8 changed files with 74 additions and 7 deletions

View File

@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = {
.name = "display-message",
.alias = "display",
.args = { "c:pt:F:v", 0, 1 },
.usage = "[-pv] [-c target-client] [-F format] "
.args = { "ac:pt:F:v", 0, 1 },
.usage = "[-apv] [-c target-client] [-F format] "
CMD_TARGET_PANE_USAGE " [message]",
.target = { 't', CMD_FIND_PANE, 0 },
@ -49,6 +49,14 @@ const struct cmd_entry cmd_display_message_entry = {
.exec = cmd_display_message_exec
};
static void
cmd_display_message_each(const char *key, const char *value, void *arg)
{
struct cmdq_item *item = arg;
cmdq_print(item, "%s=%s", key, value);
}
static enum cmd_retval
cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
{
@ -91,6 +99,12 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
ft = format_create(item->client, item, FORMAT_NONE, flags);
format_defaults(ft, target_c, s, wl, wp);
if (args_has(args, 'a')) {
if (item != NULL)
format_each(ft, cmd_display_message_each, item);
return (CMD_RETURN_NORMAL);
}
msg = format_expand_time(ft, template);
if (args_has(self->args, 'p'))
cmdq_print(item, "%s", msg);