-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtparser.h
118 lines (110 loc) · 3.67 KB
/
vtparser.h
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
/*
* Copyright 2017 - 2019 Rob King <jking@deadpixi.com>
* Copyright 2020 - 2023 William Pursell <william.r.pursell@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VTC_H
#define VTC_H
#include <stddef.h>
#include <wchar.h>
/* The names for handlers come from their ANSI/ECMA/DEC mnemonics. */
enum cmd {
ack=1, /* Acknowledge Enquiry */
bell, /* Terminal bell. */
cnl, /* Cursor Next Line */
cpl, /* Cursor Previous Line */
cr, /* Carriage Return */
csr, /* Change Scrolling Region */
cub, /* Cursor Backward */
cud, /* Cursor Down */
cuf, /* Cursor Forward */
cup, /* Cursor Position */
cuu, /* Cursor Up */
dch, /* Delete Character */
ech, /* Erase Character */
ed, /* Erase in Display */
el, /* Erase in Line */
hpa, /* Cursor Horizontal Absolute */
hpr, /* Cursor Horizontal Relative */
hts, /* Horizontal Tab Set */
ich, /* Insert Character */
idl, /* Insert/Delete Line */
ind, /* Index */
mode, /* Set or Reset Mode */
nel, /* Next Line */
numkp, /* Application/Numeric Keypad Mode */
osc, /* Operating System Command */
pnl, /* Newline */
print, /* Print a character to the terminal */
rc, /* Restore Cursor */
rep, /* Repeat Character */
ri, /* Reverse Index (scroll back) */
ris, /* Reset to Initial State */
sc, /* Save Cursor */
scs, /* Select Character Set */
sgr, /* SGR - Select Graphic Rendition */
so, /* Switch Out/In Character Set */
su, /* Scroll Up/Down */
tab, /* Tab forwards or backwards */
tbc, /* Tabulation Clear */
vis, /* Cursor visibility */
vpa, /* Cursor Vertical Absolute */
vpr, /* Cursor Vertical Relative */
#if 0
The following are unimplemented:
decid, /* Send Terminal Identification */
decreqtparm, /* Request Device Parameters */
dsr, /* Device Status Report */
#endif
};
/*
* VTPARSER_BAD_CHAR is the character that will be displayed when
* an application sends an invalid multibyte sequence to the terminal.
*/
#ifndef VTPARSER_BAD_CHAR
#ifdef __STDC_ISO_10646__
#define VTPARSER_BAD_CHAR ((wchar_t)0xfffd)
#else
#define VTPARSER_BAD_CHAR L'?'
#endif
#endif
#define MAXPARAM 16
#define MAXOSC 511
struct pty;
struct vtp {
struct pty *p;
struct state *s;
wchar_t inter;
int argc;
int args[MAXPARAM];
char oscbuf[MAXOSC + 1];
char *osc;
mbstate_t ms;
};
extern int cons[0x80];
extern int csis[0x80];
extern int escs[0x80];
extern int oscs[0x80];
extern int gnds[0x80];
extern void set_status(struct pty *p, const char *arg);
extern void tput(struct pty *, wchar_t, wchar_t, int, int *, int);
extern void vtreset(struct vtp *v);
extern void vtwrite(struct vtp *vp, const char *s, size_t n);
extern int build_layout(const char *);
/* Debugging/test harness */
#ifndef NDEBUG
extern void show_status(const char *);
#endif
#endif