Introduction
Introduction Statistics Contact Development Disclaimer Help
libg.h - sam - An updated version of the sam text editor.
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
libg.h (6115B)
---
1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
2 #ifndef _LIBG_H
3 #define _LIBG_H
4
5 /*
6 * Like Plan9's libg.h, but suitable for inclusion on non-Plan9 machines
7 */
8
9 #include <X11/Xft/Xft.h>
10
11 enum{ EMAXMSG = 128+8192 }; /* max event size */
12
13 /*
14 * Cursors
15 */
16
17 enum{
18 DefaultCursor,
19 ArrowCursor,
20 BullseyeCursor,
21 SweepCursor,
22 DeadCursor,
23 LockCursor
24 };
25
26 /*
27 * Types
28 */
29
30 typedef struct Bitmap Bitmap;
31 typedef struct Point Point;
32 typedef struct Rectangle Rectangle;
33 typedef struct Keystroke Keystroke;
34 typedef struct Mouse Mouse;
35 typedef struct Menu Menu;
36 typedef struct Event Event;
37 typedef struct RGB RGB;
38
39 struct Point
40 {
41 int x;
42 int y;
43 };
44
45 struct Rectangle
46 {
47 Point min;
48 Point max;
49 };
50
51 struct Bitmap
52 {
53 Rectangle r; /* rectangle in data area, local coords */
54 Rectangle clipr; /* clipping region */
55 int ldepth;
56 int id; /* as known by the X server */
57 Bitmap *cache; /* zero; distinguishes bitmap from layer */
58 XftDraw *fd; /* font drawable */
59 int flag; /* flag used by X implementation of libg */
60 };
61
62 struct Mouse
63 {
64 int buttons; /* bit array: LMR=124 */
65 Point xy;
66 uint64_t msec;
67 char *a;
68 };
69
70 struct Keystroke
71 {
72 int k;
73 int c;
74 int t;
75 Point p;
76 const char *a;
77 };
78
79 struct Menu
80 {
81 char **item;
82 char *(*gen)(int);
83 int lasthit;
84 };
85
86 struct Event
87 {
88 Keystroke keystroke;
89 Mouse mouse;
90 int n; /* number of characters in mesage */
91 unsigned char data[EMAXMSG]; /* message from an arbitrary file de…
92 };
93
94 struct RGB
95 {
96 uint64_t red;
97 uint64_t green;
98 uint64_t blue;
99 };
100
101 enum{
102 Knone, /* invalid command type */
103 Kdefault, /* perform default command action */
104 Kraw, /* insert raw character code, subject to transformation …
105 Kcommand, /* execute command (see below) */
106 Kend /* mark the end of a command list */
107 };
108
109 enum{
110 Cnone, /* no command */
111 Cdefault, /* default action */
112 Csysmax
113 };
114
115 enum{
116 Tcurrent, /* command is sent to focused layer */
117 Tmouse /* command is sent to layer containing the mouse */
118 };
119
120 /*
121 * Codes for bitblt etc.
122 *
123 * D
124 * 0 1
125 * ---------
126 * 0 | 1 | 2 |
127 * S |---|---|
128 * 1 | 4 | 8 |
129 * ---------
130 *
131 * Usually used as D|S; DorS is so tracebacks are readable.
132 */
133 typedef
134 enum Fcode
135 {
136 Zero = 0x0,
137 DnorS = 0x1,
138 DandnotS = 0x2,
139 notS = 0x3,
140 notDandS = 0x4,
141 notD = 0x5,
142 DxorS = 0x6,
143 DnandS = 0x7,
144 DandS = 0x8,
145 DxnorS = 0x9,
146 D = 0xA,
147 DornotS = 0xB,
148 S = 0xC,
149 notDorS = 0xD,
150 DorS = 0xE,
151 F = 0xF
152 } Fcode;
153
154 /*
155 * Miscellany
156 */
157
158 typedef void (*Errfunc)(char *);
159
160 extern void addlatin(char, char, int16_t);
161 extern Point add(Point, Point);
162 extern Point sub(Point, Point);
163 extern Point mul(Point, int);
164 extern Point divpt(Point, int);
165 extern Rectangle rsubp(Rectangle, Point);
166 extern Rectangle raddp(Rectangle, Point);
167 extern Rectangle inset(Rectangle, int);
168 extern Rectangle rmul(Rectangle, int);
169 extern Rectangle rdiv(Rectangle, int);
170 extern Rectangle rshift(Rectangle, int);
171 extern Rectangle rcanon(Rectangle);
172 extern Bitmap* balloc(Rectangle, int);
173 extern void bfree(Bitmap*);
174 extern int rectclip(Rectangle*, Rectangle);
175 extern void xtbinit(Errfunc, char*, int*, char**, char**);
176 extern void bclose(void);
177 extern void berror(char*);
178 extern void bitblt2(Bitmap*, Point, Bitmap*, Rectangle, Fcode, uint64_t…
179 extern void bitblt(Bitmap*, Point, Bitmap*, Rectangle, Fcode);
180
181 extern Point string(Bitmap*, Point, XftFont*, char*, Fcode);
182 extern int64_t strwidth(XftFont*, char*);
183 extern int64_t charwidth(XftFont*, wchar_t);
184 extern void texture(Bitmap*, Rectangle, Bitmap*, Fcode);
185 extern void wrbitmap(Bitmap*, int, int, unsigned char*);
186 extern int ptinrect(Point, Rectangle);
187 extern int rectXrect(Rectangle, Rectangle);
188 extern int eqpt(Point, Point);
189 extern int eqrect(Rectangle, Rectangle);
190 extern void border(Bitmap*, Rectangle, int, Fcode, uint64_t);
191 extern void cursorswitch(unsigned int);
192 extern void cursorset(Point);
193 extern Rectangle bscreenrect(Rectangle*);
194 extern void bflush(void);
195
196 extern int clipr(Bitmap*, Rectangle);
197 extern int scrpix(int*,int*);
198 extern uint64_t getbg(void);
199
200 extern void einit(uint64_t);
201 extern uint64_t estart(uint64_t, int, size_t, bool);
202
203 extern uint64_t event(Event*);
204 extern uint64_t eread(uint64_t, Event*);
205 extern Mouse emouse(void);
206 extern Keystroke ekbd(void);
207 extern void pushkbd(int c);
208 extern int ecanread(uint64_t);
209 extern int ecanmouse(void);
210 extern int ecankbd(void);
211 extern void ereshaped(Rectangle); /* supplied by user */
212
213 extern int menuhit(int, Mouse*, Menu*);
214 extern Rectangle getrect(int, Mouse*);
215
216 extern void rdcolmap(Bitmap*, RGB*);
217 extern void wrcolmap(Bitmap*, RGB*);
218 extern void raisewindow(void);
219
220 /* Extra functions supplied by libXg */
221 extern int snarfswap(char*, int, char**);
222
223 enum{
224 Emouse = 1,
225 Ekeyboard = 2
226 };
227
228 extern Point Pt(int, int);
229 extern Rectangle Rect(int, int, int, int);
230 extern Rectangle Rpt(Point, Point);
231
232
233 #define Dx(r) ((r).max.x-(r).min.x)
234 #define Dy(r) ((r).max.y-(r).min.y)
235
236
237 extern Bitmap screen;
238 extern XftFont *font;
239 extern XftColor fontcolor;
240 extern XftColor bgcolor;
241
242 #define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
243 #define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
244 #define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
245 #define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))
246
247 extern int installbinding(int, KeySym, int, int, const char *);
248 extern int installchord(int, int, int, int, const char *);
249 extern int removebinding(int, KeySym);
250 extern int removechord(int, int);
251
252 extern char foregroundspec[1024];
253 extern char backgroundspec[1024];
254 extern char borderspec[1024];
255 extern char fontspec[1024];
256 #endif
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.