Solaris build fix

This commit is contained in:
Markus Gans 2020-10-11 09:14:52 +02:00
parent 73e587b9c2
commit 396cda69e8
20 changed files with 193 additions and 86 deletions

View File

@ -1,6 +1,5 @@
language: cpp language: cpp
dist: xenial dist: xenial
sudo: required
compiler: compiler:
- gcc - gcc
@ -41,7 +40,7 @@ env:
bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy
lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I= lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I=
matrix: jobs:
include: include:
# #
# Coverity Scan # Coverity Scan

View File

@ -1,3 +1,10 @@
2020-10-11 Markus Gans <guru.mail@muenster.de>
* Solaris build fix
* Added saving and restoring xterm titles to the stack
for vte terminals
* Menu key - activates the menu bar
* Shift-Menu - opens the dialog menu
2020-10-08 Markus Gans <guru.mail@muenster.de> 2020-10-08 Markus Gans <guru.mail@muenster.de>
* Better keyboard support for urxvt terminals * Better keyboard support for urxvt terminals
* Screen reports (like Secondary DA) are now read directly * Screen reports (like Secondary DA) are now read directly

View File

@ -137,7 +137,7 @@ int main (int argc, char* argv[])
After entering the source code in *dialog.cpp* you can compile After entering the source code in *dialog.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ dialog.cpp -o dialog -O2 -lfinal g++ dialog.cpp -o dialog -O2 -lfinal
``` ```
@ -284,7 +284,7 @@ int main (int argc, char* argv[])
After entering the source code in *memory.cpp* you can compile After entering the source code in *memory.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ memory.cpp -o memory -O2 -lfinal g++ memory.cpp -o memory -O2 -lfinal
``` ```
@ -424,7 +424,7 @@ int main (int argc, char* argv[])
After entering the source code in *timer.cpp* you can compile After entering the source code in *timer.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ timer.cpp -o timer -O2 -lfinal -std=c++11 g++ timer.cpp -o timer -O2 -lfinal -std=c++11
``` ```
@ -537,7 +537,7 @@ int main (int argc, char* argv[])
After entering the source code in *user-event.cpp* you can compile After entering the source code in *user-event.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ user-event.cpp -o user-event -O2 -lfinal -std=c++11 g++ user-event.cpp -o user-event -O2 -lfinal -std=c++11
``` ```
@ -808,7 +808,7 @@ int main (int argc, char* argv[])
After entering the source code in *callback-function.cpp* you can compile After entering the source code in *callback-function.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ callback-function.cpp -o callback-function -O2 -lfinal g++ callback-function.cpp -o callback-function -O2 -lfinal
``` ```
&nbsp; &nbsp;
@ -871,7 +871,7 @@ int main (int argc, char* argv[])
After entering the source code in *callback-lambda.cpp* you can compile After entering the source code in *callback-lambda.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ callback-lambda.cpp -o callback-lambda -O2 -lfinal -std=c++11 g++ callback-lambda.cpp -o callback-lambda -O2 -lfinal -std=c++11
``` ```
&nbsp; &nbsp;
@ -930,7 +930,7 @@ int main (int argc, char* argv[])
After entering the source code in *callback-method.cpp* you can compile After entering the source code in *callback-method.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ callback-method.cpp -o callback-method -O2 -lfinal -std=c++11 g++ callback-method.cpp -o callback-method -O2 -lfinal -std=c++11
``` ```
&nbsp; &nbsp;
@ -1051,7 +1051,7 @@ int main (int argc, char* argv[])
After entering the source code in *emit-signal.cpp* you can compile After entering the source code in *emit-signal.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ emit-signal.cpp -o emit-signal -O2 -lfinal -std=c++11 g++ emit-signal.cpp -o emit-signal -O2 -lfinal -std=c++11
``` ```
@ -1322,7 +1322,7 @@ int main (int argc, char* argv[])
After entering the source code in *size-adjustment.cpp* you can compile After entering the source code in *size-adjustment.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ size-adjustment.cpp -o size-adjustment -O2 -lfinal -std=c++11 g++ size-adjustment.cpp -o size-adjustment -O2 -lfinal -std=c++11
``` ```
@ -1450,6 +1450,6 @@ int main (int argc, char* argv[])
After entering the source code in *scrollview.cpp* you can compile After entering the source code in *scrollview.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ scrollview.cpp -o scrollview -O2 -lfinal -std=c++11 g++ scrollview.cpp -o scrollview -O2 -lfinal -std=c++11
``` ```

View File

@ -437,7 +437,7 @@ int main (int argc, char* argv[])
After entering the source code in *theme.cpp* you can compile After entering the source code in *theme.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```bash
g++ theme.cpp -o theme -O2 -lfinal -std=c++11 g++ theme.cpp -o theme -O2 -lfinal -std=c++11
``` ```

View File

@ -151,8 +151,10 @@ Menu::Menu (finalcut::FWidget* parent)
// Info label // Info label
Info << "<F10> Activate menu bar\n" Info << "<F10> Activate menu bar\n"
<< "<Ctrl>+<Space> Activate menu bar\n" << "<Ctrl>+<Space> Activate menu bar\n"
<< "<Menu> Activate menu bar\n"
<< "<Shift>+<Menu> Open dialog menu\n"
<< "<Meta>+<X> Exit"; << "<Meta>+<X> Exit";
Info.setGeometry(FPoint{2, 1}, FSize{36, 3}); Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -327,7 +329,7 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Menu main_dlg {&app}; Menu main_dlg {&app};
main_dlg.setText ("Menu example"); main_dlg.setText ("Menu example");
main_dlg.setSize ({40, 6}); main_dlg.setSize ({40, 8});
main_dlg.setShadow(); main_dlg.setShadow();
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget

View File

@ -780,10 +780,9 @@ void MyDialog::initWidgetsCallbacks()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::adjustSize() void MyDialog::adjustSize()
{ {
finalcut::FDialog::adjustSize();
const auto h = getDesktopHeight() - 4; const auto h = getDesktopHeight() - 4;
setHeight (h, false); setHeight (h, false);
finalcut::FDialog::adjustSize(); // with new client area size
auto x = int((getDesktopWidth() - getWidth()) / 2); auto x = int((getDesktopWidth() - getWidth()) / 2);
if ( x < 1 ) if ( x < 1 )
@ -792,7 +791,7 @@ void MyDialog::adjustSize()
setPos (FPoint{x, 2}, false); setPos (FPoint{x, 2}, false);
if ( initialized ) if ( initialized )
myList.setHeight (getHeight() - 3, true); myList.setHeight (h - 3, true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -66,9 +66,35 @@ FMouseControl* FApplication::mouse {nullptr}; // mouse control
int FApplication::loop_level {0}; // event loop level int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {EXIT_SUCCESS}; int FApplication::quit_code {EXIT_SUCCESS};
bool FApplication::quit_now {false}; bool FApplication::quit_now {false};
uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms /200 Hz uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms (200 Hz)
struct timeval FApplication::time_last_event{}; struct timeval FApplication::time_last_event{};
constexpr FApplication::CmdOption FApplication::long_options[] =
{
{"encoding", required_argument, nullptr, 'e' },
{"log-file", required_argument, nullptr, 'l' },
{"no-mouse", no_argument, nullptr, 'm' },
{"no-optimized-cursor", no_argument, nullptr, 'o' },
{"no-terminal-detection", no_argument, nullptr, 'd' },
{"no-terminal-data-request", no_argument, nullptr, 'r' },
{"no-color-change", no_argument, nullptr, 'c' },
{"no-sgr-optimizer", no_argument, nullptr, 's' },
{"vgafont", no_argument, nullptr, 'v' },
{"newfont", no_argument, nullptr, 'n' },
{"dark-theme", no_argument, nullptr, 't' },
#if defined(__FreeBSD__) || defined(__DragonFly__)
{"no-esc-for-alt-meta", no_argument, nullptr, 'E' },
{"no-cursorstyle-change", no_argument, nullptr, 'C' },
#elif defined(__NetBSD__) || defined(__OpenBSD__)
{"no-esc-for-alt-meta", no_argument, nullptr, 'E' },
#endif
{nullptr, 0, nullptr, 0 }
};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FApplication // class FApplication
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -382,7 +408,9 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
void FApplication::processExternalUserEvent() void FApplication::processExternalUserEvent()
{ {
// This method can be overloaded and replaced by own code // This method can be overloaded and replaced by own code
std::this_thread::sleep_for(std::chrono::milliseconds(5));
if ( FKeyboard::getReadBlockingTime() < 10000 )
std::this_thread::sleep_for(std::chrono::milliseconds(5));
} }
@ -463,81 +491,72 @@ void FApplication::cmd_options (const int& argc, char* argv[])
while ( true ) while ( true )
{ {
static struct option long_options[] =
{
{"encoding", required_argument, nullptr, 0 },
{"log-file", required_argument, nullptr, 0 },
{"no-mouse", no_argument, nullptr, 0 },
{"no-optimized-cursor", no_argument, nullptr, 0 },
{"no-terminal-detection", no_argument, nullptr, 0 },
{"no-terminal-data-request", no_argument, nullptr, 0 },
{"no-color-change", no_argument, nullptr, 0 },
{"no-sgr-optimizer", no_argument, nullptr, 0 },
{"vgafont", no_argument, nullptr, 0 },
{"newfont", no_argument, nullptr, 0 },
{"dark-theme", no_argument, nullptr, 0 },
#if defined(__FreeBSD__) || defined(__DragonFly__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
{"no-cursorstyle-change", no_argument, nullptr, 0 },
#elif defined(__NetBSD__) || defined(__OpenBSD__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
#endif
{nullptr, 0, nullptr, 0 }
};
opterr = 0; opterr = 0;
int idx{0}; int idx{0};
const int c = getopt_long (argc, argv, "", long_options, &idx); auto p = reinterpret_cast<const struct option*>(long_options);
const int opt = getopt_long (argc, argv, "", p, &idx);
if ( c == -1 ) if ( opt == -1 )
break; break;
if ( c == 0 ) switch ( opt )
{ {
if ( std::strcmp(long_options[idx].name, "encoding") == 0 ) case 'e': // --encoding
setTerminalEncoding(FString(optarg)); setTerminalEncoding(FString(optarg));
break;
if ( std::strcmp(long_options[idx].name, "log-file") == 0 ) case 'l': // --log-file
setLogFile(FString(optarg)); setLogFile(FString(optarg));
break;
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 ) case 'm': // --no-mouse
getStartOptions().mouse_support = false; getStartOptions().mouse_support = false;
break;
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 ) case 'o': // --no-optimized-cursor
getStartOptions().cursor_optimisation = false; getStartOptions().cursor_optimisation = false;
break;
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 ) case 'd': // --no-terminal-detection
getStartOptions().terminal_detection = false; getStartOptions().terminal_detection = false;
break;
if ( std::strcmp(long_options[idx].name, "no-terminal-data-request") == 0 ) case 'r': // --no-terminal-data-request
getStartOptions().terminal_data_request = false; getStartOptions().terminal_data_request = false;
break;
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 ) case 'c': // --no-color-change
getStartOptions().color_change = false; getStartOptions().color_change = false;
break;
if ( std::strcmp(long_options[idx].name, "no-sgr-optimizer") == 0 ) case 's': // --no-sgr-optimizer
getStartOptions().sgr_optimizer = false; getStartOptions().sgr_optimizer = false;
break;
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 ) case 'v': // --vgafont
getStartOptions().vgafont = true; getStartOptions().vgafont = true;
break;
if ( std::strcmp(long_options[idx].name, "newfont") == 0 ) case 'n': // --newfont
getStartOptions().newfont = true; getStartOptions().newfont = true;
break;
if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 ) case 't': // --dark-theme
getStartOptions().dark_theme = true; getStartOptions().dark_theme = true;
break;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 ) case 'E': // --no-esc-for-alt-meta
getStartOptions().meta_sends_escape = false; getStartOptions().meta_sends_escape = false;
break;
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 ) case 'C': // --no-cursorstyle-change
getStartOptions().change_cursorstyle = false; getStartOptions().change_cursorstyle = false;
break;
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 ) case 'E': // --no-esc-for-alt-meta
getStartOptions().meta_sends_escape = false; getStartOptions().meta_sends_escape = false;
break;
#endif #endif
} }
} }

View File

@ -459,8 +459,9 @@ void FDialog::onKeyPress (FKeyEvent* ev)
cancelMouseResize(); cancelMouseResize();
if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6) if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|| ev->key() == fc::Fkey_f22 ) // Shift+F10 || ev->key() == fc::Fkey_f22 // Shift+F10
|| ev->key() == fc::Fkey_smenu ) // Shift+Menu
{ {
ev->accept(); ev->accept();
// open the titlebar menu // open the titlebar menu

View File

@ -47,6 +47,7 @@ FLog& FLog::operator << (LogLevel l)
{ {
using std::placeholders::_1; using std::placeholders::_1;
sync(); sync();
std::lock_guard<std::mutex> lock_guard(mut);
switch ( l ) switch ( l )
{ {
@ -77,6 +78,7 @@ int FLog::sync()
{ {
if ( ! str().empty() ) if ( ! str().empty() )
{ {
std::lock_guard<std::mutex> lock_guard(mut);
current_log (str()); current_log (str());
str(""); str("");
} }

View File

@ -72,8 +72,10 @@ std::string FLogger::getTimeString() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FLogger::getEOL() const std::string FLogger::getEOL()
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
if ( getEnding() == FLog::LF ) if ( getEnding() == FLog::LF )
return "\n"; return "\n";
else if ( getEnding() == FLog::CR ) else if ( getEnding() == FLog::CR )
@ -89,6 +91,8 @@ void FLogger::printLogLine (const std::string& msg)
{ {
const std::string& log_level = [this] () const std::string& log_level = [this] ()
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
switch ( getLevel() ) switch ( getLevel() )
{ {
case Info: case Info:

View File

@ -256,6 +256,7 @@ void FMenuBar::init()
addAccelerator (fc::Fkey_f10); addAccelerator (fc::Fkey_f10);
addAccelerator (fc::Fckey_space); addAccelerator (fc::Fckey_space);
addAccelerator (fc::Fkey_menu);
resetColors(); resetColors();
unsetFocusable(); unsetFocusable();
} }

View File

@ -553,15 +553,13 @@ FPoint readCursorPos()
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
std::array<char, 20> temp{};
std::size_t pos{0};
// 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}; return FPoint{x, y};
constexpr auto parse = "\033[%4d;%4dR";
std::array<char, 20> temp{};
std::size_t pos{0};
do do
{ {
std::size_t bytes_free = temp.size() - pos - 1; std::size_t bytes_free = temp.size() - pos - 1;
@ -572,10 +570,13 @@ FPoint readCursorPos()
pos += std::size_t(bytes); pos += std::size_t(bytes);
} }
while ( pos < temp.size() && std::strchr(temp.data(), 'R') == nullptr ); while ( pos < temp.size() && ! std::strchr(temp.data(), 'R') );
if ( pos > 4 ) if ( pos > 4 )
{
constexpr auto parse = "\033[%4d;%4dR";
std::sscanf(temp.data(), parse, &x, &y); std::sscanf(temp.data(), parse, &x, &y);
}
return FPoint{x, y}; return FPoint{x, y};
} }

View File

@ -91,7 +91,7 @@ void FTermcap::termcap()
// Open termcap file // Open termcap file
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
char* termtype = fterm_data->getTermType(); char* termtype = const_cast<char*>(fterm_data->getTermType());
#else #else
const char* termtype = fterm_data->getTermType(); const char* termtype = fterm_data->getTermType();
#endif #endif

View File

@ -20,6 +20,7 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <cstring>
#include <string> #include <string>
#include "final/fc.h" #include "final/fc.h"
@ -267,6 +268,25 @@ void FTermcapQuirks::vte()
// set exit underline for gnome terminal // set exit underline for gnome terminal
TCAP(fc::t_exit_underline_mode) = \ TCAP(fc::t_exit_underline_mode) = \
CSI "24m"; CSI "24m";
if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
{
if ( ! std::strstr(TCAP(fc::t_enter_ca_mode), "\033[22;0;0t") )
{
// Save the cursor position, enter alternate screen buffer
// and save xterm icon and window title on stack
TCAP(fc::t_enter_ca_mode) = \
CSI "?1049h" CSI "22;0;0t";
}
if ( ! std::strstr(TCAP(fc::t_exit_ca_mode), "\033[23;0;0t") )
{
// Use normal screen buffer, restore the cursor position
// and restore xterm icon and window title from stack
TCAP(fc::t_exit_ca_mode) = \
CSI "?1049l" CSI "23;0;0t";
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -843,7 +843,7 @@ FString FTermDetection::getSecDA()
pos += std::size_t(bytes); pos += std::size_t(bytes);
} }
while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); while ( pos < temp.size() && ! std::strchr(temp.data(), 'c') );
if ( pos > 3 && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 ) if ( pos > 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);

View File

@ -316,9 +316,11 @@ bool FTermLinux::loadNewFont()
// Set the graphical font // Set the graphical font
int ret; int ret;
#if defined(ISA_SYSCTL_SUPPORT)
if ( has9BitCharacters() ) if ( has9BitCharacters() )
ret = setScreenFont(fc::__9x16graph, 256, 8, 16); // set 9×16 ret = setScreenFont(fc::__9x16graph, 256, 8, 16); // set 9×16
else else
#endif
ret = setScreenFont(fc::__8x16graph, 256, 8, 16); // set 8×16 ret = setScreenFont(fc::__8x16graph, 256, 8, 16); // set 8×16
if ( ret != 0 ) if ( ret != 0 )

View File

@ -805,7 +805,7 @@ FString FTermXTerminal::captureXTermFont() const
pos += std::size_t(bytes); pos += std::size_t(bytes);
} }
while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); while ( pos < temp.size() && ! std::strchr(temp.data(), '\a') );
if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5' if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5'
&& temp[3] == '0' && temp[4] == ';' ) && temp[3] == '0' && temp[4] == ';' )

View File

@ -218,6 +218,20 @@ class FApplication : public FWidget
static FMouseControl* mouse; static FMouseControl* mouse;
static FKeyboard* keyboard; static FKeyboard* keyboard;
static FWidget* keyboard_widget; static FWidget* keyboard_widget;
#if defined(__sun) && defined(__SVR4)
struct CmdOption
{
const char* name; // <- name is without 'const' in Solaris
int has_arg;
int* flag;
int val;
};
#else
using CmdOption = struct option;
#endif
static const CmdOption long_options[];
}; };

View File

@ -42,6 +42,7 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <mutex>
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -97,15 +98,17 @@ class FLog : public std::stringbuf
protected: protected:
int sync() override; int sync() override;
const LogLevel& getLevel() const; const LogLevel& getLevel();
LogLevel& setLevel(); LogLevel& setLevel();
const LineEnding& getEnding() const; const LineEnding& getEnding();
LineEnding& setEnding(); LineEnding& setEnding();
std::mutex& getMutex();
private: private:
// Data member // Data member
LogLevel level{Info}; LogLevel level{Info};
LineEnding end_of_line{CRLF}; LineEnding end_of_line{CRLF};
std::mutex mut;
FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)}; FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
std::ostream stream{this}; std::ostream stream{this};
@ -118,6 +121,7 @@ class FLog : public std::stringbuf
template <typename T> template <typename T>
inline FLog& FLog::operator << (const T& s) inline FLog& FLog::operator << (const T& s)
{ {
std::lock_guard<std::mutex> lock_guard(mut);
stream << s; stream << s;
return *this; return *this;
} }
@ -125,6 +129,7 @@ inline FLog& FLog::operator << (const T& s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FLog& FLog::operator << (IOManip pf) inline FLog& FLog::operator << (IOManip pf)
{ {
std::lock_guard<std::mutex> lock_guard(mut);
pf(stream); pf(stream);
return *this; return *this;
} }
@ -134,21 +139,33 @@ inline FString FLog::getClassName() const
{ return "FLog"; } { return "FLog"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FLog::LogLevel& FLog::getLevel() const inline const FLog::LogLevel& FLog::getLevel()
{ return level; } {
return level;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FLog::LogLevel& FLog::setLevel() inline FLog::LogLevel& FLog::setLevel()
{ return level; } {
return level;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FLog::LineEnding& FLog::getEnding() const inline const FLog::LineEnding& FLog::getEnding()
{ return end_of_line; } {
std::lock_guard<std::mutex> lock_guard(mut);
return end_of_line;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FLog::LineEnding& FLog::setEnding() inline FLog::LineEnding& FLog::setEnding()
{ return end_of_line; } {
return end_of_line;
}
//----------------------------------------------------------------------
inline std::mutex& FLog::getMutex()
{ return mut; }
} // namespace finalcut } // namespace finalcut

View File

@ -87,7 +87,7 @@ class FLogger : public FLog
// Methods // Methods
void newlineReplace (std::string&, const std::string&) const; void newlineReplace (std::string&, const std::string&) const;
std::string getTimeString() const; std::string getTimeString() const;
std::string getEOL() const; std::string getEOL();
void printLogLine (const std::string&); void printLogLine (const std::string&);
// Data member // Data member
@ -103,6 +103,7 @@ inline FString FLogger::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::info (const std::string& msg) inline void FLogger::info (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Info; setLevel() = Info;
printLogLine (msg); printLogLine (msg);
} }
@ -110,6 +111,7 @@ inline void FLogger::info (const std::string& msg)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::warn (const std::string& msg) inline void FLogger::warn (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Warn; setLevel() = Warn;
printLogLine (msg); printLogLine (msg);
} }
@ -117,6 +119,7 @@ inline void FLogger::warn (const std::string& msg)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::error (const std::string& msg) inline void FLogger::error (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Error; setLevel() = Error;
printLogLine (msg); printLogLine (msg);
} }
@ -124,29 +127,45 @@ inline void FLogger::error (const std::string& msg)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::debug (const std::string& msg) inline void FLogger::debug (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Debug; setLevel() = Debug;
printLogLine (msg); printLogLine (msg);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::flush() inline void FLogger::flush()
{ output.flush(); } {
std::lock_guard<std::mutex> lock_guard(getMutex());
output.flush();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::setOutputStream (const std::ostream& os) inline void FLogger::setOutputStream (const std::ostream& os)
{ output.rdbuf(os.rdbuf()); } {
std::lock_guard<std::mutex> lock_guard(getMutex());
output.rdbuf(os.rdbuf());
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::setLineEnding (LineEnding eol) inline void FLogger::setLineEnding (LineEnding eol)
{ setEnding() = eol; } {
std::lock_guard<std::mutex> lock_guard(getMutex());
setEnding() = eol;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::enableTimestamp() inline void FLogger::enableTimestamp()
{ timestamp = true; } {
std::lock_guard<std::mutex> lock_guard(getMutex());
timestamp = true;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FLogger::disableTimestamp() inline void FLogger::disableTimestamp()
{ timestamp = false; } {
std::lock_guard<std::mutex> lock_guard(getMutex());
timestamp = false;
}
} // namespace finalcut } // namespace finalcut