diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-11-07 07:11:26 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-11-07 07:11:26 +0000 |
commit | 9b2b8e17cfdc462bd540a101c43c204770f2a3f3 (patch) | |
tree | e5b09ecc97fe0dc2c9ecb8554df4b0e55232423c /usr.bin/tmux | |
parent | 49f2fe39358a549cf8b79da586afeee7e1f1b32f (diff) |
Add -F flag to send-keys to expand formats in search-backward and
forward copy mode commands, this makes it easier to use the cursor_word
and cursor_line formats. From Anindya Mukherjee in GitHub issue 1964.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-send-keys.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 10 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 34 |
3 files changed, 39 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 9350f8b004e..e30f2f09a19 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.50 2019/07/10 14:33:24 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.51 2019/11/07 07:11:25 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -33,8 +33,9 @@ const struct cmd_entry cmd_send_keys_entry = { .name = "send-keys", .alias = "send", - .args = { "HlXRMN:t:", 0, -1 }, - .usage = "[-HlXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...", + .args = { "FHlMN:Rt:X", 0, -1 }, + .usage = "[-FHlMRX] [-N repeat-count] " CMD_TARGET_PANE_USAGE + " key ...", .target = { 't', CMD_FIND_PANE, 0 }, diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 7b7f4004099..89558a70785 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.693 2019/10/23 14:10:13 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.694 2019/11/07 07:11:25 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: October 23 2019 $ +.Dd $Mdocdate: November 7 2019 $ .Dt TMUX 1 .Os .Sh NAME @@ -2672,7 +2672,7 @@ With only .Ar key-table . .It Xo Ic send-keys -.Op Fl HlMRX +.Op Fl FHlMRX .Op Fl N Ar repeat-count .Op Fl t Ar target-pane .Ar key Ar ... @@ -2711,7 +2711,9 @@ the .Sx WINDOWS AND PANES section. .Fl N -specifies a repeat count. +specifies a repeat count and +.Fl F +expands formats in arguments where appropriate. .It Xo Ic send-prefix .Op Fl 2 .Op Fl t Ar target-pane diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 36a8575715c..92e30885cca 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.237 2019/10/23 07:42:05 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.238 2019/11/07 07:11:25 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1673,12 +1673,24 @@ window_copy_cmd_search_backward(struct window_copy_cmd_state *cs) struct window_copy_mode_data *data = wme->data; u_int np = wme->prefix; const char *argument; + char *expanded; if (cs->args->argc == 2) { argument = cs->args->argv[1]; if (*argument != '\0') { - free(data->searchstr); - data->searchstr = xstrdup(argument); + if (args_has(cs->args, 'F')) { + expanded = format_single(NULL, argument, NULL, + NULL, NULL, wme->wp); + if (*expanded == '\0') { + free(expanded); + return (WINDOW_COPY_CMD_NOTHING); + } + free(data->searchstr); + data->searchstr = expanded; + } else { + free(data->searchstr); + data->searchstr = xstrdup(argument); + } } } if (data->searchstr != NULL) { @@ -1696,12 +1708,24 @@ window_copy_cmd_search_forward(struct window_copy_cmd_state *cs) struct window_copy_mode_data *data = wme->data; u_int np = wme->prefix; const char *argument; + char *expanded; if (cs->args->argc == 2) { argument = cs->args->argv[1]; if (*argument != '\0') { - free(data->searchstr); - data->searchstr = xstrdup(argument); + if (args_has(cs->args, 'F')) { + expanded = format_single(NULL, argument, NULL, + NULL, NULL, wme->wp); + if (*expanded == '\0') { + free(expanded); + return (WINDOW_COPY_CMD_NOTHING); + } + free(data->searchstr); + data->searchstr = expanded; + } else { + free(data->searchstr); + data->searchstr = xstrdup(argument); + } } } if (data->searchstr != NULL) { |