From 5c67c969bf41ec0171e3ce139004ce7cd64e74fb Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 29 May 2012 12:16:18 +0200 Subject: [PATCH] vte: add kmscon_vte_reset() This performs a soft reset of the VTE state machine. It does not affect the console that is bound to the VTE, though. Signed-off-by: David Herrmann --- src/vte.c | 26 ++++++++++++++++++++++++++ src/vte.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/vte.c b/src/vte.c index bba0dab..96aadd8 100644 --- a/src/vte.c +++ b/src/vte.c @@ -237,6 +237,32 @@ static void vte_write_debug(struct kmscon_vte *vte, const char *u8, size_t len, #define vte_write_raw(_vte, _u8, _len) \ vte_write_debug((_vte), (_u8), (_len), true, __FILE__, __LINE__) +/* + * Reset VTE state + * This performs a soft reset of the VTE. That is, everything is reset to the + * same state as when the VTE was created. This does not affect the console, + * though. + */ +void kmscon_vte_reset(struct kmscon_vte *vte) +{ + if (!vte) + return; + + vte->flags = 0; + kmscon_utf8_mach_reset(vte->mach); + vte->state = STATE_GROUND; + + vte->cattr.fr = 255; + vte->cattr.fg = 255; + vte->cattr.fb = 255; + vte->cattr.br = 0; + vte->cattr.bg = 0; + vte->cattr.bb = 0; + vte->cattr.bold = 0; + vte->cattr.underline = 0; + vte->cattr.inverse = 0; +} + /* execute control character (C0 or C1) */ static void do_execute(struct kmscon_vte *vte, uint32_t ctrl) { diff --git a/src/vte.h b/src/vte.h index 779fe65..2cd830c 100644 --- a/src/vte.h +++ b/src/vte.h @@ -65,6 +65,7 @@ int kmscon_vte_new(struct kmscon_vte **out, struct kmscon_console *con, void kmscon_vte_ref(struct kmscon_vte *vte); void kmscon_vte_unref(struct kmscon_vte *vte); +void kmscon_vte_reset(struct kmscon_vte *vte); void kmscon_vte_input(struct kmscon_vte *vte, const char *u8, size_t len); void kmscon_vte_handle_keyboard(struct kmscon_vte *vte, const struct uterm_input_event *ev);