Show the escape key properly when server unavailable.

Fixes #624.

Signed-off-by: John Hood <cgull@glup.org>
This commit is contained in:
John Hood
2015-06-08 21:57:08 -04:00
parent 39c8b04c97
commit fc80eaaecf
3 changed files with 10 additions and 2 deletions
+1
View File
@@ -186,6 +186,7 @@ void STMClient::init( void )
tmp = string( escape_key_name_buf ); tmp = string( escape_key_name_buf );
wstring escape_key_name = std::wstring(tmp.begin(), tmp.end()); wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name; escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
overlays.get_notification_engine().set_escape_key_string( tmp );
} }
wchar_t tmp[ 128 ]; wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() ); swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );
+1 -2
View File
@@ -233,10 +233,9 @@ 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 static char blank[] = "";
const char *keystroke_str = show_quit_keystroke ? quit_keystroke : blank; const char *keystroke_str = show_quit_keystroke ? escape_key_string.c_str() : blank;
if ( message.empty() && (!time_expired) ) { if ( message.empty() && (!time_expired) ) {
return; return;
+8
View File
@@ -145,6 +145,7 @@ namespace Overlay {
private: private:
uint64_t last_word_from_server; uint64_t last_word_from_server;
uint64_t last_acked_state; uint64_t last_acked_state;
string escape_key_string;
wstring message; wstring message;
bool message_is_network_exception; bool message_is_network_exception;
uint64_t message_expiration; uint64_t message_expiration;
@@ -174,6 +175,13 @@ namespace Overlay {
show_quit_keystroke = s_show_quit_keystroke; show_quit_keystroke = s_show_quit_keystroke;
} }
void set_escape_key_string( const string &s_name )
{
char tmp[ 128 ];
snprintf( tmp, sizeof tmp, " [To quit: %s .]", s_name.c_str() );
escape_key_string = tmp;
}
void set_network_exception( const std::exception &e ) void set_network_exception( const std::exception &e )
{ {
wchar_t tmp[ 128 ]; wchar_t tmp[ 128 ];