mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
When clearing the entire screen, clear lines that are used into the
history like xterm does. Requested ages ago by someone I've forgotten.
This commit is contained in:
parent
1270f8fed8
commit
ecc22c521d
24
grid-view.c
24
grid-view.c
@ -74,6 +74,30 @@ grid_view_set_utf8(
|
|||||||
grid_set_utf8(gd, grid_view_x(gd, px), grid_view_y(gd, py), gu);
|
grid_set_utf8(gd, grid_view_x(gd, px), grid_view_y(gd, py), gu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear into history. */
|
||||||
|
void
|
||||||
|
grid_view_clear_history(struct grid *gd)
|
||||||
|
{
|
||||||
|
struct grid_line *gl;
|
||||||
|
u_int yy, last;
|
||||||
|
|
||||||
|
GRID_DEBUG(gd, "");
|
||||||
|
|
||||||
|
/* Find the last used line. */
|
||||||
|
last = 0;
|
||||||
|
for (yy = 0; yy < gd->sy; yy++) {
|
||||||
|
gl = &gd->linedata[grid_view_y(gd, yy)];
|
||||||
|
if (gl->cellsize != 0 || gl->utf8size != 0)
|
||||||
|
last = yy + 1;
|
||||||
|
}
|
||||||
|
if (last == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Scroll the lines into the history. */
|
||||||
|
for (yy = 0; yy < last; yy++)
|
||||||
|
grid_scroll_history(gd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear area. */
|
/* Clear area. */
|
||||||
void
|
void
|
||||||
grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
|
grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
|
||||||
|
@ -931,9 +931,14 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx)
|
|||||||
sx = screen_size_x(s);
|
sx = screen_size_x(s);
|
||||||
sy = screen_size_y(s);
|
sy = screen_size_y(s);
|
||||||
|
|
||||||
|
/* Scroll into history if it is enabled and clearing entire screen. */
|
||||||
|
if (s->cy == 0 && s->grid->flags & GRID_HISTORY)
|
||||||
|
grid_view_clear_history(s->grid);
|
||||||
|
else {
|
||||||
if (s->cx <= sx - 1)
|
if (s->cx <= sx - 1)
|
||||||
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
|
||||||
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
|
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
|
||||||
|
}
|
||||||
|
|
||||||
tty_write(tty_cmd_clearendofscreen, &ttyctx);
|
tty_write(tty_cmd_clearendofscreen, &ttyctx);
|
||||||
}
|
}
|
||||||
@ -969,7 +974,13 @@ screen_write_clearscreen(struct screen_write_ctx *ctx)
|
|||||||
|
|
||||||
screen_write_initctx(ctx, &ttyctx, 0);
|
screen_write_initctx(ctx, &ttyctx, 0);
|
||||||
|
|
||||||
grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
|
/* Scroll into history if it is enabled. */
|
||||||
|
if (s->grid->flags & GRID_HISTORY)
|
||||||
|
grid_view_clear_history(s->grid);
|
||||||
|
else {
|
||||||
|
grid_view_clear(
|
||||||
|
s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
|
||||||
|
}
|
||||||
|
|
||||||
tty_write(tty_cmd_clearscreen, &ttyctx);
|
tty_write(tty_cmd_clearscreen, &ttyctx);
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -1741,6 +1741,7 @@ const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
|
|||||||
struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
|
struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
|
||||||
void grid_view_set_utf8(
|
void grid_view_set_utf8(
|
||||||
struct grid *, u_int, u_int, const struct grid_utf8 *);
|
struct grid *, u_int, u_int, const struct grid_utf8 *);
|
||||||
|
void grid_view_clear_history(struct grid *);
|
||||||
void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
|
void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
|
||||||
void grid_view_scroll_region_up(struct grid *, u_int, u_int);
|
void grid_view_scroll_region_up(struct grid *, u_int, u_int);
|
||||||
void grid_view_scroll_region_down(struct grid *, u_int, u_int);
|
void grid_view_scroll_region_down(struct grid *, u_int, u_int);
|
||||||
|
Loading…
Reference in New Issue
Block a user