From f527d51747c30c500bc1fa9c4cf5d218a9eb487a Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Fri, 24 Jul 2009 11:21:56 +0430 Subject: [PATCH] term: implement term reset --- term.c | 16 +++++++++++----- vt102.c | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/term.c b/term.c index a525200..69ca26b 100644 --- a/term.c +++ b/term.c @@ -375,12 +375,19 @@ void term_read(void) lazy = 0; } +static void term_reset(void) +{ + row = col = 0; + top = 0; + bot = pad_rows(); + mode = MODE_DEFAULT; + setattr(0); + term_blank(); +} + void term_exec(char *cmd) { memset(term, 0, sizeof(*term)); - term->bot = pad_rows(); - term->cur.mode = term->sav.mode = MODE_DEFAULT; - term_load(term, visible); if ((term->pid = forkpty(&term->fd, NULL, NULL, NULL)) == -1) { perror("failed to fork"); term->fd = 0; @@ -394,8 +401,7 @@ void term_exec(char *cmd) fcntl(term->fd, F_SETFD, fcntl(term->fd, F_GETFD) | FD_CLOEXEC); fcntl(term->fd, F_SETFL, fcntl(term->fd, F_GETFL) | O_NONBLOCK); setsize(); - setattr(0); - term_blank(); + term_reset(); } static void misc_save(struct term_state *state) diff --git a/vt102.c b/vt102.c index 0170489..b8d91da 100644 --- a/vt102.c +++ b/vt102.c @@ -111,6 +111,8 @@ static void escseq(void) advance(1, -col, 1); break; case 'c': /* RIS reset */ + term_reset(); + break; case 'H': /* HTS set tab stop at current column */ case 'Z': /* DECID DEC private ID; return ESC [ ? 6 c (VT102) */ case '#': /* DECALN ("#8") DEC alignment test - fill screen with E's */ -- 2.11.4.GIT