-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathst.h
229 lines (131 loc) · 4.3 KB
/
st.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#ifndef ST_H
#define ST_H
#include <QObject>
#include <QString>
#include <QSocketNotifier>
#include <sys/ioctl.h>
#include "st-utils.h"
class SimpleTerminal : public QObject {
Q_OBJECT
public:
Term term;
Selection sel;
SimpleTerminal(QObject *parent = nullptr);
~SimpleTerminal();
void tnew(int col, int row);
void ttynew();
void execsh();
void closePty();
void tresize(int col, int row);
void ttyresize(int tw, int th);
int twrite(const char *buf, int size, int show_ctrl);
void ttywrite(const char *s, size_t n, int may_echo);
void ttywriteraw(const char *s, size_t n);
void kscrollup(int n);
void kscrolldown(int n);
void tdumpsel(void);
char *getsel(void);
void selstart(int col, int row, int snap);
void selextend(int col, int row, int type, int done);
void selsnap(int *x, int *y, int direction);
int selected(int x, int y);
void selclear(void);
void selscroll(int orig, int n);
public
slots:
size_t ttyread();
signals:
void s_error(QString);
void s_closed();
void s_updateView(Term *state);
private:
TermWindow win;
winsize wsize;
int master, slave;
pid_t processId;
char readBuf[BUFSIZ];
int readBufPos = 0;
int readBufSize = 0;
QSocketNotifier *readNotifier;
CSIEscape csiescseq;
STREscape strescseq;
/*
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultcs = 256;
unsigned int defaultrcs = 257;
unsigned int defaultfg = 258;
unsigned int defaultbg = 259;
unsigned int defaultCursor = 160; // no longer used
const int tabspaces = 8;
/* allow certain non-interactive (insecure) window operations such as:
setting the clipboard text */
int allowwindowops = 0;
const char *vtiden = "\033[?6c";
const uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
const Rune utfmin[UTF_SIZ + 1] = {0, 0, 0x80, 0x800, 0x10000};
const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
size_t utf8decode(const char *c, Rune *u, size_t clen);
Rune utf8decodebyte(char c, size_t *i);
size_t utf8validate(Rune *u, size_t i);
size_t utf8encode(Rune u, char *c);
char utf8encodebyte(Rune u, size_t i);
void tputc(Rune u);
void tcontrolcode(uchar ascii);
void tputtab(int n);
void tmoveto(int x, int y);
void tstrsequence(uchar c);
void strreset(void);
void tclearregion(int x1, int y1, int x2, int y2);
void selnormalize(void);
void strhandle(void);
void strparse(void);
void strdump(void);
void tsetchar(Rune u, const Glyph *attr, int x, int y);
void csireset(void);
void csiparse(void);
void csihandle(void);
void csidump(void);
void tsetdirt(int top, int bot);
void tdump(void);
void tdumpline(int n);
int tlinelen(int y);
void tnewline(int first_col);
void tinsertblank(int n);
void tinsertblankline(int n);
void tscrollup(int orig, int n, int copyhist);
void tscrolldown(int orig, int n, int copyhist);
void tsetscroll(int t, int b);
void tcursor(int mode);
void tmoveato(int x, int y);
void tdeletechar(int n);
void tdeftran(char ascii);
void tdectest(char c);
void tdefutf8(char ascii);
void tdeleteline(int n);
int eschandle(uchar ascii);
void treset(void);
void tfulldirt(void);
void osc_color_response(int num, int index, int is_osc4);
void redraw(void);
void draw(void);
char *base64dec(const char *src);
char base64dec_getc(const char **src);
void tsetattr(const int *attr, int l);
int32_t tdefcolor(const int *attr, int *npar, int l);
void xsetmode(int set, unsigned int flags);
void tsetmode(int priv, int set, const int *args, int narg);
void tswapscreen(void);
void bell(void);
// TODO
void xsetsel(char *str);
void xclipcopy(void);
int xsetcolorname(int x, const char *name);
int xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b);
void xloadcols(void);
int xsetcursor(int cursor);
void tprinter(char *s, size_t len); // TODO
};
#endif // ST_H