mirror of
https://github.com/tmux/tmux.git
synced 2026-10-13 06:04:34 +00:00
Add a refresh-now command and change the r binding back to it in copy mode.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: window-copy.c,v 1.424 2026/07/29 17:42:56 nicm Exp $ */
|
||||
/* $OpenBSD: window-copy.c,v 1.425 2026/08/05 12:23:25 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -54,6 +54,7 @@ static void window_copy_redraw_screen(struct window_mode_entry *);
|
||||
static void window_copy_do_refresh(struct window_mode_entry *, int);
|
||||
static void window_copy_refresh_timer(int, short, void *);
|
||||
static void window_copy_refresh_arm(struct window_mode_entry *);
|
||||
static int window_copy_refresh_allowed(struct window_mode_entry *);
|
||||
static void window_copy_refresh_start(struct window_mode_entry *);
|
||||
static void window_copy_refresh_stop(struct window_mode_entry *);
|
||||
static void window_copy_style_changed(struct window_mode_entry *);
|
||||
@@ -3036,6 +3037,20 @@ window_copy_refresh_arm(struct window_mode_entry *wme)
|
||||
evtimer_add(&data->refresh_timer, &tv);
|
||||
}
|
||||
|
||||
static int
|
||||
window_copy_refresh_allowed(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
|
||||
/*
|
||||
* Do not refresh a view of another pane (copy-mode -s): the source may
|
||||
* disappear and changes are not tracked on this pane.
|
||||
*/
|
||||
if (data->viewmode || wme->swp != wme->wp)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
window_copy_refresh_timer(__unused int fd, __unused short events, void *arg)
|
||||
{
|
||||
@@ -3070,11 +3085,7 @@ window_copy_refresh_start(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
|
||||
/*
|
||||
* Do not refresh a view of another pane (copy-mode -s): the source may
|
||||
* disappear and changes are not tracked on this pane.
|
||||
*/
|
||||
if (data->viewmode || wme->swp != wme->wp || data->refresh_active)
|
||||
if (!window_copy_refresh_allowed(wme) || data->refresh_active)
|
||||
return;
|
||||
data->refresh_active = 1;
|
||||
window_copy_refresh_arm(wme);
|
||||
@@ -3089,6 +3100,25 @@ window_copy_refresh_stop(struct window_mode_entry *wme)
|
||||
evtimer_del(&data->refresh_timer);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_refresh_now(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
struct window_pane *wp = wme->wp;
|
||||
int follow;
|
||||
|
||||
if (!window_copy_refresh_allowed(wme))
|
||||
return (WINDOW_COPY_CMD_NOTHING);
|
||||
|
||||
follow = (data->oy == 0 &&
|
||||
data->cy == screen_size_y(&data->screen) - 1);
|
||||
window_copy_do_refresh(wme, follow);
|
||||
wp->flags &= ~PANE_UNSEENCHANGES;
|
||||
|
||||
return (WINDOW_COPY_CMD_REDRAW);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_refresh_on(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
@@ -3631,6 +3661,12 @@ static const struct {
|
||||
.clear = WINDOW_COPY_CMD_CLEAR_NEVER,
|
||||
.f = window_copy_cmd_refresh_off
|
||||
},
|
||||
{ .command = "refresh-now",
|
||||
.args = { "", 0, 0, NULL },
|
||||
.flags = WINDOW_COPY_CMD_FLAG_READONLY,
|
||||
.clear = WINDOW_COPY_CMD_CLEAR_NEVER,
|
||||
.f = window_copy_cmd_refresh_now
|
||||
},
|
||||
{ .command = "refresh-toggle",
|
||||
.args = { "", 0, 0, NULL },
|
||||
.flags = WINDOW_COPY_CMD_FLAG_READONLY,
|
||||
|
||||
Reference in New Issue
Block a user