Treat empty OSC number as zero.

For interoperability's sake, accept OSCs of the form ESC];title^G
treating them the same as ESC]0;title^G

Signed-off-by: sqweek <sqweek@gmail.com>
This commit is contained in:
sqweek
2013-01-18 20:48:51 +08:00
committed by Keith Winstein
parent 1ee95974bc
commit 13a16332d4
+21 -23
View File
@@ -526,29 +526,27 @@ static Function func_CSI_DECSTR( CSI, "!p", CSI_DECSTR );
/* xterm uses an Operating System Command to set the window title */ /* xterm uses an Operating System Command to set the window title */
void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb ) void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb )
{ {
if ( OSC_string.size() >= 2 ) { if ( OSC_string.size() >= 1 ) {
if ( ( (OSC_string[ 0 ] == L'0') long cmd_num = -1;
|| (OSC_string[ 0 ] == L'1') int offset = 0;
|| (OSC_string[ 0 ] == L'2') ) if ( OSC_string[ 0 ] == L';' ) {
&& (OSC_string[ 1 ] == L';') ) { /* OSC of the form "\033];<title>\007" */
std::deque<wchar_t> newtitle( OSC_string.begin(), OSC_string.end() ); cmd_num = 0; /* treat it as as a zero */
newtitle.erase( newtitle.begin() ); offset = 1;
newtitle.erase( newtitle.begin() ); } else if ( (OSC_string.size() >= 2) && (OSC_string[ 1 ] == L';') ) {
/* OSC of the form "\033]X;<title>\007" where X can be:
switch ( OSC_string[ 0 ] ) { * 0: set icon name and window title
case L'0': * 1: set icon name
fb->set_icon_name( newtitle ); * 2: set window title */
fb->set_window_title( newtitle ); cmd_num = OSC_string[ 0 ] - L'0';
break; offset = 2;
case L'1': }
fb->set_icon_name( newtitle ); bool set_icon = (cmd_num == 0 || cmd_num == 1);
break; bool set_title = (cmd_num == 0 || cmd_num == 2);
case L'2': if ( set_icon || set_title ) {
fb->set_window_title( newtitle ); std::deque<wchar_t> newtitle( OSC_string.begin() + offset, OSC_string.end() );
break; if ( set_icon ) { fb->set_icon_name( newtitle ); }
default: if ( set_title ) { fb->set_window_title( newtitle ); }
break;
}
act->handled = true; act->handled = true;
} }