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:
committed by
Keith Winstein
parent
feb352c809
commit
c390ee9b80
@@ -42,9 +42,10 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* has icon name or window title changed? */
|
/* has icon name or window title changed? */
|
||||||
if ( (!initialized)
|
if ( has_title &&
|
||||||
|
( (!initialized)
|
||||||
|| (f.get_icon_name() != frame.last_frame.get_icon_name())
|
|| (f.get_icon_name() != frame.last_frame.get_icon_name())
|
||||||
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) {
|
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) ) {
|
||||||
/* set icon name and window title */
|
/* set icon name and window title */
|
||||||
if ( f.get_icon_name() == f.get_window_title() ) {
|
if ( f.get_icon_name() == f.get_window_title() ) {
|
||||||
/* write combined Icon Name and Window Title */
|
/* write combined Icon Name and Window Title */
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ namespace Terminal {
|
|||||||
|
|
||||||
bool has_bce; /* erases result in cell filled with background color */
|
bool has_bce; /* erases result in cell filled with background color */
|
||||||
|
|
||||||
|
bool has_title; /* supports window title and icon name */
|
||||||
|
|
||||||
int posterize_colors; /* downsample input colors >8 to [0..7] */
|
int posterize_colors; /* downsample input colors >8 to [0..7] */
|
||||||
|
|
||||||
void put_cell( bool initialized, FrameState &frame, const Framebuffer &f ) const;
|
void put_cell( bool initialized, FrameState &frame, const Framebuffer &f ) const;
|
||||||
|
|||||||
@@ -25,11 +25,13 @@
|
|||||||
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
using namespace Terminal;
|
using namespace Terminal;
|
||||||
|
|
||||||
Display::Display( bool use_environment )
|
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 ) {
|
if ( use_environment ) {
|
||||||
int errret = -2;
|
int errret = -2;
|
||||||
@@ -70,6 +72,28 @@ Display::Display( bool use_environment )
|
|||||||
has_bce = false;
|
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
|
/* posterization disabled because server now only advertises
|
||||||
xterm-256color when client has colors = 256 */
|
xterm-256color when client has colors = 256 */
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user