mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 19:39:04 +00:00
Helper function to shorten history.
This commit is contained in:
parent
03519021b9
commit
e7d53020b4
17
grid.c
17
grid.c
@ -286,6 +286,15 @@ grid_compare(struct grid *ga, struct grid *gb)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Trim lines from the history. */
|
||||
static void
|
||||
grid_trim_history(struct grid *gd, u_int ny)
|
||||
{
|
||||
grid_free_lines(gd, 0, ny);
|
||||
memmove(&gd->linedata[0], &gd->linedata[ny],
|
||||
(gd->hsize + gd->sy - ny) * (sizeof *gd->linedata));
|
||||
}
|
||||
|
||||
/*
|
||||
* Collect lines from the history if at the limit. Free the top (oldest) 10%
|
||||
* and shift up.
|
||||
@ -308,9 +317,7 @@ grid_collect_history(struct grid *gd)
|
||||
* Free the lines from 0 to ny then move the remaining lines over
|
||||
* them.
|
||||
*/
|
||||
grid_free_lines(gd, 0, ny);
|
||||
memmove(&gd->linedata[0], &gd->linedata[ny],
|
||||
(gd->hsize + gd->sy - ny) * (sizeof *gd->linedata));
|
||||
grid_trim_history(gd, ny);
|
||||
|
||||
gd->hsize -= ny;
|
||||
if (gd->hscrolled > gd->hsize)
|
||||
@ -340,9 +347,7 @@ grid_scroll_history(struct grid *gd, u_int bg)
|
||||
void
|
||||
grid_clear_history(struct grid *gd)
|
||||
{
|
||||
grid_free_lines(gd, 0, gd->hsize);
|
||||
memmove(&gd->linedata[0], &gd->linedata[gd->hsize],
|
||||
gd->sy * (sizeof *gd->linedata));
|
||||
grid_trim_history(gd, gd->hsize);
|
||||
|
||||
gd->hscrolled = 0;
|
||||
gd->hsize = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user