-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvterm_dec_RM.c
More file actions
156 lines (130 loc) · 3.77 KB
/
Copy pathvterm_dec_RM.c
File metadata and controls
156 lines (130 loc) · 3.77 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "vterm.h"
#include "vterm_private.h"
#include "vterm_csi.h"
#include "vterm_buffer.h"
#include "vterm_cursor.h"
#include "mouse_driver.h"
/*
Interpret the DEC RM / DEC PRIVATE RM (reset mode)
ESC [ ? x l
*/
void
interpret_dec_RM(vterm_t *vterm, int param[], int pcount)
{
vterm_desc_t *v_desc = NULL;
int i;
int idx;
if(pcount == 0) return;
// active buffer descriptor (idx kept for VTERM_BUF_* compares below)
idx = vterm->vterm_desc_idx;
v_desc = vterm->v_desc_active;
for(i = 0; i < pcount; i++)
{
// DECCKM: normal cursor keys
if(param[i] == 1)
{
vterm->internal_state &= ~STATE_CURSOR_APP;
continue;
}
/*
DECCOLM
restore to 80 column mode. it also erases the screen
which is all we're going to do.
*/
if(param[i] == 3)
{
vterm_erase(vterm, idx, 0);
v_desc->ccol = 0;
v_desc->crow = 0;
continue;
}
/*
DECOM
set origin mode. this means that cursor home position is
relative to the scrolling region. it also cause the cursor
to move to the effective home position.
we don't support this yet.
*/
if(param[i] == 6)
{
v_desc->buffer_state &= ~STATE_ORIGIN_MODE;
vterm_cursor_move_home(vterm);
continue;
}
// disable auto-wrap mode
if(param[i] == 7)
{
v_desc->buffer_state |= STATE_NO_WRAP;
continue;
}
if(param[i] == 20)
{
v_desc->buffer_state &= ~STATE_AUTOMATIC_LF;
continue;
}
/* civis is actually the "normal" vibility for rxvt */
if(param[i] == 25)
{
vterm_cursor_hide(vterm, idx);
continue;
}
// restore standard buffer
// CSI hanlder: ESC [ ? 47 l
if(param[i] == 47)
{
// check to see if we're already using the ALT buffer
if(idx == VTERM_BUF_STANDARD) continue;
vterm_buffer_set_active(vterm, VTERM_BUF_STANDARD);
continue;
}
// shutdown whatever mouse driver is installed
if(param[i] == 1000 || param[i] == 1005 || param[i] == 1006)
{
mouse_driver_stop(vterm);
continue;
}
/*
turn off alternate scroll mode. in alternate scroll mode
the wheel mouse sends cursor up and cursor down movements
instead of button events.
*/
if(param[i] == 1007)
{
vterm->mouse_mode &= ~VTERM_MOUSE_ALTSCROLL;
continue;
}
/*
not reall well documented but this code turns on the
meta key. see terminfo(5). we just pass this along
to ncurses via the meta() function.
*/
if(param[i] == 1034)
{
/*
according to man pages for meta() "The window
argument, win, is always ignored."
*/
meta(NULL, FALSE);
return;
}
/*
similar to ESC [ ? 47 l except it restores the cursor after
switching back to standard buffer.
*/
if(param[i] == 1049)
{
if(idx != VTERM_BUF_STANDARD)
{
vterm_buffer_set_active(vterm, VTERM_BUF_STANDARD);
}
vterm_cursor_restore(vterm);
continue;
}
// DECRST 2004 -- bracketed paste off
if(param[i] == 2004)
{
vterm->internal_state &= ~STATE_BRACKETED_PASTE;
continue;
}
}
}