-/*
- * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include "config.h"
#include <X11/Xlib.h>
-#include <X11/Xlocale.h>
-
-#define SPACE 30 /* px */
-
-/* color */
-enum { ColFG, ColBG, ColLast };
-
-typedef struct DC DC;
-typedef struct Fnt Fnt;
-
-struct Fnt {
- XFontStruct *xfont;
- XFontSet set;
- int ascent;
- int descent;
- int height;
-};
-
-struct DC {
- int x, y, w, h;
- unsigned long norm[ColLast];
- unsigned long sel[ColLast];
- Drawable drawable;
- Fnt font;
- GC gc;
-}; /* draw context */
+#include <draw.h>
+#include "config.h"
+/* macros */
+#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define IS_UTF8_1ST_CHAR(c) ((((c) & 0xc0) == 0xc0) || !((c) & 0x80))
+
+/* forward declarations */
+void drawbar(void);
+void grabkeyboard(void);
+void kpress(XKeyEvent *e);
+void run(void);
+void setup(unsigned int lines);
+
+/* variables */
+extern char *prompt;
+extern char text[4096];
+extern int promptw;
extern int screen;
+extern unsigned int numlockmask;
+extern unsigned int mw, mh;
+extern unsigned long normcol[ColLast];
+extern unsigned long selcol[ColLast];
+extern Bool topbar;
+extern DC dc;
extern Display *dpy;
-extern DC dc; /* global drawing context */
-
-/* draw.c */
-extern void drawtext(const char *text,
- unsigned long col[ColLast]); /* draws text with the defined color tuple */
-extern unsigned long getcolor(const char *colstr); /* returns color of colstr */
-extern void setfont(const char *fontstr); /* sets global font */
-extern unsigned int textw(const char *text); /* returns width of text in px */
-
-/* util.c */
-extern void *emalloc(unsigned int size); /* allocates memory, exits on error */
-extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
-extern char *estrdup(const char *str); /* duplicates str, exits on allocation error */
+extern Window win, root;