summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-05-12 10:45:39 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-05-12 10:45:39 +0000
commitb8924904635ae0a8abe9d4a79a0cccde221369ca (patch)
tree0f90813e4e61a59c87351fd0f36c7306dc2c5f04 /usr.bin/tmux
parente8cea33558658acac59d6d1890b9ad3b83cae57f (diff)
Store copy mode search string in pane so search-again command works even
if you exit and reenter copy mode (it doesn't remember the position, just the search string), suggested by espie@.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/format.c6
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window-copy.c27
-rw-r--r--usr.bin/tmux/window.c3
4 files changed, 18 insertions, 22 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 7010e6130c0..697dd17beee 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.134 2017/05/07 22:27:57 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.135 2017/05/12 10:45:38 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1376,8 +1376,8 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
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));
+ if (wp->searchstr != NULL)
+ format_add(ft, "pane_search_string", "%s", wp->searchstr);
format_add(ft, "pane_tty", "%s", wp->tty);
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 4baa3061c77..1adede81a3f 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.764 2017/05/11 07:34:54 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.765 2017/05/12 10:45:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -792,6 +792,7 @@ struct window_pane {
struct event modetimer;
time_t modelast;
u_int modeprefix;
+ char *searchstr;
TAILQ_ENTRY(window_pane) entry;
RB_ENTRY(window_pane) tree_entry;
@@ -2177,7 +2178,6 @@ 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 beecbb36f5f..1d84314cf4a 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.173 2017/05/07 22:27:57 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.174 2017/05/12 10:45:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -208,8 +208,13 @@ window_copy_init(struct window_pane *wp)
data->rectflag = 0;
data->scroll_exit = 0;
- data->searchtype = WINDOW_COPY_OFF;
- data->searchstr = NULL;
+ if (wp->searchstr != NULL) {
+ data->searchtype = WINDOW_COPY_SEARCHUP;
+ data->searchstr = xstrdup(wp->searchstr);
+ } else {
+ data->searchtype = WINDOW_COPY_OFF;
+ data->searchstr = NULL;
+ }
data->searchmark = NULL;
data->searchx = data->searchy = data->searcho = -1;
@@ -1134,6 +1139,9 @@ window_copy_search(struct window_pane *wp, int direction, int moveflag)
u_int fx, fy, endline;
int wrapflag, cis, found;
+ free(wp->searchstr);
+ wp->searchstr = xstrdup(data->searchstr);
+
fx = data->cx;
fy = screen_hsize(data->backing) - data->oy + data->cy;
@@ -2482,16 +2490,3 @@ 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);
-}
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index c55d916a02e..3f2d293f0fe 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.193 2017/05/04 07:16:43 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.194 2017/05/12 10:45:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -828,6 +828,7 @@ static void
window_pane_destroy(struct window_pane *wp)
{
window_pane_reset_mode(wp);
+ free(wp->searchstr);
if (wp->fd != -1) {
bufferevent_free(wp->event);