-
Notifications
You must be signed in to change notification settings - Fork 0
/
term.h
75 lines (62 loc) · 1.67 KB
/
term.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
#ifndef TERM_H
#define TERM_H
//
// Internal terminal structs.
//
#include "glyph.h"
#include <stdint.h>
#define HISTSIZE 100000
typedef struct {
Glyph attr; /* current char attributes */
int x;
int y;
char state;
} TCursor;
typedef struct {
int mode;
int type;
int snap;
/// Selection variables:
/// ob – original coordinates of the beginning of the selection
/// oe – original coordinates of the end of the selection
struct {
int x, y, scroll;
} ob, oe;
/// Selection variables; currently displayed chunk.
/// nb – normalized coordinates of the beginning of the selection
/// ne – normalized coordinates of the end of the selection
struct {
int x, y;
} nb, ne;
int alt;
} Selection;
/* Internal representation of the screen */
typedef struct {
int row; /* nb row */
int col; /* nb col */
int maxcol;
Line *line; /* screen */
Line *alt; /* alternate screen */
Line hist[HISTSIZE]; /* history buffer */
int histi; /* history index */
int scr; /* scroll back */
int *dirty; /* dirtyness of lines */
TCursor c; /* cursor */
int ocx; /* old cursor col */
int ocy; /* old cursor row */
int top; /* top scroll limit */
int bot; /* bottom scroll limit */
int mode; /* terminal mode flags */
int esc; /* escape state flags */
char trantbl[4]; /* charset table translation */
int charset; /* current charset */
int icharset; /* selected charset for sequence */
int *tabs;
Rune lastc;
} Term;
extern Term term;
#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
term.scr + HISTSIZE + 1) % HISTSIZE] : \
term.line[(y) - term.scr])
extern Selection sel;
#endif // TERM_H