eed5689b54b7c20088f7f87640530186c0edf26f
[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 "config.h"
7 #include <X11/Xlib.h>
8 #include <X11/Xlocale.h>
9
10 #define SPACE           30 /* px */
11
12 /* color */
13 enum { ColFG, ColBG, ColLast };
14
15 typedef struct DC DC;
16 typedef struct Fnt Fnt;
17
18 struct Fnt {
19         XFontStruct *xfont;
20         XFontSet set;
21         int ascent;
22         int descent;
23         int height;
24 };
25
26 struct DC {
27         int x, y, w, h;
28         unsigned long norm[ColLast];
29         unsigned long sel[ColLast];
30         Drawable drawable;
31         Fnt font;
32         GC gc;
33 }; /* draw context */
34
35 extern int screen;
36 extern Display *dpy;
37 extern DC dc;                   /* global drawing context */
38
39 /* draw.c */
40 extern void drawtext(const char *text,
41                         unsigned long col[ColLast]);    /* draws text with the defined color tuple */
42 extern unsigned long getcolor(const char *colstr);      /* returns color of colstr */
43 extern void setfont(const char *fontstr);               /* sets global font */
44 extern unsigned int textw(const char *text);            /* returns width of text in px */
45
46 /* util.c */
47 extern void *emalloc(unsigned int size);                /* allocates memory, exits on error */
48 extern void eprint(const char *errstr, ...);            /* prints errstr and exits with 1 */
49 extern char *estrdup(const char *str);                  /* duplicates str, exits on allocation error */