diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-03-20 11:01:01 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-03-20 11:01:01 +0000 |
commit | 6cc19c0e25db197e4936c72bccee94fe437fd774 (patch) | |
tree | 3bc3b8a5f842c010724d87cf9f042c1814e37f59 /usr.bin/tmux/input.c | |
parent | c99c9ef7592d38921c978efcf49a95e63665b991 (diff) |
Add a simple form of output rate limiting by counting the number of
certain C0 sequences (linefeeds, backspaces, carriage returns) and if it
exceeds a threshold (current default 50/millisecond), start to redraw
the pane every 100 milliseconds instead of making each change as it
comes. Two configuration options - c0-change-trigger and
c0-change-interval.
This makes tmux much more responsive under very fast output (for example
yes(1) or accidentally cat'ing a large file) but may not be perfect on
all terminals and connections - feedback very welcome, particularly
where this change has a negative rather than positive effect (making it
off by default is a possibility).
After much experimentation based originally on a request Robin Lee
Powell (which ended with a completely different solution), this idea
from discussion with Ailin Nemui.
Diffstat (limited to 'usr.bin/tmux/input.c')
-rw-r--r-- | usr.bin/tmux/input.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index bf0eb618855..5ff90241da3 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.50 2012/03/15 10:05:49 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.51 2012/03/20 11:01:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -908,6 +908,7 @@ input_c0_dispatch(struct input_ctx *ictx) struct screen_write_ctx *sctx = &ictx->ctx; struct window_pane *wp = ictx->wp; struct screen *s = sctx->s; + u_int trigger; log_debug("%s: '%c", __func__, ictx->ch); @@ -919,7 +920,7 @@ input_c0_dispatch(struct input_ctx *ictx) break; case '\010': /* BS */ screen_write_backspace(sctx); - break; + goto count_c0; case '\011': /* HT */ /* Don't tab beyond the end of the line. */ if (s->cx >= screen_size_x(s) - 1) @@ -936,10 +937,10 @@ input_c0_dispatch(struct input_ctx *ictx) case '\013': /* VT */ case '\014': /* FF */ screen_write_linefeed(sctx, 0); - break; + goto count_c0; case '\015': /* CR */ screen_write_carriagereturn(sctx); - break; + goto count_c0; case '\016': /* SO */ ictx->cell.attr |= GRID_ATTR_CHARSET; break; @@ -952,6 +953,15 @@ input_c0_dispatch(struct input_ctx *ictx) } return (0); + +count_c0: + trigger = options_get_number(&wp->window->options, "c0-change-trigger"); + if (++wp->changes == trigger) { + wp->flags |= PANE_DROP; + window_pane_timer_start(wp); + } + + return (0); } /* Execute escape sequence. */ |