mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 22:43:58 +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:
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",
|
format_add(ft, "pane_synchronized", "%d",
|
||||||
!!options_get_number(wp->window->options, "synchronize-panes"));
|
!!options_get_number(wp->window->options, "synchronize-panes"));
|
||||||
format_add(ft, "pane_search_string", "%s",
|
if (wp->searchstr != NULL)
|
||||||
window_copy_search_string(wp));
|
format_add(ft, "pane_search_string", "%s", wp->searchstr);
|
||||||
|
|
||||||
format_add(ft, "pane_tty", "%s", wp->tty);
|
format_add(ft, "pane_tty", "%s", wp->tty);
|
||||||
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
|
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
|
||||||
|
@ -208,8 +208,13 @@ window_copy_init(struct window_pane *wp)
|
|||||||
data->rectflag = 0;
|
data->rectflag = 0;
|
||||||
data->scroll_exit = 0;
|
data->scroll_exit = 0;
|
||||||
|
|
||||||
data->searchtype = WINDOW_COPY_OFF;
|
if (wp->searchstr != NULL) {
|
||||||
data->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->searchmark = NULL;
|
||||||
data->searchx = data->searchy = data->searcho = -1;
|
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;
|
u_int fx, fy, endline;
|
||||||
int wrapflag, cis, found;
|
int wrapflag, cis, found;
|
||||||
|
|
||||||
|
free(wp->searchstr);
|
||||||
|
wp->searchstr = xstrdup(data->searchstr);
|
||||||
|
|
||||||
fx = data->cx;
|
fx = data->cx;
|
||||||
fy = screen_hsize(data->backing) - data->oy + data->cy;
|
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))
|
if (window_copy_update_selection(wp, 1))
|
||||||
window_copy_redraw_selection(wp, old_cy);
|
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);
|
|
||||||
}
|
|
||||||
|
1
window.c
1
window.c
@ -828,6 +828,7 @@ static void
|
|||||||
window_pane_destroy(struct window_pane *wp)
|
window_pane_destroy(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
|
free(wp->searchstr);
|
||||||
|
|
||||||
if (wp->fd != -1) {
|
if (wp->fd != -1) {
|
||||||
bufferevent_free(wp->event);
|
bufferevent_free(wp->event);
|
||||||
|
Reference in New Issue
Block a user