summaryrefslogtreecommitdiffstats
path: root/cmd-find-window.c
diff options
context:
space:
mode:
authornicm <nicm>2019-06-20 20:31:04 +0000
committernicm <nicm>2019-06-20 20:31:04 +0000
commit1d8e545bc1cf9de10b718dc81b422edf81dabe07 (patch)
tree23b4d388d86c96d8a3b423a8a0c05455c6fcb891 /cmd-find-window.c
parent97a317a656e27523ed7437d8512be36080c739ed (diff)
Add -r to find-window for regex instead of fnmatch.
Diffstat (limited to 'cmd-find-window.c')
-rw-r--r--cmd-find-window.c81
1 files changed, 55 insertions, 26 deletions
diff --git a/cmd-find-window.c b/cmd-find-window.c
index c2d230a5..c29878b5 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -32,8 +32,8 @@ const struct cmd_entry cmd_find_window_entry = {
.name = "find-window",
.alias = "findw",
- .args = { "CNt:TZ", 1, 1 },
- .usage = "[-CNTZ] " CMD_TARGET_PANE_USAGE " match-string",
+ .args = { "CNrt:TZ", 1, 1 },
+ .usage = "[-CNrTZ] " CMD_TARGET_PANE_USAGE " match-string",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -57,30 +57,59 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
if (!C && !N && !T)
C = N = T = 1;
- if (C && N && T) {
- xasprintf(&filter,
- "#{||:"
- "#{C:%s},#{||:#{m:*%s*,#{window_name}},"
- "#{m:*%s*,#{pane_title}}}}",
- s, s, s);
- } else if (C && N) {
- xasprintf(&filter,
- "#{||:#{C:%s},#{m:*%s*,#{window_name}}}",
- s, s);
- } else if (C && T) {
- xasprintf(&filter,
- "#{||:#{C:%s},#{m:*%s*,#{pane_title}}}",
- s, s);
- } else if (N && T) {
- xasprintf(&filter,
- "#{||:#{m:*%s*,#{window_name}},#{m:*%s*,#{pane_title}}}",
- s, s);
- } else if (C)
- xasprintf(&filter, "#{C:%s}", s);
- else if (N)
- xasprintf(&filter, "#{m:*%s*,#{window_name}}", s);
- else
- xasprintf(&filter, "#{m:*%s*,#{pane_title}}", s);
+ if (!args_has(args, 'r')) {
+ if (C && N && T) {
+ xasprintf(&filter,
+ "#{||:"
+ "#{C:%s},#{||:#{m:*%s*,#{window_name}},"
+ "#{m:*%s*,#{pane_title}}}}",
+ s, s, s);
+ } else if (C && N) {
+ xasprintf(&filter,
+ "#{||:#{C:%s},#{m:*%s*,#{window_name}}}",
+ s, s);
+ } else if (C && T) {
+ xasprintf(&filter,
+ "#{||:#{C:%s},#{m:*%s*,#{pane_title}}}",
+ s, s);
+ } else if (N && T) {
+ xasprintf(&filter,
+ "#{||:#{m:*%s*,#{window_name}},"
+ "#{m:*%s*,#{pane_title}}}",
+ s, s);
+ } else if (C)
+ xasprintf(&filter, "#{C:%s}", s);
+ else if (N)
+ xasprintf(&filter, "#{m:*%s*,#{window_name}}", s);
+ else
+ xasprintf(&filter, "#{m:*%s*,#{pane_title}}", s);
+ } else {
+ if (C && N && T) {
+ xasprintf(&filter,
+ "#{||:"
+ "#{C/r:%s},#{||:#{m/r:%s,#{window_name}},"
+ "#{m/r:%s,#{pane_title}}}}",
+ s, s, s);
+ } else if (C && N) {
+ xasprintf(&filter,
+ "#{||:#{C/r:%s},#{m/r:%s,#{window_name}}}",
+ s, s);
+ } else if (C && T) {
+ xasprintf(&filter,
+ "#{||:#{C/r:%s},#{m/r:%s,#{pane_title}}}",
+ s, s);
+ } else if (N && T) {
+ xasprintf(&filter,
+ "#{||:#{m/r:%s,#{window_name}},"
+ "#{m/r:%s,#{pane_title}}}",
+ s, s);
+ } else if (C)
+ xasprintf(&filter, "#{C/r:%s}", s);
+ else if (N)
+ xasprintf(&filter, "#{m/r:%s,#{window_name}}", s);
+ else
+ xasprintf(&filter, "#{m/r:%s,#{pane_title}}", s);
+ }
new_args = args_parse("", 1, &argv);
if (args_has(args, 'Z'))