about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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 */
'#n134'>134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225