Implement DA (device attributes), including writeback to host
This commit is contained in:
+18
-1
@@ -172,12 +172,29 @@ int termemu( int fd, Terminal::Emulator *terminal )
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string terminal_to_host;
|
||||
|
||||
/* feed to terminal */
|
||||
for ( int i = 0; i < bytes_read; i++ ) {
|
||||
terminal->input( buf[ i ] );
|
||||
terminal_to_host.append( terminal->input( buf[ i ] ) );
|
||||
}
|
||||
|
||||
terminal->debug_printout( stdout );
|
||||
|
||||
/* write writeback */
|
||||
ssize_t total_bytes_written = 0;
|
||||
ssize_t bytes_to_write = terminal_to_host.length();
|
||||
const char *str = terminal_to_host.c_str();
|
||||
while ( total_bytes_written < bytes_to_write ) {
|
||||
ssize_t bytes_written = write( fd, str + total_bytes_written,
|
||||
bytes_to_write - total_bytes_written );
|
||||
if ( bytes_written <= 0 ) {
|
||||
perror( "write" );
|
||||
return -1;
|
||||
} else {
|
||||
total_bytes_written += bytes_written;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+9
-2
@@ -38,7 +38,8 @@ Emulator::Emulator( size_t s_width, size_t s_height )
|
||||
cursor_col( 0 ), cursor_row( 0 ),
|
||||
combining_char_col( 0 ), combining_char_row( 0 ),
|
||||
rows( height, Row( width ) ),
|
||||
params(), dispatch_chars(), errors(), parsed_params()
|
||||
params(), dispatch_chars(), terminal_to_host(),
|
||||
errors(), parsed_params()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -48,8 +49,10 @@ Emulator::~Emulator()
|
||||
|
||||
}
|
||||
|
||||
void Emulator::input( char c )
|
||||
std::string Emulator::input( char c )
|
||||
{
|
||||
terminal_to_host.clear();
|
||||
|
||||
std::vector<Parser::Action *> vec = parser.input( c );
|
||||
|
||||
for ( std::vector<Parser::Action *>::iterator i = vec.begin();
|
||||
@@ -61,6 +64,8 @@ void Emulator::input( char c )
|
||||
|
||||
delete act;
|
||||
}
|
||||
|
||||
return terminal_to_host;
|
||||
}
|
||||
|
||||
void Emulator::scroll( int N )
|
||||
@@ -229,6 +234,8 @@ void Emulator::CSI_dispatch( Parser::CSI_Dispatch *act )
|
||||
|| (dispatch_chars == "D")
|
||||
|| (dispatch_chars == "H") ) {
|
||||
CSI_cursormove();
|
||||
} else if ( dispatch_chars == "c" ) {
|
||||
CSI_DA();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -48,6 +48,7 @@ namespace Terminal {
|
||||
std::string params;
|
||||
std::string dispatch_chars;
|
||||
|
||||
std::string terminal_to_host;
|
||||
std::string errors;
|
||||
|
||||
/* action methods */
|
||||
@@ -70,12 +71,13 @@ namespace Terminal {
|
||||
void CSI_EL( void );
|
||||
void CSI_ED( void );
|
||||
void CSI_cursormove( void );
|
||||
void CSI_DA( void );
|
||||
|
||||
public:
|
||||
Emulator( size_t s_width, size_t s_height );
|
||||
~Emulator();
|
||||
|
||||
void input( char c );
|
||||
std::string input( char c );
|
||||
|
||||
void resize( size_t s_width, size_t s_height );
|
||||
|
||||
|
||||
@@ -83,3 +83,8 @@ void Emulator::CSI_cursormove( void )
|
||||
|
||||
newgrapheme();
|
||||
}
|
||||
|
||||
void Emulator::CSI_DA( void )
|
||||
{
|
||||
terminal_to_host.append( "\033[?1;0c" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user