summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2019-08-05 06:42:02 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2019-08-26 17:28:24 +0100
commit79f09b4d855b2339db2c859266135ab1b6368a61 (patch)
treec5ea8f88c382bdecf9b1b47ece54dc7b27df561d
parente85ea9f67dcecab91599a658ad694d8e08514509 (diff)
Add support for the SD (scroll down) escape sequence, GitHub issue 1861.
-rw-r--r--input.c7
-rw-r--r--screen-write.c25
-rw-r--r--tmux.h3
-rw-r--r--tty-term.c1
-rw-r--r--tty.c44
5 files changed, 76 insertions, 4 deletions
diff --git a/input.c b/input.c
index ff8d7a17..f37f8fd8 100644
--- a/input.c
+++ b/input.c
@@ -244,6 +244,7 @@ enum input_csi_type {
INPUT_CSI_RM,
INPUT_CSI_RM_PRIVATE,
INPUT_CSI_SCP,
+ INPUT_CSI_SD,
INPUT_CSI_SGR,
INPUT_CSI_SM,
INPUT_CSI_SM_PRIVATE,
@@ -270,6 +271,7 @@ static const struct input_table_entry input_csi_table[] = {
{ 'M', "", INPUT_CSI_DL },
{ 'P', "", INPUT_CSI_DCH },
{ 'S', "", INPUT_CSI_SU },
+ { 'T', "", INPUT_CSI_SD },
{ 'X', "", INPUT_CSI_ECH },
{ 'Z', "", INPUT_CSI_CBT },
{ '`', "", INPUT_CSI_HPA },
@@ -1525,6 +1527,11 @@ input_csi_dispatch(struct input_ctx *ictx)
if (n != -1)
screen_write_scrollup(sctx, n, bg);
break;
+ case INPUT_CSI_SD:
+ n = input_get(ictx, 0, 1, 1);
+ if (n != -1)
+ screen_write_scrolldown(sctx, n, bg);
+ break;
case INPUT_CSI_TBC:
switch (input_get(ictx, 0, 0, 0)) {
case -1:
diff --git a/screen-write.c b/screen-write.c
index 98cdf158..66053eaf 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1088,6 +1088,31 @@ screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg)
ctx->scrolled += lines;
}
+/* Scroll down. */
+void
+screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg)
+{
+ struct screen *s = ctx->s;
+ struct grid *gd = s->grid;
+ struct tty_ctx ttyctx;
+ u_int i;
+
+ screen_write_initctx(ctx, &ttyctx);
+ ttyctx.bg = bg;
+
+ if (lines == 0)
+ lines = 1;
+ else if (lines > s->rlower - s->rupper + 1)
+ lines = s->rlower - s->rupper + 1;
+
+ for (i = 0; i < lines; i++)
+ grid_view_scroll_region_down(gd, s->rupper, s->rlower, bg);
+
+ screen_write_collect_flush(ctx, 0);
+ ttyctx.num = lines;
+ tty_write(tty_cmd_scrolldown, &ttyctx);
+}
+
/* Carriage return (cursor to start of line). */
void
screen_write_carriagereturn(struct screen_write_ctx *ctx)
diff --git a/tmux.h b/tmux.h
index 5c10420a..9bf9f933 100644
--- a/tmux.h
+++ b/tmux.h
@@ -422,6 +422,7 @@ enum tty_code_code {
TTYC_REV,
TTYC_RGB,
TTYC_RI,
+ TTYC_RIN,
TTYC_RMACS,
TTYC_RMCUP,
TTYC_RMKX,
@@ -1927,6 +1928,7 @@ void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
void tty_cmd_scrollup(struct tty *, const struct tty_ctx *);
+void tty_cmd_scrolldown(struct tty *, const struct tty_ctx *);
void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
@@ -2303,6 +2305,7 @@ void screen_write_reverseindex(struct screen_write_ctx *, u_int);
void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
void screen_write_linefeed(struct screen_write_ctx *, int, u_int);
void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int);
+void screen_write_scrolldown(struct screen_write_ctx *, u_int, u_int);
void screen_write_carriagereturn(struct screen_write_ctx *);
void screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int);
diff --git a/tty-term.c b/tty-term.c
index eabadf6b..182edd7d 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -242,6 +242,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_REV] = { TTYCODE_STRING, "rev" },
[TTYC_RGB] = { TTYCODE_FLAG, "RGB" },
[TTYC_RI] = { TTYCODE_STRING, "ri" },
+ [TTYC_RIN] = { TTYCODE_STRING, "rin" },
[TTYC_RMACS] = { TTYCODE_STRING, "rmacs" },
[TTYC_RMCUP] = { TTYCODE_STRING, "rmcup" },
[TTYC_RMKX] = { TTYCODE_STRING, "rmkx" },
diff --git a/tty.c b/tty.c
index 024aef27..1658fb74 100644
--- a/tty.c
+++ b/tty.c
@@ -1558,10 +1558,11 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
return;
if (ctx->bigger ||
- !tty_pane_full_width(tty, ctx) ||
+ (!tty_pane_full_width(tty, ctx) && !tty_use_margin(tty)) ||
tty_fake_bce(tty, wp, 8) ||
!tty_term_has(tty->term, TTYC_CSR) ||
- !tty_term_has(tty->term, TTYC_RI) ||
+ (!tty_term_has(tty->term, TTYC_RI) &&
+ !tty_term_has(tty->term, TTYC_RIN)) ||
ctx->wp->sx == 1 ||
ctx->wp->sy == 1) {
tty_redraw_region(tty, ctx);
@@ -1571,10 +1572,13 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
tty_default_attributes(tty, wp, ctx->bg);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
- tty_margin_off(tty);
+ tty_margin_pane(tty, ctx);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
- tty_putcode(tty, TTYC_RI);
+ if (tty_term_has(tty->term, TTYC_RI))
+ tty_putcode(tty, TTYC_RI);
+ else
+ tty_putcode1(tty, TTYC_RIN, 1);
}
void
@@ -1653,6 +1657,38 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx)
}
void
+tty_cmd_scrolldown(struct tty *tty, const struct tty_ctx *ctx)
+{
+ struct window_pane *wp = ctx->wp;
+ u_int i;
+
+ if (ctx->bigger ||
+ (!tty_pane_full_width(tty, ctx) && !tty_use_margin(tty)) ||
+ tty_fake_bce(tty, wp, 8) ||
+ !tty_term_has(tty->term, TTYC_CSR) ||
+ (!tty_term_has(tty->term, TTYC_RI) &&
+ !tty_term_has(tty->term, TTYC_RIN)) ||
+ wp->sx == 1 ||
+ wp->sy == 1) {
+ tty_redraw_region(tty, ctx);
+ return;
+ }
+
+ tty_default_attributes(tty, wp, ctx->bg);
+
+ tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
+ tty_margin_pane(tty, ctx);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
+
+ if (tty_term_has(tty->term, TTYC_RIN))
+ tty_putcode1(tty, TTYC_RIN, ctx->num);
+ else {
+ for (i = 0; i < ctx->num; i++)
+ tty_putcode(tty, TTYC_RI);
+ }
+}
+
+void
tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;