summaryrefslogtreecommitdiff
path: root/src/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bar.c')
-rw-r--r--src/bar.c20
1 files changed, 15 insertions, 5 deletions
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. */