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