Xinqi Bao's Git

d4065d2f959f4c7e71df21bc96422c701d85da69
[dmenu.git] / dmenu.h
1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
5
6 #include <X11/Xlib.h>
7 #include <X11/Xlocale.h>
8
9 #define FONT "fixed"
10 #define NORMBGCOLOR "#333366"
11 #define NORMFGCOLOR "#cccccc"
12 #define SELBGCOLOR "#666699"
13 #define SELFGCOLOR "#eeeeee"
14 #define SPACE 30 /* px */
15
16 /* color */
17 enum { ColFG, ColBG, ColLast };
18
19 typedef struct DC DC;
20 typedef struct Fnt Fnt;
21
22 struct Fnt {
23 XFontStruct *xfont;
24 XFontSet set;
25 int ascent;
26 int descent;
27 int height;
28 };
29
30 struct DC {
31 int x, y, w, h;
32 unsigned long norm[ColLast];
33 unsigned long sel[ColLast];
34 Drawable drawable;
35 Fnt font;
36 GC gc;
37 }; /* draw context */
38
39 extern int screen;
40 extern Display *dpy;
41 extern DC dc; /* global drawing context */
42
43 /* draw.c */
44 extern void drawtext(const char *text,
45 unsigned long col[ColLast]); /* draws text with the defined color tuple */
46 extern unsigned long getcolor(const char *colstr); /* returns color of colstr */
47 extern void setfont(const char *fontstr); /* sets global font */
48 extern unsigned int textw(const char *text); /* returns width of text in px */
49
50 /* util.c */
51 extern void *emalloc(unsigned int size); /* allocates memory, exits on error */
52 extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
53 extern char *estrdup(const char *str); /* duplicates str, exits on allocation error */