From 2edf66c9e9a9fe864b225864bdd4b149fb05077d Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Fri, 4 Feb 2011 01:52:43 -0500 Subject: [PATCH] Treat resize as another Action --- parseraction.cpp | 6 ++++++ parseraction.hpp | 14 ++++++++++++++ termemu.cpp | 3 ++- terminal.hpp | 5 ++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/parseraction.cpp b/parseraction.cpp index d329247..02c927f 100644 --- a/parseraction.cpp +++ b/parseraction.cpp @@ -71,3 +71,9 @@ void UserByte::act_on_terminal( Terminal::Emulator *emu ) emu->dispatch.terminal_to_host.append( emu->user.input( this, emu->fb.ds.application_mode_cursor_keys ) ); } + +void Resize::act_on_terminal( Terminal::Emulator *emu ) +{ + emu->resize( width, height ); + handled = true; +} diff --git a/parseraction.hpp b/parseraction.hpp index fc9a329..3a644e9 100644 --- a/parseraction.hpp +++ b/parseraction.hpp @@ -98,6 +98,20 @@ namespace Parser { UserByte( int s_c ) : c( s_c ) {} }; + + class Resize : public Action { + /* resize event -- not part of the host-source state machine*/ + public: + size_t width, height; + + std::string name( void ) { return std::string( "Resize" ); } + void act_on_terminal( Terminal::Emulator *emu ); + + Resize( size_t s_width, size_t s_height ) + : width( s_width ), + height( s_height ) + {} + }; } #endif diff --git a/termemu.cpp b/termemu.cpp index 1712d9a..2a1957d 100644 --- a/termemu.cpp +++ b/termemu.cpp @@ -207,7 +207,8 @@ void emulate_terminal( int fd, int debug_fd ) } /* tell emulator */ - terminal.resize( window_size.ws_col, window_size.ws_row ); + Parser::Resize r( window_size.ws_col, window_size.ws_row ); + r.act_on_terminal( &terminal ); /* tell child process */ if ( ioctl( fd, TIOCSWINSZ, &window_size ) < 0 ) { diff --git a/terminal.hpp b/terminal.hpp index 83e764e..b61d9d1 100644 --- a/terminal.hpp +++ b/terminal.hpp @@ -24,6 +24,7 @@ namespace Terminal { friend void Parser::OSC_Put::act_on_terminal( Emulator * ); friend void Parser::OSC_End::act_on_terminal( Emulator * ); friend void Parser::UserByte::act_on_terminal( Emulator * ); + friend void Parser::Resize::act_on_terminal( Emulator * ); private: Framebuffer fb; @@ -36,6 +37,7 @@ namespace Terminal { void CSI_dispatch( Parser::CSI_Dispatch *act ); void Esc_dispatch( Parser::Esc_Dispatch *act ); void OSC_end( Parser::OSC_End *act ); + void resize( size_t s_width, size_t s_height ); public: Emulator( size_t s_width, size_t s_height ); @@ -46,9 +48,6 @@ namespace Terminal { std::string open( void ); /* put user cursor keys in application mode */ std::string close( void ); /* restore user cursor keys */ - - void resize( size_t s_width, size_t s_height ); - }; }