Restore window titl only if it could be read before

This commit is contained in:
Markus Gans 2016-11-29 00:23:45 +01:00
parent 4012cdb7b0
commit b10cf800bd
3 changed files with 22 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2016-11-29 Markus Gans <guru.mail@muenster.de>
* Restore the xterm window title and font
only if it could be read before
2016-11-27 Markus Gans <guru.mail@muenster.de> 2016-11-27 Markus Gans <guru.mail@muenster.de>
* Some minor bug fixes * Some minor bug fixes
* Version 0.3.0 * Version 0.3.0

View File

@ -802,10 +802,8 @@ void FTerm::setKDECursor (fc::kdeKonsoleCursorShape style)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString FTerm::getXTermFont() FString* FTerm::getXTermFont()
{ {
FString font("");
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
fd_set ifds; fd_set ifds;
@ -833,21 +831,19 @@ const FString FTerm::getXTermFont()
if ( n >= 5 && temp[n-1] == BEL[0] && temp[n] == '\0' ) if ( n >= 5 && temp[n-1] == BEL[0] && temp[n] == '\0' )
temp[n-1] = '\0'; temp[n-1] = '\0';
font = temp; return new FString(temp);
} }
} }
} }
return font; return 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString FTerm::getXTermTitle() FString* FTerm::getXTermTitle()
{ {
FString title("");
if ( kde_konsole ) if ( kde_konsole )
return title; return 0;
fd_set ifds; fd_set ifds;
struct timeval tv; struct timeval tv;
@ -869,14 +865,18 @@ const FString FTerm::getXTermTitle()
size_t n = std::strlen(temp); size_t n = std::strlen(temp);
// Esc + \ = OSC string terminator // Esc + \ = OSC string terminator
if ( n >= 4 && temp[n-1] == '\\' && temp[n-2] == ESC[0] ) if ( n >= 2 && temp[n-2] == ESC[0] && temp[n-1] == '\\' )
{
if ( n < 4 )
return 0;
temp[n-2] = '\0'; temp[n-2] = '\0';
return new FString(temp);
title = temp; }
} }
} }
return title; return 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -913,7 +913,7 @@ const FString FTerm::getXTermColorName (int color)
temp[n-1] = '\0'; temp[n-1] = '\0';
// Esc + \ = OSC string terminator (mintty) // Esc + \ = OSC string terminator (mintty)
if ( n >= 6 && temp[n-1] == '\\' && temp[n-2] == ESC[0] ) if ( n >= 6 && temp[n-2] == ESC[0] && temp[n-1] == '\\' )
temp[n-2] = '\0'; temp[n-2] = '\0';
color_str = temp; color_str = temp;
@ -3303,8 +3303,8 @@ void FTerm::init()
t.c_lflag &= uInt(~(ICANON | ECHO)); t.c_lflag &= uInt(~(ICANON | ECHO));
tcsetattr (stdin_no, TCSANOW, &t); tcsetattr (stdin_no, TCSANOW, &t);
xterm_font = new FString(getXTermFont()); xterm_font = getXTermFont();
xterm_title = new FString(getXTermTitle()); xterm_title = getXTermTitle();
t.c_lflag |= uInt(ICANON | ECHO); t.c_lflag |= uInt(ICANON | ECHO);
tcsetattr (stdin_no, TCSADRAIN, &t); tcsetattr (stdin_no, TCSADRAIN, &t);

View File

@ -176,8 +176,8 @@ class FTerm
static void detectTermSize(); static void detectTermSize();
static void setTermSize (int, int); static void setTermSize (int, int);
static void setKDECursor (fc::kdeKonsoleCursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static const FString getXTermFont(); static FString* getXTermFont();
static const FString getXTermTitle(); static FString* getXTermTitle();
static const FString getXTermColorName (int); static const FString getXTermColorName (int);
static void setXTermCursorStyle (fc::xtermCursorStyle); static void setXTermCursorStyle (fc::xtermCursorStyle);
static void setXTermTitle (const FString&); static void setXTermTitle (const FString&);