Xinqi Bao's Git
1 /* See LICENSE for licence details. */
12 #include <sys/types.h>
14 #include <sys/select.h>
15 #include <sys/ioctl.h>
17 #include <X11/keysym.h>
18 #include <X11/Xutil.h>
21 #define KEYDELETE "\033[3~"
22 #define KEYHOME "\033[1~"
23 #define KEYEND "\033[4~"
24 #define KEYPREV "\033[5~"
25 #define KEYNEXT "\033[6~"
28 #define SHELL "/bin/bash"
31 #define FONT "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
33 #define LINESPACE 1 /* additional pixel between each line */
39 #define BellCol DefaultFG /* visual bell color */
41 static char* colorname
[] = {
57 #define MIN(a, b) ((a) < (b) ? (a) : (b))
58 #define MAX(a, b) ((a) < (b) ? (b) : (a))
59 #define LEN(a) (sizeof(a) / sizeof(a[0]))
60 #define DEFAULT(a, b) (a) = (a) ? (a) : (b)
61 #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
62 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
65 enum { ATnone
=0 , ATreverse
=1 , ATunderline
=2, ATbold
=4 }; /* Attribute */
66 enum { CSup
, CSdown
, CSright
, CSleft
, CShide
, CSdraw
, CSwrap
, CSsave
, CSload
}; /* Cursor */
67 enum { CRset
=1 , CRupdate
=2 }; /* Character state */
68 enum { TMwrap
=1 , TMinsert
=2 }; /* Terminal mode */
69 enum { SCupdate
, SCredraw
}; /* screen draw mode */
72 #error Truecolor not implemented yet
80 char c
; /* character code */
81 char mode
; /* attribute flags */
82 Color fg
; /* foreground */
83 Color bg
; /* background */
84 char state
; /* state flag */
90 Glyph attr
; /* current char attributes */
96 /* Escape sequence structs */
98 char buf
[ESCSIZ
+1]; /* raw string */
99 int len
; /* raw string length */
100 /* ESC <pre> [[ [<priv>] <arg> [;]] <mode>] */
104 int narg
; /* nb of args */
108 /* Internal representation of the screen */
110 int row
; /* nb row */
111 int col
; /* nb col */
112 Line
* line
; /* screen */
113 TCursor c
; /* cursor */
114 int top
; /* top scroll limit */
115 int bot
; /* bottom scroll limit */
116 int mode
; /* terminal mode */
119 /* Purely graphic info */
124 int w
; /* window width */
125 int h
; /* window height */
126 int ch
; /* char height */
127 int cw
; /* char width */
130 /* Drawing Context */
132 unsigned long col
[LEN(colorname
)];
138 void die(const char *errstr
, ...);
141 void kpress(XKeyEvent
*);
142 void resize(XEvent
*);
148 void eschandle(void);
152 void tclearregion(int, int, int, int);
155 void tdeletechar(int);
156 void tdeleteline(int);
158 void tinsertblank(int);
159 void tinsertblankline(int);
160 void tmoveto(int, int);
164 void tputs(char*, int);
165 void tresize(int, int);
167 void tsetattr(int*, int);
169 void tsetscroll(int, int);
173 void ttyresize(int, int);
174 void ttywrite(char *, size_t);
176 unsigned long xgetcol(const char *);
177 void xclear(int, int, int, int);
179 void xdrawc(int, int, Glyph
);