diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-03 05:53:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-03 05:53:35 +0000 |
commit | 200c47be76c8204f4b0a68fe72e137cfc0873121 (patch) | |
tree | 4e189f7e90e6b23fb8eeeb339ff20e83a1f45e8f | |
parent | 23a5acabe918a853248fd1ab81172f3494cea6ae (diff) |
Add a format for the last search string in copy mode and fix the prompt
so it can work when in -I, suggested by Suraj N Kurapati.
-rw-r--r-- | usr.bin/tmux/format.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 15 |
5 files changed, 30 insertions, 7 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 8e06ede6706..69f35bd31d2 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.131 2017/05/01 12:20:55 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.132 2017/05/03 05:53:34 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1346,6 +1346,8 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp) format_add(ft, "pane_in_mode", "%d", wp->screen != &wp->base); format_add(ft, "pane_synchronized", "%d", !!options_get_number(wp->window->options, "synchronize-panes")); + format_add(ft, "pane_search_string", "%s", + window_copy_search_string(wp)); format_add(ft, "pane_tty", "%s", wp->tty); format_add(ft, "pane_pid", "%ld", (long) wp->pid); diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index c82f69c8de7..6515ffc417e 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.164 2017/05/01 12:20:55 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.165 2017/05/03 05:53:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -661,7 +661,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input, { struct format_tree *ft; time_t t; - char *tmp; + char *tmp, *cp; ft = format_create(c, NULL, FORMAT_NONE, 0); format_defaults(ft, c, NULL, NULL, NULL); @@ -690,6 +690,12 @@ status_prompt_set(struct client *c, const char *msg, const char *input, c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_STATUS; + if ((flags & PROMPT_INCREMENTAL) && *tmp != '\0') { + xasprintf(&cp, "=%s", tmp); + c->prompt_callbackfn(c->prompt_data, cp, 0); + free(cp); + } + free(tmp); format_free(ft); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 06ad78a1415..8db298af82b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.545 2017/04/28 13:39:59 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.546 2017/05/03 05:53:34 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: April 28 2017 $ +.Dd $Mdocdate: May 3 2017 $ .Dt TMUX 1 .Os .Sh NAME @@ -3563,6 +3563,7 @@ The following variables are available, where appropriate: .It Li "pane_left" Ta "" Ta "Left of pane" .It Li "pane_pid" Ta "" Ta "PID of first process in pane" .It Li "pane_right" Ta "" Ta "Right of pane" +.It Li "pane_search_string" Ta "" Ta "Last search string in copy mode" .It Li "pane_start_command" Ta "" Ta "Command pane started with" .It Li "pane_synchronized" Ta "" Ta "If pane is synchronized" .It Li "pane_tabs" Ta "" Ta "Pane tab positions" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index fa09693f82b..ae1d8ae3cf5 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.756 2017/05/01 12:20:55 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.757 2017/05/03 05:53:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2171,6 +2171,7 @@ void window_copy_vadd(struct window_pane *, const char *, va_list); void window_copy_pageup(struct window_pane *, int); void window_copy_start_drag(struct client *, struct mouse_event *); int window_copy_scroll_position(struct window_pane *); +const char *window_copy_search_string(struct window_pane *); /* window-choose.c */ extern const struct window_mode window_choose_mode; diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 9cdee9aa542..65b8c1da4f7 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.171 2017/04/20 09:20:22 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.172 2017/05/03 05:53:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2480,3 +2480,16 @@ window_copy_drag_update(__unused struct client *c, struct mouse_event *m) if (window_copy_update_selection(wp, 1)) window_copy_redraw_selection(wp, old_cy); } + +const char * +window_copy_search_string(struct window_pane *wp) +{ + struct window_copy_mode_data *data; + + if (wp->mode != &window_copy_mode) + return (""); + data = wp->modedata; + if (data->searchtype == WINDOW_COPY_OFF || data->searchstr == NULL) + return (""); + return (data->searchstr); +} |