-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterm.h
More file actions
191 lines (123 loc) · 3.4 KB
/
Copy pathterm.h
File metadata and controls
191 lines (123 loc) · 3.4 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
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
#ifndef TERM_H
#define TERM_H
#include "libccor/ccor.h"
#include "parser.h"
#include "screen.h"
#include "types.h"
typedef enum {
MODE_WRAP = 1 << 0,
MODE_INSERT = 1 << 1,
MODE_CRLF = 1 << 3,
MODE_BRACKETED_PASTE = 1 << 4,
MODE_PRINT = 1 << 5,
MODE_FOCUS = 1 << 6,
MODE_APPKEYPAD = 1 << 7,
MODE_APPCURSOR = 1 << 8,
MODE_MOUSEBTN = 1 << 9,
MODE_MOUSEMOTION = 1 << 10,
MODE_MOUSEX10 = 1 << 11,
MODE_MOUSEMANY = 1 << 12,
MODE_MOUSESGR = 1 << 13,
MODE_HIDE = 1 << 16,
MODE_BLINK = 1 << 19,
} TermMode;
#define MODE_MOUSE (MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10|MODE_MOUSEMANY)
enum {
CURSOR_SAVE,
CURSOR_LOAD,
};
enum {
CURSOR_DEFAULT,
CURSOR_WRAPNEXT,
CURSOR_ORIGIN,
CURSOR_INPUT_NEEDS_WRAP = 4,
};
typedef enum {
CURSOR_SHAPE_DEFAULT,
CURSOR_SHAPE_BLOCK_BLINK,
CURSOR_SHAPE_BLOCK,
CURSOR_SHAPE_UNDERLINE_BLINK,
CURSOR_SHAPE_UNDERLINE,
CURSOR_SHAPE_BAR_BLINK,
CURSOR_SHAPE_BAR,
} CursorShape;
int cursor_shape_blinks(int shape);
typedef enum {
SNAP_NONE,
SNAP_WORD,
SNAP_LINE,
} SelectionSnap;
typedef struct {
int start_x, start_y;
int end_x, end_y;
int anchor_x1, anchor_y1;
int anchor_x2, anchor_y2;
SelectionSnap snap;
unsigned flags;
} Selection;
enum {
SELECTION_ACTIVE = 1 << 0,
};
typedef struct Term Term;
typedef void (*TermWriteFn)(const char *buf, size_t len, void *userdata);
typedef void (*TermBellFn)(void *userdata);
typedef void (*TermTitleFn)(const char *title, void *userdata);
struct Term {
Screen *screen;
Palette *pal;
int cx, cy;
Cell curcell;
int cursor_state;
CursorShape cursor_shape;
Cell save_curcell[2];
int save_cx[2], save_cy[2];
int save_cursor_state[2];
int mode;
int top, bot;
int *tabstops;
int ntabstops;
int cur_charset;
int sel_charset;
int charset_table[4];
Rune last_rune;
char title[256];
char clip[4096];
TermWriteFn write_fn;
void *write_ctx;
TermBellFn bell_fn;
void *bell_ctx;
TermTitleFn title_fn;
void *title_ctx;
unsigned flags;
};
enum {
TERM_ALLOW_ALT_SCREEN = 1 << 0,
};
Term *term_new(int cols, int rows, Palette * pal);
void term_free(Term * t);
void term_process_batch(Term * t, const Event * ev, int nev);
void term_resize(Term * t, int cols, int rows);
void term_reset(Term * t);
const Screen *term_screen(const Term * t);
void term_dirty(Term * t);
int term_mode(const Term * t, TermMode mode);
int term_mode_raw(const Term * t);
void term_set_mode(Term * t, int set, TermMode mode);
int term_cursor_x(const Term * t);
int term_cursor_y(const Term * t);
int term_cursor_shape(const Term * t);
const char *term_title(const Term * t);
void term_sel_start(Term * t, int x, int y, SelectionSnap snap);
void term_sel_extend(Term * t, int x, int y);
void term_sel_clear(Term * t);
int term_sel_active(const Term * t);
char *term_sel_get(const Term * t);
void term_sel_get_bounds(const Term * t, int *active, int *start_x,
int *start_y, int *end_x, int *end_y);
void term_set_write_fn(Term * t, TermWriteFn fn, void *userdata);
void term_set_bell_fn(Term * t, TermBellFn fn, void *userdata);
void term_set_title_fn(Term * t, TermTitleFn fn, void *userdata);
void term_set_allow_alt_screen(Term * t, int allow);
void term_write(Term * t, const char *buf, size_t len);
void term_bell(Term * t);
#endif