summaryrefslogtreecommitdiffstats
path: root/cmd-list-panes.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-12 08:36:18 +0000
committernicm <nicm>2020-04-12 08:36:18 +0000
commit756591b4ca28089879ef785bde3a6fb30e9f5943 (patch)
tree8ecfea303c59d7fce8f0df15cfae5e4b0b46c9a0 /cmd-list-panes.c
parent70534cfde68d7f9002a26e8e23d767b05967f31e (diff)
Add a -f filter argument to the list commands like choose-tree.
Diffstat (limited to 'cmd-list-panes.c')
-rw-r--r--cmd-list-panes.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/cmd-list-panes.c b/cmd-list-panes.c
index 7f6994bd..10789460 100644
--- a/cmd-list-panes.c
+++ b/cmd-list-panes.c
@@ -38,8 +38,8 @@ const struct cmd_entry cmd_list_panes_entry = {
.name = "list-panes",
.alias = "lsp",
- .args = { "asF:t:", 0, 0 },
- .usage = "[-as] [-F format] " CMD_TARGET_WINDOW_USAGE,
+ .args = { "asF:f:t:", 0, 0 },
+ .usage = "[-as] [-F format] [-f filter] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 },
@@ -91,8 +91,9 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
struct window_pane *wp;
u_int n;
struct format_tree *ft;
- const char *template;
- char *line;
+ const char *template, *filter;
+ char *line, *expanded;
+ int flag;
template = args_get(args, 'F');
if (template == NULL) {
@@ -120,6 +121,7 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
break;
}
}
+ filter = args_get(args, 'f');
n = 0;
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
@@ -127,9 +129,17 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, wp);
- line = format_expand(ft, template);
- cmdq_print(item, "%s", line);
- free(line);
+ if (filter != NULL) {
+ expanded = format_expand(ft, filter);
+ flag = format_true(expanded);
+ free(expanded);
+ } else
+ flag = 1;
+ if (flag) {
+ line = format_expand(ft, template);
+ cmdq_print(item, "%s", line);
+ free(line);
+ }
format_free(ft);
n++;