summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2002-02-03 00:45:18 +0000
committersabetts <sabetts>2002-02-03 00:45:18 +0000
commitf0d5e1a21cf9798300394563b9107754ad1c62ef (patch)
treecf1e5c7ee48088b92ba2da4e4af8191a4478def0
parent5ca712fc606b1839de5bcbe80833fa9d3a17332d (diff)
downloadratpoison-f0d5e1a21cf9798300394563b9107754ad1c62ef.zip
(marked_message): Fix text marking bug.
-rw-r--r--ChangeLog4
-rw-r--r--src/bar.c20
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 37046a5..4711037 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-02-02 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/bar.c (marked_message): Fix text marking bug.
+
2002-02-01 Shawn Betts <sabetts@vcn.bc.ca>
* src/actions.c (command): bail out if alias recursion gets too deep.
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. */