mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-08 01:04:06 +01:00
Implement ECH (erase character, CSI X). Reported by Christian Neukirchen.
This commit is contained in:
parent
bc2e4a36df
commit
44f8e1caff
5
input.c
5
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;
|
||||
|
@ -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)
|
||||
|
3
tmux.h
3
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 *);
|
||||
|
@ -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" },
|
||||
|
17
tty.c
17
tty.c
@ -718,6 +718,23 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
|
||||
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user