X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=drw.c;h=ebdf8fe71127db2351f09e80215c9f4b633ead5f;hp=b13040565f6c01bec3f5927cbf7fcd30409f7c3d;hb=4b5d30e4192ad507934aca816aaae5dd4d7c28e9;hpb=3e5cca9ec9b04e5d0fbf9eb059c37fa3e689b46d diff --git a/drw.c b/drw.c index b130405..ebdf8fe 100644 --- a/drw.c +++ b/drw.c @@ -141,6 +141,16 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) { + _drw_text(drw, x, y, w, h, text, invert, 1); +} + +void +drw_text_nopad(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert) { + _drw_text(drw, x, y, w, h, text, invert, 0); +} + +void +_drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert, int pad) { char buf[256]; int i, tx, ty, th, len, olen; Extnts tex; @@ -155,9 +165,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex drw_font_getexts(drw->font, text, olen, &tex); th = drw->font->ascent + drw->font->descent; ty = y + (h / 2) - (th / 2) + drw->font->ascent; - tx = x + (h / 2); + tx = x + (h / 2) * pad; /* shorten text if necessary */ - for(len = MIN(olen, sizeof buf); len && (tex.w > w - tex.h || w < tex.h); len--) + for(len = MIN(olen, sizeof buf); len && (tex.w > w - tex.h * pad || w < tex.h * pad); len--) drw_font_getexts(drw->font, text, len, &tex); if(!len) return;