Show infobar when Ctrl-^ is typed.
This commit is contained in:
@@ -255,6 +255,8 @@ bool STMClient::process_user_input( int fd )
|
|||||||
|
|
||||||
overlays.get_prediction_engine().new_user_byte( the_byte, *local_framebuffer );
|
overlays.get_prediction_engine().new_user_byte( the_byte, *local_framebuffer );
|
||||||
|
|
||||||
|
const static wstring help_message( L"Commands: Ctrl-Z suspends, \".\" quits, \"^\" gives literal Ctrl-^" );
|
||||||
|
|
||||||
if ( quit_sequence_started ) {
|
if ( quit_sequence_started ) {
|
||||||
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */
|
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */
|
||||||
if ( network->has_remote_addr() && (!network->shutdown_in_progress()) ) {
|
if ( network->has_remote_addr() && (!network->shutdown_in_progress()) ) {
|
||||||
@@ -291,11 +293,17 @@ bool STMClient::process_user_input( int fd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
quit_sequence_started = false;
|
quit_sequence_started = false;
|
||||||
|
|
||||||
|
if ( overlays.get_notification_engine().get_notification_string() == help_message ) {
|
||||||
|
overlays.get_notification_engine().set_notification_string( L"" );
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
quit_sequence_started = (the_byte == 0x1E);
|
quit_sequence_started = (the_byte == 0x1E);
|
||||||
if ( quit_sequence_started ) {
|
if ( quit_sequence_started ) {
|
||||||
|
overlays.get_notification_engine().set_notification_string( help_message, true, false );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,8 @@ NotificationEngine::NotificationEngine()
|
|||||||
last_acked_state( timestamp() ),
|
last_acked_state( timestamp() ),
|
||||||
message(),
|
message(),
|
||||||
message_is_network_exception( false ),
|
message_is_network_exception( false ),
|
||||||
message_expiration( -1 )
|
message_expiration( -1 ),
|
||||||
|
show_quit_keystroke( true )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
static std::string human_readable_duration( int num_seconds, const std::string seconds_abbr ) {
|
static std::string human_readable_duration( int num_seconds, const std::string seconds_abbr ) {
|
||||||
@@ -232,16 +233,22 @@ void NotificationEngine::apply( Framebuffer &fb ) const
|
|||||||
explanation = reply_message;
|
explanation = reply_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const static char quit_keystroke[] = " [To quit: Ctrl-^ .]";
|
||||||
|
const static char blank[] = "";
|
||||||
|
|
||||||
|
const char *keystroke_str = show_quit_keystroke ? quit_keystroke : blank;
|
||||||
|
|
||||||
if ( message.empty() && (!time_expired) ) {
|
if ( message.empty() && (!time_expired) ) {
|
||||||
return;
|
return;
|
||||||
} else if ( message.empty() && time_expired ) {
|
} else if ( message.empty() && time_expired ) {
|
||||||
swprintf( tmp, 128, L"mosh: Last %s %s ago. [To quit: Ctrl-^ .]", explanation,
|
swprintf( tmp, 128, L"mosh: Last %s %s ago.%s", explanation,
|
||||||
human_readable_duration( time_elapsed, "seconds" ).c_str() );
|
human_readable_duration( time_elapsed, "seconds" ).c_str(),
|
||||||
|
keystroke_str );
|
||||||
} else if ( (!message.empty()) && (!time_expired) ) {
|
} else if ( (!message.empty()) && (!time_expired) ) {
|
||||||
swprintf( tmp, 128, L"mosh: %ls [To quit: Ctrl-^ .]", message.c_str() );
|
swprintf( tmp, 128, L"mosh: %ls%s", message.c_str(), keystroke_str );
|
||||||
} else {
|
} else {
|
||||||
swprintf( tmp, 128, L"mosh: %ls (%s without %s.) [To quit: Ctrl-^ .]", message.c_str(),
|
swprintf( tmp, 128, L"mosh: %ls (%s without %s.)%s", message.c_str(),
|
||||||
human_readable_duration( time_elapsed, "s" ).c_str(), explanation );
|
human_readable_duration( time_elapsed, "s" ).c_str(), explanation, keystroke_str );
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring string_to_draw( tmp );
|
wstring string_to_draw( tmp );
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ namespace Overlay {
|
|||||||
wstring message;
|
wstring message;
|
||||||
bool message_is_network_exception;
|
bool message_is_network_exception;
|
||||||
uint64_t message_expiration;
|
uint64_t message_expiration;
|
||||||
|
bool show_quit_keystroke;
|
||||||
|
|
||||||
bool server_late( uint64_t ts ) const { return (ts - last_word_from_server) > 6500; }
|
bool server_late( uint64_t ts ) const { return (ts - last_word_from_server) > 6500; }
|
||||||
bool reply_late( uint64_t ts ) const { return (ts - last_acked_state) > 10000; }
|
bool reply_late( uint64_t ts ) const { return (ts - last_acked_state) > 10000; }
|
||||||
@@ -160,7 +161,7 @@ namespace Overlay {
|
|||||||
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
|
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
|
||||||
int wait_time( void ) const;
|
int wait_time( void ) const;
|
||||||
|
|
||||||
void set_notification_string( const wstring &s_message, bool permanent = false )
|
void set_notification_string( const wstring &s_message, bool permanent = false, bool s_show_quit_keystroke = true )
|
||||||
{
|
{
|
||||||
message = s_message;
|
message = s_message;
|
||||||
if ( permanent ) {
|
if ( permanent ) {
|
||||||
@@ -169,6 +170,7 @@ namespace Overlay {
|
|||||||
message_expiration = timestamp() + 1000;
|
message_expiration = timestamp() + 1000;
|
||||||
}
|
}
|
||||||
message_is_network_exception = false;
|
message_is_network_exception = false;
|
||||||
|
show_quit_keystroke = s_show_quit_keystroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_network_exception( const NetworkException &e )
|
void set_network_exception( const NetworkException &e )
|
||||||
|
|||||||
Reference in New Issue
Block a user