-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvterm_history.c
46 lines (34 loc) · 955 Bytes
/
vterm_history.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "macros.h"
#include "vterm.h"
#include "vterm_private.h"
#include "vterm_buffer.h"
void
vterm_set_history_size(vterm_t *vterm, int rows)
{
vterm_desc_t *v_desc;
int delta;
if(vterm == NULL) return;
v_desc = &vterm->vterm_desc[VTERM_BUF_HISTORY];
// nothing to do
delta = rows - v_desc->rows;
if(delta == 0) return;
// buffer is shrinking
if(delta < 0)
{
vterm_buffer_shift_up(vterm, VTERM_BUF_HISTORY, -1, -1, ABSINT(delta));
vterm_buffer_realloc(vterm, VTERM_BUF_HISTORY, -1, rows);
return;
}
// buffer is growing
vterm_buffer_realloc(vterm, VTERM_BUF_HISTORY, -1, rows);
vterm_buffer_shift_down(vterm, VTERM_BUF_HISTORY, -1, -1, delta);
return;
}
int
vterm_get_history_size(vterm_t *vterm)
{
vterm_desc_t *v_desc;
if(vterm == NULL) return -1;
v_desc = &vterm->vterm_desc[VTERM_BUF_HISTORY];
return v_desc->rows;
}