diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2009-06-16 02:33:38 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2009-06-16 02:33:38 +0200 |
commit | 2e37752961f439c33614a9d8469d7c297f0465cb (patch) | |
tree | 6c15000913cfef0ceb3455dfea08dacd22b0aeec /st.h | |
parent | 8b4bfe31ec1075316dbb2e7d21753771ae3e5590 (diff) | |
download | st-patched-2e37752961f439c33614a9d8469d7c297f0465cb.tar.bz2 st-patched-2e37752961f439c33614a9d8469d7c297f0465cb.tar.xz st-patched-2e37752961f439c33614a9d8469d7c297f0465cb.zip |
added/removed files, updated Makefile.
Diffstat (limited to 'st.h')
-rw-r--r-- | st.h | 178 |
1 files changed, 0 insertions, 178 deletions
@@ -1,178 +0,0 @@ | |||
1 | /* See LICENSE for licence details. */ | ||
2 | #define _XOPEN_SOURCE | ||
3 | #include <ctype.h> | ||
4 | #include <errno.h> | ||
5 | #include <fcntl.h> | ||
6 | #include <locale.h> | ||
7 | #include <stdarg.h> | ||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
11 | #include <signal.h> | ||
12 | #include <sys/ioctl.h> | ||
13 | #include <sys/select.h> | ||
14 | #include <sys/stat.h> | ||
15 | #include <sys/types.h> | ||
16 | #include <sys/wait.h> | ||
17 | #include <unistd.h> | ||
18 | #include <X11/Xlib.h> | ||
19 | #include <X11/keysym.h> | ||
20 | #include <X11/Xutil.h> | ||
21 | |||
22 | /* special keys */ | ||
23 | #define KEYDELETE "\033[3~" | ||
24 | #define KEYHOME "\033[1~" | ||
25 | #define KEYEND "\033[4~" | ||
26 | #define KEYPREV "\033[5~" | ||
27 | #define KEYNEXT "\033[6~" | ||
28 | |||
29 | #define TNAME "st" | ||
30 | #define SHELL "/bin/bash" | ||
31 | #define TAB 8 | ||
32 | |||
33 | #define FONT "fixed" | ||
34 | #define BORDER 3 | ||
35 | #define LINESPACE 1 /* additional pixel between each line */ | ||
36 | |||
37 | /* Default colors */ | ||
38 | #define DefaultFG 7 | ||
39 | #define DefaultBG 0 | ||
40 | #define DefaultCS 1 | ||
41 | #define BellCol DefaultFG /* visual bell color */ | ||
42 | |||
43 | static char* colorname[] = { | ||
44 | "black", | ||
45 | "red", | ||
46 | "green", | ||
47 | "yellow", | ||
48 | "blue", | ||
49 | "magenta", | ||
50 | "cyan", | ||
51 | "white", | ||
52 | }; | ||
53 | |||
54 | /* Arbitrary sizes */ | ||
55 | #define ESCSIZ 256 | ||
56 | #define ESCARG 16 | ||
57 | |||
58 | #define SERRNO strerror(errno) | ||
59 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) | ||
60 | #define MAX(a, b) ((a) < (b) ? (b) : (a)) | ||
61 | #define LEN(a) (sizeof(a) / sizeof(a[0])) | ||
62 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) | ||
63 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) | ||
64 | #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) | ||
65 | |||
66 | |||
67 | enum { ATnone=0 , ATreverse=1 , ATunderline=2, ATbold=4 }; /* Attribute */ | ||
68 | enum { CSup, CSdown, CSright, CSleft, CShide, CSdraw, CSwrap, CSsave, CSload }; /* Cursor */ | ||
69 | enum { CRset=1 , CRupdate=2 }; /* Character state */ | ||
70 | enum { TMwrap=1 , TMinsert=2, TMaltcharset }; /* Terminal mode */ | ||
71 | enum { SCupdate, SCredraw }; /* screen draw mode */ | ||
72 | |||
73 | typedef int Color; | ||
74 | |||
75 | typedef struct { | ||
76 | char c; /* character code */ | ||
77 | char mode; /* attribute flags */ | ||
78 | Color fg; /* foreground */ | ||
79 | Color bg; /* background */ | ||
80 | char state; /* state flag */ | ||
81 | } Glyph; | ||
82 | |||
83 | typedef Glyph* Line; | ||
84 | |||
85 | typedef struct { | ||
86 | Glyph attr; /* current char attributes */ | ||
87 | char hidden; | ||
88 | int x; | ||
89 | int y; | ||
90 | } TCursor; | ||
91 | |||
92 | /* Escape sequence structs */ | ||
93 | typedef struct { | ||
94 | char buf[ESCSIZ+1]; /* raw string */ | ||
95 | int len; /* raw string length */ | ||
96 | /* ESC <pre> [[ [<priv>] <arg> [;]] <mode>] */ | ||
97 | char pre; | ||
98 | char priv; | ||
99 | int arg[ESCARG+1]; | ||
100 | int narg; /* nb of args */ | ||
101 | char mode; | ||
102 | } Escseq; | ||
103 | |||
104 | /* Internal representation of the screen */ | ||
105 | typedef struct { | ||
106 | int row; /* nb row */ | ||
107 | int col; /* nb col */ | ||
108 | Line* line; /* screen */ | ||
109 | TCursor c; /* cursor */ | ||
110 | int top; /* top scroll limit */ | ||
111 | int bot; /* bottom scroll limit */ | ||
112 | int mode; /* terminal mode */ | ||
113 | } Term; | ||
114 | |||
115 | /* Purely graphic info */ | ||
116 | typedef struct { | ||
117 | Display* dis; | ||
118 | Window win; | ||
119 | int scr; | ||
120 | int w; /* window width */ | ||
121 | int h; /* window height */ | ||
122 | int ch; /* char height */ | ||
123 | int cw; /* char width */ | ||
124 | } XWindow; | ||
125 | |||
126 | /* Drawing Context */ | ||
127 | typedef struct { | ||
128 | unsigned long col[LEN(colorname)]; | ||
129 | XFontStruct* font; | ||
130 | GC gc; | ||
131 | } DC; | ||
132 | |||
133 | |||
134 | void die(const char *errstr, ...); | ||
135 | void draw(int); | ||
136 | void execsh(void); | ||
137 | void sigchld(int); | ||
138 | void kpress(XKeyEvent *); | ||
139 | void resize(XEvent *); | ||
140 | void run(void); | ||
141 | |||
142 | int escaddc(char); | ||
143 | int escfinal(char); | ||
144 | void escdump(void); | ||
145 | void eschandle(void); | ||
146 | void escparse(void); | ||
147 | void escreset(void); | ||
148 | |||
149 | void tclearregion(int, int, int, int); | ||
150 | void tcpos(int); | ||
151 | void tcursor(int); | ||
152 | void tdeletechar(int); | ||
153 | void tdeleteline(int); | ||
154 | void tdump(void); | ||
155 | void tinsertblank(int); | ||
156 | void tinsertblankline(int); | ||
157 | void tmoveto(int, int); | ||
158 | void tnew(int, int); | ||
159 | void tnewline(void); | ||
160 | void tputc(char); | ||
161 | void tputs(char*, int); | ||
162 | void tresize(int, int); | ||
163 | void tscroll(void); | ||
164 | void tsetattr(int*, int); | ||
165 | void tsetchar(char); | ||
166 | void tsetscroll(int, int); | ||
167 | |||
168 | void ttynew(void); | ||
169 | void ttyread(void); | ||
170 | void ttyresize(int, int); | ||
171 | void ttywrite(char *, size_t); | ||
172 | |||
173 | unsigned long xgetcol(const char *); | ||
174 | void xclear(int, int, int, int); | ||
175 | void xcursor(int); | ||
176 | void xdrawc(int, int, Glyph); | ||
177 | void xinit(void); | ||
178 | void xscroll(void); | ||