Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
removed unnecessary Xlib call
[dmenu.git]
/
draw.c
diff --git
a/draw.c
b/draw.c
index
383e130
..
38ae8c3
100644
(file)
--- a/
draw.c
+++ b/
draw.c
@@
-28,7
+28,7
@@
drawtext(const char *text, Bool invert, Bool border)
{
int x, y, w, h;
static char buf[256];
{
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 };
XGCValues gcv;
XPoint points[5];
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
@@
-38,8
+38,6
@@
drawtext(const char *text, Bool invert, Bool border)
w = 0;
if(border) {
w = 0;
if(border) {
- XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
- XSetForeground(dpy, dc.gc, dc.border);
points[0].x = dc.x;
points[0].y = dc.y;
points[1].x = dc.w - 1;
points[0].x = dc.x;
points[0].y = dc.y;
points[1].x = dc.w - 1;
@@
-50,13
+48,14
@@
drawtext(const char *text, Bool invert, Bool border)
points[3].y = 0;
points[4].x = 0;
points[4].y = -(dc.h - 1);
points[3].y = 0;
points[4].x = 0;
points[4].y = -(dc.h - 1);
+ XSetForeground(dpy, dc.gc, dc.border);
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
}
if(!text)
return;
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
}
if(!text)
return;
- len = strlen(text);
+
olen =
len = strlen(text);
if(len >= sizeof(buf))
len = sizeof(buf) - 1;
memcpy(buf, text, len);
if(len >= sizeof(buf))
len = sizeof(buf) - 1;
memcpy(buf, text, len);
@@
-69,6
+68,14
@@
drawtext(const char *text, Bool invert, Bool border)
/* shorten text if necessary */
while(len && (w = textnw(buf, len)) > dc.w - h)
buf[--len] = 0;
/* shorten text if necessary */
while(len && (w = textnw(buf, len)) > dc.w - h)
buf[--len] = 0;
+ if(len < olen) {
+ if(len > 1)
+ buf[len - 1] = '.';
+ if(len > 2)
+ buf[len - 2] = '.';
+ if(len > 3)
+ buf[len - 3] = '.';
+ }
if(w > dc.w)
return; /* too long */
if(w > dc.w)
return; /* too long */