Use shared_ptr and references for Actions.
This slows terminal emulation slightly.
This commit is contained in:
@@ -199,21 +199,19 @@ static int vt_parser( int fd, Parser::UTF8Parser *parser )
|
||||
j != actions.end();
|
||||
j++ ) {
|
||||
|
||||
Parser::Action *act = *j;
|
||||
assert( act );
|
||||
assert( *j );
|
||||
Parser::Action &act = **j;
|
||||
|
||||
if ( act->char_present ) {
|
||||
if ( iswprint( act->ch ) ) {
|
||||
printf( "%s(0x%02x=%lc) ", act->name().c_str(), (unsigned int)act->ch, (wint_t)act->ch );
|
||||
if ( act.char_present ) {
|
||||
if ( iswprint( act.ch ) ) {
|
||||
printf( "%s(0x%02x=%lc) ", act.name().c_str(), (unsigned int)act.ch, (wint_t)act.ch );
|
||||
} else {
|
||||
printf( "%s(0x%02x) ", act->name().c_str(), (unsigned int)act->ch );
|
||||
printf( "%s(0x%02x) ", act.name().c_str(), (unsigned int)act.ch );
|
||||
}
|
||||
} else {
|
||||
printf( "[%s] ", act->name().c_str() );
|
||||
printf( "[%s] ", act.name().c_str() );
|
||||
}
|
||||
|
||||
delete act;
|
||||
|
||||
fflush( stdout );
|
||||
}
|
||||
actions.clear();
|
||||
|
||||
@@ -270,8 +270,7 @@ static void emulate_terminal( int fd )
|
||||
std::string terminal_to_host;
|
||||
|
||||
for ( int i = 0; i < bytes_read; i++ ) {
|
||||
Parser::UserByte ub( buf[ i ] );
|
||||
terminal_to_host += complete.act( &ub );
|
||||
terminal_to_host += complete.act( Parser::UserByte( buf[ i ] ) );
|
||||
}
|
||||
|
||||
if ( swrite( fd, terminal_to_host.c_str(), terminal_to_host.length() ) < 0 ) {
|
||||
@@ -302,8 +301,7 @@ static void emulate_terminal( int fd )
|
||||
}
|
||||
|
||||
/* tell emulator */
|
||||
Parser::Resize r( window_size.ws_col, window_size.ws_row );
|
||||
complete.act( &r );
|
||||
complete.act( Parser::Resize( window_size.ws_col, window_size.ws_row ) );
|
||||
|
||||
/* tell child process */
|
||||
if ( ioctl( fd, TIOCSWINSZ, &window_size ) < 0 ) {
|
||||
|
||||
Reference in New Issue
Block a user