diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-29 13:42:14 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-29 13:42:14 +0000 |
commit | 77d2f4868a97b2cb4f72eba7fe9bdff53feec60d (patch) | |
tree | ee06345c2371ffa4682aa7828426310bd29a9215 /usr.bin | |
parent | e0005b34120a986770a9fe05fcae4da091fb6251 (diff) |
Add -i to find-window to ignore case.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-find-window.c | 93 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 8 |
2 files changed, 41 insertions, 60 deletions
diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c index d487d564053..1ba7d608c62 100644 --- a/usr.bin/tmux/cmd-find-window.c +++ b/usr.bin/tmux/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find-window.c,v 1.49 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.50 2020/05/29 13:42:13 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -32,8 +32,8 @@ const struct cmd_entry cmd_find_window_entry = { .name = "find-window", .alias = "findw", - .args = { "CNrt:TZ", 1, 1 }, - .usage = "[-CNrTZ] " CMD_TARGET_PANE_USAGE " match-string", + .args = { "CiNrt:TZ", 1, 1 }, + .usage = "[-CiNrTZ] " CMD_TARGET_PANE_USAGE " match-string", .target = { 't', CMD_FIND_PANE, 0 }, @@ -47,7 +47,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) struct args *args = cmd_get_args(self), *new_args; struct cmd_find_state *target = cmdq_get_target(item); struct window_pane *wp = target->wp; - const char *s = args->argv[0]; + const char *s = args->argv[0], *suffix = ""; char *filter, *argv = { NULL }; int C, N, T; @@ -55,62 +55,41 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) N = args_has(args, 'N'); T = args_has(args, 'T'); + if (args_has(args, 'r') && args_has(args, 'i')) + suffix = "/ri"; + else if (args_has(args, 'r')) + suffix = "/r"; + else if (args_has(args, 'i')) + suffix = "/i"; + if (!C && !N && !T) C = N = T = 1; - 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); - } + if (C && N && T) { + xasprintf(&filter, + "#{||:" + "#{C%s:%s},#{||:#{m%s:*%s*,#{window_name}}," + "#{m%s:*%s*,#{pane_title}}}}", + suffix, s, suffix, s, suffix, s); + } else if (C && N) { + xasprintf(&filter, + "#{||:#{C%s:%s},#{m%s:*%s*,#{window_name}}}", + suffix, s, suffix, s); + } else if (C && T) { + xasprintf(&filter, + "#{||:#{C%s:%s},#{m%s:*%s*,#{pane_title}}}", + suffix, s, suffix, s); + } else if (N && T) { + xasprintf(&filter, + "#{||:#{m%s:*%s*,#{window_name}}," + "#{m%s:*%s*,#{pane_title}}}", + suffix, s, suffix, s); + } else if (C) + xasprintf(&filter, "#{C%s:%s}", suffix, s); + else if (N) + xasprintf(&filter, "#{m%s:*%s*,#{window_name}}", suffix, s); + else + xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s); new_args = args_parse("", 1, &argv); if (args_has(args, 'Z')) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index d21adbb5ef6..45e96cc0277 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.774 2020/05/26 13:19:21 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.775 2020/05/29 13:42:13 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 26 2020 $ +.Dd $Mdocdate: May 29 2020 $ .Dt TMUX 1 .Os .Sh NAME @@ -2079,7 +2079,7 @@ With .Fl b , other commands are not blocked from running until the indicator is closed. .It Xo Ic find-window -.Op Fl rCNTZ +.Op Fl iCNrTZ .Op Fl t Ar target-pane .Ar match-string .Xc @@ -2098,6 +2098,8 @@ matches only visible window contents, matches only the window name and .Fl T matches only the window title. +.Fl i +makes the search ignore case. The default is .Fl CNT . .Fl Z |