From f0aad68aeef493954d3a840bea134abd22b37c2d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 23 Oct 2011 10:16:14 +0000 Subject: [PATCH] Support for \e[3J to clear the history. Also send the corresponding terminfo code (E3) before locking. --- input.c | 11 +++++++++++ screen-write.c | 11 +++++++++++ server-fn.c | 1 + tmux.h | 2 ++ tty-term.c | 1 + 5 files changed, 26 insertions(+) diff --git a/input.c b/input.c index 9237ef5c..a914aa5a 100644 --- a/input.c +++ b/input.c @@ -1126,6 +1126,17 @@ input_csi_dispatch(struct input_ctx *ictx) case 2: screen_write_clearscreen(sctx); break; + case 3: + switch (input_get(ictx, 1, 0, 0)) { + case 0: + /* + * Linux console extension to clear history + * (for example before locking the screen). + */ + screen_write_clearhistory(sctx); + break; + } + break; default: log_debug("%s: unknown '%c'", __func__, ictx->ch); break; diff --git a/screen-write.c b/screen-write.c index 60623701..d1d02c7c 100644 --- a/screen-write.c +++ b/screen-write.c @@ -985,6 +985,17 @@ screen_write_clearscreen(struct screen_write_ctx *ctx) tty_write(tty_cmd_clearscreen, &ttyctx); } +/* Clear entire history. */ +void +screen_write_clearhistory(struct screen_write_ctx *ctx) +{ + struct screen *s = ctx->s; + struct grid *gd = s->grid; + + grid_move_lines(gd, 0, gd->hsize, gd->sy); + gd->hsize = 0; +} + /* Write cell data. */ void screen_write_cell(struct screen_write_ctx *ctx, diff --git a/server-fn.c b/server-fn.c index e697af77..c8f85cd0 100644 --- a/server-fn.c +++ b/server-fn.c @@ -237,6 +237,7 @@ server_lock_client(struct client *c) tty_stop_tty(&c->tty); tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_SMCUP)); tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_CLEAR)); + tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_E3)); c->flags |= CLIENT_SUSPENDED; server_write_client(c, MSG_LOCK, &lockdata, sizeof lockdata); diff --git a/tmux.h b/tmux.h index a94bbaf9..87bb6852 100644 --- a/tmux.h +++ b/tmux.h @@ -206,6 +206,7 @@ enum tty_code_code { TTYC_DIM, /* enter_dim_mode, mh */ TTYC_DL, /* parm_delete_line, DL */ TTYC_DL1, /* delete_line, dl */ + TTYC_E3, TTYC_EL, /* clr_eol, ce */ TTYC_EL1, /* clr_bol, cb */ TTYC_ENACS, /* ena_acs, eA */ @@ -1866,6 +1867,7 @@ void screen_write_kkeypadmode(struct screen_write_ctx *, int); void screen_write_clearendofscreen(struct screen_write_ctx *); void screen_write_clearstartofscreen(struct screen_write_ctx *); void screen_write_clearscreen(struct screen_write_ctx *); +void screen_write_clearhistory(struct screen_write_ctx *); void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *, const struct utf8_data *); void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); diff --git a/tty-term.c b/tty-term.c index 41cb97c4..201d0e1d 100644 --- a/tty-term.c +++ b/tty-term.c @@ -61,6 +61,7 @@ const struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_DIM, TTYCODE_STRING, "dim" }, { TTYC_DL, TTYCODE_STRING, "dl" }, { TTYC_DL1, TTYCODE_STRING, "dl1" }, + { TTYC_E3, TTYCODE_STRING, "E3" }, { TTYC_EL, TTYCODE_STRING, "el" }, { TTYC_EL1, TTYCODE_STRING, "el1" }, { TTYC_ENACS, TTYCODE_STRING, "enacs" },