--- drw.c | 30 +++++++++++++++--------------- drw.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drw.c b/drw.c index f23df84..95839c9 100644 --- a/drw.c +++ b/drw.c _AT_@ -235,10 +235,10 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int } int -drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) +drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) { char buf[1024]; - int tx, ty, th; + int ty; unsigned int ew; XftDraw *d = NULL; Fnt *usedfont, *curfont, *nextfont; _AT_@ -258,12 +258,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex if (!render) { w = ~w; } else { - XSetForeground(drw->dpy, drw->gc, invert ? - drw->scheme[ColFg].pixel : drw->scheme[ColBg].pixel); + XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); d = XftDrawCreate(drw->dpy, drw->drawable, DefaultVisual(drw->dpy, drw->screen), DefaultColormap(drw->dpy, drw->screen)); + x += lpad; + w -= lpad; } usedfont = drw->fonts; _AT_@ -295,20 +296,20 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex if (utf8strlen) { drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); /* shorten text if necessary */ - for (len = MIN(utf8strlen, (sizeof buf) - 1); len && (ew > w - usedfont->h || w < usedfont->h); len--) + for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) drw_font_getexts(usedfont, utf8str, len, &ew, NULL); if (len) { memcpy(buf, utf8str, len); buf[len] = '\0'; if (len < utf8strlen) - for (i = len; i && i > len - 3; buf[--i] = '.'); + for (i = len; i && i > len - 3; buf[--i] = '.') + ; /* NOP */ if (render) { - th = usedfont->h; - ty = y + (h - th) / 2 + usedfont->xfont->ascent; - tx = x + (h / 2); - XftDrawStringUtf8(d, invert ? &drw->scheme[ColBg] : &drw->scheme[ColFg], usedfont->xfont, tx, ty, (XftChar8 *)buf, len); + ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; + XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], + usedfont->xfont, x, ty, (XftChar8 *)buf, len); } x += ew; w -= ew; _AT_@ -322,8 +323,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex usedfont = nextfont; } else { /* Regardless of whether or not a fallback font is found, the - * character must be drawn. - */ + * character must be drawn. */ charexists = 1; fccharset = FcCharSetCreate(); _AT_@ -349,7 +349,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex usedfont = xfont_create(drw, NULL, match); if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) { for (curfont = drw->fonts; curfont->next; curfont = curfont->next) - ; /* just find the end of the linked list */ + ; /* NOP */ curfont->next = usedfont; } else { xfont_free(usedfont); _AT_@ -361,7 +361,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex if (d) XftDrawDestroy(d); - return x; + return x + (render ? w : 0); } void _AT_@ -379,7 +379,7 @@ drw_fontset_getwidth(Drw *drw, const char *text) { if (!drw || !drw->fonts || !text) return 0; - return drw_text(drw, 0, 0, 0, 0, text, 0); + return drw_text(drw, 0, 0, 0, 0, 0, text, 0); } void diff --git a/drw.h b/drw.h index cf0e7b4..4c67419 100644 --- a/drw.h +++ b/drw.h _AT_@ -51,7 +51,7 @@ void drw_setscheme(Drw *drw, Clr *scm); /* Drawing functions */ void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); -int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert); +int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); /* Map functions */ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); -- 2.7.3 --mYCpIKhGyMATD0i+ Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="dmenu.patch"Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Tue May 24 2016 - 20:12:11 CEST