about summary refs log tree commit diff stats
path: root/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/draw.c b/draw.c
index 3b6967c..6edb0a3 100644
--- a/draw.c
+++ b/draw.c
@@ -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 };
@@ -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);
@@ -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 */
' href='/acidbong/suckless/dwm/commit/config.mk?h=2.2&id=ecc95c903ba6c9a548588a79c1093e6372555f2c'>ecc95c9 ^
12b1d43 ^


d7e1708 ^
95766d6 ^
1076f2b
95766d6 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25