summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarg@suckless.org <unknown>2008-06-02 12:19:02 +0200
committerarg@suckless.org <unknown>2008-06-02 12:19:02 +0200
commit08bcf721b436018306bdbb9fbaca87f941ee6441 (patch)
tree3c81731fb98785e9eb168f6aeb15f9beae0fc4ea
parentfixed the tile() issue with xpdf (diff)
downloaddwm-08bcf721b436018306bdbb9fbaca87f941ee6441.tar.gz
dwm-08bcf721b436018306bdbb9fbaca87f941ee6441.zip
small change to drawtext
Diffstat (limited to '')
-rw-r--r--dwm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/dwm.c b/dwm.c
index 8930100..ada272c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -551,7 +551,7 @@ drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) {
551 551
552void 552void
553drawtext(const char *text, ulong col[ColLast], Bool invert) { 553drawtext(const char *text, ulong col[ColLast], Bool invert) {
554 int x, y, w, h; 554 int i, x, y, h;
555 uint len, olen; 555 uint len, olen;
556 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; 556 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
557 char buf[256]; 557 char buf[256];
@@ -563,16 +563,15 @@ drawtext(const char *text, ulong col[ColLast], Bool invert) {
563 olen = strlen(text); 563 olen = strlen(text);
564 len = MIN(olen, sizeof buf); 564 len = MIN(olen, sizeof buf);
565 memcpy(buf, text, len); 565 memcpy(buf, text, len);
566 w = 0;
567 h = dc.font.ascent + dc.font.descent; 566 h = dc.font.ascent + dc.font.descent;
568 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; 567 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
569 x = dc.x + (h / 2); 568 x = dc.x + (h / 2);
570 /* shorten text if necessary */ 569 /* shorten text if necessary */
571 for(; len && (w = textnw(buf, len)) > dc.w - h; len--); 570 for(; len && (i = textnw(buf, len)) > dc.w - h; len--);
572 if(!len) 571 if(!len)
573 return; 572 return;
574 if(len < olen) 573 if(len < olen)
575 memcpy(&buf[MAX(0, len - 3)], "...", 3); 574 for(i = len; i >= MAX(0, len - 3); buf[i--] = '.');
576 XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); 575 XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
577 if(dc.font.set) 576 if(dc.font.set)
578 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); 577 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);