User sequences to repaint and quit
This commit is contained in:
@@ -70,11 +70,6 @@ void UserByte::act_on_terminal( Terminal::Emulator *emu ) const
|
||||
{
|
||||
emu->dispatch.terminal_to_host.append( emu->user.input( this,
|
||||
emu->fb.ds.application_mode_cursor_keys ) );
|
||||
/*
|
||||
if ( c == 0x0c ) { // Ctrl-L
|
||||
emu->display.invalidate();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Resize::act_on_terminal( Terminal::Emulator *emu ) const
|
||||
|
||||
+35
-1
@@ -128,11 +128,13 @@ void STMClient::output_new_frame( void )
|
||||
overlays.apply( new_state );
|
||||
|
||||
/* calculate minimal difference from where we are */
|
||||
string diff = Terminal::Display::new_frame( true,
|
||||
string diff = Terminal::Display::new_frame( !repaint_requested,
|
||||
*local_framebuffer,
|
||||
new_state );
|
||||
swrite( STDOUT_FILENO, diff.data(), diff.size() );
|
||||
*local_framebuffer = new_state;
|
||||
|
||||
repaint_requested = false;
|
||||
}
|
||||
|
||||
bool STMClient::process_network_input( void )
|
||||
@@ -161,6 +163,38 @@ bool STMClient::process_user_input( int fd )
|
||||
if ( !network->shutdown_in_progress() ) {
|
||||
for ( int i = 0; i < bytes_read; i++ ) {
|
||||
char the_byte = buf[ i ];
|
||||
|
||||
if ( quit_sequence_started ) {
|
||||
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */
|
||||
if ( network->attached() && (!network->shutdown_in_progress()) ) {
|
||||
overlays.get_notification_engine().set_notification_string( wstring( L"Exiting on user request..." ) );
|
||||
network->start_shutdown();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ( the_byte == '^' ) {
|
||||
/* Emulation sequence to type Ctrl-^ is Ctrl-^ ^ */
|
||||
network->get_current_state().push_back( Parser::UserByte( 0x1E ) );
|
||||
} else {
|
||||
/* Ctrl-^ followed by anything other than . and ^ gets sent literally */
|
||||
network->get_current_state().push_back( Parser::UserByte( 0x1E ) );
|
||||
network->get_current_state().push_back( Parser::UserByte( the_byte ) );
|
||||
}
|
||||
|
||||
quit_sequence_started = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
quit_sequence_started = (the_byte == 0x1E);
|
||||
if ( quit_sequence_started ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( the_byte == 0x0C ) { /* Ctrl-L */
|
||||
repaint_requested = true;
|
||||
}
|
||||
|
||||
network->get_current_state().push_back( Parser::UserByte( the_byte ) );
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -26,6 +26,8 @@ private:
|
||||
Network::Transport< Network::UserStream, Terminal::Complete > *network;
|
||||
uint64_t last_remote_num;
|
||||
|
||||
bool repaint_requested, quit_sequence_started;
|
||||
|
||||
void main_init( void );
|
||||
bool process_network_input( void );
|
||||
bool process_user_input( int fd );
|
||||
@@ -42,7 +44,9 @@ public:
|
||||
local_framebuffer( NULL ),
|
||||
overlays(),
|
||||
network( NULL ),
|
||||
last_remote_num( -1 )
|
||||
last_remote_num( -1 ),
|
||||
repaint_requested( false ),
|
||||
quit_sequence_started( false )
|
||||
{}
|
||||
|
||||
void init( void );
|
||||
|
||||
+2
-2
@@ -140,11 +140,11 @@ void NotificationEngine::render_notification( void )
|
||||
if ( message.empty() && (!time_expired) ) {
|
||||
return;
|
||||
} else if ( message.empty() && time_expired ) {
|
||||
swprintf( tmp, 128, L"[stm] No contact for %.0f seconds.", (double)(now - last_word) / 1000.0 );
|
||||
swprintf( tmp, 128, L"[stm] No contact for %.0f seconds. [To quit: Ctrl-^ .]", (double)(now - last_word) / 1000.0 );
|
||||
} else if ( (!message.empty()) && (!time_expired) ) {
|
||||
swprintf( tmp, 128, L"[stm] %ls", message.c_str() );
|
||||
} else {
|
||||
swprintf( tmp, 128, L"[stm] %ls (No contact for %.0f seconds.)", message.c_str(),
|
||||
swprintf( tmp, 128, L"[stm] %ls [To quit: Ctrl-^ .] (No contact for %.0f seconds.)", message.c_str(),
|
||||
(double)(now - last_word) / 1000.0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace Terminal {
|
||||
class UserInput {
|
||||
private:
|
||||
short last_byte;
|
||||
wchar_t last_byte;
|
||||
|
||||
public:
|
||||
UserInput()
|
||||
|
||||
Reference in New Issue
Block a user