Hardcode the terminals which accept "set window title"

terminfo does not have reliable information on this, so we hardcode a whitelist
of terminal type prefixes.  This is the list from Debian's default screenrc,
plus "screen" itself (which also covers tmux).

Closes #172.
Closes #191.
This commit is contained in:
Keegan McAllister
2012-04-16 00:17:53 -04:00
committed by Keith Winstein
parent feb352c809
commit c390ee9b80
3 changed files with 31 additions and 4 deletions
+25 -1
View File
@@ -25,11 +25,13 @@
#include <curses.h>
#include <term.h>
#include <stdlib.h>
#include <string.h>
using namespace Terminal;
Display::Display( bool use_environment )
: has_ech( true ), has_bce( true ), posterize_colors( false )
: has_ech( true ), has_bce( true ), has_title( true ), posterize_colors( false )
{
if ( use_environment ) {
int errret = -2;
@@ -70,6 +72,28 @@ Display::Display( bool use_environment )
has_bce = false;
}
/* Check if we can set the window title and icon name. terminfo does not
have reliable information on this, so we hardcode a whitelist of
terminal type prefixes. This is the list from Debian's default
screenrc, plus "screen" itself (which also covers tmux). */
static const char * const title_term_types[] = {
"xterm", "rxvt", "kterm", "Eterm", "screen"
};
has_title = false;
const char *term_type = getenv( "TERM" );
if ( term_type ) {
for ( size_t i = 0;
i < sizeof( title_term_types ) / sizeof( const char * );
i++ ) {
if ( 0 == strncmp( term_type, title_term_types[ i ],
strlen( title_term_types[ i ] ) ) ) {
has_title = true;
break;
}
}
}
/* posterization disabled because server now only advertises
xterm-256color when client has colors = 256 */
/*