Applied and backported to dmenu as well.

Thank you.
Anselm

2008/8/14 Martin Hurton <[EMAIL PROTECTED]>:
> Here is anothe little patch. No big change, just makes the drawtext()
> function a bit more compact and efficient. Comments are welcome.
>
> Cheers,
> /Martin
>
> diff -r a63cb246f35c dwm.c
> --- a/dwm.c     Thu Aug 14 12:36:49 2008 +0200
> +++ b/dwm.c     Thu Aug 14 15:44:56 2008 +0200
> @@ -576,15 +576,14 @@
>        if(!text)
>                return;
>        olen = strlen(text);
> -       len = MIN(olen, sizeof buf);
> -       memcpy(buf, text, len);
>        h = dc.font.ascent + dc.font.descent;
>        y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
>        x = dc.x + (h / 2);
>        /* shorten text if necessary */
> -       for(; len && (i = textnw(buf, len)) > dc.w - h; len--);
> +       for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; 
> len--);
>        if(!len)
>                return;
> +       memcpy(buf, text, len);
>        if(len < olen)
>                for(i = len; i && i > len - 3; buf[--i] = '.');
>        XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);

Reply via email to