Treat resize as another Action

This commit is contained in:
Keith Winstein
2011-02-04 01:52:43 -05:00
parent c4366234b1
commit 2edf66c9e9
4 changed files with 24 additions and 4 deletions
+6
View File
@@ -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;
}
+14
View File
@@ -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
+2 -1
View File
@@ -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 ) {
+2 -3
View File
@@ -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 );
};
}