Introduction
Introduction Statistics Contact Development Disclaimer Help
tfixed string cutting in draw.c - dwm - [fork] customized build of dwm, the dyn…
git clone git://src.adamsgaard.dk/dwm
Log
Files
Refs
README
LICENSE
---
commit 4d67199a4bb68e5377d2fece62a83fde66c92861
parent 95766d6241a401b3665ac1ad528b90c55e7b6810
Author: Anselm R.Garbe <[email protected]>
Date: Mon, 14 Aug 2006 08:52:15 +0200
fixed string cutting in draw.c
Diffstat:
M draw.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/draw.c b/draw.c
t@@ -26,7 +26,7 @@ drawtext(const char *text, Bool invert)
{
int x, y, w, h;
static char buf[256];
- unsigned int len;
+ unsigned int len, olen;
XGCValues gcv;
XPoint points[5];
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
t@@ -51,7 +51,7 @@ drawtext(const char *text, Bool invert)
return;
w = 0;
- len = strlen(text);
+ olen = len = strlen(text);
if(len >= sizeof(buf))
len = sizeof(buf) - 1;
memcpy(buf, text, len);
t@@ -64,6 +64,14 @@ drawtext(const char *text, Bool invert)
/* shorten text if necessary */
while(len && (w = textnw(buf, len)) > dc.w - h)
buf[--len] = 0;
+ if(len < olen) {
+ if(len > 3)
+ memcpy(buf + len - 4, "...\0", 4);
+ else if(len > 2)
+ memcpy(buf + len - 3, "..\0", 3);
+ else if(len > 1)
+ memcpy(buf + len - 2, ".\0", 2);
+ }
if(w > dc.w)
return; /* too long */
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.