Minor changes

This commit is contained in:
Markus Gans 2020-10-08 12:09:48 +02:00
parent e74dccf481
commit 9f1bd87151
7 changed files with 176 additions and 172 deletions

View File

@ -96,12 +96,14 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l)
{ {
for (std::size_t i{0}; i < 8; i++) for (std::size_t i{0}; i < 8; i++)
{ {
data[h++] = L' '; data[h] = L' ';
h++;
} }
for (std::size_t i{0}; i < 8; i++) for (std::size_t i{0}; i < 8; i++)
{ {
data[h++] = L'+'; data[h] = L'+';
h++;
} }
} }
@ -109,12 +111,14 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l)
{ {
for (std::size_t i{0}; i < 8; i++) for (std::size_t i{0}; i < 8; i++)
{ {
data[h++] = L'x'; data[h] = L'x';
h++;
} }
for (std::size_t i{0}; i < 8; i++) for (std::size_t i{0}; i < 8; i++)
{ {
data[h++] = L' '; data[h] = L' ';
h++;
} }
} }
} }

View File

@ -97,9 +97,9 @@ FApplication::FApplication (const int& _argc, char* _argv[])
if ( ! (_argc && _argv) ) if ( ! (_argc && _argv) )
{ {
typedef char* CString; typedef char* CString;
static CString empty[1]{CString("")}; static std::array<CString, 1> empty{CString("")};
app_argc = 0; app_argc = 0;
app_argv = empty; app_argv = empty.data();
} }
init(); init();

View File

@ -25,6 +25,7 @@
#include <strings.h> // need for strcasecmp #include <strings.h> // need for strcasecmp
#endif #endif
#include <array>
#include <vector> #include <vector>
#include "final/fevent.h" #include "final/fevent.h"
@ -427,7 +428,7 @@ inline bool FFileDialog::patternMatch ( const char* const pattern
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1); std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
} }
else else
std::strncpy(search.data(), pattern, search.size()); std::strncpy(search.data(), pattern, search.size() - 1);
search[search.size() - 1] = '\0'; search[search.size() - 1] = '\0';
@ -602,7 +603,7 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
if ( ! fsystem ) if ( ! fsystem )
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
std::strncpy (symLink.data(), dir, symLink.size()); std::strncpy (symLink.data(), dir, symLink.size() - 1);
symLink[symLink.size() - 1] = '\0'; symLink[symLink.size() - 1] = '\0';
std::strncat ( symLink.data() std::strncat ( symLink.data()
, entry.name.c_str() , entry.name.c_str()

View File

@ -545,10 +545,9 @@ FPoint readCursorPos()
constexpr auto& DECXCPR{ESC "[6n"}; constexpr auto& DECXCPR{ESC "[6n"};
// Report Cursor Position (DECXCPR) // Report Cursor Position (DECXCPR)
const ssize_t ret = write(stdout_no, DECXCPR, std::strlen(DECXCPR)); if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
return FPoint{x, y};
if ( ret > 0 )
{
std::fflush(stdout); std::fflush(stdout);
FD_ZERO(&ifds); FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
@ -556,8 +555,9 @@ FPoint readCursorPos()
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
// Read the answer // Read the answer
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) != 1 )
{ return FPoint{x, y};
constexpr auto parse = "\033[%4d;%4dR"; constexpr auto parse = "\033[%4d;%4dR";
std::array<char, 20> temp{}; std::array<char, 20> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -576,8 +576,6 @@ FPoint readCursorPos()
if ( pos > 4 ) if ( pos > 4 )
std::sscanf(temp.data(), parse, &x, &y); std::sscanf(temp.data(), parse, &x, &y);
}
}
return FPoint{x, y}; return FPoint{x, y};
} }

View File

@ -580,8 +580,9 @@ FString FTermDetection::getXTermColorName (FColor color)
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the terminal answer // read the terminal answer
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
{ return color_str;
constexpr auto parse = "\033]4;%10hu;%509[^\n]s"; constexpr auto parse = "\033]4;%10hu;%509[^\n]s";
std::array<char, 35> temp{}; std::array<char, 35> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -598,8 +599,7 @@ FString FTermDetection::getXTermColorName (FColor color)
} }
while ( pos < temp.size() ); while ( pos < temp.size() );
if ( pos > 4 if ( pos > 4 && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 )
&& std::sscanf(temp.data(), parse, &color, buf.data()) == 2 )
{ {
std::size_t n = std::strlen(buf.data()); std::size_t n = std::strlen(buf.data());
@ -613,7 +613,6 @@ FString FTermDetection::getXTermColorName (FColor color)
color_str = buf.data(); color_str = buf.data();
} }
}
return color_str; return color_str;
} }
@ -647,8 +646,8 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
new_termtype = "putty"; new_termtype = "putty";
} }
// Some terminal like cygwin or the windows terminal // Some terminals like cygwin or the Windows terminal
// needs to delete the '♣' char // have to delete the printed character '♣'
std::fprintf (stdout, "\r " BS); std::fprintf (stdout, "\r " BS);
std::fflush (stdout); std::fflush (stdout);
@ -681,8 +680,9 @@ FString FTermDetection::getAnswerbackMsg()
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// Read the answerback message // Read the answerback message
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
{ return answerback;
std::array<char, 10> temp{}; std::array<char, 10> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -700,7 +700,6 @@ FString FTermDetection::getAnswerbackMsg()
if ( pos > 0 ) if ( pos > 0 )
answerback = temp.data(); answerback = temp.data();
}
return answerback; return answerback;
} }
@ -815,9 +814,7 @@ FString FTermDetection::getSecDA()
constexpr auto& SECDA{ESC "[>c"}; constexpr auto& SECDA{ESC "[>c"};
// Get the secondary device attributes // Get the secondary device attributes
const ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA)); if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 )
if ( ret == -1 )
return sec_da_str; return sec_da_str;
std::fflush(stdout); std::fflush(stdout);
@ -827,8 +824,9 @@ FString FTermDetection::getSecDA()
tv.tv_usec = 600000; // 600 ms tv.tv_usec = 600000; // 600 ms
// Read the answer // Read the answer
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
{ return sec_da_str;
constexpr auto parse = "\033[>%10d;%10d;%10dc"; constexpr auto parse = "\033[>%10d;%10d;%10dc";
std::array<char, 40> temp{}; std::array<char, 40> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -845,10 +843,8 @@ FString FTermDetection::getSecDA()
} }
while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr );
if ( pos > 3 if ( pos > 3 && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 )
&& std::sscanf(temp.data(), parse, &a, &b, &c) == 3 )
sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c);
}
return sec_da_str; return sec_da_str;
} }

View File

@ -765,10 +765,13 @@ FString FTermXTerminal::captureXTermFont() const
{ {
initCheck(FString{}); initCheck(FString{});
if ( term_detection->isXTerminal() if ( ! term_detection->isXTerminal()
|| term_detection->isScreenTerm() && ! term_detection->isScreenTerm()
|| FTermcap::osc_support ) && ! FTermcap::osc_support )
{ {
return FString{};
}
fd_set ifds{}; fd_set ifds{};
struct timeval tv{}; struct timeval tv{};
const int stdin_no = FTermios::getStdIn(); const int stdin_no = FTermios::getStdIn();
@ -784,8 +787,9 @@ FString FTermXTerminal::captureXTermFont() const
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// Read the terminal answer // Read the terminal answer
if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
{ return FString{};
std::array<char, 150> temp{}; std::array<char, 150> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -801,8 +805,8 @@ FString FTermXTerminal::captureXTermFont() const
} }
while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr );
if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5'
&& temp[2] == '5' && temp[3] == '0' && temp[4] == ';' ) && temp[3] == '0' && temp[4] == ';' )
{ {
// Skip leading Esc ] 5 0 ; // Skip leading Esc ] 5 0 ;
char* str = &temp[5]; char* str = &temp[5];
@ -814,8 +818,6 @@ FString FTermXTerminal::captureXTermFont() const
return FString{str}; return FString{str};
} }
}
}
return FString{}; return FString{};
} }
@ -841,8 +843,9 @@ FString FTermXTerminal::captureXTermTitle() const
tv.tv_usec = 150000; // 150 ms tv.tv_usec = 150000; // 150 ms
// read the terminal answer // read the terminal answer
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 )
{ return FString{};
std::array<char, 512> temp{}; std::array<char, 512> temp{};
std::size_t pos{0}; std::size_t pos{0};
@ -874,7 +877,6 @@ FString FTermXTerminal::captureXTermTitle() const
return FString{str}; return FString{str};
} }
} }
}
return FString{}; return FString{};
} }

View File

@ -153,6 +153,8 @@ template <typename T>
class FData : public FDataAccess class FData : public FDataAccess
{ {
public: public:
typedef typename std::remove_cv<T>::type T_nocv;
// Constructors // Constructors
explicit FData (T& v) // constructor explicit FData (T& v) // constructor
: value_ref{v} : value_ref{v}
@ -244,8 +246,9 @@ class FData : public FDataAccess
// Inquiries // Inquiries
bool isInitializedCopy() const bool isInitializedCopy() const
{ {
return bool( reinterpret_cast<void*>(&value) const auto& v = reinterpret_cast<void*>(const_cast<T_nocv*>(&value));
== reinterpret_cast<void*>(&value_ref.get()) ); const auto& r = reinterpret_cast<void*>(const_cast<T_nocv*>(&value_ref.get()));
return bool( v == r );
} }
bool isInitializedReference() const bool isInitializedReference() const