aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-18 17:28:17 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-18 17:28:17 +0000
commitf9dedfcccac39efbf4d6aee8a24259ca3470f9af (patch)
treee5d90c40cd100705833a104338299a83c11ba69b
parent2d3ea8b5b4d1f529ab0084943a416e8d39eb820c (diff)
downloadrtmux-f9dedfcccac39efbf4d6aee8a24259ca3470f9af.tar.gz
rtmux-f9dedfcccac39efbf4d6aee8a24259ca3470f9af.tar.bz2
rtmux-f9dedfcccac39efbf4d6aee8a24259ca3470f9af.zip
Fix a couple of bugs. Handle 0 width properly (w/o overflow), and draw left < in the right place.
-rw-r--r--status.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/status.c b/status.c
index 1420c850..2e2069dc 100644
--- a/status.c
+++ b/status.c
@@ -1,4 +1,4 @@
-/* $Id: status.c,v 1.28 2008-06-18 17:14:02 nicm Exp $ */
+/* $Id: status.c,v 1.29 2008-06-18 17:28:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -99,8 +99,10 @@ status_redraw(struct client *c)
* start and just leave off the end.
*/
if (offset + size < xx) {
- rarrow = 1;
- xx--;
+ if (xx > 0) {
+ rarrow = 1;
+ xx--;
+ }
width = xx;
goto draw;
@@ -111,11 +113,13 @@ status_redraw(struct client *c)
* are xx characters to fill, and offset + size must be the last. So,
* the start character is offset + size - xx.
*/
- larrow = 1;
- xx--;
+ if (xx > 0) {
+ larrow = 1;
+ xx--;
+ }
start = offset + size - xx;
- if (width > start + xx + 1) { /* + 1, eh? */
+ if (xx > 0 && width > start + xx + 1) { /* + 1, eh? */
rarrow = 1;
start++;
xx--;
@@ -123,6 +127,10 @@ status_redraw(struct client *c)
width = xx;
draw:
+ /* Bail here if anything is too small too. XXX. */
+ if (width == 0 || xx == 0)
+ goto blank;
+
/* Begin drawing and move to the starting position. */
screen_redraw_start_client(&ctx, c);
screen_redraw_set_attributes(&ctx, 0, colr);
@@ -192,7 +200,10 @@ draw:
screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
else
screen_redraw_set_attributes(&ctx, 0, colr);
- screen_redraw_move_cursor(&ctx, 0, yy);
+ if (llen != 0)
+ screen_redraw_move_cursor(&ctx, llen + 1, yy);
+ else
+ screen_redraw_move_cursor(&ctx, 0, yy);
ctx.write(ctx.data, TTY_CHARACTER, '<');
}
if (rarrow != 0) {
@@ -200,7 +211,10 @@ draw:
screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
else
screen_redraw_set_attributes(&ctx, 0, colr);
- screen_redraw_move_cursor(&ctx, c->sx - rlen - 2, yy);
+ if (rlen != 0)
+ screen_redraw_move_cursor(&ctx, c->sx - rlen - 2, yy);
+ else
+ screen_redraw_move_cursor(&ctx, c->sx - 1, yy);
ctx.write(ctx.data, TTY_CHARACTER, '>');
}