Replace some std::bind with lambda functions
This commit is contained in:
parent
0fefcd81c2
commit
24553aa7d0
|
@ -1,3 +1,6 @@
|
|||
2021-05-01 Markus Gans <guru.mail@muenster.de>
|
||||
* Replace some std::bind with lambda functions
|
||||
|
||||
2021-04-30 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes Linux console bug from February 20, 2021
|
||||
|
||||
|
|
|
@ -397,10 +397,10 @@ void FApplication::init()
|
|||
|
||||
// Initialize keyboard
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
auto cmd1 = std::bind(&FApplication::keyPressed, this);
|
||||
auto cmd2 = std::bind(&FApplication::keyReleased, this);
|
||||
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
|
||||
auto cmd4 = std::bind(&FApplication::mouseTracking, this);
|
||||
auto cmd1 = [this] () { this->keyPressed(); };
|
||||
auto cmd2 = [this] () { this->keyReleased(); };
|
||||
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
||||
auto cmd4 = [this] () { this->mouseTracking(); };
|
||||
FKeyboardCommand key_cmd1 (cmd1);
|
||||
FKeyboardCommand key_cmd2 (cmd2);
|
||||
FKeyboardCommand key_cmd3 (cmd3);
|
||||
|
@ -414,8 +414,7 @@ void FApplication::init()
|
|||
|
||||
// Initialize mouse control
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
using namespace std::placeholders;
|
||||
auto cmd = std::bind(&FApplication::mouseEvent, this, _1);
|
||||
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
||||
FMouseCommand mouse_cmd (cmd);
|
||||
mouse->setEventCommand (mouse_cmd);
|
||||
// Set stdin number for a gpm-mouse
|
||||
|
@ -484,9 +483,8 @@ inline void FApplication::setLongOptions (std::vector<CmdOption>& long_options)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FApplication::setCmdOptionsMap (CmdMap& cmd_map)
|
||||
{
|
||||
using std::placeholders::_1;
|
||||
auto enc = std::bind(&FApplication::setTerminalEncoding, _1);
|
||||
auto log = std::bind(&FApplication::setLogFile, _1);
|
||||
auto enc = [] (const FString& s) { FApplication::setTerminalEncoding(s); };
|
||||
auto log = [] (const FString& s) { FApplication::setLogFile(s); };
|
||||
auto opt = &FApplication::getStartOptions;
|
||||
|
||||
// --encoding
|
||||
|
|
|
@ -48,19 +48,19 @@ FLog& FLog::operator << (LogLevel l)
|
|||
switch ( l )
|
||||
{
|
||||
case LogLevel::Info:
|
||||
current_log = std::bind(&FLog::info, this, _1);
|
||||
current_log = [this] (const std::string& s) { info(s); };
|
||||
break;
|
||||
|
||||
case LogLevel::Warn:
|
||||
current_log = std::bind(&FLog::warn, this, _1);
|
||||
current_log = [this] (const std::string& s) { warn(s); };
|
||||
break;
|
||||
|
||||
case LogLevel::Error:
|
||||
current_log = std::bind(&FLog::error, this, _1);
|
||||
current_log = [this] (const std::string& s) { error(s); };
|
||||
break;
|
||||
|
||||
case LogLevel::Debug:
|
||||
current_log = std::bind(&FLog::debug, this, _1);
|
||||
current_log = [this] (const std::string& s) { debug(s); };
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class FLog : public std::stringbuf
|
|||
// Data member
|
||||
LogLevel level{LogLevel::Info};
|
||||
LineEnding end_of_line{LineEnding::CRLF};
|
||||
FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
|
||||
FLogPrint current_log{ [this] (const std::string& s) { info(s); } };
|
||||
std::mutex current_log_mutex{};
|
||||
std::mutex stream_mutex{};
|
||||
std::ostream stream{this};
|
||||
|
|
|
@ -43,7 +43,11 @@ class FTermFunctionsTest : public CPPUNIT_NS::TestFixture, test::ConEmu
|
|||
public:
|
||||
FTermFunctionsTest()
|
||||
{
|
||||
std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
auto ret = std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
|
||||
if ( ! ret )
|
||||
ret = std::setlocale (LC_CTYPE, "C.UTF-8");
|
||||
|
||||
fwide(stdout, 1); // Makes stream wide-character oriented
|
||||
}
|
||||
|
||||
|
@ -516,7 +520,12 @@ void FTermFunctionsTest::FullWidthHalfWidthTest()
|
|||
CPPUNIT_ASSERT ( finalcut::getColumnWidth(L'└') == 1 ); // wcwidth(L'└') == -1 (for LC_CTYPE = C)
|
||||
CPPUNIT_ASSERT ( finalcut::getColumnWidth(L'┌') == 1 ); // wcwidth(L'┌') == -1 (for LC_CTYPE = C)
|
||||
CPPUNIT_ASSERT ( finalcut::getColumnWidth(L'┘') == 1 ); // wcwidth(L'┘') == -1 (for LC_CTYPE = C)
|
||||
std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
|
||||
auto ret = std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
|
||||
if ( ! ret )
|
||||
ret = std::setlocale (LC_CTYPE, "C.UTF-8");
|
||||
|
||||
data->setTermEncoding (finalcut::Encoding::UTF8);
|
||||
|
||||
// Column width (FString)
|
||||
|
|
|
@ -42,7 +42,11 @@ class FTermBufferTest : public CPPUNIT_NS::TestFixture
|
|||
public:
|
||||
FTermBufferTest()
|
||||
{
|
||||
std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
auto ret = std::setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
|
||||
if ( ! ret )
|
||||
ret = std::setlocale (LC_CTYPE, "C.UTF-8");
|
||||
|
||||
fwide(stdout, 1); // Makes stream wide-character oriented
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue