aboutsummaryrefslogtreecommitdiff
path: root/st.h
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2009-06-16 02:33:38 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2009-06-16 02:33:38 +0200
commit2e37752961f439c33614a9d8469d7c297f0465cb (patch)
tree6c15000913cfef0ceb3455dfea08dacd22b0aeec /st.h
parent8b4bfe31ec1075316dbb2e7d21753771ae3e5590 (diff)
downloadst-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.h178
1 files changed, 0 insertions, 178 deletions
diff --git a/st.h b/st.h
deleted file mode 100644
index 0bd2c4e..0000000
--- a/st.h
+++ /dev/null
@@ -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
43static 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
67enum { ATnone=0 , ATreverse=1 , ATunderline=2, ATbold=4 }; /* Attribute */
68enum { CSup, CSdown, CSright, CSleft, CShide, CSdraw, CSwrap, CSsave, CSload }; /* Cursor */
69enum { CRset=1 , CRupdate=2 }; /* Character state */
70enum { TMwrap=1 , TMinsert=2, TMaltcharset }; /* Terminal mode */
71enum { SCupdate, SCredraw }; /* screen draw mode */
72
73typedef int Color;
74
75typedef 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
83typedef Glyph* Line;
84
85typedef struct {
86 Glyph attr; /* current char attributes */
87 char hidden;
88 int x;
89 int y;
90} TCursor;
91
92/* Escape sequence structs */
93typedef 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 */
105typedef 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 */
116typedef 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 */
127typedef struct {
128 unsigned long col[LEN(colorname)];
129 XFontStruct* font;
130 GC gc;
131} DC;
132
133
134void die(const char *errstr, ...);
135void draw(int);
136void execsh(void);
137void sigchld(int);
138void kpress(XKeyEvent *);
139void resize(XEvent *);
140void run(void);
141
142int escaddc(char);
143int escfinal(char);
144void escdump(void);
145void eschandle(void);
146void escparse(void);
147void escreset(void);
148
149void tclearregion(int, int, int, int);
150void tcpos(int);
151void tcursor(int);
152void tdeletechar(int);
153void tdeleteline(int);
154void tdump(void);
155void tinsertblank(int);
156void tinsertblankline(int);
157void tmoveto(int, int);
158void tnew(int, int);
159void tnewline(void);
160void tputc(char);
161void tputs(char*, int);
162void tresize(int, int);
163void tscroll(void);
164void tsetattr(int*, int);
165void tsetchar(char);
166void tsetscroll(int, int);
167
168void ttynew(void);
169void ttyread(void);
170void ttyresize(int, int);
171void ttywrite(char *, size_t);
172
173unsigned long xgetcol(const char *);
174void xclear(int, int, int, int);
175void xcursor(int);
176void xdrawc(int, int, Glyph);
177void xinit(void);
178void xscroll(void);