FTermDetection now has clean code by using FString instead of char*
This commit is contained in:
parent
e38d604544
commit
2dc8d7f2d3
|
@ -1,5 +1,6 @@
|
||||||
2021-06-06 Markus Gans <guru.mail@muenster.de>
|
2021-06-06 Markus Gans <guru.mail@muenster.de>
|
||||||
* Bug fixing in FString and FTermDetection
|
* Bug fixing in FString and FTermDetection
|
||||||
|
* FTermDetection now has clean code by using FString instead of char*
|
||||||
|
|
||||||
2021-06-03 Markus Gans <guru.mail@muenster.de>
|
2021-06-03 Markus Gans <guru.mail@muenster.de>
|
||||||
* Some FString optimizations
|
* Some FString optimizations
|
||||||
|
|
|
@ -2168,7 +2168,7 @@ bool FTerm::init_terminal() const
|
||||||
// Terminal detection
|
// Terminal detection
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTerm::getFTermDetection();
|
||||||
term_detection.detect();
|
term_detection.detect();
|
||||||
setTermType (term_detection.getTermType());
|
setTermType (term_detection.getTermType().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,21 +51,21 @@ const FString& FTermDebugData::getSecDAString()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDebugData::getTermType_256color()
|
const FString& FTermDebugData::getTermType_256color()
|
||||||
{
|
{
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTerm::getFTermDetection();
|
||||||
return term_detection.getTermType_256color();
|
return term_detection.getTermType_256color();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDebugData::getTermType_Answerback()
|
const FString& FTermDebugData::getTermType_Answerback()
|
||||||
{
|
{
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTerm::getFTermDetection();
|
||||||
return term_detection.getTermType_Answerback();
|
return term_detection.getTermType_Answerback();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDebugData::getTermType_SecDA()
|
const FString& FTermDebugData::getTermType_SecDA()
|
||||||
{
|
{
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTerm::getFTermDetection();
|
||||||
return term_detection.getTermType_SecDA();
|
return term_detection.getTermType_SecDA();
|
||||||
|
|
|
@ -56,29 +56,10 @@ namespace finalcut
|
||||||
|
|
||||||
// constructors and destructor
|
// constructors and destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermDetection::FTermDetection()
|
FTermDetection::FTermDetection() = default;
|
||||||
{
|
|
||||||
// Preset to true
|
|
||||||
terminal_detection = true;
|
|
||||||
|
|
||||||
// Preset to false
|
|
||||||
decscusr_support = false;
|
|
||||||
|
|
||||||
// Gnome terminal id from SecDA
|
|
||||||
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
|
|
||||||
// a.b.c = a * 100 + b * 100 + c
|
|
||||||
gnome_terminal_id = 0;
|
|
||||||
|
|
||||||
// Set default ttytype file
|
|
||||||
std::strncpy (ttytypename, "/etc/ttytype", sizeof(ttytypename));
|
|
||||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermDetection::~FTermDetection() // destructor
|
FTermDetection::~FTermDetection() = default; // destructor
|
||||||
{
|
|
||||||
deallocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// public methods of FTermDetection
|
// public methods of FTermDetection
|
||||||
|
@ -86,31 +67,28 @@ FTermDetection::~FTermDetection() // destructor
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
const FString& FTermDetection::getAnswerbackString() const
|
const FString& FTermDetection::getAnswerbackString() const
|
||||||
{
|
{
|
||||||
return ( answer_back ) ? *answer_back : fc::emptyFString::get();
|
return answer_back;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString& FTermDetection::getSecDAString() const
|
const FString& FTermDetection::getSecDAString() const
|
||||||
{
|
{
|
||||||
return ( sec_da ) ? *sec_da : fc::emptyFString::get();
|
return sec_da;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
|
void FTermDetection::setTtyTypeFileName (const FString& ttytype_filename)
|
||||||
{
|
{
|
||||||
if ( ! ttytype_filename )
|
if ( ! ttytype_filename )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::strncpy (ttytypename, ttytype_filename, sizeof(ttytypename));
|
ttytypename = ttytype_filename;
|
||||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::detect()
|
void FTermDetection::detect()
|
||||||
{
|
{
|
||||||
deallocation();
|
|
||||||
|
|
||||||
// Set the variable 'termtype' to the predefined type of the terminal
|
// Set the variable 'termtype' to the predefined type of the terminal
|
||||||
getSystemTermType();
|
getSystemTermType();
|
||||||
|
|
||||||
|
@ -123,16 +101,6 @@ void FTermDetection::detect()
|
||||||
|
|
||||||
|
|
||||||
// private methods of FTermDetection
|
// private methods of FTermDetection
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTermDetection::deallocation()
|
|
||||||
{
|
|
||||||
if ( sec_da )
|
|
||||||
delete sec_da;
|
|
||||||
|
|
||||||
if ( answer_back )
|
|
||||||
delete answer_back;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::getSystemTermType()
|
void FTermDetection::getSystemTermType()
|
||||||
{
|
{
|
||||||
|
@ -143,8 +111,7 @@ void FTermDetection::getSystemTermType()
|
||||||
if ( term_env )
|
if ( term_env )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, term_env, sizeof(termtype));
|
termtype = term_env;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
||||||
|
@ -159,8 +126,7 @@ void FTermDetection::getSystemTermType()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd fallback: use vt100 if not found
|
// 2nd fallback: use vt100 if not found
|
||||||
std::strncpy (termtype, "vt100", sizeof(termtype));
|
termtype = "vt100";
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -188,7 +154,7 @@ bool FTermDetection::getTTYtype()
|
||||||
std::array<char, BUFSIZ> str{};
|
std::array<char, BUFSIZ> str{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FTerm::getFSystem();
|
||||||
|
|
||||||
if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
|
if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read and parse the file
|
// Read and parse the file
|
||||||
|
@ -213,8 +179,7 @@ bool FTermDetection::getTTYtype()
|
||||||
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, type, sizeof(termtype));
|
termtype = type;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
fsystem->fclose(fp);
|
fsystem->fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -249,8 +214,7 @@ bool FTermDetection::getTTYSFileEntry()
|
||||||
if ( type != nullptr )
|
if ( type != nullptr )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, type, sizeof(termtype));
|
termtype = type;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
endttyent();
|
endttyent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -265,48 +229,49 @@ bool FTermDetection::getTTYSFileEntry()
|
||||||
void FTermDetection::termtypeAnalysis()
|
void FTermDetection::termtypeAnalysis()
|
||||||
{
|
{
|
||||||
// Cygwin console
|
// Cygwin console
|
||||||
if ( std::strncmp(termtype, "cygwin", 6) == 0 )
|
|
||||||
|
if ( termtype.left(6) == "cygwin" )
|
||||||
terminal_type.cygwin = true;
|
terminal_type.cygwin = true;
|
||||||
|
|
||||||
// rxvt terminal emulator (native MS Window System port) on cygwin
|
// rxvt terminal emulator (native MS Window System port) on cygwin
|
||||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
if ( termtype == "rxvt-cygwin-native" )
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
// Ansi terminal
|
// Ansi terminal
|
||||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
if ( termtype.left(4) == "ansi" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.ansi = true;
|
terminal_type.ansi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sun Microsystems workstation console
|
// Sun Microsystems workstation console
|
||||||
if ( std::strncmp(termtype, "sun", 3) == 0 )
|
if ( termtype.left(3) == "sun" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.sun_con = true;
|
terminal_type.sun_con = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kterm
|
// Kterm
|
||||||
if ( std::strncmp(termtype, "kterm", 5) == 0 )
|
if ( termtype.left(5) == "kterm" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.kterm = true;
|
terminal_type.kterm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mlterm
|
// mlterm
|
||||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
if ( termtype.left(6) == "mlterm" )
|
||||||
terminal_type.mlterm = true;
|
terminal_type.mlterm = true;
|
||||||
|
|
||||||
// rxvt
|
// rxvt
|
||||||
if ( std::strncmp(termtype, "rxvt", 4) == 0 )
|
if ( termtype.left(4) == "rxvt" )
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
// urxvt
|
// urxvt
|
||||||
if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
|
if ( termtype.left(12) == "rxvt-unicode" )
|
||||||
terminal_type.urxvt = true;
|
terminal_type.urxvt = true;
|
||||||
|
|
||||||
// screen/tmux
|
// screen/tmux
|
||||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
if ( termtype.left(6) == "screen" )
|
||||||
{
|
{
|
||||||
terminal_type.screen = true;
|
terminal_type.screen = true;
|
||||||
auto tmux = std::getenv("TMUX");
|
auto tmux = std::getenv("TMUX");
|
||||||
|
@ -316,16 +281,15 @@ void FTermDetection::termtypeAnalysis()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linux console
|
// Linux console
|
||||||
if ( std::strncmp(termtype, "linux", 5) == 0
|
if ( termtype.left(5) == "linux" || termtype.left(3) == "con" )
|
||||||
|| std::strncmp(termtype, "con", 3) == 0 )
|
|
||||||
terminal_type.linux_con = true;
|
terminal_type.linux_con = true;
|
||||||
|
|
||||||
// NetBSD workstation console
|
// NetBSD workstation console
|
||||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
if ( termtype.left(6) == "wsvt25" )
|
||||||
terminal_type.netbsd_con = true;
|
terminal_type.netbsd_con = true;
|
||||||
|
|
||||||
// kitty
|
// kitty
|
||||||
if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
|
if ( termtype.left(11) == "xterm-kitty" )
|
||||||
terminal_type.kitty = true;
|
terminal_type.kitty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +298,7 @@ void FTermDetection::detectTerminal()
|
||||||
{
|
{
|
||||||
// Terminal detection
|
// Terminal detection
|
||||||
|
|
||||||
const char* new_termtype{nullptr};
|
FString new_termtype{};
|
||||||
|
|
||||||
if ( terminal_detection )
|
if ( terminal_detection )
|
||||||
{
|
{
|
||||||
|
@ -363,24 +327,22 @@ void FTermDetection::detectTerminal()
|
||||||
//
|
//
|
||||||
|
|
||||||
// Test if the terminal is a xterm
|
// Test if the terminal is a xterm
|
||||||
if ( std::strncmp(termtype, "xterm", 5) == 0
|
if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" )
|
||||||
|| std::strncmp(termtype, "Eterm", 5) == 0 )
|
|
||||||
{
|
{
|
||||||
terminal_type.xterm = true;
|
terminal_type.xterm = true;
|
||||||
|
|
||||||
// Each xterm should be able to use at least 16 colors
|
// Each xterm should be able to use at least 16 colors
|
||||||
if ( ! new_termtype && std::strlen(termtype) == 5 )
|
if ( ! new_termtype && termtype.getLength() == 5 )
|
||||||
new_termtype = "xterm-16color";
|
new_termtype = "xterm-16color";
|
||||||
}
|
}
|
||||||
else if ( std::strncmp(termtype, "ansi", 4) == 0 ) // ANSI detection
|
else if ( termtype.left(4) == "ansi" ) // ANSI detection
|
||||||
terminal_type.ansi = true;
|
terminal_type.ansi = true;
|
||||||
|
|
||||||
// set the new environment variable TERM
|
// set the new environment variable TERM
|
||||||
if ( new_termtype )
|
if ( new_termtype )
|
||||||
{
|
{
|
||||||
setenv("TERM", new_termtype, 1);
|
setenv("TERM", new_termtype.c_str(), 1);
|
||||||
std::strncpy (termtype, new_termtype, sizeof(termtype));
|
termtype = new_termtype;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
|
@ -394,13 +356,13 @@ void FTermDetection::detectTerminal()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::init_256colorTerminal()
|
FString FTermDetection::init_256colorTerminal()
|
||||||
{
|
{
|
||||||
const char* new_termtype{nullptr};
|
FString new_termtype{};
|
||||||
|
|
||||||
if ( get256colorEnvString() )
|
if ( get256colorEnvString() )
|
||||||
color256 = true;
|
color256 = true;
|
||||||
else if ( std::strstr (termtype, "256color") )
|
else if ( termtype.includes("256color") )
|
||||||
color256 = true;
|
color256 = true;
|
||||||
else
|
else
|
||||||
color256 = false;
|
color256 = false;
|
||||||
|
@ -408,13 +370,8 @@ const char* FTermDetection::init_256colorTerminal()
|
||||||
new_termtype = termtype_256color_quirks();
|
new_termtype = termtype_256color_quirks();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_256color = new_termtype;
|
||||||
std::strncpy ( termtype_256color
|
|
||||||
, new_termtype
|
|
||||||
, sizeof(termtype_256color) );
|
|
||||||
termtype_256color[sizeof(termtype_256color) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
|
@ -447,9 +404,9 @@ bool FTermDetection::get256colorEnvString()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::termtype_256color_quirks()
|
FString FTermDetection::termtype_256color_quirks()
|
||||||
{
|
{
|
||||||
const char* new_termtype{nullptr};
|
FString new_termtype{};
|
||||||
|
|
||||||
if ( color_env.string2
|
if ( color_env.string2
|
||||||
|| (color_env.string1
|
|| (color_env.string1
|
||||||
|
@ -469,19 +426,19 @@ const char* FTermDetection::termtype_256color_quirks()
|
||||||
if ( ! color256 )
|
if ( ! color256 )
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "xterm", 5) == 0 )
|
if ( termtype.left(5) == "xterm" )
|
||||||
new_termtype = "xterm-256color";
|
new_termtype = "xterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
if ( termtype.left(6) == "screen" )
|
||||||
new_termtype = "screen-256color";
|
new_termtype = "screen-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "Eterm", 5) == 0 )
|
if ( termtype.left(5) == "Eterm" )
|
||||||
new_termtype = "Eterm-256color";
|
new_termtype = "Eterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
if ( termtype.left(6) == "mlterm" )
|
||||||
new_termtype = "mlterm-256color";
|
new_termtype = "mlterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt", 4) != 0
|
if ( termtype.left(4) == "rxvt"
|
||||||
&& color_env.string1
|
&& color_env.string1
|
||||||
&& std::strncmp(color_env.string1, "rxvt-xpm", 8) == 0 )
|
&& std::strncmp(color_env.string1, "rxvt-xpm", 8) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -503,11 +460,11 @@ const char* FTermDetection::termtype_256color_quirks()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
FString FTermDetection::determineMaxColor (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Determine xterm maximum number of colors via OSC 4
|
// Determine xterm maximum number of colors via OSC 4
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FTerm::getFKeyboard();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
|
|
||||||
|
@ -542,7 +499,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermDetection::getXTermColorName (FColor color)
|
FString FTermDetection::getXTermColorName (FColor color) const
|
||||||
{
|
{
|
||||||
FString color_str{""};
|
FString color_str{""};
|
||||||
std::array<char, 30> buf{};
|
std::array<char, 30> buf{};
|
||||||
|
@ -598,26 +555,16 @@ FString FTermDetection::getXTermColorName (FColor color)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FTerm::getFKeyboard();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
// send ENQ and read the answerback message
|
// send ENQ and read the answerback message
|
||||||
const auto& ans = getAnswerbackMsg();
|
answer_back = getAnswerbackMsg();
|
||||||
keyboard.unsetNonBlockingInput();
|
keyboard.unsetNonBlockingInput();
|
||||||
|
|
||||||
try
|
if ( answer_back == "PuTTY" )
|
||||||
{
|
|
||||||
answer_back = new FString(ans);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FString");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( *answer_back == "PuTTY" )
|
|
||||||
{
|
{
|
||||||
terminal_type.putty = true;
|
terminal_type.putty = true;
|
||||||
|
|
||||||
|
@ -633,20 +580,15 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||||
std::fflush (stdout);
|
std::fflush (stdout);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_Answerback = new_termtype;
|
||||||
std::strncpy ( termtype_Answerback
|
|
||||||
, new_termtype
|
|
||||||
, sizeof(termtype_Answerback) - 1);
|
|
||||||
termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermDetection::getAnswerbackMsg()
|
FString FTermDetection::getAnswerbackMsg() const
|
||||||
{
|
{
|
||||||
FString answerback{""};
|
FString answerback{""};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
|
@ -686,45 +628,31 @@ FString FTermDetection::getAnswerbackMsg()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::parseSecDA (const char current_termtype[])
|
FString FTermDetection::parseSecDA (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// The Linux console and older cygwin terminals knows no Sec_DA
|
// The Linux console and older cygwin terminals knows no Sec_DA
|
||||||
if ( isLinuxTerm() || isCygwinTerminal() )
|
if ( isLinuxTerm() || isCygwinTerminal() )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||||
const auto& ans = getSecDA();
|
sec_da = getSecDA();
|
||||||
|
|
||||||
try
|
if ( sec_da.getLength() < 6 )
|
||||||
{
|
|
||||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
|
||||||
sec_da = new FString(ans);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FString");
|
|
||||||
return current_termtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( sec_da->getLength() < 6 )
|
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
// remove the first 3 bytes ("\033[>")
|
// remove the first 3 bytes ("\033[>")
|
||||||
FString temp{sec_da->right(sec_da->getLength() - 3)};
|
FString temp(sec_da.right(sec_da.getLength() - 3));
|
||||||
// remove the last byte ("c")
|
// remove the last byte ("c")
|
||||||
temp.remove(temp.getLength() - 1, 1);
|
temp.remove(temp.getLength() - 1, 1);
|
||||||
// split into components
|
// split into components
|
||||||
const FStringList sec_da_list = temp.split(';');
|
const auto sec_da_components = temp.split(';');
|
||||||
|
const auto num_components = sec_da_components.size();
|
||||||
const uLong num_components = sec_da_list.size();
|
|
||||||
|
|
||||||
// The second device attribute (SEC_DA) always has 3 parameters,
|
// The second device attribute (SEC_DA) always has 3 parameters,
|
||||||
// otherwise it usually has a copy of the device attribute (primary DA)
|
// otherwise it usually has a copy of the device attribute (primary DA)
|
||||||
if ( num_components < 3 )
|
if ( num_components < 3 )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
const FString* sec_da_components = &sec_da_list[0];
|
|
||||||
|
|
||||||
if ( sec_da_components[0].isEmpty() )
|
if ( sec_da_components[0].isEmpty() )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
|
@ -737,21 +665,18 @@ const char* FTermDetection::parseSecDA (const char current_termtype[])
|
||||||
// Read the terminal hardware option
|
// Read the terminal hardware option
|
||||||
secondary_da.terminal_id_hardware = str2int(sec_da_components[2]);
|
secondary_da.terminal_id_hardware = str2int(sec_da_components[2]);
|
||||||
|
|
||||||
const char* new_termtype = secDA_Analysis(current_termtype);
|
FString new_termtype = secDA_Analysis(current_termtype);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_SecDA = new_termtype;
|
||||||
std::strncpy (termtype_SecDA, new_termtype, sizeof(termtype_SecDA));
|
|
||||||
termtype_SecDA[sizeof(termtype_SecDA) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FTermDetection::str2int (const FString& s)
|
int FTermDetection::str2int (const FString& s) const
|
||||||
{
|
{
|
||||||
// This is not a general string to integer conversion method.
|
// This is not a general string to integer conversion method.
|
||||||
// It is only used in this class to convert the device attribute
|
// It is only used in this class to convert the device attribute
|
||||||
|
@ -781,7 +706,7 @@ int FTermDetection::str2int (const FString& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermDetection::getSecDA()
|
FString FTermDetection::getSecDA() const
|
||||||
{
|
{
|
||||||
FString sec_da_str{""};
|
FString sec_da_str{""};
|
||||||
|
|
||||||
|
@ -831,9 +756,9 @@ FString FTermDetection::getSecDA()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
switch ( secondary_da.terminal_id_type )
|
switch ( secondary_da.terminal_id_type )
|
||||||
{
|
{
|
||||||
|
@ -854,7 +779,7 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32: // Tera Term
|
case 32: // Tera Term
|
||||||
new_termtype = secDA_Analysis_32(current_termtype);
|
new_termtype = secDA_Analysis_32();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 41: // DEC VT420
|
case 41: // DEC VT420
|
||||||
|
@ -867,11 +792,11 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 67: // Cygwin
|
case 67: // Cygwin
|
||||||
new_termtype = secDA_Analysis_67(current_termtype);
|
new_termtype = secDA_Analysis_67();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 77: // mintty
|
case 77: // mintty
|
||||||
new_termtype = secDA_Analysis_77(current_termtype);
|
new_termtype = secDA_Analysis_77();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 82: // rxvt
|
case 82: // rxvt
|
||||||
|
@ -907,11 +832,11 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 0 - DEC VT100
|
// Terminal ID 0 - DEC VT100
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( secondary_da.terminal_id_version == 10
|
if ( secondary_da.terminal_id_version == 10
|
||||||
&& secondary_da.terminal_id_hardware == 1 )
|
&& secondary_da.terminal_id_hardware == 1 )
|
||||||
|
@ -930,11 +855,11 @@ inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 1 - DEC VT220
|
// Terminal ID 1 - DEC VT220
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( isKittyTerminal() )
|
if ( isKittyTerminal() )
|
||||||
new_termtype = secDA_Analysis_kitty(new_termtype);
|
new_termtype = secDA_Analysis_kitty(new_termtype);
|
||||||
|
@ -945,11 +870,11 @@ inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 24 - DEC VT320
|
// Terminal ID 24 - DEC VT320
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||||
|
|
||||||
|
@ -957,9 +882,9 @@ inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtyp
|
||||||
&& FTermOpenBSD::isBSDConsole() )
|
&& FTermOpenBSD::isBSDConsole() )
|
||||||
{
|
{
|
||||||
// NetBSD/OpenBSD workstation console
|
// NetBSD/OpenBSD workstation console
|
||||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
if ( termtype.left(6) == "wsvt25" )
|
||||||
terminal_type.netbsd_con = true;
|
terminal_type.netbsd_con = true;
|
||||||
else if ( std::strncmp(termtype, "vt220", 5) == 0 )
|
else if ( termtype.left(5) == "vt220" )
|
||||||
{
|
{
|
||||||
terminal_type.openbsd_con = true;
|
terminal_type.openbsd_con = true;
|
||||||
new_termtype = "pccon";
|
new_termtype = "pccon";
|
||||||
|
@ -972,17 +897,16 @@ inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtyp
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_32 (const char[])
|
inline FString FTermDetection::secDA_Analysis_32()
|
||||||
{
|
{
|
||||||
// Terminal ID 32 - Tera Term
|
// Terminal ID 32 - Tera Term
|
||||||
|
|
||||||
terminal_type.tera_term = true;
|
terminal_type.tera_term = true;
|
||||||
const char* new_termtype = "teraterm";
|
return "teraterm";
|
||||||
return new_termtype;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 65 - DEC VT525 and VTE >= 0.53.0
|
// Terminal ID 65 - DEC VT525 and VTE >= 0.53.0
|
||||||
|
|
||||||
|
@ -990,37 +914,35 @@ inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtyp
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_67 (const char[])
|
inline FString FTermDetection::secDA_Analysis_67()
|
||||||
{
|
{
|
||||||
// Terminal ID 67 - cygwin
|
// Terminal ID 67 - cygwin
|
||||||
|
|
||||||
terminal_type.cygwin = true;
|
terminal_type.cygwin = true;
|
||||||
const char* new_termtype = "cygwin";
|
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
return new_termtype;
|
return "cygwin";
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_77 (const char[])
|
inline FString FTermDetection::secDA_Analysis_77()
|
||||||
{
|
{
|
||||||
// Terminal ID 77 - mintty
|
// Terminal ID 77 - mintty
|
||||||
|
|
||||||
terminal_type.mintty = true;
|
terminal_type.mintty = true;
|
||||||
decscusr_support = true;
|
decscusr_support = true;
|
||||||
const char* new_termtype = "xterm-256color";
|
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
return new_termtype;
|
return "xterm-256color";
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_82()
|
inline FString FTermDetection::secDA_Analysis_82()
|
||||||
{
|
{
|
||||||
// Terminal ID 82 - rxvt
|
// Terminal ID 82 - rxvt
|
||||||
|
|
||||||
const char* new_termtype{};
|
FString new_termtype{};
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
if ( termtype == "rxvt-cygwin-native" )
|
||||||
new_termtype = "rxvt-16color";
|
new_termtype = "rxvt-16color";
|
||||||
else
|
else
|
||||||
new_termtype = "rxvt";
|
new_termtype = "rxvt";
|
||||||
|
@ -1029,36 +951,34 @@ inline const char* FTermDetection::secDA_Analysis_82()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_83 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_83 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 83 - screen
|
// Terminal ID 83 - screen
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
|
||||||
terminal_type.screen = true;
|
terminal_type.screen = true;
|
||||||
return new_termtype;
|
return current_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_84 (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_84 (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// Terminal ID 84 - tmux
|
// Terminal ID 84 - tmux
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
|
||||||
terminal_type.screen = true;
|
terminal_type.screen = true;
|
||||||
terminal_type.tmux = true;
|
terminal_type.tmux = true;
|
||||||
return new_termtype;
|
return current_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_85()
|
inline FString FTermDetection::secDA_Analysis_85()
|
||||||
{
|
{
|
||||||
// Terminal ID 85 - rxvt-unicode
|
// Terminal ID 85 - rxvt-unicode
|
||||||
|
|
||||||
const char* new_termtype{};
|
FString new_termtype{};
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
terminal_type.urxvt = true;
|
terminal_type.urxvt = true;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt-", 5) != 0 )
|
if ( termtype.left(5) == "rxvt-" )
|
||||||
{
|
{
|
||||||
if ( color256 )
|
if ( color256 )
|
||||||
new_termtype = "rxvt-256color";
|
new_termtype = "rxvt-256color";
|
||||||
|
@ -1072,12 +992,12 @@ inline const char* FTermDetection::secDA_Analysis_85()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_vte (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// VTE terminal library
|
// VTE terminal library
|
||||||
// (Since VTE ) the terminal ID has changed from 1 to 65)
|
// (Since VTE ) the terminal ID has changed from 1 to 65)
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( secondary_da.terminal_id_version > 1000 )
|
if ( secondary_da.terminal_id_version > 1000 )
|
||||||
{
|
{
|
||||||
|
@ -1096,11 +1016,11 @@ inline const char* FTermDetection::secDA_Analysis_vte (const char current_termty
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::secDA_Analysis_kitty (const char current_termtype[])
|
inline FString FTermDetection::secDA_Analysis_kitty (const FString& current_termtype)
|
||||||
{
|
{
|
||||||
// kitty
|
// kitty
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( secondary_da.terminal_id_version > 3999 )
|
if ( secondary_da.terminal_id_version > 3999 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* This file is part of the FINAL CUT widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2018-2020 Markus Gans *
|
* Copyright 2018-2021 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -65,9 +65,9 @@ class FTermDebugData final
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString& getAnswerbackString();
|
const FString& getAnswerbackString();
|
||||||
const FString& getSecDAString();
|
const FString& getSecDAString();
|
||||||
const char* getTermType_256color();
|
const FString& getTermType_256color();
|
||||||
const char* getTermType_Answerback();
|
const FString& getTermType_Answerback();
|
||||||
const char* getTermType_SecDA();
|
const FString& getTermType_SecDA();
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
int getFramebufferBpp();
|
int getFramebufferBpp();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -100,7 +100,7 @@ class FTermDetection final
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
const char* getTermType() const;
|
const FString& getTermType() const;
|
||||||
int getGnomeTerminalID() const;
|
int getGnomeTerminalID() const;
|
||||||
kittyVersion getKittyVersion() const;
|
kittyVersion getKittyVersion() const;
|
||||||
FTerminalType& getTermTypeStruct();
|
FTerminalType& getTermTypeStruct();
|
||||||
|
@ -108,9 +108,9 @@ class FTermDetection final
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
const FString& getAnswerbackString() const;
|
const FString& getAnswerbackString() const;
|
||||||
const FString& getSecDAString() const;
|
const FString& getSecDAString() const;
|
||||||
const char* getTermType_256color() const;
|
const FString& getTermType_256color() const;
|
||||||
const char* getTermType_Answerback() const;
|
const FString& getTermType_Answerback() const;
|
||||||
const char* getTermType_SecDA() const;
|
const FString& getTermType_SecDA() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Inquiries
|
// Inquiries
|
||||||
|
@ -162,7 +162,7 @@ class FTermDetection final
|
||||||
void setMltermTerminal (bool = true);
|
void setMltermTerminal (bool = true);
|
||||||
void setKittyTerminal (bool = true);
|
void setKittyTerminal (bool = true);
|
||||||
void setTerminalDetection (bool = true);
|
void setTerminalDetection (bool = true);
|
||||||
void setTtyTypeFileName (const char[]);
|
void setTtyTypeFileName (const FString&);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void detect();
|
void detect();
|
||||||
|
@ -188,7 +188,6 @@ class FTermDetection final
|
||||||
};
|
};
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void deallocation();
|
|
||||||
void getSystemTermType();
|
void getSystemTermType();
|
||||||
bool getTTYtype();
|
bool getTTYtype();
|
||||||
#if F_HAVE_GETTTYNAM
|
#if F_HAVE_GETTTYNAM
|
||||||
|
@ -196,45 +195,48 @@ class FTermDetection final
|
||||||
#endif
|
#endif
|
||||||
void termtypeAnalysis();
|
void termtypeAnalysis();
|
||||||
void detectTerminal();
|
void detectTerminal();
|
||||||
const char* init_256colorTerminal();
|
FString init_256colorTerminal();
|
||||||
bool get256colorEnvString();
|
bool get256colorEnvString();
|
||||||
const char* termtype_256color_quirks();
|
FString termtype_256color_quirks();
|
||||||
const char* determineMaxColor (const char[]);
|
FString determineMaxColor (const FString&);
|
||||||
FString getXTermColorName (FColor);
|
FString getXTermColorName (FColor) const;
|
||||||
const char* parseAnswerbackMsg (const char[]);
|
FString parseAnswerbackMsg (const FString&);
|
||||||
FString getAnswerbackMsg();
|
FString getAnswerbackMsg() const;
|
||||||
const char* parseSecDA (const char[]);
|
FString parseSecDA (const FString&);
|
||||||
int str2int (const FString&);
|
int str2int (const FString&) const;
|
||||||
FString getSecDA();
|
FString getSecDA() const;
|
||||||
const char* secDA_Analysis (const char[]);
|
FString secDA_Analysis (const FString&);
|
||||||
const char* secDA_Analysis_0 (const char[]);
|
FString secDA_Analysis_0 (const FString&);
|
||||||
const char* secDA_Analysis_1 (const char[]);
|
FString secDA_Analysis_1 (const FString&);
|
||||||
const char* secDA_Analysis_24 (const char[]);
|
FString secDA_Analysis_24 (const FString&);
|
||||||
const char* secDA_Analysis_32 (const char[]);
|
FString secDA_Analysis_32 ();
|
||||||
const char* secDA_Analysis_65 (const char[]);
|
FString secDA_Analysis_65 (const FString&);
|
||||||
const char* secDA_Analysis_67 (const char[]);
|
FString secDA_Analysis_67 ();
|
||||||
const char* secDA_Analysis_77 (const char[]);
|
FString secDA_Analysis_77 ();
|
||||||
const char* secDA_Analysis_82 ();
|
FString secDA_Analysis_82 ();
|
||||||
const char* secDA_Analysis_83 (const char[]);
|
FString secDA_Analysis_83 (const FString&);
|
||||||
const char* secDA_Analysis_84 (const char[]);
|
FString secDA_Analysis_84 (const FString&);
|
||||||
const char* secDA_Analysis_85 ();
|
FString secDA_Analysis_85 ();
|
||||||
const char* secDA_Analysis_vte (const char[]);
|
FString secDA_Analysis_vte (const FString&);
|
||||||
const char* secDA_Analysis_kitty (const char[]);
|
FString secDA_Analysis_kitty (const FString&);
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
char termtype_256color[256]{};
|
FString termtype_256color{};
|
||||||
char termtype_Answerback[256]{};
|
FString termtype_Answerback{};
|
||||||
char termtype_SecDA[256]{};
|
FString termtype_SecDA{};
|
||||||
#endif
|
#endif
|
||||||
char termtype[256]{};
|
FString termtype{};
|
||||||
char ttytypename[256]{};
|
FString ttytypename{"/etc/ttytype"}; // Default ttytype file
|
||||||
bool decscusr_support{};
|
bool decscusr_support{false}; // Preset to false
|
||||||
bool terminal_detection{};
|
bool terminal_detection{true}; // Preset to true
|
||||||
bool color256{};
|
bool color256{};
|
||||||
int gnome_terminal_id{};
|
// Gnome terminal id from SecDA
|
||||||
const FString* answer_back{nullptr};
|
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
|
||||||
const FString* sec_da{nullptr};
|
// a.b.c = a * 100 + b * 100 + c
|
||||||
|
int gnome_terminal_id{0};
|
||||||
|
FString answer_back{};
|
||||||
|
FString sec_da{};
|
||||||
FTerminalType terminal_type{};
|
FTerminalType terminal_type{};
|
||||||
colorEnv color_env{};
|
colorEnv color_env{};
|
||||||
kittyVersion kitty_version{};
|
kittyVersion kitty_version{};
|
||||||
|
@ -248,7 +250,7 @@ inline FString FTermDetection::getClassName() const
|
||||||
{ return "FTermDetection"; }
|
{ return "FTermDetection"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType() const
|
inline const FString& FTermDetection::getTermType() const
|
||||||
{ return termtype; }
|
{ return termtype; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -265,15 +267,15 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_256color() const
|
inline const FString& FTermDetection::getTermType_256color() const
|
||||||
{ return termtype_256color; }
|
{ return termtype_256color; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_Answerback() const
|
inline const FString& FTermDetection::getTermType_Answerback() const
|
||||||
{ return termtype_Answerback; }
|
{ return termtype_Answerback; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_SecDA() const
|
inline const FString& FTermDetection::getTermType_SecDA() const
|
||||||
{ return termtype_SecDA; }
|
{ return termtype_SecDA; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -34,23 +34,6 @@
|
||||||
#include <conemu.h>
|
#include <conemu.h>
|
||||||
#include <final/final.h>
|
#include <final/final.h>
|
||||||
|
|
||||||
#define CPPUNIT_ASSERT_CSTRING(expected, actual) \
|
|
||||||
check_c_string (expected, actual, CPPUNIT_SOURCELINE())
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void check_c_string ( const char* s1
|
|
||||||
, const char* s2
|
|
||||||
, CppUnit::SourceLine sourceLine )
|
|
||||||
{
|
|
||||||
if ( s1 == 0 && s2 == 0 ) // Strings are equal
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal
|
|
||||||
return;
|
|
||||||
|
|
||||||
::CppUnit::Asserter::fail ("Strings are not equal", sourceLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// class FTermDetectionTest
|
// class FTermDetectionTest
|
||||||
|
@ -188,14 +171,14 @@ void FTermDetectionTest::ansiTest()
|
||||||
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "ansi" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "ansi" );
|
||||||
|
|
||||||
// Test fallback to vt100 without TERM environment variable
|
// Test fallback to vt100 without TERM environment variable
|
||||||
unsetenv("TERM");
|
unsetenv("TERM");
|
||||||
detect.setAnsiTerminal(false);
|
detect.setAnsiTerminal(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
|
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -326,7 +309,7 @@ void FTermDetectionTest::rxvtTest()
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "rxvt-16color" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "rxvt-16color" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -986,7 +969,7 @@ void FTermDetectionTest::linuxTest()
|
||||||
detect.setLinuxTerm(false);
|
detect.setLinuxTerm(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
|
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1061,7 +1044,7 @@ void FTermDetectionTest::freebsdTest()
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
|
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
|
||||||
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
|
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1134,7 +1117,7 @@ void FTermDetectionTest::netbsdTest()
|
||||||
detect.setNetBSDTerm(false);
|
detect.setNetBSDTerm(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
|
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1207,7 +1190,7 @@ void FTermDetectionTest::openbsdTest()
|
||||||
detect.setOpenBSDTerm(false);
|
detect.setOpenBSDTerm(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
|
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1278,7 +1261,7 @@ void FTermDetectionTest::sunTest()
|
||||||
detect.setSunTerminal(false);
|
detect.setSunTerminal(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
|
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1344,12 +1327,12 @@ void FTermDetectionTest::screenTest()
|
||||||
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "screen" );
|
||||||
|
|
||||||
setenv ("XTERM_VERSION", "XTerm(312)", 1);
|
setenv ("XTERM_VERSION", "XTerm(312)", 1);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "screen-256color" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1416,12 +1399,12 @@ void FTermDetectionTest::tmuxTest()
|
||||||
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "screen" );
|
||||||
|
|
||||||
setenv ("VTE_VERSION", "3801", 1);
|
setenv ("VTE_VERSION", "3801", 1);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "screen-256color" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "screen-256color" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1493,7 +1476,7 @@ void FTermDetectionTest::ktermTest()
|
||||||
detect.setKtermTerminal(false);
|
detect.setKtermTerminal(false);
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
|
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1560,13 +1543,13 @@ void FTermDetectionTest::mltermTest()
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "mlterm-256color" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "mlterm-256color" );
|
||||||
|
|
||||||
setenv ("TERM", "mlterm", 1);
|
setenv ("TERM", "mlterm", 1);
|
||||||
unsetenv("COLORFGBG");
|
unsetenv("COLORFGBG");
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "xterm-256color" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "xterm-256color" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
@ -1631,7 +1614,7 @@ void FTermDetectionTest::kittyTest()
|
||||||
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
|
||||||
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
|
||||||
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "xterm-kitty" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "xterm-kitty" );
|
||||||
|
|
||||||
auto kitty_version = detect.getKittyVersion();
|
auto kitty_version = detect.getKittyVersion();
|
||||||
CPPUNIT_ASSERT ( kitty_version.primary == 0 );
|
CPPUNIT_ASSERT ( kitty_version.primary == 0 );
|
||||||
|
@ -1714,17 +1697,17 @@ void FTermDetectionTest::ttytypeTest()
|
||||||
// Test /dev/tty3 with linux
|
// Test /dev/tty3 with linux
|
||||||
data.setTermFileName("/dev/tty3");
|
data.setTermFileName("/dev/tty3");
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "linux" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "linux" );
|
||||||
|
|
||||||
// Test /dev/ttyp0 with vt100
|
// Test /dev/ttyp0 with vt100
|
||||||
data.setTermFileName("/dev/ttyp0");
|
data.setTermFileName("/dev/ttyp0");
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
// Test non-existent /dev/tty8 with fallback to vt100
|
// Test non-existent /dev/tty8 with fallback to vt100
|
||||||
data.setTermFileName("/dev/tty8");
|
data.setTermFileName("/dev/tty8");
|
||||||
detect.detect();
|
detect.detect();
|
||||||
CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "vt100" );
|
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
|
||||||
|
|
||||||
printConEmuDebug();
|
printConEmuDebug();
|
||||||
closeConEmuStdStreams();
|
closeConEmuStdStreams();
|
||||||
|
|
|
@ -522,7 +522,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
|
||||||
CPPUNIT_ASSERT ( data.getTermGeometry().getHeight() == 25 );
|
CPPUNIT_ASSERT ( data.getTermGeometry().getHeight() == 25 );
|
||||||
CPPUNIT_ASSERT ( ! data.hasShadowCharacter() );
|
CPPUNIT_ASSERT ( ! data.hasShadowCharacter() );
|
||||||
CPPUNIT_ASSERT ( ! data.hasHalfBlockCharacter() );
|
CPPUNIT_ASSERT ( ! data.hasHalfBlockCharacter() );
|
||||||
CPPUNIT_ASSERT_CSTRING ( term_detection.getTermType(), "pccon" );
|
CPPUNIT_ASSERT ( term_detection.getTermType() == "pccon" );
|
||||||
|
|
||||||
openbsd.finish();
|
openbsd.finish();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue