Move parser outside of terminal emulator -- prepare for keyboard input

This commit is contained in:
Keith Winstein
2011-02-03 01:59:55 -05:00
parent 7989265fa0
commit 9bca84b3c6
7 changed files with 48 additions and 61 deletions
+4 -28
View File
@@ -10,38 +10,14 @@
using namespace Terminal;
Emulator::Emulator( size_t s_width, size_t s_height )
: parser(), fb( s_width, s_height ), dispatch()
: fb( s_width, s_height ), dispatch()
{}
std::string Emulator::input( char c, int actfd )
std::string Emulator::read_octets_to_host( void )
{
std::string ret = dispatch.terminal_to_host;
dispatch.terminal_to_host.clear();
std::vector<Parser::Action *> vec = parser.input( c );
for ( std::vector<Parser::Action *>::iterator i = vec.begin();
i != vec.end();
i++ ) {
Parser::Action *act = *i;
act->act_on_terminal( this );
/* print out debugging information */
if ( (actfd > 0) && ( !act->handled ) ) {
char actsum[ 64 ];
if ( (typeid( *act ) == typeid( Parser::CSI_Dispatch ))
|| (typeid( *act ) == typeid( Parser::Esc_Dispatch )) ) {
snprintf( actsum, 64, "%s%s ", act->str().c_str(), dispatch.str().c_str() );
} else {
snprintf( actsum, 64, "%s ", act->str().c_str() );
}
swrite( actfd, actsum );
}
delete act;
}
/* the user is supposed to send this string to the host, as if typed */
return dispatch.terminal_to_host;
return ret;
}
void Emulator::execute( Parser::Execute *act )