@@ -145,12 +145,14 @@ grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce,
145
145
return (gcp );
146
146
}
147
147
148
+ /* Get line data. */
148
149
struct grid_line *
149
150
grid_get_line (struct grid * gd , u_int line )
150
151
{
151
152
return (& gd -> linedata [line ]);
152
153
}
153
154
155
+ /* Adjust number of lines. */
154
156
void
155
157
grid_adjust_lines (struct grid * gd , u_int lines )
156
158
{
@@ -284,6 +286,15 @@ grid_compare(struct grid *ga, struct grid *gb)
284
286
return (0 );
285
287
}
286
288
289
+ /* Trim lines from the history. */
290
+ static void
291
+ grid_trim_history (struct grid * gd , u_int ny )
292
+ {
293
+ grid_free_lines (gd , 0 , ny );
294
+ memmove (& gd -> linedata [0 ], & gd -> linedata [ny ],
295
+ (gd -> hsize + gd -> sy - ny ) * (sizeof * gd -> linedata ));
296
+ }
297
+
287
298
/*
288
299
* Collect lines from the history if at the limit. Free the top (oldest) 10%
289
300
* and shift up.
@@ -306,9 +317,7 @@ grid_collect_history(struct grid *gd)
306
317
* Free the lines from 0 to ny then move the remaining lines over
307
318
* them.
308
319
*/
309
- grid_free_lines (gd , 0 , ny );
310
- memmove (& gd -> linedata [0 ], & gd -> linedata [ny ],
311
- (gd -> hsize + gd -> sy - ny ) * (sizeof * gd -> linedata ));
320
+ grid_trim_history (gd , ny );
312
321
313
322
gd -> hsize -= ny ;
314
323
if (gd -> hscrolled > gd -> hsize )
@@ -338,9 +347,7 @@ grid_scroll_history(struct grid *gd, u_int bg)
338
347
void
339
348
grid_clear_history (struct grid * gd )
340
349
{
341
- grid_free_lines (gd , 0 , gd -> hsize );
342
- memmove (& gd -> linedata [0 ], & gd -> linedata [gd -> hsize ],
343
- gd -> sy * (sizeof * gd -> linedata ));
350
+ grid_trim_history (gd , gd -> hsize );
344
351
345
352
gd -> hscrolled = 0 ;
346
353
gd -> hsize = 0 ;
0 commit comments