diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2013-01-15 23:18:55 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2013-01-15 23:18:55 +0000 |
commit | 44f8e1caffce2e887682c3314ee22becc09e1d3c (patch) | |
tree | a63dd217894d16337ba0880077064fadc5e7077f | |
parent | bc2e4a36df2023a738c433779ba8f1e08b6951fe (diff) | |
download | rtmux-44f8e1caffce2e887682c3314ee22becc09e1d3c.tar.gz rtmux-44f8e1caffce2e887682c3314ee22becc09e1d3c.tar.bz2 rtmux-44f8e1caffce2e887682c3314ee22becc09e1d3c.zip |
Implement ECH (erase character, CSI X). Reported by Christian Neukirchen.
-rw-r--r-- | input.c | 5 | ||||
-rw-r--r-- | screen-write.c | 24 | ||||
-rw-r--r-- | tmux.h | 3 | ||||
-rw-r--r-- | tty-term.c | 1 | ||||
-rw-r--r-- | tty.c | 17 |
5 files changed, 50 insertions, 0 deletions
@@ -135,6 +135,7 @@ enum input_csi_type { INPUT_CSI_DECSTBM, INPUT_CSI_DL, INPUT_CSI_DSR, + INPUT_CSI_ECH, INPUT_CSI_ED, INPUT_CSI_EL, INPUT_CSI_HPA, @@ -167,6 +168,7 @@ const struct input_table_entry input_csi_table[] = { { 'L', "", INPUT_CSI_IL }, { 'M', "", INPUT_CSI_DL }, { 'P', "", INPUT_CSI_DCH }, + { 'X', "", INPUT_CSI_ECH }, { 'Z', "", INPUT_CSI_CBT }, { 'c', "", INPUT_CSI_DA }, { 'c', ">", INPUT_CSI_DA_TWO }, @@ -1143,6 +1145,9 @@ input_csi_dispatch(struct input_ctx *ictx) break; } break; + case INPUT_CSI_ECH: + screen_write_clearcharacter(sctx, input_get(ictx, 0, 1, 1)); + break; case INPUT_CSI_DCH: screen_write_deletecharacter(sctx, input_get(ictx, 0, 1, 1)); break; diff --git a/screen-write.c b/screen-write.c index ec7d741e..4d147b5b 100644 --- a/screen-write.c +++ b/screen-write.c @@ -649,6 +649,30 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) tty_write(tty_cmd_deletecharacter, &ttyctx); } +/* Clear nx characters. */ +void +screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx) +{ + struct screen *s = ctx->s; + struct tty_ctx ttyctx; + + if (nx == 0) + nx = 1; + + if (nx > screen_size_x(s) - s->cx) + nx = screen_size_x(s) - s->cx; + if (nx == 0) + return; + + screen_write_initctx(ctx, &ttyctx, 0); + + if (s->cx <= screen_size_x(s) - 1) + grid_view_clear(s->grid, s->cx, s->cy, nx, 1); + + ttyctx.num = nx; + tty_write(tty_cmd_clearcharacter, &ttyctx); +} + /* Insert ny lines. */ void screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) @@ -274,6 +274,7 @@ enum tty_code_code { TTYC_DL, /* parm_delete_line, DL */ TTYC_DL1, /* delete_line, dl */ TTYC_E3, + TTYC_ECH, /* erase_chars, ec */ TTYC_EL, /* clr_eol, ce */ TTYC_EL1, /* clr_bol, cb */ TTYC_ENACS, /* ena_acs, eA */ @@ -1660,6 +1661,7 @@ void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *); void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *); void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); +void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *); void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *); void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); @@ -2049,6 +2051,7 @@ void screen_write_cursorleft(struct screen_write_ctx *, u_int); void screen_write_alignmenttest(struct screen_write_ctx *); void screen_write_insertcharacter(struct screen_write_ctx *, u_int); void screen_write_deletecharacter(struct screen_write_ctx *, u_int); +void screen_write_clearcharacter(struct screen_write_ctx *, u_int); void screen_write_insertline(struct screen_write_ctx *, u_int); void screen_write_deleteline(struct screen_write_ctx *, u_int); void screen_write_clearline(struct screen_write_ctx *); @@ -62,6 +62,7 @@ const struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_DL, TTYCODE_STRING, "dl" }, { TTYC_DL1, TTYCODE_STRING, "dl1" }, { TTYC_E3, TTYCODE_STRING, "E3" }, + { TTYC_ECH, TTYCODE_STRING, "ech" }, { TTYC_EL, TTYCODE_STRING, "el" }, { TTYC_EL1, TTYCODE_STRING, "el1" }, { TTYC_ENACS, TTYCODE_STRING, "enacs" }, @@ -719,6 +719,23 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) } void +tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx) +{ + u_int i; + + tty_reset(tty); + + tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); + + if (tty_term_has(tty->term, TTYC_ECH)) + tty_putcode1(tty, TTYC_ECH, ctx->num); + else { + for (i = 0; i < ctx->num; i++) + tty_putc(tty, ' '); + } +} + +void tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) { if (!tty_pane_full_width(tty, ctx) || |