Display <> for more windows and highlight if activity.

This commit is contained in:
Nicholas Marriott 2008-06-18 17:14:02 +00:00
parent 6c23e89f48
commit 2d3ea8b5b4
3 changed files with 72 additions and 16 deletions

View File

@ -1,5 +1,7 @@
18 June 2008
* Show arrows at either end of status line when scrolled if more windows
exist. Highlight the arrow if a hidden window has activity or bell.
* Scroll the status line to show the current window if necessary. Also handle
windows smaller than needed better (show a blank status line instead of
hanging or crashing).
@ -492,4 +494,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.123 2008-06-18 16:34:48 nicm Exp $
$Id: CHANGES,v 1.124 2008-06-18 17:14:02 nicm Exp $

4
TODO
View File

@ -82,9 +82,11 @@ accept them all, save to window title
option to pass through to xterm window when switching window
-- For 0.4 --------------------------------------------------------------------
- document status-left/status-right/status-interval
- test and fix wsvt25
- clear EOL etc CANNOT rely on term using the current colour/attr and probably
should not emulate it doing so
- activity/bell should be per-window not per-link? what if it is cur win in
session not being watched?
- document status-left/status-right/status-interval
- enhance paste buffers. per-session buffers, lots of command love

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.27 2008-06-18 16:34:07 nicm Exp $ */
/* $Id: status.c,v 1.28 2008-06-18 17:14:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -39,10 +39,12 @@ status_redraw(struct client *c)
size_t llen, rlen, offset, xx, yy;
size_t size, start, width;
u_char attr, colr;
int larrow, rarrow;
yy = options_get_number(&s->options, "status-lines");
if (c->sy == 0 || yy == 0)
return;
larrow = rarrow = 0;
if (clock_gettime(CLOCK_REALTIME, &c->status_ts) != 0)
fatal("clock_gettime failed");
@ -97,7 +99,10 @@ status_redraw(struct client *c)
* start and just leave off the end.
*/
if (offset + size < xx) {
width = xx - 1;
rarrow = 1;
xx--;
width = xx;
goto draw;
}
@ -106,9 +111,17 @@ 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.
*/
start = offset + size - xx;
width = xx - 1;
larrow = 1;
xx--;
start = offset + size - xx;
if (width > start + xx + 1) { /* + 1, eh? */
rarrow = 1;
start++;
xx--;
}
width = xx;
draw:
/* Begin drawing and move to the starting position. */
screen_redraw_start_client(&ctx, c);
@ -116,24 +129,42 @@ draw:
if (llen != 0) {
screen_redraw_move_cursor(&ctx, 0, yy);
screen_redraw_write_string(&ctx, "%s ", lbuf);
} else
screen_redraw_move_cursor(&ctx, 0, yy);
if (larrow)
ctx.write(ctx.data, TTY_CHARACTER, ' ');
} else {
if (larrow)
screen_redraw_move_cursor(&ctx, 1, yy);
else
screen_redraw_move_cursor(&ctx, 0, yy);
}
/* Draw each character in succession. */
offset = 0;
RB_FOREACH(wl, winlinks, &s->windows) {
text = status_print(s, wl, &attr);
screen_redraw_set_attributes(&ctx, attr, colr);
for (ptr = text; *ptr != '\0'; ptr++) {
if (offset >= start && offset <= start + width)
if (larrow == 1 && offset < start) {
if (session_alert_has(s, wl, WINDOW_ACTIVITY))
larrow = -1;
if (session_alert_has(s, wl, WINDOW_BELL))
larrow = -1;
}
for (ptr = text; *ptr != '\0'; ptr++) {
if (offset >= start && offset < start + width)
ctx.write(ctx.data, TTY_CHARACTER, *ptr);
offset++;
}
xfree(text);
if (rarrow == 1 && offset > start + width) {
if (session_alert_has(s, wl, WINDOW_ACTIVITY))
rarrow = -1;
if (session_alert_has(s, wl, WINDOW_BELL))
rarrow = -1;
}
if (offset <= start + width) {
if (offset < start + width) {
if (offset >= start) {
screen_redraw_set_attributes(&ctx, 0, colr);
ctx.write(ctx.data, TTY_CHARACTER, ' ');
@ -141,16 +172,37 @@ draw:
offset++;
}
if (offset >= start + width)
break;
xfree(text);
}
/* Fill the remaining space if any. */
screen_redraw_set_attributes(&ctx, 0, colr);
while (offset++ < xx)
ctx.write(ctx.data, TTY_CHARACTER, ' ');
if (rlen > 0)
/* Draw the last item. */
if (rlen != 0) {
screen_redraw_move_cursor(&ctx, c->sx - rlen - 1, yy);
screen_redraw_write_string(&ctx, " %s", rbuf);
}
/* Draw the arrows. */
if (larrow != 0) {
if (larrow == -1)
screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
else
screen_redraw_set_attributes(&ctx, 0, colr);
screen_redraw_move_cursor(&ctx, 0, yy);
ctx.write(ctx.data, TTY_CHARACTER, '<');
}
if (rarrow != 0) {
if (rarrow == -1)
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);
ctx.write(ctx.data, TTY_CHARACTER, '>');
}
screen_redraw_stop(&ctx);
return;