A small benchmakt test was added to the Rotozoomer example

This commit is contained in:
Markus Gans 2020-03-22 21:53:27 +01:00
parent 86ccd30eae
commit 4c0404ac60
25 changed files with 243 additions and 96 deletions

View File

@ -1,3 +1,6 @@
2020-03-22 Markus Gans <guru.mail@muenster.de>
* A small benchmakt test was added to the Rotozoomer example
2020-03-08 Markus Gans <guru.mail@muenster.de> 2020-03-08 Markus Gans <guru.mail@muenster.de>
* A rotozoomer example was added to demonstrate the drawing speed * A rotozoomer example was added to demonstrate the drawing speed
of FINAL CUT of FINAL CUT

View File

@ -77,6 +77,11 @@ The calculator example in newfont mode:
![calculator](doc/calculator.png) ![calculator](doc/calculator.png)
Benchmark
---------
Here you can find a test for ![measuring the character speed](doc/benchmark.md) in the terminal.
Virtual terminal Virtual terminal
---------------- ----------------
FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen. FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen.

30
doc/benchmark.md Normal file
View File

@ -0,0 +1,30 @@
Benchmark
=========
The Rotozoomer example can perform a benchmark run with the parameter "-b" to determine the FINAL CUT character speed in the terminal.
[![rotozoomer-benchmark](https://asciinema.org/a/voRnNvr7M97BxiDWVhMr3IVIN.svg)](https://asciinema.org/a/voRnNvr7M97BxiDWVhMr3IVIN)
Speed tests
-----------
| Terminal | Size | Time | Loops | Frame rate |
|--------------------|-------|---------|-------|------------|
| XTerm | 80x24 | 2.693ms | 314 | 116.598fps |
| PuTTY | 80x24 | 2.711ms | 314 | 115.824fps |
| Mintty | 80x24 | 2.799ms | 314 | 112.182fps |
| Cygwin (cmd) | 80x24 | 2.99ms | 314 | 105.016fps |
| rxvt-cygwin-native | 80x24 | 2.836ms | 314 | 110.719fps |
| rxvt | 80x24 | 3.064ms | 314 | 102.480fps |
| rxvt-unicode | 80x24 | 2.853ms | 314 | 110.059fps |
| Tera Term | 80x24 | 3.154ms | 314 | 99.5561fps |
| Konsole | 80x24 | 2.727ms | 314 | 115.144fps |
| GNOME-Terminal | 80x24 | 2.683ms | 314 | 117.033fps |
| Linux console | 80x25 | 2.757ms | 314 | 113.891fps |
| FreeBSD console | 80x25 | 2.726ms | 314 | 115.187fps |
| NetBSD console | 80x25 | 2.747ms | 314 | 114.306fps |
| OpenBSD console | 80x25 | 2.751ms | 314 | 114.140fps |
| Solaris console | 80x34 | 3.072ms | 314 | 102.213fps |

View File

@ -10,6 +10,14 @@ Formatting
* Use one blank line before and after a for, if, switch, * Use one blank line before and after a for, if, switch,
while, do..while code block while, do..while code block
* In parameter lists, leave a space after each comma * In parameter lists, leave a space after each comma
* Starting curly brace "{" in a new line
Naming
------
* class name: upperCamelCase
* Function: lowerCamelCase
* Callback function: cb_lowerCamelCase (beginning with "cb_" as prefix)
* Variable: lower_case_underscored
Class declaration order Class declaration order
----------------------- -----------------------

View File

@ -20,11 +20,15 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <chrono>
#include <iomanip>
#include <cmath> #include <cmath>
#include <final/final.h> #include <final/final.h>
namespace fc = finalcut::fc; namespace fc = finalcut::fc;
using namespace std::chrono;
using finalcut::FPoint; using finalcut::FPoint;
using finalcut::FSize; using finalcut::FSize;
@ -42,11 +46,14 @@ class RotoZoomer : public finalcut::FDialog
{ {
public: public:
// Constructor // Constructor
explicit RotoZoomer (finalcut::FWidget* = nullptr); explicit RotoZoomer (finalcut::FWidget* = nullptr, bool = false, int = 314);
// Destructor // Destructor
~RotoZoomer() override; ~RotoZoomer() override;
// Accessors
finalcut::FString getReport();
// Event handlers // Event handlers
void onShow (finalcut::FShowEvent*) override; void onShow (finalcut::FShowEvent*) override;
void onTimer (finalcut::FTimerEvent*) override; void onTimer (finalcut::FTimerEvent*) override;
@ -57,17 +64,25 @@ class RotoZoomer : public finalcut::FDialog
// Methods // Methods
void draw() override; void draw() override;
void rotozoomer (double, double, double, double); void rotozoomer (double, double, double, double);
void generateReport();
void adjustSize() override; void adjustSize() override;
// Data member // Data member
wchar_t data[256]{}; bool benchmark{false};
int loops{0};
int path{0}; int path{0};
wchar_t data[256]{};
finalcut::FString report;
time_point<system_clock> start{};
time_point<system_clock> end{};
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
RotoZoomer::RotoZoomer (finalcut::FWidget* parent) RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int i)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
, benchmark(b)
, loops(i)
{ {
setText ("Rotozoomer effect"); setText ("Rotozoomer effect");
@ -107,12 +122,14 @@ RotoZoomer::~RotoZoomer()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::draw() void RotoZoomer::draw()
{ {
if ( benchmark && start == time_point<system_clock>() )
start = system_clock::now();
finalcut::FDialog::draw(); finalcut::FDialog::draw();
double cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0))); double cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0)));
double cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0))); double cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0)));
double r = double(128.0 + 96.0 * std::cos(double(path) / 10.0)); double r = double(128.0 + 96.0 * std::cos(double(path) / 10.0));
double a = double(path) / 50.0; double a = double(path) / 50.0;
print() << finalcut::FColorPair(fc::White, fc::Black);
rotozoomer (cx, cy, r, a); rotozoomer (cx, cy, r, a);
} }
@ -159,16 +176,61 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
} }
} }
//----------------------------------------------------------------------
void RotoZoomer::generateReport()
{
finalcut::FString term_type = getTermType();
finalcut::FString dimension_str{};
finalcut::FString time_str{};
finalcut::FString fps_str{};
std::wostringstream rep;
dimension_str << getDesktopWidth()
<< "x" << getDesktopHeight();
int elapsed_ms = duration_cast<milliseconds>(end - start).count();
time_str << double(elapsed_ms) / 1000 << "ms";
fps_str << double(loops) * 1000.0 / double(elapsed_ms);
rep << finalcut::FString(55, '-') << "\n"
<< "Terminal Size Time Loops Frame rate\n"
<< finalcut::FString(55, '-') << "\n"
<< std::left << std::setw(20) << term_type
<< std::setw(8) << dimension_str
<< std::setw(10) << time_str
<< std::setw(7) << loops
<< std::setw(7) << fps_str.left(7) << "fps\n";
report << rep.str();
}
//----------------------------------------------------------------------
inline finalcut::FString RotoZoomer::getReport()
{
return report;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::onShow (finalcut::FShowEvent*) void RotoZoomer::onShow (finalcut::FShowEvent*)
{ {
if ( ! benchmark )
addTimer(33); addTimer(33);
else
{
for (path = 1; path < loops; path++)
{
redraw();
updateTerminal();
}
end = system_clock::now();
generateReport();
flush();
quit();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::onTimer (finalcut::FTimerEvent*) void RotoZoomer::onTimer (finalcut::FTimerEvent*)
{ {
if ( path >= 314 ) if ( path >= 314 ) // More than 360 degrees
path = 0; path = 0;
else else
path++; path++;
@ -196,11 +258,14 @@ void RotoZoomer::onKeyPress (finalcut::FKeyEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::onClose (finalcut::FCloseEvent* ev) void RotoZoomer::onClose (finalcut::FCloseEvent* ev)
{ {
if ( ! benchmark )
finalcut::FApplication::closeConfirmationDialog (this, ev); finalcut::FApplication::closeConfirmationDialog (this, ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void RotoZoomer::adjustSize() void RotoZoomer::adjustSize()
{
if ( ! benchmark )
{ {
std::size_t h = getDesktopHeight(); std::size_t h = getDesktopHeight();
std::size_t w = getDesktopWidth(); std::size_t w = getDesktopWidth();
@ -212,6 +277,8 @@ void RotoZoomer::adjustSize()
w -= 8; w -= 8;
setGeometry(FPoint(5, 1), FSize(w, h), false); setGeometry(FPoint(5, 1), FSize(w, h), false);
}
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -219,20 +286,55 @@ void RotoZoomer::adjustSize()
// main part // main part
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{
constexpr int iterations = 314;
bool benchmark{false};
finalcut::FString report{};
int quit_code{0};
if ( argv[1] && ( strcmp(argv[1], "--help") == 0
|| strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "RotoZoomer options:\n"
<< " -b, --benchmark "
<< "Starting a benchmark run\n\n";
}
else if ( argv[1] && ( strcmp(argv[1], "--benchmark") == 0
|| strcmp(argv[1], "-b") == 0 ) )
{
benchmark = true;
}
{ {
// Create the application object // Create the application object
finalcut::FApplication app(argc, argv); finalcut::FApplication app(argc, argv);
app.setNonBlockingRead(); app.setNonBlockingRead();
// Create a simple dialog box // Create a simple dialog box
RotoZoomer p(&app); RotoZoomer roto(&app, benchmark, iterations);
p.setGeometry (FPoint(5, 1), FSize(72, 23));
p.setShadow(); if ( benchmark )
roto.setGeometry (FPoint(1, 1), FSize(80, 24));
else
roto.setGeometry (FPoint(5, 1), FSize(72, 23));
roto.setShadow();
// Set the RotoZoomer object as main widget // Set the RotoZoomer object as main widget
app.setMainWidget(&p); app.setMainWidget(&roto);
// Show and start the application // Show and start the application
p.show(); roto.show();
return app.exec(); quit_code = app.exec();
if ( benchmark )
report = roto.getReport();
}
if ( benchmark )
{
std::cout << "Benchmark:\n" << report;
}
return quit_code;
} }

View File

@ -54,10 +54,10 @@ class Scrollview : public finalcut::FScrollView
void draw() override; void draw() override;
// Callback methods // Callback methods
void cb_go_east (finalcut::FWidget*, FDataPtr); void cb_goEast (finalcut::FWidget*, FDataPtr);
void cb_go_south (finalcut::FWidget*, FDataPtr); void cb_goSouth (finalcut::FWidget*, FDataPtr);
void cb_go_west (finalcut::FWidget*, FDataPtr); void cb_goWest (finalcut::FWidget*, FDataPtr);
void cb_go_north (finalcut::FWidget*, FDataPtr); void cb_goNorth (finalcut::FWidget*, FDataPtr);
// Data members // Data members
wchar_t pointer_right{fc::BlackRightPointingPointer}; wchar_t pointer_right{fc::BlackRightPointingPointer};
@ -88,25 +88,25 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
go_east.addCallback go_east.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_east) F_METHOD_CALLBACK (this, &Scrollview::cb_goEast)
); );
go_south.addCallback go_south.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_south) F_METHOD_CALLBACK (this, &Scrollview::cb_goSouth)
); );
go_west.addCallback go_west.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_west) F_METHOD_CALLBACK (this, &Scrollview::cb_goWest)
); );
go_north.addCallback go_north.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_north) F_METHOD_CALLBACK (this, &Scrollview::cb_goNorth)
); );
} }
@ -150,7 +150,7 @@ void Scrollview::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_go_east (finalcut::FWidget*, FDataPtr) void Scrollview::cb_goEast (finalcut::FWidget*, FDataPtr)
{ {
scrollToX (int(getScrollWidth() - getViewportWidth()) + 1); scrollToX (int(getScrollWidth() - getViewportWidth()) + 1);
go_south.setFocus(); go_south.setFocus();
@ -159,7 +159,7 @@ void Scrollview::cb_go_east (finalcut::FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_go_south (finalcut::FWidget*, FDataPtr) void Scrollview::cb_goSouth (finalcut::FWidget*, FDataPtr)
{ {
scrollToY (int(getScrollHeight() - getViewportHeight()) + 1); scrollToY (int(getScrollHeight() - getViewportHeight()) + 1);
go_west.setFocus(); go_west.setFocus();
@ -168,7 +168,7 @@ void Scrollview::cb_go_south (finalcut::FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_go_west (finalcut::FWidget*, FDataPtr) void Scrollview::cb_goWest (finalcut::FWidget*, FDataPtr)
{ {
scrollToX (1); scrollToX (1);
go_north.setFocus(); go_north.setFocus();
@ -177,7 +177,7 @@ void Scrollview::cb_go_west (finalcut::FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_go_north (finalcut::FWidget*, FDataPtr) void Scrollview::cb_goNorth (finalcut::FWidget*, FDataPtr)
{ {
scrollToY (1); scrollToY (1);
go_east.setFocus(); go_east.setFocus();

View File

@ -293,7 +293,7 @@ class MyDialog : public finalcut::FDialog
void cb_clearInput (finalcut::FWidget*, FDataPtr); void cb_clearInput (finalcut::FWidget*, FDataPtr);
void cb_input2buttonText (finalcut::FWidget*, FDataPtr); void cb_input2buttonText (finalcut::FWidget*, FDataPtr);
void cb_setTitlebar (finalcut::FWidget*, FDataPtr); void cb_setTitlebar (finalcut::FWidget*, FDataPtr);
void cb_ProgressBar (finalcut::FWidget*, FDataPtr); void cb_showProgressBar (finalcut::FWidget*, FDataPtr);
void cb_updateNumber (finalcut::FWidget*, FDataPtr); void cb_updateNumber (finalcut::FWidget*, FDataPtr);
void cb_activateButton (finalcut::FWidget*, FDataPtr); void cb_activateButton (finalcut::FWidget*, FDataPtr);
void cb_view (finalcut::FWidget*, FDataPtr); void cb_view (finalcut::FWidget*, FDataPtr);
@ -671,7 +671,7 @@ void MyDialog::initButtons()
MyButton5.addCallback MyButton5.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_ProgressBar) F_METHOD_CALLBACK (this, &MyDialog::cb_showProgressBar)
); );
MyButton6.addCallback MyButton6.addCallback
@ -907,7 +907,7 @@ void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_ProgressBar (finalcut::FWidget*, FDataPtr) void MyDialog::cb_showProgressBar (finalcut::FWidget*, FDataPtr)
{ {
auto p_dgl = new ProgressDialog(this); auto p_dgl = new ProgressDialog(this);
p_dgl->show(); p_dgl->show();

View File

@ -99,7 +99,7 @@ void FLabel::setAccelWidget (FWidget* widget)
accel_widget->addCallback accel_widget->addCallback
( (
"destroy", "destroy",
F_METHOD_CALLBACK (this, &FLabel::cb_accel_widget_destroyed) F_METHOD_CALLBACK (this, &FLabel::cb_accelWidgetDestroyed)
); );
} }
@ -234,7 +234,7 @@ void FLabel::onAccel (FAccelEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::cb_accel_widget_destroyed (FWidget*, FDataPtr) void FLabel::cb_accelWidgetDestroyed (FWidget*, FDataPtr)
{ {
accel_widget = nullptr; accel_widget = nullptr;
delAccelerator(); delAccelerator();

View File

@ -652,8 +652,8 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::init() void FListBox::init()
{ {
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange);
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
@ -1745,7 +1745,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_VBarChange (FWidget*, FDataPtr) void FListBox::cb_vbarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType; FScrollbar::sType scrollType;
const std::size_t current_before = current; const std::size_t current_before = current;
@ -1808,7 +1808,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_HBarChange (FWidget*, FDataPtr) void FListBox::cb_hbarChange (FWidget*, FDataPtr)
{ {
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -1454,8 +1454,8 @@ void FListView::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::init() void FListView::init()
{ {
initScrollbar (vbar, fc::vertical, this, &FListView::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FListView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FListView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange);
selflist.push_back(this); selflist.push_back(this);
root = selflist.begin(); root = selflist.begin();
null_iter = selflist.end(); null_iter = selflist.end();
@ -2791,7 +2791,7 @@ void FListView::scrollBy (int dx, int dy)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_VBarChange (FWidget*, FDataPtr) void FListView::cb_vbarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::sType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
@ -2850,7 +2850,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_HBarChange (FWidget*, FDataPtr) void FListView::cb_hbarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::sType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -319,7 +319,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitem_toggled (FWidget* widget, FDataPtr) void FMenu::cb_menuitemToggled (FWidget* widget, FDataPtr)
{ {
const auto& m_item = static_cast<FMenuItem*>(widget); const auto& m_item = static_cast<FMenuItem*>(widget);

View File

@ -218,7 +218,7 @@ void FMenuBar::onAccel (FAccelEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::cb_item_deactivated (FWidget* widget, FDataPtr) void FMenuBar::cb_itemDeactivated (FWidget* widget, FDataPtr)
{ {
auto menuitem = static_cast<FMenuItem*>(widget); auto menuitem = static_cast<FMenuItem*>(widget);

View File

@ -544,7 +544,7 @@ void FMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"deactivate", "deactivate",
F_METHOD_CALLBACK (menubar_ptr, &FMenuBar::cb_item_deactivated) F_METHOD_CALLBACK (menubar_ptr, &FMenuBar::cb_itemDeactivated)
); );
} }
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu

View File

@ -69,7 +69,7 @@ void FRadioMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"toggled", "toggled",
F_METHOD_CALLBACK (menu_ptr, &FMenu::cb_menuitem_toggled) F_METHOD_CALLBACK (menu_ptr, &FMenu::cb_menuitemToggled)
); );
} }
} }

View File

@ -305,7 +305,7 @@ bool FScrollView::setBorder (bool enable)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode) void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
{ {
hMode = mode; h_mode = mode;
if ( isShown() ) if ( isShown() )
setHorizontalScrollBarVisibility(); setHorizontalScrollBarVisibility();
@ -314,7 +314,7 @@ void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode) void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
{ {
vMode = mode; v_mode = mode;
if ( isShown() ) if ( isShown() )
setVerticalScrollBarVisibility(); setVerticalScrollBarVisibility();
@ -712,8 +712,8 @@ void FScrollView::init (FWidget* parent)
assert ( parent != nullptr ); assert ( parent != nullptr );
assert ( ! parent->isInstanceOf("FScrollView") ); assert ( ! parent->isInstanceOf("FScrollView") );
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange); initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange);
mapKeyFunctions(); mapKeyFunctions();
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
@ -790,7 +790,7 @@ void FScrollView::calculateScrollbarPos()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setHorizontalScrollBarVisibility() void FScrollView::setHorizontalScrollBarVisibility()
{ {
switch ( hMode ) switch ( h_mode )
{ {
case fc::Auto: case fc::Auto:
if ( getScrollWidth() > getViewportWidth() ) if ( getScrollWidth() > getViewportWidth() )
@ -812,7 +812,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setVerticalScrollBarVisibility() void FScrollView::setVerticalScrollBarVisibility()
{ {
switch ( vMode ) switch ( v_mode )
{ {
case fc::Auto: case fc::Auto:
if ( getScrollHeight() > getViewportHeight() ) if ( getScrollHeight() > getViewportHeight() )
@ -852,7 +852,7 @@ void FScrollView::setViewportCursor()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_VBarChange (FWidget*, FDataPtr) void FScrollView::cb_vbarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::sType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
@ -903,7 +903,7 @@ void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_HBarChange (FWidget*, FDataPtr) void FScrollView::cb_hbarChange (FWidget*, FDataPtr)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::sType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -940,11 +940,10 @@ inline char* FTermDetection::secDA_Analysis_82()
char* new_termtype{}; char* new_termtype{};
terminal_type.rxvt = true; terminal_type.rxvt = true;
if ( std::strncmp(termtype, "rxvt-", 5) != 0 if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
&& std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
new_termtype = C_STR("rxvt-16color"); new_termtype = C_STR("rxvt-16color");
else else
new_termtype = termtype; new_termtype = C_STR("rxvt");
return new_termtype; return new_termtype;
} }

View File

@ -140,7 +140,7 @@ void FTextView::scrollTo (int x, int y)
if ( changeX && isHorizontallyScrollable() ) if ( changeX && isHorizontallyScrollable() )
{ {
const int xoffset_end = int(maxLineWidth - getTextWidth()); const int xoffset_end = int(max_line_width - getTextWidth());
xoffset = x; xoffset = x;
if ( xoffset < 0 ) if ( xoffset < 0 )
@ -215,17 +215,17 @@ void FTextView::insert (const FString& str, int pos)
.rtrim(); .rtrim();
const auto column_width = getColumnWidth(line); const auto column_width = getColumnWidth(line);
if ( column_width > maxLineWidth ) if ( column_width > max_line_width )
{ {
maxLineWidth = column_width; max_line_width = column_width;
if ( column_width > getTextWidth() ) if ( column_width > getTextWidth() )
{ {
const int hmax = ( maxLineWidth > getTextWidth() ) const int hmax = ( max_line_width > getTextWidth() )
? int(maxLineWidth) - int(getTextWidth()) ? int(max_line_width) - int(getTextWidth())
: 0; : 0;
hbar->setMaximum (hmax); hbar->setMaximum (hmax);
hbar->setPageSize (int(maxLineWidth), int(getTextWidth())); hbar->setPageSize (int(max_line_width), int(getTextWidth()));
hbar->calculateSliderValues(); hbar->calculateSliderValues();
if ( isShown() && isHorizontallyScrollable() ) if ( isShown() && isHorizontallyScrollable() )
@ -272,7 +272,7 @@ void FTextView::clear()
data.shrink_to_fit(); data.shrink_to_fit();
xoffset = 0; xoffset = 0;
yoffset = 0; yoffset = 0;
maxLineWidth = 0; max_line_width = 0;
vbar->setMinimum(0); vbar->setMinimum(0);
vbar->setValue(0); vbar->setValue(0);
@ -484,7 +484,7 @@ void FTextView::adjustSize()
const std::size_t width = getWidth(); const std::size_t width = getWidth();
const std::size_t height = getHeight(); const std::size_t height = getHeight();
const int last_line = int(getRows()); const int last_line = int(getRows());
const int max_width = int(maxLineWidth); const int max_width = int(max_line_width);
if ( xoffset >= max_width - int(width) - nf_offset ) if ( xoffset >= max_width - int(width) - nf_offset )
xoffset = max_width - int(width) - nf_offset - 1; xoffset = max_width - int(width) - nf_offset - 1;
@ -555,8 +555,8 @@ std::size_t FTextView::getTextWidth()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::init() void FTextView::init()
{ {
initScrollbar (vbar, fc::vertical, this, &FTextView::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FTextView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_hbarChange);
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
@ -744,7 +744,7 @@ void FTextView::changeOnResize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_VBarChange (FWidget*, FDataPtr) void FTextView::cb_vbarChange (FWidget*, FDataPtr)
{ {
const FScrollbar::sType scrollType = vbar->getScrollType(); const FScrollbar::sType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
@ -795,7 +795,7 @@ void FTextView::cb_VBarChange (FWidget*, FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_HBarChange (FWidget*, FDataPtr) void FTextView::cb_hbarChange (FWidget*, FDataPtr)
{ {
const FScrollbar::sType scrollType = hbar->getScrollType(); const FScrollbar::sType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -1009,7 +1009,7 @@ void FWidget::show()
show_root_widget = this; show_root_widget = this;
} }
draw(); draw(); // Draw the widget
flags.hidden = false; flags.hidden = false;
flags.shown = true; flags.shown = true;

View File

@ -122,7 +122,7 @@ class FLabel : public FWidget
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
// Callback method // Callback method
void cb_accel_widget_destroyed (FWidget*, FDataPtr); void cb_accelWidgetDestroyed (FWidget*, FDataPtr);
private: private:
// Constants // Constants

View File

@ -309,8 +309,8 @@ class FListBox : public FWidget
listBoxItems::iterator index2iterator (std::size_t); listBoxItems::iterator index2iterator (std::size_t);
listBoxItems::const_iterator index2iterator (std::size_t index) const; listBoxItems::const_iterator index2iterator (std::size_t index) const;
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_vbarChange (FWidget*, FDataPtr);
void cb_HBarChange (FWidget*, FDataPtr); void cb_hbarChange (FWidget*, FDataPtr);
// Function Pointer // Function Pointer
lazyInsert lazy_inserter{}; lazyInsert lazy_inserter{};

View File

@ -441,8 +441,8 @@ class FListView : public FWidget
bool hasCheckableItems() const; bool hasCheckableItems() const;
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_vbarChange (FWidget*, FDataPtr);
void cb_HBarChange (FWidget*, FDataPtr); void cb_hbarChange (FWidget*, FDataPtr);
// Data members // Data members
iterator root{}; iterator root{};

View File

@ -121,7 +121,7 @@ class FMenu : public FWindow, public FMenuList
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
// Callback method // Callback method
void cb_menuitem_toggled (FWidget*, FDataPtr); void cb_menuitemToggled (FWidget*, FDataPtr);
private: private:
// Constants // Constants

View File

@ -98,7 +98,7 @@ class FMenuBar : public FWindow, public FMenuList
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
// Callback methods // Callback methods
void cb_item_deactivated (FWidget*, FDataPtr); void cb_itemDeactivated (FWidget*, FDataPtr);
private: private:
// Constants // Constants

View File

@ -171,8 +171,8 @@ class FScrollView : public FWidget
void setViewportCursor(); void setViewportCursor();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_vbarChange (FWidget*, FDataPtr);
void cb_HBarChange (FWidget*, FDataPtr); void cb_hbarChange (FWidget*, FDataPtr);
// Data members // Data members
FRect scroll_geometry{1, 1, 1, 1}; FRect scroll_geometry{1, 1, 1, 1};
@ -185,8 +185,8 @@ class FScrollView : public FWidget
bool border{true}; bool border{true};
bool use_own_print_area{false}; bool use_own_print_area{false};
bool update_scrollbar{true}; bool update_scrollbar{true};
fc::scrollBarMode vMode{fc::Auto}; // fc:Auto, fc::Hidden or fc::Scroll fc::scrollBarMode v_mode{fc::Auto}; // fc:Auto, fc::Hidden or fc::Scroll
fc::scrollBarMode hMode{fc::Auto}; fc::scrollBarMode h_mode{fc::Auto};
}; };
// FScrollView inline functions // FScrollView inline functions

View File

@ -157,8 +157,8 @@ class FTextView : public FWidget
void changeOnResize(); void changeOnResize();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_vbarChange (FWidget*, FDataPtr);
void cb_HBarChange (FWidget*, FDataPtr); void cb_hbarChange (FWidget*, FDataPtr);
// Data members // Data members
FStringList data{}; FStringList data{};
@ -169,7 +169,7 @@ class FTextView : public FWidget
int xoffset{0}; int xoffset{0};
int yoffset{0}; int yoffset{0};
int nf_offset{0}; int nf_offset{0};
std::size_t maxLineWidth{0}; std::size_t max_line_width{0};
}; };
// FListBox inline functions // FListBox inline functions
@ -213,7 +213,7 @@ inline const FString FTextView::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FTextView::getColumns() const inline std::size_t FTextView::getColumns() const
{ return maxLineWidth; } { return max_line_width; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FTextView::getRows() const inline std::size_t FTextView::getRows() const
@ -256,7 +256,7 @@ inline void FTextView::deleteLine (int pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTextView::isHorizontallyScrollable() inline bool FTextView::isHorizontallyScrollable()
{ return bool( maxLineWidth > getTextWidth() ); } { return bool( max_line_width > getTextWidth() ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTextView::isVerticallyScrollable() inline bool FTextView::isVerticallyScrollable()