Track icon name and window title separately. Implement MOSH_TITLE_NOPREFIX

This commit is contained in:
Keith Winstein
2012-04-14 01:55:28 -04:00
parent 53f79e4261
commit d0a818d2e2
6 changed files with 72 additions and 14 deletions
+10
View File
@@ -114,6 +114,16 @@ server. Otherwise, \fBmosh\fP will choose a port between 60000 and
The escape sequence to shut down the connection is \fBCtrl-^ .\fP
(typically typed with Ctrl-Shift-6, then a period).
.SH ENVIRONMENT VARIABLES
.TP
.B MOSH_PREDICTION_DISPLAY
Controls local echo as described above.
.TP
.B MOSH_TITLE_NOPREFIX
When set, inhibits prepending "[mosh]" to window title.
.SH SEE ALSO
.BR mosh-client (1),
.BR mosh-server (1).
+3 -1
View File
@@ -79,7 +79,9 @@ void STMClient::init( void )
swrite( STDOUT_FILENO, Terminal::Emulator::open().c_str() );
/* Add our name to window title */
overlays.set_title_prefix( wstring( L"[mosh] " ) );
if ( !getenv( "MOSH_TITLE_NOPREFIX" ) ) {
overlays.set_title_prefix( wstring( L"[mosh] " ) );
}
}
void STMClient::shutdown( void )
+36 -10
View File
@@ -42,19 +42,45 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
frame.append( "\x07" );
}
/* has window title changed? */
/* has icon name or window title changed? */
if ( (!initialized)
|| (f.get_icon_name() != frame.last_frame.get_icon_name())
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) {
/* set window title */
frame.append( "\033]0;" );
const std::deque<wchar_t> &window_title( f.get_window_title() );
for ( BOOST_AUTO( i, window_title.begin() );
i != window_title.end();
i++ ) {
snprintf( tmp, 64, "%lc", *i );
frame.append( tmp );
/* set icon name and window title */
if ( f.get_icon_name() == f.get_window_title() ) {
/* write combined Icon Name and Window Title */
frame.append( "\033]0;" );
const std::deque<wchar_t> &window_title( f.get_window_title() );
for ( BOOST_AUTO( i, window_title.begin() );
i != window_title.end();
i++ ) {
snprintf( tmp, 64, "%lc", *i );
frame.append( tmp );
}
frame.append( "\033\\" );
} else {
/* write Icon Name */
frame.append( "\033]1;" );
const std::deque<wchar_t> &icon_name( f.get_icon_name() );
for ( BOOST_AUTO( i, icon_name.begin() );
i != icon_name.end();
i++ ) {
snprintf( tmp, 64, "%lc", *i );
frame.append( tmp );
}
frame.append( "\033\\" );
frame.append( "\033]2;" );
const std::deque<wchar_t> &window_title( f.get_window_title() );
for ( BOOST_AUTO( i, window_title.begin() );
i != window_title.end();
i++ ) {
snprintf( tmp, 64, "%lc", *i );
frame.append( tmp );
}
frame.append( "\033\\" );
}
frame.append( "\033\\" );
}
/* has reverse video state changed? */
+1 -1
View File
@@ -49,7 +49,7 @@ DrawState::DrawState( int s_width, int s_height )
}
Framebuffer::Framebuffer( int s_width, int s_height )
: rows( s_height, Row( s_width, 0 ) ), window_title(), bell_count( 0 ), ds( s_width, s_height )
: rows( s_height, Row( s_width, 0 ) ), icon_name(), window_title(), bell_count( 0 ), ds( s_width, s_height )
{
assert( s_height > 0 );
assert( s_width > 0 );
+3
View File
@@ -218,6 +218,7 @@ namespace Terminal {
class Framebuffer {
private:
std::deque<Row> rows;
std::deque<wchar_t> icon_name;
std::deque<wchar_t> window_title;
unsigned int bell_count;
@@ -283,7 +284,9 @@ namespace Terminal {
void reset( void );
void soft_reset( void );
void set_icon_name( const std::deque<wchar_t> &s ) { icon_name = s; }
void set_window_title( const std::deque<wchar_t> &s ) { window_title = s; }
const std::deque<wchar_t> & get_icon_name( void ) const { return icon_name; }
const std::deque<wchar_t> & get_window_title( void ) const { return window_title; }
void prefix_window_title( const std::deque<wchar_t> &s );
+19 -2
View File
@@ -506,12 +506,29 @@ static Function func_CSI_DECSTR( CSI, "!p", CSI_DECSTR );
void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb )
{
if ( OSC_string.size() >= 2 ) {
if ( (OSC_string[ 0 ] == L'0')
if ( ( (OSC_string[ 0 ] == L'0')
|| (OSC_string[ 0 ] == L'1')
|| (OSC_string[ 0 ] == L'2') )
&& (OSC_string[ 1 ] == L';') ) {
std::deque<wchar_t> newtitle( OSC_string.begin(), OSC_string.end() );
newtitle.erase( newtitle.begin() );
newtitle.erase( newtitle.begin() );
fb->set_window_title( newtitle );
switch ( OSC_string[ 0 ] ) {
case L'0':
fb->set_icon_name( newtitle );
fb->set_window_title( newtitle );
break;
case L'1':
fb->set_icon_name( newtitle );
break;
case L'2':
fb->set_window_title( newtitle );
break;
default:
break;
}
act->handled = true;
}
}