From 73af007db430839de4b6e44eae4448751ee577d8 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Tue, 1 Feb 2011 02:29:54 -0500 Subject: [PATCH] Support "reset" --- terminalframebuffer.cpp | 7 +++++++ terminalframebuffer.hpp | 2 ++ terminalfunctions.cpp | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index 40c7f27..6884817 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -306,3 +306,10 @@ void Framebuffer::delete_cell( int row, int col ) { rows[ row ].delete_cell( col ); } + +void Framebuffer::reset( void ) +{ + int width = ds.get_width(), height = ds.get_height(); + rows = std::deque( height, Row( width ) ); + ds = DrawState( width, height ); +} diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 970091a..43069c7 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -127,6 +127,8 @@ namespace Terminal { void insert_cell( int row, int col ); void delete_cell( int row, int col ); + + void reset( void ); }; } diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index c5682fb..d22eae9 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -439,3 +439,11 @@ void CSI_ECH( Framebuffer *fb, Dispatcher *dispatch ) } static Function func_CSI_ECH( CSI, "X", CSI_ECH ); + +/* reset to initial state */ +void Esc_RIS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) +{ + fb->reset(); +} + +static Function func_Esc_RIS( ESCAPE, "c", Esc_RIS );