mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 03:08:46 +00:00
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@.
This commit is contained in:
parent
c0d3f204b0
commit
7d3e2c83d4
4
format.c
4
format.c
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user