-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvterm_csi_DCH.c
64 lines (50 loc) · 1.57 KB
/
vterm_csi_DCH.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdlib.h>
#include "vterm.h"
#include "vterm_private.h"
#include "vterm_csi.h"
#include "vterm_buffer.h"
/* Interpret the 'delete chars' sequence (DCH) */
void
interpret_csi_DCH(vterm_t *vterm, int param[], int pcount)
{
vterm_desc_t *v_desc = NULL;
vterm_cell_t *vcell_src;
vterm_cell_t *vcell_dst;
int stride;
int idx;
int n = 1;
int c;
if(pcount && param[0] > 0) n = param[0];
// select the correct desc
idx = vterm_buffer_get_active(vterm);
v_desc = &vterm->vterm_desc[idx];
stride = v_desc->cols - v_desc->ccol;
stride -= n;
// copy into temporary buffer
vcell_src = &v_desc->cells[v_desc->crow][v_desc->ccol];
vcell_src += n;
vcell_dst = &v_desc->cells[v_desc->crow][v_desc->ccol];
/*
by experintation and review of other emulators it seems that DCH
only copies the character from its neighbor and not the attributes
or colors. IMO that's bizarre but reality.
*/
for(c = 0; c < stride; c++)
{
memcpy(&vcell_dst->wch, &vcell_src->wch, sizeof(vcell_dst->wch));
VCELL_ROW_SET_DIRTY(vcell_dst, 1);
vcell_src++;
vcell_dst++;
}
// zero out cells created by the void
vcell_dst = &v_desc->cells[v_desc->crow][v_desc->ccol];
vcell_dst += stride;
// same logic as above change the character of the cell only
for(c = 0; c < n; c++)
{
VCELL_SET_CHAR((*vcell_dst), ' ');
VCELL_SET_COLORS((*vcell_dst), v_desc);
vcell_dst++;
}
return;
}