diff options
author | nicm <nicm> | 2019-11-07 07:11:25 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-11-07 07:11:25 +0000 |
commit | c225262e132ded1b4e1e8c0bd21884e9da78ddb3 (patch) | |
tree | f8ba43a0f4a71f2b90b924098f30ea6c4eff1749 | |
parent | bad95db8785f4ee6b6e17750500c024642e83134 (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.
-rw-r--r-- | cmd-send-keys.c | 5 | ||||
-rw-r--r-- | tmux.1 | 6 | ||||
-rw-r--r-- | window-copy.c | 32 |
3 files changed, 35 insertions, 8 deletions
diff --git a/cmd-send-keys.c b/cmd-send-keys.c index fe202335..ddbab6f7 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -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 }, @@ -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/window-copy.c b/window-copy.c index 473112e3..01dc1f85 100644 --- a/window-copy.c +++ b/window-copy.c @@ -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) { |