From b10cf800bd39550a1c69b79cb192ebfadbe8c81d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 29 Nov 2016 00:23:45 +0100 Subject: [PATCH] Restore window titl only if it could be read before --- ChangeLog | 4 ++++ src/fterm.cpp | 32 ++++++++++++++++---------------- src/fterm.h | 4 ++-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4868570..5c8d7572 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-11-29 Markus Gans + * Restore the xterm window title and font + only if it could be read before + 2016-11-27 Markus Gans * Some minor bug fixes * Version 0.3.0 diff --git a/src/fterm.cpp b/src/fterm.cpp index 5d3b407b..8ab3dd9b 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -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 ) { fd_set ifds; @@ -833,21 +831,19 @@ const FString FTerm::getXTermFont() if ( n >= 5 && temp[n-1] == BEL[0] && temp[n] == '\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 ) - return title; + return 0; fd_set ifds; struct timeval tv; @@ -869,14 +865,18 @@ const FString FTerm::getXTermTitle() size_t n = std::strlen(temp); // Esc + \ = OSC string terminator - if ( n >= 4 && temp[n-1] == '\\' && temp[n-2] == ESC[0] ) - temp[n-2] = '\0'; + if ( n >= 2 && temp[n-2] == ESC[0] && temp[n-1] == '\\' ) + { + if ( n < 4 ) + return 0; - title = temp; + temp[n-2] = '\0'; + return new FString(temp); + } } } - return title; + return 0; } //---------------------------------------------------------------------- @@ -913,7 +913,7 @@ const FString FTerm::getXTermColorName (int color) temp[n-1] = '\0'; // 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'; color_str = temp; @@ -3303,8 +3303,8 @@ void FTerm::init() t.c_lflag &= uInt(~(ICANON | ECHO)); tcsetattr (stdin_no, TCSANOW, &t); - xterm_font = new FString(getXTermFont()); - xterm_title = new FString(getXTermTitle()); + xterm_font = getXTermFont(); + xterm_title = getXTermTitle(); t.c_lflag |= uInt(ICANON | ECHO); tcsetattr (stdin_no, TCSADRAIN, &t); diff --git a/src/fterm.h b/src/fterm.h index eb20ea42..4e181f31 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -176,8 +176,8 @@ class FTerm static void detectTermSize(); static void setTermSize (int, int); static void setKDECursor (fc::kdeKonsoleCursorShape); - static const FString getXTermFont(); - static const FString getXTermTitle(); + static FString* getXTermFont(); + static FString* getXTermTitle(); static const FString getXTermColorName (int); static void setXTermCursorStyle (fc::xtermCursorStyle); static void setXTermTitle (const FString&);