From f0d5e1a21cf9798300394563b9107754ad1c62ef Mon Sep 17 00:00:00 2001 From: sabetts Date: Sun, 3 Feb 2002 00:45:18 +0000 Subject: (marked_message): Fix text marking bug. --- src/bar.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bar.c b/src/bar.c index 617eee2..62d99fd 100644 --- a/src/bar.c +++ b/src/bar.c @@ -231,23 +231,33 @@ marked_message (char *msg, int mark_start, int mark_end) { int start; int end; + int width; - start = XTextWidth (defaults.font, msg, mark_start) + defaults.bar_x_padding; - end = XTextWidth (defaults.font, msg + mark_start, mark_end - mark_start) + defaults.bar_x_padding; + if (mark_start == 0) + start = 0; + else + start = XTextWidth (defaults.font, msg, mark_start) + defaults.bar_x_padding; - PRINT_DEBUG ("%d %d strlen(%d)==> %d %d\n", mark_start, mark_end, strlen(msg), start, end); + if (mark_end == strlen (msg)) + end = XTextWidth (defaults.font, msg, mark_end) + defaults.bar_x_padding * 2; + else + end = XTextWidth (defaults.font, msg, mark_end) + defaults.bar_x_padding; + + width = end - start; + + PRINT_DEBUG ("start = %d, end = %d, width = %d\n", start, end, width); lgv.foreground = current_screen()->fg_color; lgv.function = GXxor; mask = GCForeground | GCFunction; lgc = XCreateGC(dpy, s->root, mask, &lgv); - XFillRectangle (dpy, s->bar_window, lgc, start, 0, end, height); + XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); lgv.foreground = s->bg_color; lgc = XCreateGC(dpy, s->root, mask, &lgv); - XFillRectangle (dpy, s->bar_window, lgc, start, 0, end, height); + XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); } /* Keep a record of the message. */ -- cgit v1.2.3