From 7475165cd87d443da34da11298e638d3d17f43e9 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Feb 2017 15:49:29 +0000 Subject: Some other tidying bits. --- input.c | 1 - 1 file changed, 1 deletion(-) (limited to 'input.c') diff --git a/input.c b/input.c index 26eb1686..04dc8ce1 100644 --- a/input.c +++ b/input.c @@ -920,7 +920,6 @@ input_parse(struct window_pane *wp) /* Split the parameter list (if any). */ static int input_split(struct input_ctx *ictx) - { const char *errstr; char *ptr, *out; -- cgit From 13a0b6bb3fe05454cace81f5ec7624f6fd9021a5 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Feb 2017 16:45:18 +0000 Subject: Collect sequences of printable ASCII characters and process them together instead of handling them one by one. This is significantly faster. Sequences are terminated when we reach the end of the line, fill the internal buffer, or a different character is seen by the input parser (an escape sequence, or UTF-8). Rather than writing collected sequences out immediately, hold them until it is necessary (another screen modification, or we consume all available data). This means we can discard changes that would have no effect (for example, lines that would just be scrolled off the screen or cleared). This reduces the total amount of data we write out to the terminal - not important for fast terminals, but a big help with slow (like xterm). --- input.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'input.c') diff --git a/input.c b/input.c index 04dc8ce1..d5b8737d 100644 --- a/input.c +++ b/input.c @@ -895,6 +895,16 @@ input_parse(struct window_pane *wp) fatalx("no transition from state"); } + /* + * Any state except print stops the current collection. This is + * an optimization to avoid checking if the attributes have + * changed for every character. It will stop unnecessarily for + * sequences that don't make a terminal change, but they should + * be the minority. + */ + if (itr->handler != input_print) + screen_write_collect_end(&ictx->ctx); + /* * Execute the handler, if any. Don't switch state if it * returns non-zero. @@ -1020,7 +1030,7 @@ input_print(struct input_ctx *ictx) ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET; utf8_set(&ictx->cell.cell.data, ictx->ch); - screen_write_cell(&ictx->ctx, &ictx->cell.cell); + screen_write_collect_add(&ictx->ctx, &ictx->cell.cell); ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET; -- cgit From e100d465daefd20da0bb5eea87c4b4896badff16 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Feb 2017 17:31:09 +0000 Subject: Add support for scroll up escape sequence (CSI S) and use it when possible instead of sending individual line feeds. --- input.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'input.c') diff --git a/input.c b/input.c index d5b8737d..b96ac7ef 100644 --- a/input.c +++ b/input.c @@ -222,6 +222,7 @@ enum input_csi_type { INPUT_CSI_SGR, INPUT_CSI_SM, INPUT_CSI_SM_PRIVATE, + INPUT_CSI_SU, INPUT_CSI_TBC, INPUT_CSI_VPA, INPUT_CSI_WINOPS, @@ -243,6 +244,7 @@ static const struct input_table_entry input_csi_table[] = { { 'L', "", INPUT_CSI_IL }, { 'M', "", INPUT_CSI_DL }, { 'P', "", INPUT_CSI_DCH }, + { 'S', "", INPUT_CSI_SU }, { 'X', "", INPUT_CSI_ECH }, { 'Z', "", INPUT_CSI_CBT }, { 'c', "", INPUT_CSI_DA }, @@ -1413,6 +1415,9 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_SM_PRIVATE: input_csi_dispatch_sm_private(ictx); break; + case INPUT_CSI_SU: + screen_write_scrollup(sctx, input_get(ictx, 0, 1, 1)); + break; case INPUT_CSI_TBC: switch (input_get(ictx, 0, 0, 0)) { case 0: -- cgit