std::clog now streams everything to the FLogger object

This commit is contained in:
Markus Gans 2020-09-25 00:48:58 +02:00
parent a69d38fb1e
commit 3d9f621258
42 changed files with 420 additions and 290 deletions

View File

@ -1,3 +1,6 @@
2020-09-25 Markus Gans <guru.mail@muenster.de>
* std::clog now streams everything to the FLogger object
2020-09-23 Markus Gans <guru.mail@muenster.de>
* Bugfix: empty FString() + wchar_t

View File

@ -68,8 +68,8 @@ class SegmentView final : public finalcut::FDialog
// Data members
std::map<wchar_t, sevenSegment> code{};
finalcut::FString line[3]{};
finalcut::FLineEdit Input{"0123", this};
finalcut::FButton Exit{"E&xit", this};
finalcut::FLineEdit input{"0123", this};
finalcut::FButton exit{"E&xit", this};
};
//----------------------------------------------------------------------
@ -86,18 +86,18 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
hexEncoding();
// Input field
Input.setGeometry (FPoint(2, 2), FSize{12, 1});
Input.setLabelText (L"&Hex value");
Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
Input.setLabelOrientation(finalcut::FLineEdit::label_above);
Input.setMaxLength(9);
Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
input.setGeometry (FPoint(2, 2), FSize{12, 1});
input.setLabelText (L"&Hex value");
input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
input.setLabelOrientation(finalcut::FLineEdit::label_above);
input.setMaxLength(9);
input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
// Exit button
Exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
// Add some function callbacks
Input.addCallback
input.addCallback
(
"changed",
[] (SegmentView& dialog)
@ -107,7 +107,7 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
std::ref(*this)
);
Exit.addCallback
exit.addCallback
(
"clicked",
finalcut::getFApplication(),
@ -206,7 +206,7 @@ void SegmentView::draw()
setColor(fc::LightGray, fc::Black);
finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
for (auto&& ch : Input.getText().toUpper())
for (auto&& ch : input.getText().toUpper())
{
const FColorPair color{fc::LightRed, fc::Black};
get7Segment(ch);

View File

@ -89,13 +89,13 @@ Dialog::Dialog (FWidget* parent)
void Dialog::adjustSize()
{
finalcut::FDialog::adjustSize();
int X = int((getDesktopWidth() - getWidth()) / 2);
const int Y = 5;
int x = int((getDesktopWidth() - getWidth()) / 2);
const int y = 5;
if ( X < 1 )
X = 1;
if ( x < 1 )
x = 1;
setPos (FPoint{X, Y}, false);
setPos (FPoint{x, y}, false);
}
//----------------------------------------------------------------------

View File

@ -36,7 +36,7 @@ using finalcut::FRect;
using finalcut::FSize;
using finalcut::FColorPair;
constexpr lDouble PI{3.141592653589793238L};
constexpr lDouble pi_value{3.141592653589793238L};
//----------------------------------------------------------------------
@ -233,13 +233,13 @@ class Calc final : public finalcut::FDialog
finalcut::FString input{""};
button button_no[Calc::NUM_OF_BUTTONS]{};
struct stack_data
struct StackData
{
lDouble term;
char infix_operator;
};
std::stack<stack_data> bracket_stack{};
std::stack<StackData> bracket_stack{};
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
std::map<Calc::button, keyFunction> key_map{};
};
@ -703,14 +703,14 @@ void Calc::percent (lDouble& x)
//----------------------------------------------------------------------
void Calc::pi (lDouble& x)
{
x = PI;
x = pi_value;
setDisplay(x);
}
//----------------------------------------------------------------------
void Calc::open_bracket (const lDouble&)
{
const stack_data d{ a, infix_operator };
const StackData d{ a, infix_operator };
bracket_stack.push(d);
clearInfixOperator();
input = "";
@ -726,7 +726,7 @@ void Calc::close_bracket (const lDouble&)
calcInfixOperator();
setDisplay(a);
const stack_data d = bracket_stack.top();
const StackData d = bracket_stack.top();
bracket_stack.pop();
b = d.term;
infix_operator = d.infix_operator;
@ -835,11 +835,11 @@ void Calc::sine (lDouble& x)
else
{
if ( arcus_mode )
x = std::asin(x) * 180.0L / PI;
x = std::asin(x) * 180.0L / pi_value;
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 = 0
x = 0.0L;
else
x = std::sin(x * PI / 180.0L);
x = std::sin(x * pi_value / 180.0L);
}
if ( errno == EDOM )
@ -873,11 +873,11 @@ void Calc::cosine (lDouble& x)
else
{
if ( arcus_mode )
x = std::acos(x) * 180.0L / PI;
x = std::acos(x) * 180.0L / pi_value;
else if ( std::fabs(std::fmod(x - 90.0L, 180.0L)) < LDBL_EPSILON ) // (x - 90) / 180 == 0
x = 0.0L;
else
x = std::cos(x * PI / 180.0L);
x = std::cos(x * pi_value / 180.0L);
}
if ( errno == EDOM )
@ -911,7 +911,7 @@ void Calc::tangent (lDouble& x)
else
{
if ( arcus_mode )
x = std::atan(x) * 180.0L / PI;
x = std::atan(x) * 180.0L / pi_value;
else
{
// Test if (x / 180) != 0 and x / 90 == 0
@ -921,7 +921,7 @@ void Calc::tangent (lDouble& x)
else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON ) // x / 180 == 0
x = 0.0L;
else
x = std::tan(x * PI / 180.0L);
x = std::tan(x * pi_value / 180.0L);
}
}

View File

@ -67,7 +67,7 @@ class CheckList final : public finalcut::FDialog
void cb_showList();
// Data members
finalcut::FListView listView{this};
finalcut::FListView listview{this};
finalcut::FStatusBar status_bar{this};
};
@ -83,22 +83,22 @@ CheckList::CheckList (finalcut::FWidget* parent)
FDialog::setGeometry ( FPoint{int(1 + (parent->getWidth() - 28) / 2), 5}
, FSize{28 + nf_offset, 13} );
setShadow();
listView.ignorePadding();
listView.setGeometry ( FPoint{1 + int(nf_offset), 2}
listview.ignorePadding();
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
, FSize{getWidth() - nf_offset, getHeight() - 1} );
// Add columns to the view
listView.addColumn ("Item");
listView.addColumn ("Priority", 9);
listview.addColumn ("Item");
listview.addColumn ("Priority", 9);
// Set the type of sorting
listView.setColumnSortType (1, fc::by_name);
listView.setColumnSortType (2, fc::by_name);
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::by_name);
// Statusbar at the bottom
finalcut::FString separator{};
separator << ' ' << fc::BoxDrawingsVertical << ' ';
listView.setStatusbarMessage ( finalcut::FString{}
listview.setStatusbarMessage ( finalcut::FString{}
<< "<Q> exit" << separator
<< "<Space> select an item" << separator
<< "<Enter> see your pick list");
@ -107,7 +107,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
populate();
// Add callback method
listView.addCallback
listview.addCallback
(
"clicked",
this, &CheckList::cb_showList
@ -138,7 +138,7 @@ void CheckList::populate()
for (const auto& line : list)
{
const finalcut::FStringList string_line (&line[0], &line[0] + 2);
auto iter = listView.insert (string_line);
auto iter = listview.insert (string_line);
auto item = static_cast<finalcut::FListViewItem*>(*iter);
item->setCheckable(true);
}
@ -170,10 +170,10 @@ void CheckList::onClose (finalcut::FCloseEvent* ev)
//----------------------------------------------------------------------
void CheckList::cb_showList()
{
auto iter = listView.beginOfList();
auto iter = listview.beginOfList();
finalcut::FString shopping_list{};
while ( iter != listView.endOfList() )
while ( iter != listview.endOfList() )
{
const auto item = static_cast<finalcut::FListViewItem*>(*iter);

View File

@ -162,8 +162,10 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
if ( key_name.isEmpty() )
key_name = wchar_t(key_id);
log << finalcut::FLog::Info
<< "Key " << key_name << " (id " << key_id << ")" << std::flush;
// std::clog redirects all stream data to FLogger
std::clog << finalcut::FLog::Info
<< "Key " << key_name
<< " (id " << key_id << ")" << std::flush;
finalcut::FDialog::onKeyPress(ev);
}
@ -257,7 +259,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
void adjustSize() override;
// Data members
finalcut::FTextView scrollText{this};
finalcut::FTextView scrolltext{this};
EventDialog* event_dialog{new EventDialog(this)};
};
@ -273,8 +275,8 @@ EventLog::EventLog (finalcut::FWidget* parent)
FDialog::setResizeable();
setMinimumSize (FSize{75, 5});
setShadow();
scrollText.ignorePadding();
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
scrolltext.ignorePadding();
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
event_dialog->setFocus();
addTimer(250); // Starts the timer every 250 milliseconds
}
@ -288,9 +290,9 @@ void EventLog::onTimer (finalcut::FTimerEvent*)
{
if ( ! str().empty() )
{
scrollText.append(str());
scrolltext.append(str());
str("");
scrollText.scrollToEnd();
scrolltext.scrollToEnd();
redraw();
updateTerminal();
}
@ -306,7 +308,7 @@ void EventLog::onClose (finalcut::FCloseEvent* ev)
void EventLog::adjustSize()
{
finalcut::FDialog::adjustSize();
scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
}

View File

@ -93,22 +93,22 @@ int main (int argc, char* argv[])
c_field.setGeometry (FPoint{11, 11}, FSize{4, 1});
// Create the button group
finalcut::FButtonGroup radioButtonGroup {"Sex", &dgl};
radioButtonGroup.setGeometry(FPoint{2, 13}, FSize{13, 4});
finalcut::FButtonGroup radiobutton_group {"Sex", &dgl};
radiobutton_group.setGeometry(FPoint{2, 13}, FSize{13, 4});
// Create radio buttons
finalcut::FRadioButton male {"&Male", &radioButtonGroup};
finalcut::FRadioButton female {"&Female", &radioButtonGroup};
finalcut::FRadioButton male {"&Male", &radiobutton_group};
finalcut::FRadioButton female {"&Female", &radiobutton_group};
male.setGeometry (FPoint{1, 1}, FSize{8, 1});
female.setGeometry (FPoint{1, 2}, FSize{10, 1});
// Create another button group
finalcut::FButtonGroup checkButtonGroup {"&Data options", &dgl};
checkButtonGroup.setGeometry(FPoint{16, 13}, FSize{19, 4});
finalcut::FButtonGroup checkbutton_group {"&Data options", &dgl};
checkbutton_group.setGeometry(FPoint{16, 13}, FSize{19, 4});
// Create checkbox buttons
finalcut::FCheckBox check1 {"Save data", &checkButtonGroup};
finalcut::FCheckBox check2 {"Encrypt data", &checkButtonGroup};
finalcut::FCheckBox check1 {"Save data", &checkbutton_group};
finalcut::FCheckBox check2 {"Encrypt data", &checkbutton_group};
check1.setGeometry (FPoint{1, 1}, FSize{13, 1});
check2.setGeometry (FPoint{1, 2}, FSize{16, 1});
check2.setDisable();

View File

@ -101,7 +101,7 @@ class Listbox final : public FDialog
FListBox list1{this};
FListBox list2{this};
FListBox list3{this};
FButton Quit{this};
FButton quit{this};
};
//----------------------------------------------------------------------
@ -151,11 +151,11 @@ Listbox::Listbox (FWidget* parent)
list3.setText ("key: value");
// Quit button
Quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
Quit.setText (L"&Quit");
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
quit.setText (L"&Quit");
// Add quit button function callback
Quit.addCallback
quit.addCallback
(
"clicked",
finalcut::getFApplication(),

View File

@ -62,8 +62,8 @@ class Listview final : public finalcut::FDialog
void cb_showInMessagebox();
// Data members
finalcut::FListView listView{this};
finalcut::FButton Quit{this};
finalcut::FListView listview{this};
finalcut::FButton quit{this};
};
//----------------------------------------------------------------------
@ -71,44 +71,44 @@ Listview::Listview (finalcut::FWidget* parent)
: finalcut::FDialog{parent}
{
// Set FListView geometry
listView.setGeometry(FPoint{2, 1}, FSize{33, 14});
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
// Add columns to the view
listView.addColumn ("City");
listView.addColumn ("Condition");
listView.addColumn ("Temp.");
listView.addColumn ("Humidity");
listView.addColumn ("Pressure", 10);
listview.addColumn ("City");
listview.addColumn ("Condition");
listview.addColumn ("Temp.");
listview.addColumn ("Humidity");
listview.addColumn ("Pressure", 10);
// Set right alignment for the third, fourth, and fifth column
listView.setColumnAlignment (3, fc::alignRight);
listView.setColumnAlignment (4, fc::alignRight);
listView.setColumnAlignment (5, fc::alignRight);
listview.setColumnAlignment (3, fc::alignRight);
listview.setColumnAlignment (4, fc::alignRight);
listview.setColumnAlignment (5, fc::alignRight);
// Set the type of sorting
listView.setColumnSortType (1, fc::by_name);
listView.setColumnSortType (2, fc::by_name);
listView.setColumnSortType (3, fc::by_number);
listView.setColumnSortType (4, fc::by_number);
listView.setColumnSortType (5, fc::by_number);
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::by_name);
listview.setColumnSortType (3, fc::by_number);
listview.setColumnSortType (4, fc::by_number);
listview.setColumnSortType (5, fc::by_number);
// Sort in ascending order by the 1st column
listView.setColumnSort (1, fc::ascending);
listview.setColumnSort (1, fc::ascending);
// Sorting follows later automatically on insert().
// Otherwise you could start the sorting directly with sort()
// Allways show the sort indicator (▼/▲)
listView.hideSortIndicator(false);
listview.hideSortIndicator(false);
// Populate FListView with a list of items
populate();
// Quit button
Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
Quit.setText (L"&Quit");
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
quit.setText (L"&Quit");
// Add some function callbacks
Quit.addCallback
quit.addCallback
(
"clicked",
finalcut::getFApplication(),
@ -116,7 +116,7 @@ Listview::Listview (finalcut::FWidget* parent)
this
);
listView.addCallback
listview.addCallback
(
"clicked",
this, &Listview::cb_showInMessagebox
@ -178,7 +178,7 @@ void Listview::populate()
for (const auto& place : weather)
{
const finalcut::FStringList line (&place[0], &place[0] + 5);
listView.insert (line);
listview.insert (line);
}
}
@ -191,7 +191,7 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
//----------------------------------------------------------------------
void Listview::cb_showInMessagebox()
{
const auto& item = listView.getCurrentItem();
const auto& item = listview.getCurrentItem();
finalcut::FMessageBox info ( "Weather in " + item->getText(1)
, " Condition: " + item->getText(2) + "\n"
"Temperature: " + item->getText(3) + "\n"

View File

@ -481,9 +481,9 @@ void stringSplittingExample()
void fromatStringExample()
{
// Test: format a string with sprintf
finalcut::FString formatStr{""};
finalcut::FString format_str{""};
std::cout << " formatted: "
<< formatStr.sprintf("sqrt(%d) = %d", 16, 4)
<< format_str.sprintf("sqrt(%d) = %d", 16, 4)
<< std::endl;
}

View File

@ -42,21 +42,21 @@ void string();
// struct data
//----------------------------------------------------------------------
struct data
struct Data
{
struct alignas(alignof(std::string)) termcap_string
struct alignas(alignof(std::string)) TermcapString
{
const std::string name;
const fc::termcaps cap;
};
static termcap_string strings[];
static TermcapString strings[];
};
//----------------------------------------------------------------------
// struct data - string data array
//----------------------------------------------------------------------
data::termcap_string data::strings[] =
Data::TermcapString Data::strings[] =
{
{ "t_bell", fc::t_bell },
{ "t_erase_chars", fc::t_erase_chars },
@ -285,7 +285,7 @@ void string()
const finalcut::FTermcap::tcap_map (&tcap_strings)[] \
= finalcut::FTermcap::strings;
for (const auto& entry : data::strings)
for (const auto& entry : Data::strings)
{
const std::string name = entry.name;
const fc::termcaps cap = entry.cap;

View File

@ -256,12 +256,12 @@ void MainWindow::onShow (finalcut::FShowEvent*)
//----------------------------------------------------------------------
void MainWindow::onTimer (finalcut::FTimerEvent*)
{
wchar_t first_Char[2];
wchar_t first_char[2];
std::size_t length = line1.getLength();
first_Char[0] = line1[0];
first_Char[1] = line2[0];
line1 = line1.right(length - 1) + first_Char[0];
line2 = line2.right(length - 1) + first_Char[1];
first_char[0] = line1[0];
first_char[1] = line2[0];
line1 = line1.right(length - 1) + first_char[0];
line2 = line2.right(length - 1) + first_char[1];
redraw();
flush();
}

View File

@ -33,7 +33,7 @@ using finalcut::FSize;
// Function prototypes
sInt64 StringToNumber (const finalcut::FString&);
sInt64 stringToNumber (const finalcut::FString&);
bool sortAscending (const finalcut::FObject*, const finalcut::FObject*);
bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
bool isLessThanInteger (const finalcut::FString&, const finalcut::FString&);
@ -44,13 +44,13 @@ bool isGreaterThanDouble (const finalcut::FString&, const finalcut::FString&);
// non-member functions
//----------------------------------------------------------------------
sInt64 StringToNumber (const finalcut::FString& str)
sInt64 stringToNumber (const finalcut::FString& str)
{
// Cut off one character (because LONG_MAX = 2147483647)
auto NumString = str.left(str.getLength() - 1);
NumString = NumString.replace(",", "");
NumString = NumString.replace('.', "");
sInt64 number = sInt64(NumString.toLong());
auto num_string = str.left(str.getLength() - 1);
num_string = num_string.replace(",", "");
num_string = num_string.replace('.', "");
sInt64 number = sInt64(num_string.toLong());
return number;
}
@ -58,8 +58,8 @@ sInt64 StringToNumber (const finalcut::FString& str)
inline bool isLessThanInteger ( const finalcut::FString& lhs
, const finalcut::FString& rhs )
{
const sInt64 l_number = StringToNumber(lhs);
const sInt64 r_number = StringToNumber(rhs);
const sInt64 l_number = stringToNumber(lhs);
const sInt64 r_number = stringToNumber(rhs);
return bool( l_number < r_number ); // lhs < rhs
}
@ -77,8 +77,8 @@ inline bool isLessThanDouble ( const finalcut::FString& lhs
inline bool isGreaterThanInteger ( const finalcut::FString& lhs
, const finalcut::FString& rhs )
{
const sInt64 l_number = StringToNumber(lhs);
const sInt64 r_number = StringToNumber(rhs);
const sInt64 l_number = stringToNumber(lhs);
const sInt64 r_number = stringToNumber(rhs);
return bool( l_number > r_number ); // lhs > rhs
}
@ -168,8 +168,8 @@ class Treeview final : public finalcut::FDialog
// Data members
bool initialized{false};
finalcut::FListView listView{this};
finalcut::FButton Quit{this};
finalcut::FListView listview{this};
finalcut::FButton quit{this};
static TreeItem africa[];
static TreeItem asia[];
static TreeItem europe[];
@ -329,26 +329,26 @@ Treeview::Treeview (finalcut::FWidget* parent)
: finalcut::FDialog{parent}
{
// Set FListView geometry
listView.setGeometry(FPoint{2, 1}, FSize{53, 14});
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
// Add columns to the view
listView.addColumn ("Name", 23);
listView.addColumn ("Population");
listView.addColumn ("Density/km²");
listview.addColumn ("Name", 23);
listview.addColumn ("Population");
listview.addColumn ("Density/km²");
// Set right alignment for the second and third column
listView.setColumnAlignment (2, fc::alignRight);
listView.setColumnAlignment (3, fc::alignRight);
listview.setColumnAlignment (2, fc::alignRight);
listview.setColumnAlignment (3, fc::alignRight);
// Set the type of sorting
listView.setColumnSortType (1, fc::by_name);
listView.setColumnSortType (2, fc::user_defined);
listView.setColumnSortType (3, fc::user_defined);
listView.setUserAscendingCompare(sortAscending);
listView.setUserDescendingCompare(sortDescending);
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::user_defined);
listview.setColumnSortType (3, fc::user_defined);
listview.setUserAscendingCompare(sortAscending);
listview.setUserDescendingCompare(sortDescending);
// Activate tree view
listView.setTreeView();
listview.setTreeView();
// Populate FListView with a list of items
static TreeItem continent_list[] =
@ -367,23 +367,23 @@ Treeview::Treeview (finalcut::FWidget* parent)
const TreeItem* country_list = continent.child_element;
finalcut::FStringList continent_line ( continent.begin()
, continent.end() );
auto iter = listView.insert (continent_line);
auto iter = listview.insert (continent_line);
while ( country_list && country_list->name )
{
finalcut::FStringList country_line ( country_list->begin()
, country_list->end() );
listView.insert (country_line, iter);
listview.insert (country_line, iter);
country_list++;
}
}
// Quit button
Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
Quit.setText (L"&Quit");
// quit button
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
quit.setText (L"&Quit");
// Callback function
Quit.addCallback
quit.addCallback
(
"clicked",
finalcut::getFApplication(),
@ -403,17 +403,17 @@ void Treeview::adjustSize()
{
std::size_t h = getDesktopHeight() - 4;
setHeight (h, false);
int X = int((getDesktopWidth() - getWidth()) / 2);
int x = int((getDesktopWidth() - getWidth()) / 2);
if ( X < 1 )
X = 1;
if ( x < 1 )
x = 1;
setX (X, false);
setX (x, false);
if ( initialized )
{
listView.setHeight (getHeight() - 6, false);
Quit.setY(int(getHeight()) - 4);
listview.setHeight (getHeight() - 6, false);
quit.setY(int(getHeight()) - 4);
}
finalcut::FDialog::adjustSize();

View File

@ -68,7 +68,7 @@ class ProgressDialog final : public finalcut::FDialog
void cb_exit_bar();
// Data members
finalcut::FProgressbar progressBar{this};
finalcut::FProgressbar progressbar{this};
finalcut::FButton reset{this};
finalcut::FButton more{this};
finalcut::FButton quit{this};
@ -100,8 +100,8 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
quit.setDisable();
progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
//progressBar.setPercentage(78);
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
//progressbar.setPercentage(78);
reset.addCallback
(
@ -140,9 +140,9 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
//----------------------------------------------------------------------
void ProgressDialog::onTimer (finalcut::FTimerEvent*)
{
auto p = progressBar.getPercentage();
auto p = progressbar.getPercentage();
p++;
progressBar.setPercentage(p);
progressbar.setPercentage(p);
flush();
if ( p != 100 )
@ -167,15 +167,15 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
//----------------------------------------------------------------------
void ProgressDialog::cb_reset_bar()
{
progressBar.reset();
progressbar.reset();
}
//----------------------------------------------------------------------
void ProgressDialog::cb_more_bar()
{
auto p = progressBar.getPercentage();
auto p = progressbar.getPercentage();
p++;
progressBar.setPercentage(p);
progressbar.setPercentage(p);
}
//----------------------------------------------------------------------
@ -212,25 +212,25 @@ class TextWindow final : public finalcut::FDialog
void adjustSize() override;
// Data members
finalcut::FTextView scrollText{this};
finalcut::FTextView scrolltext{this};
};
//----------------------------------------------------------------------
TextWindow::TextWindow (finalcut::FWidget* parent)
: finalcut::FDialog{parent}
{
scrollText.ignorePadding();
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
scrolltext.ignorePadding();
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
setMinimumSize (FSize{51, 6});
scrollText.setFocus();
scrollText.insert(" -----------------------------------------------\n"
scrolltext.setFocus();
scrolltext.insert(" -----------------------------------------------\n"
" line 1\n"
" -----------------------------------------------\n"
" line 3\n"
" line 4"
, -1);
scrollText.replaceRange(" File viewer", 1, 1);
scrollText.deleteRange(3, 4);
scrolltext.replaceRange(" File viewer", 1, 1);
scrolltext.deleteRange(3, 4);
}
//----------------------------------------------------------------------
@ -240,14 +240,14 @@ TextWindow::~TextWindow() // destructor
//----------------------------------------------------------------------
void TextWindow::append (const finalcut::FString& str)
{
scrollText.append(str);
scrolltext.append(str);
}
//----------------------------------------------------------------------
void TextWindow::adjustSize()
{
finalcut::FDialog::adjustSize();
scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
}
@ -784,12 +784,12 @@ void MyDialog::adjustSize()
{
const auto h = getParentWidget()->getHeight() - 4;
setHeight (h, false);
int X = int((getDesktopWidth() - getWidth()) / 2);
int x = int((getDesktopWidth() - getWidth()) / 2);
if ( X < 1 )
X = 1;
if ( x < 1 )
x = 1;
setX (X, false);
setX (x, false);
if ( initialized )
myList.setHeight (getHeight() - 3, false);

View File

@ -122,7 +122,7 @@ void SmallWindow::adjustSize()
else
{
top_right_label = "zoom";
bottom_label.setVisible();
bottom_label.show();
}
finalcut::FDialog::adjustSize();

View File

@ -20,6 +20,7 @@ libfinal_la_SOURCES = \
fbutton.cpp \
fbuttongroup.cpp \
fcallback.cpp \
fdata.cpp \
ftogglebutton.cpp \
fradiobutton.cpp \
fcheckbox.cpp \

View File

@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
fbuttongroup.h \
fbutton.h \
fcallback.h \
fdata.h \
fcolorpair.h \
fstyle.h \
ftogglebutton.h \
@ -93,6 +94,7 @@ OBJS = \
fsize.o \
frect.o \
fcallback.o \
fdata.o \
fscrollbar.o \
fprogressbar.o \
flineedit.o \

View File

@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
fbuttongroup.h \
fbutton.h \
fcallback.h \
fdata.h \
fcolorpair.h \
fstyle.h \
ftogglebutton.h \
@ -93,6 +94,7 @@ OBJS = \
fsize.o \
frect.o \
fcallback.o \
fdata.o \
fscrollbar.o \
fprogressbar.o \
flineedit.o \

View File

@ -22,7 +22,9 @@
#include <chrono>
#include <fstream>
#include <iostream>
#include <memory>
#include <ostream>
#include <string>
#include <thread>
@ -131,18 +133,28 @@ FWidget* FApplication::getKeyboardWidget()
FApplication::FLogPtr& FApplication::getLog()
{
// Global logger object
static FLogPtr* logger = new FLogPtr();
static FLogPtr* logger_ptr = new FLogPtr();
if ( logger && logger->get() == nullptr )
*logger = std::make_shared<FLogger>();
if ( logger_ptr && logger_ptr->get() == nullptr )
{
*logger_ptr = std::make_shared<FLogger>();
return *logger;
// Set the logger as rdbuf of clog
std::clog.rdbuf(logger_ptr->get());
}
return *logger_ptr;
}
//----------------------------------------------------------------------
void FApplication::setLog (const FLogPtr& logger)
void FApplication::setLog (const FLogPtr& log)
{
getLog() = logger;
FLogPtr& logger = getLog();
logger.reset();
logger = log;
// Set the logger as rdbuf of clog
std::clog.rdbuf(logger.get());
}
//----------------------------------------------------------------------
@ -586,6 +598,10 @@ void FApplication::showParameterUsage()
//----------------------------------------------------------------------
inline void FApplication::destroyLog()
{
// Reset the rdbuf of clog
std::clog.rdbuf(default_clog_rdbuf);
// Delete the logger
const FLogPtr* logger = &(getLog());
delete logger;
}
@ -1354,4 +1370,13 @@ bool FApplication::isNextEventTimeout()
return FObject::isTimeout (&time_last_event, next_event_wait);
}
// FLog non-member operators
//----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, FLog::LogLevel l)
{
*FApplication::getLog() << l;
return outstr;
}
} // namespace finalcut

View File

@ -159,7 +159,7 @@ uInt character[][fc::NUM_OF_ENCODINGS] =
* (2) Only supported in use with newfont
*/
const std::size_t lastCharItem = \
constexpr std::size_t last_char_item = \
std::size_t((sizeof(character) / sizeof(character[0])) - 1);
@ -206,7 +206,7 @@ constexpr int vt100_key_to_utf8[][2] =
{fc::vt100_key_diamond , fc::Bullet} // ◆
};
const std::size_t lastKeyItem = \
constexpr std::size_t last_key_item = \
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
@ -470,11 +470,11 @@ constexpr wchar_t cp437_ucs[][2] =
{0xff, 0x00a0} // no-break space
};
const std::size_t lastCP437Item = \
constexpr std::size_t last_cp437_item = \
std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1);
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
constexpr wchar_t halfWidth_fullWidth[][2] =
constexpr wchar_t halfwidth_fullwidth[][2] =
{
// Fullwidth ASCII variants
{0x0020, 0x3000}, // ' ' -> ' '
@ -712,8 +712,8 @@ constexpr wchar_t halfWidth_fullWidth[][2] =
{0xffee, 0x25cb} // ○ -> ○
};
const std::size_t lastHalfWidthItem = \
std::size_t((sizeof(halfWidth_fullWidth) / sizeof(halfWidth_fullWidth[0])) - 1);
constexpr std::size_t last_halfwidth_item = \
std::size_t((sizeof(halfwidth_fullwidth) / sizeof(halfwidth_fullwidth[0])) - 1);
} // namespace fc

View File

@ -29,7 +29,6 @@
#include "final/flabel.h"
#include "final/flineedit.h"
#include "final/flistbox.h"
#include "final/flog.h"
#include "final/fmouse.h"
#include "final/fpoint.h"
#include "final/fsize.h"

42
src/fdata.cpp Normal file
View File

@ -0,0 +1,42 @@
/***********************************************************************
* fdata.cpp - A general-purpose data wrapper *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2020 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fdata.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FDataAccess
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FDataAccess::FDataAccess()
{ }
//----------------------------------------------------------------------
FDataAccess::~FDataAccess() // destructor
{ }
} // namespace finalcut

View File

@ -25,8 +25,8 @@
#include "final/fapplication.h"
#include "final/fevent.h"
#include "final/flabel.h"
#include "final/flog.h"
#include "final/flineedit.h"
#include "final/flog.h"
#include "final/fpoint.h"
#include "final/fsize.h"
#include "final/fstatusbar.h"
@ -833,7 +833,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
@ -857,7 +857,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
}
@ -893,7 +893,7 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
@ -927,7 +927,7 @@ void FLineEdit::adjustTextOffset()
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
}
@ -940,7 +940,7 @@ void FLineEdit::adjustTextOffset()
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
}

View File

@ -136,11 +136,8 @@ void FMenu::onKeyPress (FKeyEvent* ev)
// looking for menu bar hotkey
auto menu_bar = getMenuBar();
if ( menu_bar )
{
if ( menu_bar->hotkeyMenu(ev) )
if ( menu_bar && menu_bar->hotkeyMenu(ev) )
return;
}
switch ( ev->key() )
{

View File

@ -24,7 +24,6 @@
#include "final/fapplication.h"
#include "final/fc.h"
#include "final/flog.h"
#include "final/foptimove.h"
#include "final/ftermcap.h"
@ -1107,42 +1106,41 @@ void FOptiMove::moveByMethod ( int method
//----------------------------------------------------------------------
void printDurations (const FOptiMove& om)
{
finalcut::FLog& log = *FApplication::getLog();
log << " speed: "
std::clog << " speed: "
<< om.baudrate << " baud" << std::flush;
log << " char_duration: "
std::clog << " char_duration: "
<< om.char_duration << " ms" << std::flush;
log << " cursor_home: "
std::clog << " cursor_home: "
<< om.F_cursor_home.duration << " ms" << std::flush;
log << " cursor_to_ll: "
std::clog << " cursor_to_ll: "
<< om.F_cursor_to_ll.duration << " ms" << std::flush;
log << " carriage_return: "
std::clog << " carriage_return: "
<< om.F_carriage_return.duration << " ms" << std::flush;
log << " tab: "
std::clog << " tab: "
<< om.F_tab.duration << " ms" << std::flush;
log << " back_tab: "
std::clog << " back_tab: "
<< om.F_back_tab.duration << " ms" << std::flush;
log << " cursor_up: "
std::clog << " cursor_up: "
<< om.F_cursor_up.duration << " ms" << std::flush;
log << " cursor_down: "
std::clog << " cursor_down: "
<< om.F_cursor_down.duration << " ms" << std::flush;
log << " cursor_left: "
std::clog << " cursor_left: "
<< om.F_cursor_left.duration << " ms" << std::flush;
log << " cursor_right: "
std::clog << " cursor_right: "
<< om.F_cursor_right.duration << " ms" << std::flush;
log << " cursor_address: "
std::clog << " cursor_address: "
<< om.F_cursor_address.duration << " ms" << std::flush;
log << " column_address: "
std::clog << " column_address: "
<< om.F_column_address.duration << " ms" << std::flush;
log << " row_address: "
std::clog << " row_address: "
<< om.F_row_address.duration << " ms" << std::flush;
log << " parm_up_cursor: "
std::clog << " parm_up_cursor: "
<< om.F_parm_up_cursor.duration << " ms" << std::flush;
log << " parm_down_cursor: "
std::clog << " parm_down_cursor: "
<< om.F_parm_down_cursor.duration << " ms" << std::flush;
log << " parm_left_cursor: "
std::clog << " parm_left_cursor: "
<< om.F_parm_left_cursor.duration << " ms" << std::flush;
log << "parm_right_cursor: "
std::clog << "parm_right_cursor: "
<< om.F_parm_right_cursor.duration << " ms" << std::flush;
}

View File

@ -1191,7 +1191,7 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
{
wchar_t ch_enc = c;
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
for (std::size_t i{0}; i <= fc::last_char_item; i++)
{
if ( fc::character[i][fc::UTF8] == uInt(c) )
{
@ -1421,7 +1421,7 @@ void FTerm::init_alt_charset()
};
// Update array 'character' with discovered VT100 pairs
for (std::size_t n{0}; n <= fc::lastKeyItem; n++ )
for (std::size_t n{0}; n <= fc::last_key_item; n++ )
{
const uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]);
const uChar altChar = uChar(vt100_alt_char[keyChar]);
@ -1429,9 +1429,9 @@ void FTerm::init_alt_charset()
const fc::encoding num{fc::NUM_OF_ENCODINGS};
uInt* p = std::find ( fc::character[0]
, fc::character[fc::lastCharItem] + num
, fc::character[fc::last_char_item] + num
, utf8char );
if ( p != fc::character[fc::lastCharItem] + num ) // found in character
if ( p != fc::character[fc::last_char_item] + num ) // found in character
{
const int item = int(std::distance(fc::character[0], p) / num);
@ -1506,7 +1506,7 @@ void FTerm::init_cygwin_charmap()
return;
// PC encoding changes
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::last_char_item; i++ )
{
if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
fc::character[i][fc::PC] = 0x18;
@ -1560,7 +1560,7 @@ void FTerm::init_teraterm_charmap()
if ( ! isTeraTerm() )
return;
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::last_char_item; i++ )
if ( fc::character[i][fc::PC] < 0x20 )
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
}

View File

@ -274,7 +274,7 @@ wchar_t cp437_to_unicode (uChar c)
constexpr std::size_t UNICODE = 1;
wchar_t ucs = c;
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
for (std::size_t i{0}; i <= fc::last_cp437_item; i++)
{
if ( fc::cp437_ucs[i][CP437] == c ) // found
{
@ -293,7 +293,7 @@ uChar unicode_to_cp437 (wchar_t ucs)
constexpr std::size_t UNICODE = 1;
uChar c{'?'};
for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
for (std::size_t i{0}; i <= fc::last_cp437_item; i++)
{
if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found
{
@ -322,10 +322,10 @@ const FString getFullWidth (const FString& str)
}
else
{
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++)
{
if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found
c = fc::halfWidth_fullWidth[i][FULL];
if ( fc::halfwidth_fullwidth[i][HALF] == c ) // found
c = fc::halfwidth_fullwidth[i][FULL];
}
}
}
@ -350,10 +350,10 @@ const FString getHalfWidth (const FString& str)
}
else
{
for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++)
{
if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found
c = fc::halfWidth_fullWidth[i][HALF];
if ( fc::halfwidth_fullwidth[i][FULL] == c ) // found
c = fc::halfwidth_fullwidth[i][HALF];
}
}
}
@ -457,7 +457,7 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
}
catch (const std::out_of_range& ex)
{
*FApplication::getLog() << FLog::Error
std::clog << FLog::Error
<< "Out of Range error: " << ex.what() << std::endl;
}
}

View File

@ -27,6 +27,7 @@
#include "final/emptyfstring.h"
#include "final/fc.h"
#include "final/fkey_map.h"
#include "final/flog.h"
#include "final/fsystem.h"
#include "final/fterm.h"
#include "final/ftermdata.h"
@ -127,12 +128,11 @@ void FTermcap::termcapError (int status)
static constexpr int no_entry = 0;
static constexpr int db_not_found = -1;
static constexpr int uninitialized = -2;
finalcut::FLog& log = *FApplication::getLog();
if ( status == no_entry || status == uninitialized )
{
const char* termtype = fterm_data->getTermType();
log << FLog::Error
std::clog << FLog::Error
<< "Unknown terminal: \"" << termtype << "\". "
<< "Check the TERM environment variable. "
<< "Also make sure that the terminal "
@ -142,7 +142,7 @@ void FTermcap::termcapError (int status)
}
else if ( status == db_not_found )
{
log << "The termcap/terminfo database could not be found."
std::clog << "The termcap/terminfo database could not be found."
<< std::endl;
std::abort();
}

View File

@ -171,7 +171,7 @@ void FTermFreeBSD::initCharMap()
if ( ! isFreeBSDConsole() )
return;
for (std::size_t i{0}; i <= fc::lastCharItem; i++)
for (std::size_t i{0}; i <= fc::last_char_item; i++)
if ( fc::character[i][fc::PC] < 0x1c )
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
}
@ -195,7 +195,7 @@ void FTermFreeBSD::finish()
//----------------------------------------------------------------------
void FTermFreeBSD::warnNotInitialized()
{
*FApplication::getLog() << FLog::Warn
std::clog << FLog::Warn
<< "The FTermFreeBSD object has "
<< "not yet been initialized! "
<< "Please call the init() method first."

View File

@ -202,7 +202,7 @@ void FTermLinux::init()
}
else
{
FApplication::getLog()->error("Can not open the console.");
std::clog << FLog::Error << "Can not open the console." << std::endl;
std::abort();
}
}
@ -217,7 +217,7 @@ void FTermLinux::initCharMap()
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
{
for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
for (std::size_t i{0}; i <= fc::last_char_item; i++ )
{
const auto ucs = wchar_t(fc::character[i][fc::UTF8]);
const sInt16 fontpos = getFontPos(ucs);

View File

@ -162,7 +162,7 @@ bool FTermOpenBSD::resetBeep()
//----------------------------------------------------------------------
void FTermOpenBSD::warnNotInitialized()
{
*FApplication::getLog() << FLog::Warn
std::clog << FLog::Warn
<< "The FTermOpenBSD object has "
<< "not yet been initialized! "
<< "Please call the init() method first."

View File

@ -311,7 +311,7 @@ void FTermXTerminal::captureFontAndTitle()
//----------------------------------------------------------------------
void FTermXTerminal::warnNotInitialized() const
{
*FApplication::getLog() << FLog::Warn
std::clog << FLog::Warn
<< "The FTermXTerminal object has "
<< "not yet been initialized! "
<< "Please call the init() method first."

View File

@ -35,7 +35,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include "final/fapplication.h"
#include <iostream>
#include "final/flog.h"
#include "final/fstring.h"

View File

@ -207,6 +207,7 @@ class FApplication : public FWidget
char** app_argv{};
uInt64 key_timeout{100000}; // 100 ms
uInt64 dblclick_interval{500000}; // 500 ms
std::streambuf* default_clog_rdbuf{std::clog.rdbuf()};
FEventQueue event_queue{};
static uInt64 next_event_wait;
static timeval time_last_event;

View File

@ -37,16 +37,16 @@ namespace fc
{
extern uInt character[][fc::NUM_OF_ENCODINGS];
extern const std::size_t lastCharItem;
extern const std::size_t last_char_item;
extern const int vt100_key_to_utf8[][2];
extern const std::size_t lastKeyItem;
extern const std::size_t last_key_item;
extern const wchar_t cp437_ucs[][2];
extern const std::size_t lastCP437Item;
extern const std::size_t last_cp437_item;
extern const wchar_t halfWidth_fullWidth[][2];
extern const std::size_t lastHalfWidthItem;
extern const wchar_t halfwidth_fullwidth[][2];
extern const std::size_t last_halfwidth_item;
} // namespace fc

View File

@ -57,9 +57,11 @@ class FData; // Class forward declaration
class FDataAccess
{
public:
// Constructor
FDataAccess();
// Destructor
virtual ~FDataAccess()
{ }
virtual ~FDataAccess();
// Accessors
virtual const FString getClassName() const
@ -101,7 +103,31 @@ class FData : public FDataAccess
, value_ref{value}
{ }
FData (const FData& d) // Copy constructor
: value{d.value}
, value_ref{value}
{ }
FData (FData&& d) noexcept // Move constructor
: value{std::move(d.value)}
, value_ref{value}
{ }
// Overloaded operators
FData& operator = (const FData& d) // Copy assignment operator (=)
{
value = d.value;
value_ref = value;
return *this;
}
FData& operator = (FData&& d) noexcept // Move assignment operator (=)
{
value = std::move(d.value);
value_ref = value;
return *this;
}
T operator () () const
{
return value_ref;

View File

@ -108,6 +108,9 @@ class FLog : public std::stringbuf
LineEnding end_of_line{CRLF};
FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
std::ostream stream{this};
// Friend Non-member operator functions
friend std::ostream& operator << (std::ostream&, LogLevel);
};
// FLog inline functions

View File

@ -39,7 +39,7 @@
#define null nullptr
#define badAllocOutput(object_name) \
*FApplication::getLog() << FLog::Error \
std::clog << FLog::Error \
<< __FILE__ << ":" << __LINE__ \
<< ": Not enough memory to alloc " \
<< (object_name) \

View File

@ -579,9 +579,9 @@ inline FVTerm& FVTerm::operator << (const std::string& string)
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << \
(const std::vector<FChar>& termString)
(const std::vector<FChar>& term_string)
{
print (termString);
print (term_string);
return *this;
}

View File

@ -35,16 +35,17 @@
//----------------------------------------------------------------------
// functions
//----------------------------------------------------------------------
/*void cb_function_ptr (int* value)
float my_function()
{
(*value)++;
return 13.45F;
}
//----------------------------------------------------------------------
void cb_function_ref (int& value)
long int my_function2 (long int i)
{
value += 2;
}*/
return 2 * i;
}
//----------------------------------------------------------------------
// class FDataTest

View File

@ -316,6 +316,9 @@ void FLoggerTest::fileTest()
//----------------------------------------------------------------------
void FLoggerTest::applicationObjectTest()
{
// Save the rdbuf of clog
std::streambuf* default_clog_rdbuf = std::clog.rdbuf();
// Generation of a logger in a shared_ptr via a pointer
finalcut::FApplication::setLog (std::make_shared<finalcut::FLogger>());
// Get the shared_ptr with the base class
@ -348,6 +351,15 @@ void FLoggerTest::applicationObjectTest()
CPPUNIT_ASSERT ( buf.str() == "[ERROR] test6\r\n" );
buf.str(""); // Clear buffer
// Logging to std::clog
std::clog << finalcut::FLog::Info << "test7" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[INFO] test7\r\n" );
buf.str(""); // Clear buffer
std::clog << finalcut::FLog::Warn << "test8" << std::endl;
CPPUNIT_ASSERT ( buf.str() == "[WARNING] test8\n\r\n" );
buf.str(""); // Clear buffer
// Replace the logger with another one
finalcut::FApplication::setLog(std::make_shared<myLogger>());
log = finalcut::FApplication::getLog();
@ -369,7 +381,22 @@ void FLoggerTest::applicationObjectTest()
CPPUNIT_ASSERT ( buf.str() == "Debug: myLogger 4\n" );
buf.str(""); // Clear buffer
std::shared_ptr<finalcut::FLog>* logger = &(finalcut::FApplication::getLog());
// Logging to std::clog with the replaced logger
std::clog << finalcut::FLog::Info << "myLogger 5" << std::flush;
CPPUNIT_ASSERT ( buf.str() == " Info: myLogger 5\n" );
buf.str(""); // Clear buffer
std::clog << finalcut::FLog::Error << "myLogger 6" << std::endl;
CPPUNIT_ASSERT ( buf.str() == "Error: myLogger 6\n\n" );
buf.str(""); // Clear buffer
// Reset to the default rdbuf of clog
std::clog.rdbuf(default_clog_rdbuf);
// Delete the global FApplication logger object
auto logger = &(finalcut::FApplication::getLog());
if ( logger )
delete logger;
}

View File

@ -819,7 +819,7 @@ wchar_t ftermfreebsdTest::charEncode (wchar_t c)
{
wchar_t ch_enc{L'\0'};
for (std::size_t i{0}; i <= finalcut::fc::lastCharItem; i++)
for (std::size_t i{0}; i <= finalcut::fc::last_char_item; i++)
{
if ( finalcut::fc::character[i][finalcut::fc::UTF8] == uInt(c) )
{