aewl

diff draw.c @ 273:ffc73b32084a

fixed string cutting
author Anselm R.Garbe <arg@10ksloc.org>
date Mon, 14 Aug 2006 10:58:03 +0200
parents bf6792e3e700
children 0ed2de01e9f7
line diff
     1.1 --- a/draw.c	Mon Aug 14 10:49:22 2006 +0200
     1.2 +++ b/draw.c	Mon Aug 14 10:58:03 2006 +0200
     1.3 @@ -65,12 +65,12 @@
     1.4  	while(len && (w = textnw(buf, len)) > dc.w - h)
     1.5  		buf[--len] = 0;
     1.6  	if(len < olen) {
     1.7 +		if(len > 1)
     1.8 +			buf[len - 1] = '.';
     1.9 +		if(len > 2)
    1.10 +			buf[len - 2] = '.';
    1.11  		if(len > 3)
    1.12 -			memcpy(buf + len - 4, "...\0", 4);
    1.13 -		else if(len > 2)
    1.14 -			memcpy(buf + len - 3, "..\0", 3);
    1.15 -		else if(len > 1)
    1.16 -			memcpy(buf + len - 2, ".\0", 2);
    1.17 +			buf[len - 3] = '.';
    1.18  	}
    1.19  
    1.20  	if(w > dc.w)
    1.21 @@ -160,7 +160,7 @@
    1.22  		}
    1.23  	}
    1.24  	dc.x += dc.w;
    1.25 -	dc.w = textw(c->name);
    1.26 +	dc.w = c->tw - dc.x;
    1.27  	drawtext(c->name, !istile);
    1.28  	XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
    1.29  	XSync(dpy, False);