Bug fixing in FString and FTermDetection

This commit is contained in:
Markus Gans 2021-06-06 00:07:39 +02:00
parent 7d426ae25c
commit e38d604544
15 changed files with 259 additions and 226 deletions

View File

@ -1,3 +1,6 @@
2021-06-06 Markus Gans <guru.mail@muenster.de>
* Bug fixing in FString and FTermDetection
2021-06-03 Markus Gans <guru.mail@muenster.de>
* Some FString optimizations

View File

@ -190,7 +190,7 @@ void RotoZoomer::generateReport()
finalcut::FStringStream rep;
dimension_str << getDesktopWidth()
<< "x" << getDesktopHeight();
int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
auto elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
time_str << double(elapsed_ms) / 1000 << "s";
fps_str << double(loops) * 1000.0 / double(elapsed_ms);

View File

@ -141,7 +141,7 @@ bool FLabel::setEnable (bool enable)
void FLabel::setText (const FString& txt)
{
text.setString(txt);
multiline_text = text.split("\r\n");
multiline_text = text.split("\n");
if ( int(multiline_text.size()) > 1 )
multiline = true;

View File

@ -460,10 +460,7 @@ long FString::toLong() const
const FString s{trim()};
const wchar_t* p = s.string.c_str();
if ( ! p )
throw std::invalid_argument ("null value");
if ( ! *p )
if ( s.isEmpty() )
throw std::invalid_argument ("empty value");
if ( *p == L'-' )
@ -513,10 +510,7 @@ uLong FString::toULong() const
const FString s{trim()};
const wchar_t* p = s.string.c_str();
if ( ! p )
throw std::invalid_argument ("null value");
if ( ! *p )
if ( s.isEmpty() )
throw std::invalid_argument ("empty value");
if ( *p == L'-' )
@ -612,14 +606,15 @@ FString FString::rtrim() const
if ( isEmpty() )
return *this;
const auto first = string.begin();
auto iter = string.end() - 1;
const auto r_end = string.rend();
auto r_iter = string.rbegin();
while ( iter != first && std::iswspace(std::wint_t(*iter)) )
--iter;
while ( r_iter != r_end && std::iswspace(std::wint_t(*r_iter)) )
++r_iter;
if ( first != iter )
return std::wstring(first, iter + 1);
if ( r_iter != r_end )
return std::wstring( make_reverse_iterator(r_end)
, make_reverse_iterator(r_iter) );
else
return {};
}

View File

@ -2166,8 +2166,8 @@ bool FTerm::init_terminal() const
initBaudRate();
// Terminal detection
FTermDetection::detect();
const auto& term_detection = FTerm::getFTermDetection();
auto& term_detection = FTerm::getFTermDetection();
term_detection.detect();
setTermType (term_detection.getTermType());
return true;
}

View File

@ -50,27 +50,6 @@
namespace finalcut
{
// static class attributes
FTermDetection::FTerminalType FTermDetection::terminal_type{};
FTermDetection::colorEnv FTermDetection::color_env{};
FTermDetection::kittyVersion FTermDetection::kitty_version{};
FTermDetection::secondaryDA FTermDetection::secondary_da{};
char FTermDetection::termtype[256]{};
char FTermDetection::ttytypename[256]{};
bool FTermDetection::decscusr_support{};
bool FTermDetection::terminal_detection{};
bool FTermDetection::color256{};
const FString* FTermDetection::answer_back{nullptr};
const FString* FTermDetection::sec_da{nullptr};
int FTermDetection::gnome_terminal_id{};
#if DEBUG
char FTermDetection::termtype_256color[256]{};
char FTermDetection::termtype_Answerback[256]{};
char FTermDetection::termtype_SecDA[256]{};
#endif // DEBUG
//----------------------------------------------------------------------
// class FTermDetection
//----------------------------------------------------------------------
@ -105,13 +84,13 @@ FTermDetection::~FTermDetection() // destructor
// public methods of FTermDetection
//----------------------------------------------------------------------
#if DEBUG
const FString& FTermDetection::getAnswerbackString()
const FString& FTermDetection::getAnswerbackString() const
{
return ( answer_back ) ? *answer_back : fc::emptyFString::get();
}
//----------------------------------------------------------------------
const FString& FTermDetection::getSecDAString()
const FString& FTermDetection::getSecDAString() const
{
return ( sec_da ) ? *sec_da : fc::emptyFString::get();
}
@ -330,9 +309,9 @@ void FTermDetection::termtypeAnalysis()
if ( std::strncmp(termtype, "screen", 6) == 0 )
{
terminal_type.screen = true;
std::string tmux = std::getenv("TMUX");
auto tmux = std::getenv("TMUX");
if ( tmux.length() != 0 )
if ( tmux && tmux[0] != '\0' )
terminal_type.tmux = true;
}
@ -452,7 +431,7 @@ bool FTermDetection::get256colorEnvString()
color_env.string5 = std::getenv("KONSOLE_DBUS_SESSION");
color_env.string6 = std::getenv("KONSOLE_DCOP");
color_env.string7 = std::getenv("COLORFGBG");
color_env.string7 = std::getenv("KITTY_WINDOW_ID");
color_env.string8 = std::getenv("KITTY_WINDOW_ID");
if ( color_env.string1 != nullptr
|| color_env.string2 != nullptr
@ -780,7 +759,7 @@ int FTermDetection::str2int (const FString& s)
constexpr int ERROR = -1;
if ( ! s )
if ( s.isEmpty() )
return ERROR;
try

View File

@ -225,7 +225,7 @@ void FTextView::insert (const FString& str, int pos)
else
s = FString{str}.rtrim().expandTabs(FTerm::getTabstop());
auto text_split = s.split("\r\n");
auto text_split = s.split("\n");
for (auto&& line : text_split) // Line loop
{
@ -274,13 +274,27 @@ void FTextView::insert (const FString& str, int pos)
//----------------------------------------------------------------------
void FTextView::replaceRange (const FString& str, int from, int to)
{
try
{
deleteRange (from, to);
}
catch (const std::out_of_range&)
{
throw std::out_of_range(""); // Invalid range
}
insert(str, from);
}
//----------------------------------------------------------------------
void FTextView::deleteRange (int from, int to)
{
if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
return;
throw std::out_of_range(""); // Invalid range
auto iter = data.begin();
data.erase (iter + from, iter + to + 1);
insert(str, from);
}
//----------------------------------------------------------------------

View File

@ -79,7 +79,12 @@ class FTermDetection final
uInt8 : 3; // padding bits
};
struct kittyVersion; // forward declaration
struct kittyVersion
{
int primary{0};
int secondary{0};
};
// Constructors
FTermDetection();
@ -94,138 +99,77 @@ class FTermDetection final
FTermDetection& operator = (const FTermDetection&) = delete;
// Accessor
static FString getClassName();
static const char* getTermType();
static int getGnomeTerminalID();
static kittyVersion getKittyVersion();
FString getClassName() const;
const char* getTermType() const;
int getGnomeTerminalID() const;
kittyVersion getKittyVersion() const;
FTerminalType& getTermTypeStruct();
#if DEBUG
static const FString& getAnswerbackString();
static const FString& getSecDAString();
static const char* getTermType_256color();
static const char* getTermType_Answerback();
static const char* getTermType_SecDA();
const FString& getAnswerbackString() const;
const FString& getSecDAString() const;
const char* getTermType_256color() const;
const char* getTermType_Answerback() const;
const char* getTermType_SecDA() const;
#endif
// Inquiries
static bool isAnsiTerminal();
static bool isXTerminal();
static bool isRxvtTerminal();
static bool isUrxvtTerminal();
static bool isKdeTerminal();
static bool isGnomeTerminal();
static bool isPuttyTerminal();
static bool isWindowsTerminal();
static bool isTeraTerm();
static bool isCygwinTerminal();
static bool isMinttyTerm();
static bool isLinuxTerm();
static bool isFreeBSDTerm();
static bool isNetBSDTerm();
static bool isOpenBSDTerm();
static bool isSunTerminal();
static bool isScreenTerm();
static bool isTmuxTerm();
static bool isKtermTerminal();
static bool isMltermTerminal();
static bool isKittyTerminal();
static bool canDisplay256Colors();
static bool hasTerminalDetection();
static bool hasSetCursorStyleSupport();
bool isAnsiTerminal() const;
bool isXTerminal() const;
bool isRxvtTerminal() const;
bool isUrxvtTerminal() const;
bool isKdeTerminal() const;
bool isGnomeTerminal() const;
bool isPuttyTerminal() const;
bool isWindowsTerminal() const;
bool isTeraTerm() const;
bool isCygwinTerminal() const;
bool isMinttyTerm() const;
bool isLinuxTerm() const;
bool isFreeBSDTerm() const;
bool isNetBSDTerm() const;
bool isOpenBSDTerm() const;
bool isSunTerminal() const;
bool isScreenTerm() const;
bool isTmuxTerm() const;
bool isKtermTerminal() const;
bool isMltermTerminal() const;
bool isKittyTerminal() const;
bool canDisplay256Colors() const;
bool hasTerminalDetection() const;
bool hasSetCursorStyleSupport() const;
// Mutators
static void setAnsiTerminal (bool = true);
static void setXTerminal (bool = true);
static void setRxvtTerminal (bool = true);
static void setUrxvtTerminal (bool = true);
static void setKdeTerminal (bool = true);
static void setGnomeTerminal (bool = true);
static void setPuttyTerminal (bool = true);
static void setWindowsTerminal (bool = true);
static void setTeraTerm (bool = true);
static void setCygwinTerminal (bool = true);
static void setMinttyTerm (bool = true);
static void setLinuxTerm (bool = true);
static void setFreeBSDTerm (bool = true);
static void setNetBSDTerm (bool = true);
static void setOpenBSDTerm (bool = true);
static void setSunTerminal (bool = true);
static void setScreenTerm (bool = true);
static void setTmuxTerm (bool = true);
static void setKtermTerminal (bool = true);
static void setMltermTerminal (bool = true);
static void setKittyTerminal (bool = true);
static void setTerminalDetection (bool = true);
static void setTtyTypeFileName (const char[]);
void setAnsiTerminal (bool = true);
void setXTerminal (bool = true);
void setRxvtTerminal (bool = true);
void setUrxvtTerminal (bool = true);
void setKdeTerminal (bool = true);
void setGnomeTerminal (bool = true);
void setPuttyTerminal (bool = true);
void setWindowsTerminal (bool = true);
void setTeraTerm (bool = true);
void setCygwinTerminal (bool = true);
void setMinttyTerm (bool = true);
void setLinuxTerm (bool = true);
void setFreeBSDTerm (bool = true);
void setNetBSDTerm (bool = true);
void setOpenBSDTerm (bool = true);
void setSunTerminal (bool = true);
void setScreenTerm (bool = true);
void setTmuxTerm (bool = true);
void setKtermTerminal (bool = true);
void setMltermTerminal (bool = true);
void setKittyTerminal (bool = true);
void setTerminalDetection (bool = true);
void setTtyTypeFileName (const char[]);
// Methods
static void detect();
void detect();
private:
struct colorEnv; // forward declaration
struct secondaryDA; // forward declaration
// Methods
static void deallocation();
static void getSystemTermType();
static bool getTTYtype();
#if F_HAVE_GETTTYNAM
static bool getTTYSFileEntry();
#endif
static void termtypeAnalysis();
static void detectTerminal();
static const char* init_256colorTerminal();
static bool get256colorEnvString();
static const char* termtype_256color_quirks();
static const char* determineMaxColor (const char[]);
static FString getXTermColorName (FColor);
static const char* parseAnswerbackMsg (const char[]);
static FString getAnswerbackMsg();
static const char* parseSecDA (const char[]);
static int str2int (const FString&);
static FString getSecDA();
static const char* secDA_Analysis (const char[]);
static const char* secDA_Analysis_0 (const char[]);
static const char* secDA_Analysis_1 (const char[]);
static const char* secDA_Analysis_24 (const char[]);
static const char* secDA_Analysis_32 (const char[]);
static const char* secDA_Analysis_65 (const char[]);
static const char* secDA_Analysis_67 (const char[]);
static const char* secDA_Analysis_77 (const char[]);
static const char* secDA_Analysis_82 ();
static const char* secDA_Analysis_83 (const char[]);
static const char* secDA_Analysis_84 (const char[]);
static const char* secDA_Analysis_85 ();
static const char* secDA_Analysis_vte (const char[]);
static const char* secDA_Analysis_kitty (const char[]);
// Data members
#if DEBUG
static char termtype_256color[256];
static char termtype_Answerback[256];
static char termtype_SecDA[256];
#endif
static char termtype[256];
static char ttytypename[256];
static bool decscusr_support;
static bool terminal_detection;
static bool color256;
static int gnome_terminal_id;
static const FString* answer_back;
static const FString* sec_da;
static FTerminalType terminal_type;
static colorEnv color_env;
static kittyVersion kitty_version;
static secondaryDA secondary_da;
};
//----------------------------------------------------------------------
// struct FTermDetection::colorEnv
//----------------------------------------------------------------------
struct FTermDetection::colorEnv
{
struct colorEnv
{
char* string1{nullptr};
char* string2{nullptr};
char* string3{nullptr};
@ -234,43 +178,85 @@ struct FTermDetection::colorEnv
char* string6{nullptr};
char* string7{nullptr};
char* string8{nullptr};
};
};
//----------------------------------------------------------------------
// struct FTermDetection::KittyVersion
//----------------------------------------------------------------------
struct FTermDetection::kittyVersion
{
int primary{0};
int secondary{0};
};
//----------------------------------------------------------------------
// struct FTermDetection::secondaryDA
//----------------------------------------------------------------------
struct FTermDetection::secondaryDA
{
struct secondaryDA
{
int terminal_id_type{-1};
int terminal_id_version{-1};
int terminal_id_hardware{-1};
};
// Methods
void deallocation();
void getSystemTermType();
bool getTTYtype();
#if F_HAVE_GETTTYNAM
bool getTTYSFileEntry();
#endif
void termtypeAnalysis();
void detectTerminal();
const char* init_256colorTerminal();
bool get256colorEnvString();
const char* termtype_256color_quirks();
const char* determineMaxColor (const char[]);
FString getXTermColorName (FColor);
const char* parseAnswerbackMsg (const char[]);
FString getAnswerbackMsg();
const char* parseSecDA (const char[]);
int str2int (const FString&);
FString getSecDA();
const char* secDA_Analysis (const char[]);
const char* secDA_Analysis_0 (const char[]);
const char* secDA_Analysis_1 (const char[]);
const char* secDA_Analysis_24 (const char[]);
const char* secDA_Analysis_32 (const char[]);
const char* secDA_Analysis_65 (const char[]);
const char* secDA_Analysis_67 (const char[]);
const char* secDA_Analysis_77 (const char[]);
const char* secDA_Analysis_82 ();
const char* secDA_Analysis_83 (const char[]);
const char* secDA_Analysis_84 (const char[]);
const char* secDA_Analysis_85 ();
const char* secDA_Analysis_vte (const char[]);
const char* secDA_Analysis_kitty (const char[]);
// Data members
#if DEBUG
char termtype_256color[256]{};
char termtype_Answerback[256]{};
char termtype_SecDA[256]{};
#endif
char termtype[256]{};
char ttytypename[256]{};
bool decscusr_support{};
bool terminal_detection{};
bool color256{};
int gnome_terminal_id{};
const FString* answer_back{nullptr};
const FString* sec_da{nullptr};
FTerminalType terminal_type{};
colorEnv color_env{};
kittyVersion kitty_version{};
secondaryDA secondary_da{};
};
// FTermDetection inline functions
//----------------------------------------------------------------------
inline FString FTermDetection::getClassName()
inline FString FTermDetection::getClassName() const
{ return "FTermDetection"; }
//----------------------------------------------------------------------
inline const char* FTermDetection::getTermType()
inline const char* FTermDetection::getTermType() const
{ return termtype; }
//----------------------------------------------------------------------
inline int FTermDetection::getGnomeTerminalID()
inline int FTermDetection::getGnomeTerminalID() const
{ return gnome_terminal_id; }
//----------------------------------------------------------------------
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion()
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion() const
{ return kitty_version; }
//----------------------------------------------------------------------
@ -279,112 +265,112 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
#if DEBUG
//----------------------------------------------------------------------
inline const char* FTermDetection::getTermType_256color()
inline const char* FTermDetection::getTermType_256color() const
{ return termtype_256color; }
//----------------------------------------------------------------------
inline const char* FTermDetection::getTermType_Answerback()
inline const char* FTermDetection::getTermType_Answerback() const
{ return termtype_Answerback; }
//----------------------------------------------------------------------
inline const char* FTermDetection::getTermType_SecDA()
inline const char* FTermDetection::getTermType_SecDA() const
{ return termtype_SecDA; }
#endif
//----------------------------------------------------------------------
inline bool FTermDetection::canDisplay256Colors()
inline bool FTermDetection::canDisplay256Colors() const
{ return color256; }
//----------------------------------------------------------------------
inline bool FTermDetection::hasSetCursorStyleSupport()
inline bool FTermDetection::hasSetCursorStyleSupport() const
{ return decscusr_support; }
//----------------------------------------------------------------------
inline bool FTermDetection::isXTerminal()
inline bool FTermDetection::isXTerminal() const
{ return terminal_type.xterm; }
//----------------------------------------------------------------------
inline bool FTermDetection::isAnsiTerminal()
inline bool FTermDetection::isAnsiTerminal() const
{ return terminal_type.ansi; }
//----------------------------------------------------------------------
inline bool FTermDetection::isRxvtTerminal()
inline bool FTermDetection::isRxvtTerminal() const
{ return terminal_type.rxvt; }
//----------------------------------------------------------------------
inline bool FTermDetection::isUrxvtTerminal()
inline bool FTermDetection::isUrxvtTerminal() const
{ return terminal_type.urxvt; }
//----------------------------------------------------------------------
inline bool FTermDetection::isMltermTerminal()
inline bool FTermDetection::isMltermTerminal() const
{ return terminal_type.mlterm; }
//----------------------------------------------------------------------
inline bool FTermDetection::isKittyTerminal()
inline bool FTermDetection::isKittyTerminal() const
{ return terminal_type.kitty; }
//----------------------------------------------------------------------
inline bool FTermDetection::isPuttyTerminal()
inline bool FTermDetection::isPuttyTerminal() const
{ return terminal_type.putty; }
//----------------------------------------------------------------------
inline bool FTermDetection::isWindowsTerminal()
inline bool FTermDetection::isWindowsTerminal() const
{ return terminal_type.win_terminal; }
//----------------------------------------------------------------------
inline bool FTermDetection::isKdeTerminal()
inline bool FTermDetection::isKdeTerminal() const
{ return terminal_type.kde_konsole; }
//----------------------------------------------------------------------
inline bool FTermDetection::isGnomeTerminal()
inline bool FTermDetection::isGnomeTerminal() const
{ return terminal_type.gnome_terminal; }
//----------------------------------------------------------------------
inline bool FTermDetection::isKtermTerminal()
inline bool FTermDetection::isKtermTerminal() const
{ return terminal_type.kterm; }
//----------------------------------------------------------------------
inline bool FTermDetection::isTeraTerm()
inline bool FTermDetection::isTeraTerm() const
{ return terminal_type.tera_term; }
//----------------------------------------------------------------------
inline bool FTermDetection::isCygwinTerminal()
inline bool FTermDetection::isCygwinTerminal() const
{ return terminal_type.cygwin; }
//----------------------------------------------------------------------
inline bool FTermDetection::isMinttyTerm()
inline bool FTermDetection::isMinttyTerm() const
{ return terminal_type.mintty; }
//----------------------------------------------------------------------
inline bool FTermDetection::isLinuxTerm()
inline bool FTermDetection::isLinuxTerm() const
{ return terminal_type.linux_con; }
//----------------------------------------------------------------------
inline bool FTermDetection::isFreeBSDTerm()
inline bool FTermDetection::isFreeBSDTerm() const
{ return terminal_type.freebsd_con; }
//----------------------------------------------------------------------
inline bool FTermDetection::isNetBSDTerm()
inline bool FTermDetection::isNetBSDTerm() const
{ return terminal_type.netbsd_con; }
//----------------------------------------------------------------------
inline bool FTermDetection::isOpenBSDTerm()
inline bool FTermDetection::isOpenBSDTerm() const
{ return terminal_type.openbsd_con; }
//----------------------------------------------------------------------
inline bool FTermDetection::isSunTerminal()
inline bool FTermDetection::isSunTerminal() const
{ return terminal_type.sun_con; }
//----------------------------------------------------------------------
inline bool FTermDetection::isScreenTerm()
inline bool FTermDetection::isScreenTerm() const
{ return terminal_type.screen; }
//----------------------------------------------------------------------
inline bool FTermDetection::isTmuxTerm()
inline bool FTermDetection::isTmuxTerm() const
{ return terminal_type.tmux; }
//----------------------------------------------------------------------
inline bool FTermDetection::hasTerminalDetection()
inline bool FTermDetection::hasTerminalDetection() const
{ return terminal_detection; }
//----------------------------------------------------------------------

View File

@ -251,10 +251,6 @@ void FTextView::insert (const std::initializer_list<T>& list, int pos)
}
}
//----------------------------------------------------------------------
inline void FTextView::deleteRange (int from, int to)
{ replaceRange (FString(), from, to); }
//----------------------------------------------------------------------
inline void FTextView::deleteLine (int pos)
{ deleteRange (pos, pos); }

View File

@ -119,6 +119,12 @@ std::unique_ptr<T> make_unique (Args&&... args)
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<typename Iter>
constexpr std::reverse_iterator<Iter> make_reverse_iterator (Iter iter)
{
return std::reverse_iterator<Iter>(iter);
}
using charSubstitution = std::unordered_map<wchar_t, wchar_t>;
struct FCharAttribute

View File

@ -1246,6 +1246,9 @@ void FStringTest::convertToNumberTest()
str = "255";
CPPUNIT_ASSERT ( str.toUShort() == 255U );
str = "0";
CPPUNIT_ASSERT ( str.toInt() == 0 );
str = "-32768";
CPPUNIT_ASSERT ( str.toInt() == -32768 );
@ -1336,6 +1339,12 @@ void FStringTest::exceptionTest()
CPPUNIT_ASSERT_THROW ( finalcut::FString("abc").toULong()
, std::invalid_argument );
CPPUNIT_ASSERT_THROW ( finalcut::FString("").toULong()
, std::invalid_argument );
CPPUNIT_ASSERT_THROW ( finalcut::FString().toULong()
, std::invalid_argument );
CPPUNIT_ASSERT_THROW ( finalcut::FString("abc")[4]
, std::out_of_range );
@ -1479,6 +1488,20 @@ void FStringTest::trimTest()
CPPUNIT_ASSERT ( trim_str3.trim().isEmpty() );
CPPUNIT_ASSERT ( trim_str3.trim().getLength() == 0 );
CPPUNIT_ASSERT ( trim_str3.trim().capacity() < std::wstring().max_size() );
const finalcut::FString trim_str4 = "x";
CPPUNIT_ASSERT ( trim_str4.ltrim() == "x" );
CPPUNIT_ASSERT ( ! trim_str4.ltrim().isEmpty() );
CPPUNIT_ASSERT ( trim_str4.ltrim().getLength() == 1 );
CPPUNIT_ASSERT ( trim_str4.ltrim().capacity() < std::wstring().max_size() );
CPPUNIT_ASSERT ( trim_str4.rtrim() == "x" );
CPPUNIT_ASSERT ( ! trim_str4.rtrim().isEmpty() );
CPPUNIT_ASSERT ( trim_str4.rtrim().getLength() == 1 );
CPPUNIT_ASSERT ( trim_str4.rtrim().capacity() < std::wstring().max_size() );
CPPUNIT_ASSERT ( trim_str4.trim() == "x" );
CPPUNIT_ASSERT ( ! trim_str4.trim().isEmpty() );
CPPUNIT_ASSERT ( trim_str4.trim().getLength() == 1 );
CPPUNIT_ASSERT ( trim_str4.trim().capacity() < std::wstring().max_size() );
}
//----------------------------------------------------------------------

View File

@ -150,6 +150,7 @@ void FTermDetectionTest::ansiTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "ansi", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -222,6 +223,7 @@ void FTermDetectionTest::xtermTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
setenv ("XTERM_VERSION", "XTerm(312)", 1);
unsetenv("TERMCAP");
@ -286,6 +288,7 @@ void FTermDetectionTest::rxvtTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "rxvt-cygwin-native", 1);
setenv ("COLORTERM", "rxvt-xpm", 1);
setenv ("COLORFGBG", "default;default", 1);
@ -351,6 +354,7 @@ void FTermDetectionTest::urxvtTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "rxvt-unicode-256color", 1);
setenv ("COLORTERM", "rxvt-xpm", 1);
setenv ("COLORFGBG", "default;default;0", 1);
@ -415,6 +419,7 @@ void FTermDetectionTest::kdeKonsoleTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
setenv ("KONSOLE_DBUS_SERVICE", "DCOPRef(konsole-11768,konsole)", 1);
@ -479,6 +484,7 @@ void FTermDetectionTest::gnomeTerminalTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
setenv ("VTE_VERSION", "5202", 1);
@ -543,6 +549,7 @@ void FTermDetectionTest::newerVteTerminalTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
setenv ("VTE_VERSION", "5300", 1);
@ -607,6 +614,7 @@ void FTermDetectionTest::puttyTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -672,6 +680,7 @@ void FTermDetectionTest::windowsTerminalTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -738,6 +747,7 @@ void FTermDetectionTest::teraTermTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -802,6 +812,7 @@ void FTermDetectionTest::cygwinTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "cygwin", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -866,6 +877,7 @@ void FTermDetectionTest::minttyTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -930,6 +942,7 @@ void FTermDetectionTest::linuxTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1001,6 +1014,7 @@ void FTermDetectionTest::freebsdTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1075,6 +1089,7 @@ void FTermDetectionTest::netbsdTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "wsvt25", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1147,6 +1162,7 @@ void FTermDetectionTest::openbsdTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "vt220", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1218,6 +1234,7 @@ void FTermDetectionTest::sunTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "sun-color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1289,6 +1306,7 @@ void FTermDetectionTest::screenTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "screen", 1);
setenv ("TERMCAP", "SC|screen|VT 100/ANSI X3.64 virtual terminal:...", 1);
unsetenv("COLORTERM");
@ -1359,6 +1377,7 @@ void FTermDetectionTest::tmuxTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "screen", 1);
setenv ("TMUX", "/tmp/tmux-1000/default,7844,0", 1);
setenv ("TMUX_PANE", "%0", 1);
@ -1430,6 +1449,7 @@ void FTermDetectionTest::ktermTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "kterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
@ -1501,6 +1521,7 @@ void FTermDetectionTest::mltermTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "mlterm", 1);
setenv ("MLTERM", "3.8.4", 1);
setenv ("COLORFGBG", "default;default", 1);
@ -1573,6 +1594,7 @@ void FTermDetectionTest::kittyTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-kitty", 1);
setenv ("KITTY_WINDOW_ID", "1", 1);
setenv ("COLORTERM", "truecolor", 1);
@ -1585,7 +1607,7 @@ void FTermDetectionTest::kittyTest()
unsetenv("TMUX");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
@ -1675,6 +1697,7 @@ void FTermDetectionTest::ttytypeTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
unsetenv("TERM");
unsetenv("TERMCAP");
unsetenv("COLORTERM");

View File

@ -657,6 +657,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
static constexpr int left_alt = 0x38;
finalcut::FTermFreeBSD freebsd;
const auto& fsystem = finalcut::FTerm::getFSystem();

View File

@ -2109,6 +2109,7 @@ void FTermLinuxTest::linuxConsoleTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
setenv ("COLUMNS", "90", 1);
setenv ("LINES", "30", 1);
@ -2233,6 +2234,7 @@ void FTermLinuxTest::linuxConsoleLat15Test()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
setenv ("COLUMNS", "90", 1);
setenv ("LINES", "30", 1);
@ -2314,13 +2316,14 @@ void FTermLinuxTest::linuxCursorStyleTest()
// setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
const auto& term_detection = finalcut::FTerm::getFTermDetection();
auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux;
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
setenv ("COLUMNS", "90", 1);
setenv ("LINES", "30", 1);
@ -2511,6 +2514,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
setenv ("COLUMNS", "90", 1);
setenv ("LINES", "30", 1);
@ -2778,13 +2782,14 @@ void FTermLinuxTest::linuxFontTest()
// setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
const auto& term_detection = finalcut::FTerm::getFTermDetection();
auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux;
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
setenv ("COLUMNS", "90", 1);
setenv ("LINES", "30", 1);

View File

@ -380,6 +380,7 @@ void ftermopenbsdTest::netbsdConsoleTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
finalcut::FTermOpenBSD netbsd;
setenv ("TERM", "wsvt25", 1);
@ -484,6 +485,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
finalcut::FTermOpenBSD openbsd;
setenv ("TERM", "vt220", 1);