The branch, master has been updated
       via  44f8e1caffce2e887682c3314ee22becc09e1d3c (commit)
      from  bc2e4a36df2023a738c433779ba8f1e08b6951fe (commit)

- Log -----------------------------------------------------------------
commit 44f8e1caffce2e887682c3314ee22becc09e1d3c
Author: Nicholas Marriott <n...@openbsd.org>
Commit: Nicholas Marriott <n...@openbsd.org>

    Implement ECH (erase character, CSI X). Reported by Christian Neukirchen.
---
 input.c        |    5 +++++
 screen-write.c |   24 ++++++++++++++++++++++++
 tmux.h         |    3 +++
 tty-term.c     |    1 +
 tty.c          |   17 +++++++++++++++++
 5 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/input.c b/input.c
index 71ef3b0..7d26a66 100644
--- a/input.c
+++ b/input.c
@@ -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 ec7d741..4d147b5 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)
diff --git a/tmux.h b/tmux.h
index f1a9e4d..d790dd2 100644
--- a/tmux.h
+++ b/tmux.h
@@ -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 *);
diff --git a/tty-term.c b/tty-term.c
index f088d25..c827a44 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -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" },
diff --git a/tty.c b/tty.c
index 6bc7139..a650c83 100644
--- a/tty.c
+++ b/tty.c
@@ -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) ||


-----------------------------------------------------------------------

Summary of changes:
 input.c        |    5 +++++
 screen-write.c |   24 ++++++++++++++++++++++++
 tmux.h         |    3 +++
 tty-term.c     |    1 +
 tty.c          |   17 +++++++++++++++++
 5 files changed, 50 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to