version 1.251, 2020/03/31 06:35:38 |
version 1.252, 2020/03/31 07:00:34 |
|
|
wp->pipe_off = 0; |
wp->pipe_off = 0; |
wp->pipe_event = NULL; |
wp->pipe_event = NULL; |
|
|
wp->saved_grid = NULL; |
|
wp->saved_cx = UINT_MAX; |
|
wp->saved_cy = UINT_MAX; |
|
|
|
screen_init(&wp->base, sx, sy, hlimit); |
screen_init(&wp->base, sx, sy, hlimit); |
wp->screen = &wp->base; |
wp->screen = &wp->base; |
|
|
|
|
screen_free(&wp->status_screen); |
screen_free(&wp->status_screen); |
|
|
screen_free(&wp->base); |
screen_free(&wp->base); |
if (wp->saved_grid != NULL) |
|
grid_destroy(wp->saved_grid); |
|
|
|
if (wp->pipe_fd != -1) { |
if (wp->pipe_fd != -1) { |
bufferevent_free(wp->pipe_event); |
bufferevent_free(wp->pipe_event); |
|
|
wp->sy = sy; |
wp->sy = sy; |
|
|
log_debug("%s: %%%u resize %ux%u", __func__, wp->id, sx, sy); |
log_debug("%s: %%%u resize %ux%u", __func__, wp->id, sx, sy); |
screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL); |
screen_resize(&wp->base, sx, sy, wp->base.saved_grid == NULL); |
|
|
wme = TAILQ_FIRST(&wp->modes); |
wme = TAILQ_FIRST(&wp->modes); |
if (wme != NULL && wme->mode->resize != NULL) |
if (wme != NULL && wme->mode->resize != NULL) |
|
|
wp->flags |= (PANE_RESIZE|PANE_RESIZED); |
wp->flags |= (PANE_RESIZE|PANE_RESIZED); |
} |
} |
|
|
/* |
|
* Enter alternative screen mode. A copy of the visible screen is saved and the |
|
* history is not updated |
|
*/ |
|
void |
void |
window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc, |
window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc, |
int cursor) |
int cursor) |
{ |
{ |
struct screen *s = &wp->base; |
|
u_int sx, sy; |
|
|
|
if (wp->saved_grid != NULL) |
|
return; |
|
if (!options_get_number(wp->options, "alternate-screen")) |
if (!options_get_number(wp->options, "alternate-screen")) |
return; |
return; |
sx = screen_size_x(s); |
screen_alternate_on(&wp->base, gc, cursor); |
sy = screen_size_y(s); |
|
|
|
wp->saved_grid = grid_create(sx, sy, 0); |
|
grid_duplicate_lines(wp->saved_grid, 0, s->grid, screen_hsize(s), sy); |
|
if (cursor) { |
|
wp->saved_cx = s->cx; |
|
wp->saved_cy = s->cy; |
|
} |
|
memcpy(&wp->saved_cell, gc, sizeof wp->saved_cell); |
|
|
|
grid_view_clear(s->grid, 0, 0, sx, sy, 8); |
|
|
|
wp->base.grid->flags &= ~GRID_HISTORY; |
|
|
|
wp->flags |= PANE_REDRAW; |
wp->flags |= PANE_REDRAW; |
} |
} |
|
|
/* Exit alternate screen mode and restore the copied grid. */ |
|
void |
void |
window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc, |
window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc, |
int cursor) |
int cursor) |
{ |
{ |
struct screen *s = &wp->base; |
|
u_int sx, sy; |
|
|
|
if (!options_get_number(wp->options, "alternate-screen")) |
if (!options_get_number(wp->options, "alternate-screen")) |
return; |
return; |
|
screen_alternate_off(&wp->base, gc, cursor); |
/* |
|
* Restore the cursor position and cell. This happens even if not |
|
* currently in the alternate screen. |
|
*/ |
|
if (cursor && wp->saved_cx != UINT_MAX && wp->saved_cy != UINT_MAX) { |
|
s->cx = wp->saved_cx; |
|
if (s->cx > screen_size_x(s) - 1) |
|
s->cx = screen_size_x(s) - 1; |
|
s->cy = wp->saved_cy; |
|
if (s->cy > screen_size_y(s) - 1) |
|
s->cy = screen_size_y(s) - 1; |
|
memcpy(gc, &wp->saved_cell, sizeof *gc); |
|
} |
|
|
|
if (wp->saved_grid == NULL) |
|
return; |
|
sx = screen_size_x(s); |
|
sy = screen_size_y(s); |
|
|
|
/* |
|
* If the current size is bigger, temporarily resize to the old size |
|
* before copying back. |
|
*/ |
|
if (sy > wp->saved_grid->sy) |
|
screen_resize(s, sx, wp->saved_grid->sy, 1); |
|
|
|
/* Restore the saved grid. */ |
|
grid_duplicate_lines(s->grid, screen_hsize(s), wp->saved_grid, 0, sy); |
|
|
|
/* |
|
* Turn history back on (so resize can use it) and then resize back to |
|
* the current size. |
|
*/ |
|
wp->base.grid->flags |= GRID_HISTORY; |
|
if (sy > wp->saved_grid->sy || sx != wp->saved_grid->sx) |
|
screen_resize(s, sx, sy, 1); |
|
|
|
grid_destroy(wp->saved_grid); |
|
wp->saved_grid = NULL; |
|
|
|
wp->flags |= PANE_REDRAW; |
wp->flags |= PANE_REDRAW; |
} |
} |
|
|