From b0080b00cf88e00792603ef0f5d310c09a0efb7c Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 8 Oct 2019 04:37:19 +0200 Subject: [PATCH] More code cleanups --- README.md | 93 +++--- doc/virtual-terminal.txt | 100 +++--- examples/mouse.cpp | 12 +- examples/transparent.cpp | 2 +- examples/ui.cpp | 4 +- finalcut.changes | 18 + src/Makefile.am | 2 + src/Makefile.clang | 2 + src/Makefile.gcc | 2 + src/fapplication.cpp | 35 +- src/fbuttongroup.cpp | 4 +- src/fdialog.cpp | 20 +- src/fkey_map.cpp | 6 +- src/fkeyboard.cpp | 16 +- src/flabel.cpp | 6 +- src/flineedit.cpp | 4 +- src/flistbox.cpp | 16 +- src/flistview.cpp | 18 +- src/fmenu.cpp | 22 +- src/fmenubar.cpp | 2 +- src/fmenuitem.cpp | 4 +- src/fmouse.cpp | 2 +- src/fobject.cpp | 6 +- src/foptiattr.cpp | 108 +++--- src/fprogressbar.cpp | 4 +- src/fscrollview.cpp | 12 +- src/fswitch.cpp | 2 +- src/fterm.cpp | 264 +-------------- src/fterm_functions.cpp | 285 ++++++++++++++++ src/ftermbuffer.cpp | 16 +- src/ftermcap.cpp | 86 ++--- src/ftermcapquirks.cpp | 88 ++--- src/ftermdetection.cpp | 6 +- src/ftermlinux.cpp | 14 +- src/ftermopenbsd.cpp | 5 + src/ftextview.cpp | 2 +- src/ftogglebutton.cpp | 4 +- src/fvterm.cpp | 510 ++++++++++++++--------------- src/fwidget.cpp | 467 +------------------------- src/fwidget_functions.cpp | 428 ++++++++++++++++++++++++ src/include/final/fapplication.h | 4 +- src/include/final/fkey_map.h | 6 +- src/include/final/fkeyboard.h | 4 +- src/include/final/fmouse.h | 6 +- src/include/final/fobject.h | 10 +- src/include/final/foptiattr.h | 118 +++---- src/include/final/fscrollview.h | 6 +- src/include/final/fterm.h | 12 +- src/include/final/ftermbuffer.h | 28 +- src/include/final/ftermdetection.h | 8 +- src/include/final/ftermlinux.h | 19 +- src/include/final/ftermopenbsd.h | 2 +- src/include/final/ftermxterminal.h | 6 + src/include/final/ftypes.h | 12 +- src/include/final/fvterm.h | 216 ++++++------ src/include/final/fwidget.h | 45 +-- test/fkeyboard-test.cpp | 6 +- test/fobject-test.cpp | 2 +- test/foptiattr-test.cpp | 44 +-- test/ftermcapquirks-test.cpp | 88 ++--- 60 files changed, 1689 insertions(+), 1650 deletions(-) create mode 100644 src/fterm_functions.cpp create mode 100644 src/fwidget_functions.cpp diff --git a/README.md b/README.md index 273c0369..6e7de034 100644 --- a/README.md +++ b/README.md @@ -85,56 +85,49 @@ FINAL CUT uses a virtual terminal to print character via an update method on the print(...) printf(...) │ - │ ╔═════════════════════════[ vterm ]═════════════════════════╗ - │ ║createVTerm() ║ - │ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║ - │ ║ ║ - │ ║ │ restoreVTerm(x,y,w,h) │ ║ - │ ║ ║ - │ ║ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║ - │ ║ ║ - │ ┌───────╨─────[ vwin ]─────────────┐ ║ - │ │createArea(area) │ ║ - │ │ │ ║ - │ │ │ ║ - └───┼────────► putArea(area) ────► ║ - │ │ ║ - │ putArea(x,y,area) ────► ║ - │ │ ║ - │ ◄──── getArea(x,y,area) ║ - │ │ ║ - │ │ ║ - │ │ ║ - │ resizeArea(area)│ ║ - └───────╥──────────────────────────┘ ║ - ║ ║ - ║ ║ - ║ ║ - ║ │ resizeVTerm()║ - ╚═══▼═══════════════════════════════════════════════════════╝ - │ - │ putVTerm() - └──────────────────► updateTerminalLine(y) - updateTerminal() │ - ▼ - ┌───────────────┐ - │ output_buffer │ - └───────────────┘ - │ - │ flush_out() - │ + - │ Fputchar(char) - │ - ▼ - ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ - ▌ ▐ - ▌ screen ▐ - ▌ ───────────── ▐ - ▌ real terminal ▐ - ▌ ▐ - ▀▀▀▀▀▀▀███▀▀▀▀▀▀▀ - ███ - ▀▀▀▀▀▀▀▀▀ + │ ╔════════════════════════[ vterm ]════════════════════════╗ + │ ║createVTerm() ║ + │ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║ + │ ║ ║ + │ ║ │ restoreVTerm(x,y,w,h) │ ║ + │ ┌───────╨────[ vwin ]────────────┐ ║ + │ │createArea(area) │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║ + │ │ │ ║ + │ │ │ ║ + └──┼────────► putArea(area) ────► ║ + │ │ ║ + │ putArea(x,y,area) ────► ║ + │ │ ║ + │ ◄──── getArea(x,y,area) ║ + │ │ ║ + │ │ ║ + │ │ ║ + │ resizeArea(area)│ ║ + └───────╥────────────────────────┘ ║ + ║ ║ + ║ │ resizeVTerm()║ + ╚═══════▼═════════════════════════════════════════════════╝ + │ + │ putVTerm() + └──────────────────► updateTerminalLine(y) + updateTerminal() │ + ▼ + ┌───────────────┐ + │ output_buffer │ + └───────────────┘ + │ + │ flushOutputBuffer() + │ and putchar(char) + ▼ + ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + ▌ ▐ + ▌ screen ▐ + ▌ ───────────── ▐ + ▌ real terminal ▐ + ▌ ▐ + ▀▀▀▀▀▀▀███▀▀▀▀▀▀▀ + ███ + ▀▀▀▀▀▀▀▀▀ diff --git a/doc/virtual-terminal.txt b/doc/virtual-terminal.txt index 9192157f..e2508509 100644 --- a/doc/virtual-terminal.txt +++ b/doc/virtual-terminal.txt @@ -1,9 +1,9 @@ The virtual terminal (vterm) ---------------------------- -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 +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. @@ -11,54 +11,46 @@ differences to the virtual terminal or physical screen. print(...) printf(...) │ - │ ╔═════════════════════════[ vterm ]═════════════════════════╗ - │ ║createVTerm() ║ - │ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║ - │ ║ ║ - │ ║ │ restoreVTerm(x,y,w,h) │ ║ - │ ║ ║ - │ ║ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║ - │ ║ ║ - │ ┌───────╨─────[ vwin ]─────────────┐ ║ - │ │createArea(area) │ ║ - │ │ │ ║ - │ │ │ ║ - └───┼────────► putArea(area) ────► ║ - │ │ ║ - │ putArea(x,y,area) ────► ║ - │ │ ║ - │ ◄──── getArea(x,y,area) ║ - │ │ ║ - │ │ ║ - │ │ ║ - │ resizeArea(area)│ ║ - └───────╥──────────────────────────┘ ║ - ║ ║ - ║ ║ - ║ ║ - ║ │ resizeVTerm()║ - ╚═══▼═══════════════════════════════════════════════════════╝ - │ - │ putVTerm() - └──────────────────► updateTerminalLine(y) - updateTerminal() │ - ▼ - ┌───────────────┐ - │ output_buffer │ - └───────────────┘ - │ - │ flush_out() - │ + - │ Fputchar(char) - │ - ▼ - ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ - ▌ ▐ - ▌ screen ▐ - ▌ ───────────── ▐ - ▌ real terminal ▐ - ▌ ▐ - ▀▀▀▀▀▀▀███▀▀▀▀▀▀▀ - ███ - ▀▀▀▀▀▀▀▀▀ - + │ ╔════════════════════════[ vterm ]════════════════════════╗ + │ ║createVTerm() ║ + │ ║ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ║ + │ ║ ║ + │ ║ │ restoreVTerm(x,y,w,h) │ ║ + │ ┌───────╨────[ vwin ]────────────┐ ║ + │ │createArea(area) │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ║ + │ │ │ ║ + │ │ │ ║ + └──┼────────► putArea(area) ────► ║ + │ │ ║ + │ putArea(x,y,area) ────► ║ + │ │ ║ + │ ◄──── getArea(x,y,area) ║ + │ │ ║ + │ │ ║ + │ │ ║ + │ resizeArea(area)│ ║ + └───────╥────────────────────────┘ ║ + ║ ║ + ║ │ resizeVTerm()║ + ╚═══════▼═════════════════════════════════════════════════╝ + │ + │ putVTerm() + └──────────────────► updateTerminalLine(y) + updateTerminal() │ + ▼ + ┌───────────────┐ + │ output_buffer │ + └───────────────┘ + │ + │ flushOutputBuffer() + │ and putchar(char) + ▼ + ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + ▌ ▐ + ▌ screen ▐ + ▌ ───────────── ▐ + ▌ real terminal ▐ + ▌ ▐ + ▀▀▀▀▀▀▀███▀▀▀▀▀▀▀ + ███ + ▀▀▀▀▀▀▀▀▀ diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 77e504fb..e3724e6a 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -350,7 +350,7 @@ class MouseDraw : public finalcut::FDialog void cb_colorChanged (finalcut::FWidget*, FDataPtr); // Data members - term_area* canvas{nullptr}; + FTermArea* canvas{nullptr}; ColorChooser c_chooser{this}; Brushes brush{this}; }; @@ -495,13 +495,13 @@ void MouseDraw::drawCanvas() for (int y{0}; y < y_end; y++) // line loop { - finalcut::charData* canvaschar{}; // canvas character - finalcut::charData* winchar{}; // window character - canvaschar = &canvas->text[y * x_end]; - winchar = &printarea->text[(ay + y) * w_line_len + ax]; + finalcut::FChar* canvaschar{}; // canvas character + finalcut::FChar* winchar{}; // window character + canvaschar = &canvas->data[y * x_end]; + winchar = &printarea->data[(ay + y) * w_line_len + ax]; std::memcpy ( winchar , canvaschar - , sizeof(finalcut::charData) * unsigned(x_end) ); + , sizeof(finalcut::FChar) * unsigned(x_end) ); if ( int(printarea->changes[ay + y].xmin) > ax ) printarea->changes[ay + y].xmin = uInt(ax); diff --git a/examples/transparent.cpp b/examples/transparent.cpp index cf5e9c25..fb9ec398 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -267,7 +267,7 @@ void MainWindow::onTimer (finalcut::FTimerEvent*) line1 = line1.right(length - 1) + first_Char[0]; line2 = line2.right(length - 1) + first_Char[1]; redraw(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/examples/ui.cpp b/examples/ui.cpp index be4f952c..e3e7e016 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -136,7 +136,7 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*) { auto p = progressBar.getPercentage(); progressBar.setPercentage(++p); - flush_out(); + flushOutputBuffer(); if ( p != 100 ) return; @@ -154,7 +154,7 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/finalcut.changes b/finalcut.changes index 0405520e..ca3a3629 100644 --- a/finalcut.changes +++ b/finalcut.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Sat Dec 01 21:28:25 UTC 2018 - Markus Gans +- Release (version 0.5.1) + +------------------------------------------------------------------- +Thu Nov 28 23:36:24 UTC 2018 - Markus Gans +- Package name adjustment + +------------------------------------------------------------------- +Mon Nov 26 11:22:27 UTC 2018 - mvetter@suse.com + +- Prepare to push to devel project +- Remove old tarball: finalcut-0.3.0.tar.gz +- Remove old tarball: finalcut-0.4.0.tar.gz +- Clean spec with spec-cleaner +- Add changes file + ------------------------------------------------------------------- Sun Nov 25 00:03:36 UTC 2018 - Markus Gans - Release (version 0.5.0) @@ -17,3 +34,4 @@ Sat Dec 19 21:01:48 UTC 2015 - Markus Gans ------------------------------------------------------------------- Fri Sep 18 22:35:57 UTC 2015 - Markus Gans - Initial Release (version 0.1.1) + diff --git a/src/Makefile.am b/src/Makefile.am index 3b093366..5b65d121 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,6 +57,7 @@ libfinal_la_SOURCES = \ ftermdetection.cpp \ ftermios.cpp \ fterm.cpp \ + fterm_functions.cpp \ fvterm.cpp \ fevent.cpp \ foptiattr.cpp \ @@ -66,6 +67,7 @@ libfinal_la_SOURCES = \ fcolorpalette.cpp \ fwidgetcolors.cpp \ fwidget.cpp \ + fwidget_functions.cpp \ fobject.cpp libfinal_la_LDFLAGS = -version-info @SO_VERSION@ diff --git a/src/Makefile.clang b/src/Makefile.clang index 65aecbbd..b5877f35 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -118,6 +118,7 @@ OBJS = \ fstartoptions.o \ ftermcap.o \ fterm.o \ + fterm_functions.o \ ftermdebugdata.o \ ftermios.o \ ftermdetection.o \ @@ -134,6 +135,7 @@ OBJS = \ fcolorpalette.o \ fwidgetcolors.o \ fwidget.o \ + fwidget_functions.o \ fevent.o \ fobject.o diff --git a/src/Makefile.gcc b/src/Makefile.gcc index c2e1f16b..ffbbf2ce 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -118,6 +118,7 @@ OBJS = \ ftermcap.o \ fstartoptions.o \ fterm.o \ + fterm_functions.o \ ftermdebugdata.o \ ftermios.o \ ftermdetection.o \ @@ -134,6 +135,7 @@ OBJS = \ fcolorpalette.o \ fwidgetcolors.o \ fwidget.o \ + fwidget_functions.o \ fevent.o \ fobject.o diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 415e5a9a..057e72f4 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -122,12 +122,12 @@ int FApplication::exec() // run quit_now = false; quit_code = 0; - enter_loop(); + enterLoop(); return quit_code; } //---------------------------------------------------------------------- -int FApplication::enter_loop() // event loop +int FApplication::enterLoop() // event loop { loop_level++; quit_now = false; @@ -144,7 +144,7 @@ int FApplication::enter_loop() // event loop } //---------------------------------------------------------------------- -void FApplication::exit_loop() +void FApplication::exitLoop() { app_exit_loop = true; } @@ -172,10 +172,7 @@ void FApplication::quit() bool FApplication::sendEvent ( const FObject* receiver , const FEvent* event ) { - if ( quit_now || app_exit_loop ) - return false; - - if ( ! receiver ) + if ( quit_now || app_exit_loop || ! receiver ) return false; if ( receiver->isWidget() ) @@ -672,7 +669,7 @@ void FApplication::processKeyboardEvent() return; findKeyboardWidget(); - flush_out(); + flushOutputBuffer(); keyboard->clearKeyBufferOnTimeout(); if ( isKeyPressed() ) @@ -776,10 +773,7 @@ FWidget*& FApplication::determineClickedWidget() { FWidget*& clicked = FWidget::getClickedWidget(); - if ( clicked ) - return clicked; - - if ( ! mouse ) + if ( clicked || ! mouse ) return clicked; if ( ! mouse->isLeftButtonPressed() @@ -861,7 +855,7 @@ void FApplication::closeOpenMenu() FWidget::getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -875,13 +869,7 @@ void FApplication::unselectMenubarItems() if ( openmenu || (mouse && mouse->isMoved()) ) return; - if ( ! menu_bar ) - return; - - if ( ! menu_bar->hasSelectedItem() ) - return; - - if ( ! mouse ) + if ( ! (menu_bar && menu_bar->hasSelectedItem() && mouse) ) return; const auto& mouse_position = mouse->getPos(); @@ -902,7 +890,7 @@ void FApplication::unselectMenubarItems() FWidget::getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -911,10 +899,7 @@ void FApplication::sendMouseEvent() { auto clicked = FWidget::getClickedWidget(); - if ( ! clicked ) - return; - - if ( ! mouse ) + if ( ! (clicked && mouse) ) return; const auto& mouse_position = mouse->getPos(); diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index ba406d4c..43e2b656 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -364,7 +364,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev) { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -539,7 +539,7 @@ void FButtonGroup::directFocus() { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 67dcdf31..b57ee381 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -135,7 +135,7 @@ void FDialog::show() if ( isModal() ) { auto fapp = FApplication::getApplicationObject(); - fapp->enter_loop(); + fapp->enterLoop(); if ( this == getMainWidget() ) fapp->quit(); @@ -150,7 +150,7 @@ void FDialog::hide() if ( isModal() ) { auto fapp = FApplication::getApplicationObject(); - fapp->exit_loop(); + fapp->exitLoop(); } } @@ -925,14 +925,10 @@ void FDialog::drawBorder() << fc::NF_rev_border_line_right; // border right⎹ } - print() << r.getLowerLeftPos() // lower left corner border ⎣ - << fc::NF_border_corner_lower_left; - - for (int x = r.getX1() + 1; x < r.getX2(); x++) - print (fc::NF_border_line_bottom); // low line _ - - // lower right corner border ⎦ - print (fc::NF_rev_border_corner_lower_right); + print() << r.getLowerLeftPos() + << fc::NF_border_corner_lower_left // ⎣ + << FString(r.getWidth() - 2, fc::NF_border_line_bottom) // _ + << fc::NF_rev_border_corner_lower_right; // ⎦ } else { @@ -1187,7 +1183,7 @@ void FDialog::leaveMenu() getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1232,7 +1228,7 @@ void FDialog::selectFirstMenuItem() getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index ab5708d2..07c9e8a0 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.cpp @@ -30,7 +30,7 @@ namespace finalcut namespace fc { -fkeymap Fkey[] = +FKeyMap fkey[] = { { fc::Fkey_backspace , 0, "kb" }, // backspace key { fc::Fkey_catab , 0, "ka" }, // clear-all-tabs key @@ -205,7 +205,7 @@ fkeymap Fkey[] = { 0 , 0, "\0" } }; -fmetakeymap Fmetakey[] = +FMetakeyMap fmetakey[] = { { fc::Fmkey_ic , "\033[2;3~" }, // M-insert { fc::Fmkey_ic , "\033\033[2~" }, // M-insert @@ -438,7 +438,7 @@ fmetakeymap Fmetakey[] = { 0 , "\0" } }; -keyname FkeyName[] = +FKeyName fkeyname[] = { { fc::Fckey_a , "Ctrl+A" }, { fc::Fckey_b , "Ctrl+B" }, diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 4f45908e..85e3c74f 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -83,9 +83,9 @@ void FKeyboard::fetchKeyCode() //---------------------------------------------------------------------- const FString FKeyboard::getKeyName (FKey keynum) { - for (std::size_t i{0}; fc::FkeyName[i].string[0] != 0; i++) - if ( fc::FkeyName[i].num && fc::FkeyName[i].num == keynum ) - return FString(fc::FkeyName[i].string); + for (std::size_t i{0}; fc::fkeyname[i].string[0] != 0; i++) + if ( fc::fkeyname[i].num && fc::fkeyname[i].num == keynum ) + return FString(fc::fkeyname[i].string); if ( keynum > 32 && keynum < 127 ) return FString(char(keynum)); @@ -94,7 +94,7 @@ const FString FKeyboard::getKeyName (FKey keynum) } //---------------------------------------------------------------------- -void FKeyboard::setTermcapMap (fc::fkeymap* keymap) +void FKeyboard::setTermcapMap (fc::FKeyMap* keymap) { key_map = keymap; } @@ -231,7 +231,7 @@ inline FKey FKeyboard::getTermcapKey() fifo_buf[n] = '\0'; input_data_pending = bool(fifo_buf[0] != '\0'); - return fc::Fkey[i].num; + return fc::fkey[i].num; } } @@ -245,9 +245,9 @@ inline FKey FKeyboard::getMetaKey() assert ( FIFO_BUF_SIZE > 0 ); - for (std::size_t i{0}; fc::Fmetakey[i].string[0] != 0; i++) + for (std::size_t i{0}; fc::fmetakey[i].string[0] != 0; i++) { - char* kmeta = fc::Fmetakey[i].string; // The string is never null + char* kmeta = fc::fmetakey[i].string; // The string is never null std::size_t len = std::strlen(kmeta); if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found @@ -269,7 +269,7 @@ inline FKey FKeyboard::getMetaKey() fifo_buf[n] = '\0'; input_data_pending = bool(fifo_buf[0] != '\0'); - return fc::Fmetakey[i].num; + return fc::fmetakey[i].num; } } diff --git a/src/flabel.cpp b/src/flabel.cpp index a5eb71e4..2f9c588a 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -268,7 +268,7 @@ void FLabel::onMouseDown (FMouseEvent* ev) { accel_widget->getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } } @@ -295,7 +295,7 @@ void FLabel::onAccel (FAccelEvent* ev) { accel_widget->getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } } @@ -464,7 +464,7 @@ void FLabel::printLine (FString&& line) else { to_column = width - 2; - to_char = getColumnWidthToLength(line, to_column); + to_char = getLengthFromColumnWidth(line, to_column); } if ( hasReverseMode() ) diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 467deb8a..58691245 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -596,7 +596,7 @@ void FLineEdit::onAccel (FAccelEvent* ev) { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } } @@ -623,7 +623,7 @@ void FLineEdit::onFocusIn (FFocusEvent*) { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 79cf955a..b20f7fe0 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -381,7 +381,7 @@ void FListBox::onMouseDown (FMouseEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -449,7 +449,7 @@ void FListBox::onMouseMove (FMouseEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } // Auto-scrolling when dragging mouse outside the widget @@ -526,7 +526,7 @@ void FListBox::onTimer (FTimerEvent*) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -572,7 +572,7 @@ void FListBox::onWheel (FWheelEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1116,7 +1116,7 @@ inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar) hbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1816,7 +1816,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -1869,7 +1869,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr) { drawList(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } if ( scrollType >= FScrollbar::scrollStepBackward ) @@ -1880,7 +1880,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr) hbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } diff --git a/src/flistview.cpp b/src/flistview.cpp index d80d9642..14a236de 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -968,7 +968,7 @@ void FListView::onMouseDown (FMouseEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } } @@ -1073,7 +1073,7 @@ void FListView::onMouseMove (FMouseEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } // auto-scrolling when dragging mouse outside the widget @@ -1160,7 +1160,7 @@ void FListView::onTimer (FTimerEvent*) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1199,7 +1199,7 @@ void FListView::onWheel (FWheelEvent* ev) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1823,7 +1823,7 @@ void FListView::drawBufferedHeadline() std::size_t offset{0}; bool left_truncated_fullwidth{false}; bool right_truncated_fullwidth{false}; - std::vector::const_iterator first{}, last{}; + std::vector::const_iterator first{}, last{}; last = headerline.end(); // Search for the start position @@ -1934,7 +1934,7 @@ void FListView::updateDrawing (bool draw_vbar, bool draw_hbar) hbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -2642,7 +2642,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr) vbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -2694,7 +2694,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr) drawHeadlines(); drawList(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } if ( scrollType >= FScrollbar::scrollStepBackward ) @@ -2705,7 +2705,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr) hbar->drawBar(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 0be7a681..44c54633 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -102,7 +102,7 @@ void FMenu::hide() const auto& t_geometry = getTermGeometryWithShadow(); restoreVTerm (t_geometry); updateTerminal(); - flush_out(); + flushOutputBuffer(); if ( ! isSubMenu() ) { @@ -204,7 +204,7 @@ void FMenu::onMouseDown (FMouseEvent* ev) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } return; @@ -313,7 +313,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) { closeOpenedSubMenu(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -584,7 +584,7 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -696,7 +696,7 @@ void FMenu::mouseDownSubmenu (FMenuItem* m_item) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -764,7 +764,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } return true; @@ -1038,7 +1038,7 @@ bool FMenu::selectNextItem() redraw(); updateTerminal(); - flush_out(); + flushOutputBuffer(); break; } @@ -1088,7 +1088,7 @@ bool FMenu::selectPrevItem() redraw(); updateTerminal(); - flush_out(); + flushOutputBuffer(); break; } } @@ -1151,7 +1151,7 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev) hide(); hideSuperMenus(); updateTerminal(); - flush_out(); + flushOutputBuffer(); ev->accept(); item->processClicked(); } @@ -1494,7 +1494,7 @@ inline void FMenu::selectPrevMenu (FKeyEvent* ev) getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } else keypressMenuBar(ev); // select previous menu @@ -1567,7 +1567,7 @@ inline void FMenu::closeMenu() getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index da3c965d..169bf046 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -971,7 +971,7 @@ void FMenuBar::leaveMenuBar() getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); mouse_down = false; } diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index a38d2a22..5dfcce9b 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -206,7 +206,7 @@ void FMenuItem::setText (const FString& txt) void FMenuItem::addAccelerator (FKey key, FWidget* obj) { auto root = getRootWidget(); - accelerator accel = { key, obj }; + FAccelerator accel = { key, obj }; if ( root && root->getAcceleratorList() ) { @@ -270,7 +270,7 @@ void FMenuItem::openMenu() dd_menu->raiseWindow(); dd_menu->redraw(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 4c34021e..7b41cc74 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -215,7 +215,7 @@ void FMouse::clearButtonState() // protected methods of FMouse //---------------------------------------------------------------------- -inline FMouse::button& FMouse::getButtonState() +inline FMouse::FMouseButton& FMouse::getButtonState() { return b_state; } diff --git a/src/fobject.cpp b/src/fobject.cpp index 2892689f..3ea55507 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -32,7 +32,7 @@ namespace finalcut // static class attributes bool FObject::timer_modify_lock; -FObject::TimerList* FObject::timer_list{nullptr}; +FObject::FTimerList* FObject::timer_list{nullptr}; const FString* fc::emptyFString::empty_string{nullptr}; @@ -58,7 +58,7 @@ FObject::FObject (FObject* parent) { try { - timer_list = new TimerList; + timer_list = new FTimerList; } catch (const std::bad_alloc& ex) { @@ -281,7 +281,7 @@ int FObject::addTimer (int interval) time_interval.tv_usec = (interval % 1000) * 1000; getCurrentTime (¤tTime); timeval timeout = currentTime + time_interval; - timer_data t{ id, time_interval, timeout, this }; + FTimerData t{ id, time_interval, timeout, this }; // insert in list sorted by timeout auto iter = timer_list->begin(); diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 98545a8c..fa2761fc 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -450,7 +450,7 @@ void FOptiAttr::set_orig_orig_colors (char cap[]) } //---------------------------------------------------------------------- -bool FOptiAttr::isNormal (charData*& ch) +bool FOptiAttr::isNormal (FChar*& ch) { return hasNoAttribute(ch) && ! hasColor(ch); } @@ -542,7 +542,7 @@ FColor FOptiAttr::vga2ansi (FColor color) } //---------------------------------------------------------------------- -char* FOptiAttr::changeAttribute (charData*& term, charData*& next) +char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next) { const bool next_has_color = hasColor(next); fake_reverse = false; @@ -558,7 +558,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next) // Simulate invisible characters if ( ! F_enter_secure_mode.cap && next->attr.bit.invisible ) - next->encoded_code = ' '; + next->encoded_char = ' '; // Look for no changes if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) ) @@ -584,7 +584,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next) // private methods of FOptiAttr //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermBold (charData*& term) +inline bool FOptiAttr::setTermBold (FChar*& term) { if ( ! term ) return false; @@ -598,7 +598,7 @@ inline bool FOptiAttr::setTermBold (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermBold (charData*& term) +inline bool FOptiAttr::unsetTermBold (FChar*& term) { // Back to normal intensity (turns off bold + dim) @@ -620,7 +620,7 @@ inline bool FOptiAttr::unsetTermBold (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermDim (charData*& term) +inline bool FOptiAttr::setTermDim (FChar*& term) { if ( ! term ) return false; @@ -634,7 +634,7 @@ inline bool FOptiAttr::setTermDim (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermDim (charData*& term) +inline bool FOptiAttr::unsetTermDim (FChar*& term) { // Back to normal intensity (turns off bold + dim) @@ -656,7 +656,7 @@ inline bool FOptiAttr::unsetTermDim (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermItalic (charData*& term) +inline bool FOptiAttr::setTermItalic (FChar*& term) { if ( ! term ) return false; @@ -670,7 +670,7 @@ inline bool FOptiAttr::setTermItalic (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermItalic (charData*& term) +inline bool FOptiAttr::unsetTermItalic (FChar*& term) { if ( ! term ) return false; @@ -687,7 +687,7 @@ inline bool FOptiAttr::unsetTermItalic (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermUnderline (charData*& term) +inline bool FOptiAttr::setTermUnderline (FChar*& term) { if ( ! term ) return false; @@ -701,7 +701,7 @@ inline bool FOptiAttr::setTermUnderline (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermUnderline (charData*& term) +inline bool FOptiAttr::unsetTermUnderline (FChar*& term) { // Turns off every underlining @@ -723,7 +723,7 @@ inline bool FOptiAttr::unsetTermUnderline (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermBlink (charData*& term) +inline bool FOptiAttr::setTermBlink (FChar*& term) { if ( ! term ) return false; @@ -737,7 +737,7 @@ inline bool FOptiAttr::setTermBlink (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermBlink (charData*& term) +inline bool FOptiAttr::unsetTermBlink (FChar*& term) { if ( ! term ) return false; @@ -754,7 +754,7 @@ inline bool FOptiAttr::unsetTermBlink (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermReverse (charData*& term) +inline bool FOptiAttr::setTermReverse (FChar*& term) { if ( ! term ) return false; @@ -768,7 +768,7 @@ inline bool FOptiAttr::setTermReverse (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermReverse (charData*& term) +inline bool FOptiAttr::unsetTermReverse (FChar*& term) { if ( ! term ) return false; @@ -785,7 +785,7 @@ inline bool FOptiAttr::unsetTermReverse (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermStandout (charData*& term) +inline bool FOptiAttr::setTermStandout (FChar*& term) { if ( ! term ) return false; @@ -799,7 +799,7 @@ inline bool FOptiAttr::setTermStandout (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermStandout (charData*& term) +inline bool FOptiAttr::unsetTermStandout (FChar*& term) { if ( ! term ) return false; @@ -816,7 +816,7 @@ inline bool FOptiAttr::unsetTermStandout (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermInvisible (charData*& term) +inline bool FOptiAttr::setTermInvisible (FChar*& term) { if ( ! term ) return false; @@ -830,7 +830,7 @@ inline bool FOptiAttr::setTermInvisible (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermInvisible (charData*& term) +inline bool FOptiAttr::unsetTermInvisible (FChar*& term) { if ( ! term ) return false; @@ -847,7 +847,7 @@ inline bool FOptiAttr::unsetTermInvisible (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermProtected (charData*& term) +inline bool FOptiAttr::setTermProtected (FChar*& term) { if ( ! term ) return false; @@ -861,7 +861,7 @@ inline bool FOptiAttr::setTermProtected (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermProtected (charData*& term) +inline bool FOptiAttr::unsetTermProtected (FChar*& term) { if ( ! term ) return false; @@ -878,7 +878,7 @@ inline bool FOptiAttr::unsetTermProtected (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermCrossedOut (charData*& term) +inline bool FOptiAttr::setTermCrossedOut (FChar*& term) { if ( ! term ) return false; @@ -892,7 +892,7 @@ inline bool FOptiAttr::setTermCrossedOut (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermCrossedOut (charData*& term) +inline bool FOptiAttr::unsetTermCrossedOut (FChar*& term) { if ( ! term ) return false; @@ -909,7 +909,7 @@ inline bool FOptiAttr::unsetTermCrossedOut (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermDoubleUnderline (charData*& term) +inline bool FOptiAttr::setTermDoubleUnderline (FChar*& term) { if ( ! term ) return false; @@ -923,7 +923,7 @@ inline bool FOptiAttr::setTermDoubleUnderline (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermDoubleUnderline (charData*& term) +inline bool FOptiAttr::unsetTermDoubleUnderline (FChar*& term) { // Turns off every underlining @@ -945,7 +945,7 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (charData*& term) } //---------------------------------------------------------------------- -bool FOptiAttr::setTermAttributes ( charData*& term +bool FOptiAttr::setTermAttributes ( FChar*& term , bool p1, bool p2, bool p3 , bool p4, bool p5, bool p6 , bool p7, bool p8, bool p9 ) @@ -985,7 +985,7 @@ bool FOptiAttr::setTermAttributes ( charData*& term } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermAttributes (charData*& term) +inline bool FOptiAttr::unsetTermAttributes (FChar*& term) { if ( ! term ) return false; @@ -999,7 +999,7 @@ inline bool FOptiAttr::unsetTermAttributes (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermAltCharset (charData*& term) +inline bool FOptiAttr::setTermAltCharset (FChar*& term) { if ( ! term ) return false; @@ -1016,7 +1016,7 @@ inline bool FOptiAttr::setTermAltCharset (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermAltCharset (charData*& term) +inline bool FOptiAttr::unsetTermAltCharset (FChar*& term) { if ( ! term ) return false; @@ -1033,7 +1033,7 @@ inline bool FOptiAttr::unsetTermAltCharset (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::setTermPCcharset (charData*& term) +inline bool FOptiAttr::setTermPCcharset (FChar*& term) { if ( ! term ) return false; @@ -1050,7 +1050,7 @@ inline bool FOptiAttr::setTermPCcharset (charData*& term) } //---------------------------------------------------------------------- -inline bool FOptiAttr::unsetTermPCcharset (charData*& term) +inline bool FOptiAttr::unsetTermPCcharset (FChar*& term) { if ( ! term ) return false; @@ -1067,7 +1067,7 @@ inline bool FOptiAttr::unsetTermPCcharset (charData*& term) } //---------------------------------------------------------------------- -bool FOptiAttr::setTermDefaultColor (charData*& term) +bool FOptiAttr::setTermDefaultColor (FChar*& term) { if ( ! term ) return false; @@ -1090,7 +1090,7 @@ bool FOptiAttr::setTermDefaultColor (charData*& term) } //---------------------------------------------------------------------- -void FOptiAttr::setAttributesOn (charData*& term) +void FOptiAttr::setAttributesOn (FChar*& term) { if ( on.attr.bit.alt_charset ) setTermAltCharset(term); @@ -1133,7 +1133,7 @@ void FOptiAttr::setAttributesOn (charData*& term) } //---------------------------------------------------------------------- -void FOptiAttr::setAttributesOff (charData*& term) +void FOptiAttr::setAttributesOff (FChar*& term) { if ( off.attr.bit.pc_charset ) unsetTermPCcharset(term); @@ -1176,7 +1176,7 @@ void FOptiAttr::setAttributesOff (charData*& term) } //---------------------------------------------------------------------- -bool FOptiAttr::hasColor (charData*& attr) +bool FOptiAttr::hasColor (FChar*& attr) { if ( attr && attr->fg_color == fc::Default @@ -1187,7 +1187,7 @@ bool FOptiAttr::hasColor (charData*& attr) } //---------------------------------------------------------------------- -bool FOptiAttr::hasAttribute (charData*& attr) +bool FOptiAttr::hasAttribute (FChar*& attr) { if ( attr ) { @@ -1210,13 +1210,13 @@ bool FOptiAttr::hasAttribute (charData*& attr) } //---------------------------------------------------------------------- -bool FOptiAttr::hasNoAttribute (charData*& attr) +bool FOptiAttr::hasNoAttribute (FChar*& attr) { return ! hasAttribute(attr); } //---------------------------------------------------------------------- -inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next) +inline bool FOptiAttr::hasColorChanged (FChar*& term, FChar*& next) { if ( term && next ) { @@ -1233,7 +1233,7 @@ inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next) } //---------------------------------------------------------------------- -inline void FOptiAttr::resetColor (charData*& attr) +inline void FOptiAttr::resetColor (FChar*& attr) { if ( attr ) { @@ -1243,7 +1243,7 @@ inline void FOptiAttr::resetColor (charData*& attr) } //---------------------------------------------------------------------- -inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr +inline void FOptiAttr::prevent_no_color_video_attributes ( FChar*& attr , bool next_has_color ) { // Ignore attributes which can not combined with a color @@ -1304,8 +1304,8 @@ inline void FOptiAttr::prevent_no_color_video_attributes ( charData*& attr } //---------------------------------------------------------------------- -inline void FOptiAttr::deactivateAttributes ( charData*& term - , charData*& next ) +inline void FOptiAttr::deactivateAttributes ( FChar*& term + , FChar*& next ) { if ( hasAttribute(term) ) { @@ -1328,8 +1328,8 @@ inline void FOptiAttr::deactivateAttributes ( charData*& term } //---------------------------------------------------------------------- -inline void FOptiAttr::changeAttributeSGR ( charData*& term - , charData*& next ) +inline void FOptiAttr::changeAttributeSGR ( FChar*& term + , FChar*& next ) { bool pc_charset_usable{true}; @@ -1378,8 +1378,8 @@ inline void FOptiAttr::changeAttributeSGR ( charData*& term } //---------------------------------------------------------------------- -inline void FOptiAttr::changeAttributeSeparately ( charData*& term - , charData*& next ) +inline void FOptiAttr::changeAttributeSeparately ( FChar*& term + , FChar*& next ) { setAttributesOff(term); @@ -1391,7 +1391,7 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term } //---------------------------------------------------------------------- -void FOptiAttr::change_color (charData*& term, charData*& next) +void FOptiAttr::change_color (FChar*& term, FChar*& next) { if ( ! (term && next) ) return; @@ -1434,8 +1434,8 @@ void FOptiAttr::change_color (charData*& term, charData*& next) } //---------------------------------------------------------------------- -inline void FOptiAttr::change_to_default_color ( charData*& term - , charData*& next +inline void FOptiAttr::change_to_default_color ( FChar*& term + , FChar*& next , FColor& fg, FColor& bg ) { if ( ansi_default_color ) @@ -1474,7 +1474,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term } //---------------------------------------------------------------------- -inline void FOptiAttr::change_current_color ( charData*& term +inline void FOptiAttr::change_current_color ( FChar*& term , FColor fg, FColor bg ) { char* color_str{}; @@ -1522,7 +1522,7 @@ inline void FOptiAttr::change_current_color ( charData*& term } //---------------------------------------------------------------------- -inline void FOptiAttr::resetAttribute (charData*& attr) +inline void FOptiAttr::resetAttribute (FChar*& attr) { if ( attr ) { @@ -1532,7 +1532,7 @@ inline void FOptiAttr::resetAttribute (charData*& attr) } //---------------------------------------------------------------------- -inline void FOptiAttr::reset (charData*& attr) +inline void FOptiAttr::reset (FChar*& attr) { if ( attr ) { @@ -1593,7 +1593,7 @@ inline bool FOptiAttr::hasCharsetEquivalence() } //---------------------------------------------------------------------- -inline void FOptiAttr::detectSwitchOn (charData*& term, charData*& next) +inline void FOptiAttr::detectSwitchOn (FChar*& term, FChar*& next) { if ( ! (term && next) ) return; @@ -1614,7 +1614,7 @@ inline void FOptiAttr::detectSwitchOn (charData*& term, charData*& next) } //---------------------------------------------------------------------- -inline void FOptiAttr::detectSwitchOff (charData*& term, charData*& next) +inline void FOptiAttr::detectSwitchOff (FChar*& term, FChar*& next) { if ( ! (term && next) ) return; diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index cc85bf84..d5c6c59b 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -133,7 +133,7 @@ void FProgressbar::draw() if ( getFlags().shadow ) drawShadow(this); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -179,7 +179,7 @@ void FProgressbar::drawProgressBar() setReverse(false); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index ac70245c..d1db4f96 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -589,7 +589,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev) // protected methods of FScrollView //---------------------------------------------------------------------- -FVTerm::term_area* FScrollView::getPrintArea() +FVTerm::FTermArea* FScrollView::getPrintArea() { // returns print area or viewport @@ -675,13 +675,13 @@ void FScrollView::copy2area() for (int y{0}; y < y_end; y++) // line loop { - charData* vc{}; // viewport character - charData* ac{}; // area character + FChar* vc{}; // viewport character + FChar* ac{}; // area character int v_line_len = viewport->width; int a_line_len = printarea->width + printarea->right_shadow; - vc = &viewport->text[(dy + y) * v_line_len + dx]; - ac = &printarea->text[(ay + y) * a_line_len + ax]; - std::memcpy (ac, vc, sizeof(charData) * unsigned(x_end)); + vc = &viewport->data[(dy + y) * v_line_len + dx]; + ac = &printarea->data[(ay + y) * a_line_len + ax]; + std::memcpy (ac, vc, sizeof(FChar) * unsigned(x_end)); if ( int(printarea->changes[ay + y].xmin) > ax ) printarea->changes[ay + y].xmin = uInt(ax); diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 4ebcacb4..67328d79 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -124,7 +124,7 @@ void FSwitch::draw() drawCheckButton(); FToggleButton::draw(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/fterm.cpp b/src/fterm.cpp index c3a8da0c..387083c7 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -93,8 +93,6 @@ FMouseControl* FTerm::mouse {nullptr}; FTermDebugData* FTerm::debug_data {nullptr}; #endif -// function prototypes -uInt env2uint (const char*); //---------------------------------------------------------------------- // class FTerm @@ -416,7 +414,7 @@ FTermDebugData& FTerm::getFTermDebugData() #endif // DEBUG //---------------------------------------------------------------------- -bool FTerm::isNormal (charData*& ch) +bool FTerm::isNormal (FChar*& ch) { return opti_attr->isNormal(ch); } @@ -1290,8 +1288,8 @@ void FTerm::initScreenSettings() } //---------------------------------------------------------------------- -char* FTerm::changeAttribute ( charData*& term_attr - , charData*& next_attr ) +char* FTerm::changeAttribute ( FChar*& term_attr + , FChar*& next_attr ) { return opti_attr->changeAttribute (term_attr, next_attr); } @@ -2268,7 +2266,7 @@ void FTerm::init (bool disable_alt_screen) init_alt_charset(); // Pass the terminal capabilities to the keyboard object - keyboard->setTermcapMap (fc::Fkey); + keyboard->setTermcapMap (fc::fkey); // Initializes locale information init_locale(); @@ -2539,258 +2537,4 @@ void FTerm::signal_handler (int signum) } } -// FTerm non-member functions -//---------------------------------------------------------------------- -uInt env2uint (const char* env) -{ - FString str(getenv(env)); - - if ( str.isEmpty() ) - return 0; - - try - { - return str.toUInt(); - } - catch (const std::exception&) - { - return 0; - } -} - -//---------------------------------------------------------------------- -wchar_t cp437_to_unicode (uChar c) -{ - constexpr std::size_t CP437 = 0; - constexpr std::size_t UNICODE = 1; - wchar_t ucs = c; - - for (std::size_t i{0}; i <= fc::lastCP437Item; i++) - { - if ( fc::cp437_ucs[i][CP437] == c ) // found - { - ucs = fc::cp437_ucs[i][UNICODE]; - break; - } - } - - return ucs; -} - -//---------------------------------------------------------------------- -uChar unicode_to_cp437 (wchar_t ucs) -{ - constexpr std::size_t CP437 = 0; - constexpr std::size_t UNICODE = 1; - uChar c{'?'}; - - for (std::size_t i{0}; i <= fc::lastCP437Item; i++) - { - if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found - { - c = uChar(fc::cp437_ucs[i][CP437]); - break; - } - } - - return c; -} - -//---------------------------------------------------------------------- -FString getFullWidth (const FString& str) -{ - // Converts half-width to full-width characters - - FString s(str); - constexpr std::size_t HALF = 0; - constexpr std::size_t FULL = 1; - - for (auto&& c : s) - { - if ( c > L'\x20' && c < L'\x7f' ) // half-width ASCII - { - c += 0xfee0; - } - else - { - for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) - { - if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found - c = fc::halfWidth_fullWidth[i][FULL]; - } - } - } - - return s; -} - -//---------------------------------------------------------------------- -FString getHalfWidth (const FString& str) -{ - // Converts full-width to half-width characters - - FString s(str); - constexpr std::size_t HALF = 0; - constexpr std::size_t FULL = 1; - - for (auto&& c : s) - { - if ( c > L'\xff00' && c < L'\xff5f' ) // full-width ASCII - { - c -= 0xfee0; - } - else - { - for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) - { - if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found - c = fc::halfWidth_fullWidth[i][HALF]; - } - } - } - - return s; -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidthToLength ( const FString& str - , std::size_t col_len ) -{ - std::size_t column_width{0}, length{0}; - - for (auto&& ch : str) - { - if ( column_width < col_len ) - { - column_width += getColumnWidth(ch); - length++; - } - } - - return length; -} - -//---------------------------------------------------------------------- -FString getColumnSubString ( const FString& str - , std::size_t col_pos, std::size_t col_len ) -{ - FString s(str); - std::size_t col_first{1}, col_num{0}, first{1}, num{0}; - - if ( col_len == 0 || s.isEmpty() ) - return FString(L""); - - if ( col_pos == 0 ) - col_pos = 1; - - for (auto&& ch : s) - { - std::size_t width = getColumnWidth(ch); - - if ( col_first < col_pos ) - { - if ( col_first + width <= col_pos ) - { - col_first += width; - first++; - } - else - { - ch = fc::SingleLeftAngleQuotationMark; // ‹ - num = col_num = 1; - col_pos = col_first; - } - } - else - { - if ( col_num + width <= col_len ) - { - col_num += width; - num++; - } - else if ( col_num < col_len ) - { - ch = fc::SingleRightAngleQuotationMark; // › - num++; - break; - } - } - } - - if ( col_first < col_pos ) // String length < col_pos - return FString(L""); - - return s.mid(first, num); -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidth (const FString& s, std::size_t pos) -{ - if ( s.isEmpty() ) - return 0; - - std::size_t column_width{0}; - auto length = s.getLength(); - - if ( pos > length ) - pos = length; - - for (std::size_t i{0}; i < pos; i++) - column_width += getColumnWidth(s[i]); - - return column_width; -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidth (const FString& s) -{ - if ( s.isEmpty() ) - return 0; - - const wchar_t* str = s.wc_str(); - size_t len = std::wcslen(str); - int column_width = wcswidth (str, len); - return ( column_width == -1 ) ? 0 : std::size_t(column_width); -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidth (const wchar_t wchar) -{ - int column_width{}; - - if ( wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark ) - column_width = 1; - else - column_width = wcwidth(wchar); - - return ( column_width == -1 ) ? 0 : std::size_t(column_width); -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidth (charData& term_char) -{ - std::size_t char_width = getColumnWidth(term_char.code); - - if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 ) - { - term_char.code = '.'; - term_char.attr.bit.char_width = 1; - } - else - term_char.attr.bit.char_width = char_width & 0x03; - - return char_width; -} - -//---------------------------------------------------------------------- -std::size_t getColumnWidth (const FTermBuffer& termbuffer) -{ - std::size_t column_width{0}; - - for (auto&& tc : termbuffer) - column_width += tc.attr.bit.char_width; - - return column_width; -} - } // namespace finalcut diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp new file mode 100644 index 00000000..884fc5be --- /dev/null +++ b/src/fterm_functions.cpp @@ -0,0 +1,285 @@ +/*********************************************************************** +* fterm_functions.cpp - FTerm helper functions * +* * +* This file is part of the Final Cut widget toolkit * +* * +* Copyright 2019 Markus Gans * +* * +* The 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. * +* * +* The 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 * +* . * +***********************************************************************/ + +#include "final/fcharmap.h" +#include "final/fterm.h" +#include "final/ftermbuffer.h" + + +namespace finalcut +{ + +// FTerm non-member functions +//---------------------------------------------------------------------- +uInt env2uint (const char* env) +{ + FString str(getenv(env)); + + if ( str.isEmpty() ) + return 0; + + try + { + return str.toUInt(); + } + catch (const std::exception&) + { + return 0; + } +} + +//---------------------------------------------------------------------- +wchar_t cp437_to_unicode (uChar c) +{ + constexpr std::size_t CP437 = 0; + constexpr std::size_t UNICODE = 1; + wchar_t ucs = c; + + for (std::size_t i{0}; i <= fc::lastCP437Item; i++) + { + if ( fc::cp437_ucs[i][CP437] == c ) // found + { + ucs = fc::cp437_ucs[i][UNICODE]; + break; + } + } + + return ucs; +} + +//---------------------------------------------------------------------- +uChar unicode_to_cp437 (wchar_t ucs) +{ + constexpr std::size_t CP437 = 0; + constexpr std::size_t UNICODE = 1; + uChar c{'?'}; + + for (std::size_t i{0}; i <= fc::lastCP437Item; i++) + { + if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found + { + c = uChar(fc::cp437_ucs[i][CP437]); + break; + } + } + + return c; +} + +//---------------------------------------------------------------------- +FString getFullWidth (const FString& str) +{ + // Converts half-width to full-width characters + + FString s(str); + constexpr std::size_t HALF = 0; + constexpr std::size_t FULL = 1; + + for (auto&& c : s) + { + if ( c > L'\x20' && c < L'\x7f' ) // half-width ASCII + { + c += 0xfee0; + } + else + { + for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) + { + if ( fc::halfWidth_fullWidth[i][HALF] == c ) // found + c = fc::halfWidth_fullWidth[i][FULL]; + } + } + } + + return s; +} + +//---------------------------------------------------------------------- +FString getHalfWidth (const FString& str) +{ + // Converts full-width to half-width characters + + FString s(str); + constexpr std::size_t HALF = 0; + constexpr std::size_t FULL = 1; + + for (auto&& c : s) + { + if ( c > L'\xff00' && c < L'\xff5f' ) // full-width ASCII + { + c -= 0xfee0; + } + else + { + for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++) + { + if ( fc::halfWidth_fullWidth[i][FULL] == c ) // found + c = fc::halfWidth_fullWidth[i][HALF]; + } + } + } + + return s; +} + +//---------------------------------------------------------------------- +FString getColumnSubString ( const FString& str + , std::size_t col_pos, std::size_t col_len ) +{ + FString s(str); + std::size_t col_first{1}, col_num{0}, first{1}, num{0}; + + if ( col_len == 0 || s.isEmpty() ) + return FString(L""); + + if ( col_pos == 0 ) + col_pos = 1; + + for (auto&& ch : s) + { + std::size_t width = getColumnWidth(ch); + + if ( col_first < col_pos ) + { + if ( col_first + width <= col_pos ) + { + col_first += width; + first++; + } + else + { + ch = fc::SingleLeftAngleQuotationMark; // ‹ + num = col_num = 1; + col_pos = col_first; + } + } + else + { + if ( col_num + width <= col_len ) + { + col_num += width; + num++; + } + else if ( col_num < col_len ) + { + ch = fc::SingleRightAngleQuotationMark; // › + num++; + break; + } + } + } + + if ( col_first < col_pos ) // String length < col_pos + return FString(L""); + + return s.mid(first, num); +} + +//---------------------------------------------------------------------- +std::size_t getLengthFromColumnWidth ( const FString& str + , std::size_t col_len ) +{ + std::size_t column_width{0}, length{0}; + + for (auto&& ch : str) + { + if ( column_width < col_len ) + { + column_width += getColumnWidth(ch); + length++; + } + } + + return length; +} + +//---------------------------------------------------------------------- +std::size_t getColumnWidth (const FString& s, std::size_t pos) +{ + if ( s.isEmpty() ) + return 0; + + std::size_t column_width{0}; + auto length = s.getLength(); + + if ( pos > length ) + pos = length; + + for (std::size_t i{0}; i < pos; i++) + column_width += getColumnWidth(s[i]); + + return column_width; +} + +//---------------------------------------------------------------------- +std::size_t getColumnWidth (const FString& s) +{ + if ( s.isEmpty() ) + return 0; + + const wchar_t* str = s.wc_str(); + size_t len = std::wcslen(str); + int column_width = wcswidth (str, len); + return ( column_width == -1 ) ? 0 : std::size_t(column_width); +} + +//---------------------------------------------------------------------- +std::size_t getColumnWidth (const wchar_t wchar) +{ + int column_width{}; + + if ( wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark ) + column_width = 1; + else + column_width = wcwidth(wchar); + + return ( column_width == -1 ) ? 0 : std::size_t(column_width); +} + +//---------------------------------------------------------------------- +std::size_t getColumnWidth (FChar& term_char) +{ + std::size_t char_width = getColumnWidth(term_char.ch); + + if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 ) + { + term_char.ch = '.'; + term_char.attr.bit.char_width = 1; + } + else + term_char.attr.bit.char_width = char_width & 0x03; + + return char_width; +} + +//---------------------------------------------------------------------- +std::size_t getColumnWidth (const FTermBuffer& termbuffer) +{ + std::size_t column_width{0}; + + for (auto&& tc : termbuffer) + column_width += tc.attr.bit.char_width; + + return column_width; +} + +} // namespace finalcut diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index bcbc0ce3..c2bd98dd 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -46,8 +46,8 @@ const FString FTermBuffer::toString() const std::wstring wide_string{}; wide_string.reserve(data.size()); - for (auto&& tc : data) - wide_string.push_back(tc.code); + for (auto&& fchar : data) + wide_string.push_back(fchar.ch); return FString(wide_string); } @@ -60,9 +60,9 @@ int FTermBuffer::write (const FString& string) for (auto&& c : string) { - charData nc; // next character + FChar nc; // next character nc = FVTerm::getAttribute(); - nc.code = c; + nc.ch = c; getColumnWidth(nc); // add column width nc.attr.bit.no_changes = false; nc.attr.bit.printed = false; @@ -75,8 +75,8 @@ int FTermBuffer::write (const FString& string) //---------------------------------------------------------------------- int FTermBuffer::write (wchar_t ch) { - charData nc = FVTerm::getAttribute(); // next character - nc.code = ch; + FChar nc = FVTerm::getAttribute(); // next character + nc.ch = ch; getColumnWidth(nc); // add column width nc.attr.bit.no_changes = false; nc.attr.bit.printed = false; @@ -94,8 +94,8 @@ void FTermBuffer::write (const FColorPair& pair) // FTermBuffer non-member operators //---------------------------------------------------------------------- -FTermBuffer::charDataVector& operator << ( FTermBuffer::charDataVector& termString - , const FTermBuffer& buf ) +FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& termString + , const FTermBuffer& buf ) { if ( ! buf.data.empty() ) termString.assign(buf.data.begin(), buf.data.end()); diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index f2ea3cd1..031fa540 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -230,48 +230,48 @@ void FTermcap::termcapKeys (char*& buffer) { // Read termcap key strings - for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++) + for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++) { - fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer); + fc::fkey[i].string = tgetstr(fc::fkey[i].tname, &buffer); // Fallback for rxvt with TERM=xterm - if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "7~"); // Home key + if ( std::strncmp(fc::fkey[i].tname, "khx", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "7~"); // Home key - if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "8~"); // End key + if ( std::strncmp(fc::fkey[i].tname, "@7x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "8~"); // End key - if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "11~"); // F1 + if ( std::strncmp(fc::fkey[i].tname, "k1x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "11~"); // F1 - if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "12~"); // F2 + if ( std::strncmp(fc::fkey[i].tname, "k2x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "12~"); // F2 - if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "13~"); // F3 + if ( std::strncmp(fc::fkey[i].tname, "k3x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "13~"); // F3 - if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "14~"); // F4 + if ( std::strncmp(fc::fkey[i].tname, "k4x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "14~"); // F4 // Fallback for TERM=ansi - if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "K"); // End key + if ( std::strncmp(fc::fkey[i].tname, "@7X", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "K"); // End key // Keypad keys - if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key + if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "OM"); // Enter key - if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash + if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "Oo"); // Keypad slash - if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk + if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk - if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign + if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign - if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign + if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign } // VT100 key codes for the arrow and function keys @@ -290,31 +290,31 @@ void FTermcap::termcapKeysVt100 (char*& buffer) || ( TCAP(fc::t_cursor_up) && (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) ) { - for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++) + for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++) { - if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "A"); // Key up + if ( std::strncmp(fc::fkey[i].tname, "kux", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "A"); // Key up - if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "B"); // Key down + if ( std::strncmp(fc::fkey[i].tname, "kdx", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "B"); // Key down - if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "C"); // Key right + if ( std::strncmp(fc::fkey[i].tname, "krx", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "C"); // Key right - if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "D"); // Key left + if ( std::strncmp(fc::fkey[i].tname, "klx", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "D"); // Key left - if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "OP"); // PF1 + if ( std::strncmp(fc::fkey[i].tname, "k1X", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "OP"); // PF1 - if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2 + if ( std::strncmp(fc::fkey[i].tname, "k2X", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "OQ"); // PF2 - if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "OR"); // PF3 + if ( std::strncmp(fc::fkey[i].tname, "k3X", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "OR"); // PF3 - if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 ) - fc::Fkey[i].string = C_STR(ESC "OS"); // PF4 + if ( std::strncmp(fc::fkey[i].tname, "k4X", 3) == 0 ) + fc::fkey[i].string = C_STR(ESC "OS"); // PF4 } } } diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 15cc0b5a..4c8a0b7a 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -402,71 +402,71 @@ void FTermcapQuirks::sunConsole() C_STR(CSI "%p1%dD"); // Sun Microsystems workstation console keys - for (std::size_t i{0}; fc::Fkey[i].tname[0] != 0; i++) + for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++) { - if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad + if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "218z"); // center of keypad - if ( std::strncmp(fc::Fkey[i].tname, "kb", 2) == 0 ) - fc::Fkey[i].string = C_STR("\b"); // backspace key + if ( std::strncmp(fc::fkey[i].tname, "kb", 2) == 0 ) + fc::fkey[i].string = C_STR("\b"); // backspace key - if ( std::strncmp(fc::Fkey[i].tname, "kD", 2) == 0 - && std::strlen(fc::Fkey[i].tname) == 2 ) - fc::Fkey[i].string = C_STR("\177"); // delete-character key + if ( std::strncmp(fc::fkey[i].tname, "kD", 2) == 0 + && std::strlen(fc::fkey[i].tname) == 2 ) + fc::fkey[i].string = C_STR("\177"); // delete-character key - if ( std::strncmp(fc::Fkey[i].tname, "@7", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "220z"); // end key + if ( std::strncmp(fc::fkey[i].tname, "@7", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "220z"); // end key - if ( std::strncmp(fc::Fkey[i].tname, "k;", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "233z"); // F10 function key + if ( std::strncmp(fc::fkey[i].tname, "k;", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "233z"); // F10 function key - if ( std::strncmp(fc::Fkey[i].tname, "F1", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "234z"); // F11 function key + if ( std::strncmp(fc::fkey[i].tname, "F1", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "234z"); // F11 function key - if ( std::strncmp(fc::Fkey[i].tname, "F2", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "235z"); // F12 function key + if ( std::strncmp(fc::fkey[i].tname, "F2", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "235z"); // F12 function key - if ( std::strncmp(fc::Fkey[i].tname, "kh", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "214z"); // home key + if ( std::strncmp(fc::fkey[i].tname, "kh", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "214z"); // home key - if ( std::strncmp(fc::Fkey[i].tname, "kI", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "247z"); // insert-character key + if ( std::strncmp(fc::fkey[i].tname, "kI", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "247z"); // insert-character key - if ( std::strncmp(fc::Fkey[i].tname, "kN", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "222z"); // next-page key + if ( std::strncmp(fc::fkey[i].tname, "kN", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "222z"); // next-page key - if ( std::strncmp(fc::Fkey[i].tname, "%7", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "194z"); // options key + if ( std::strncmp(fc::fkey[i].tname, "%7", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "194z"); // options key - if ( std::strncmp(fc::Fkey[i].tname, "kP", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "216z"); // prev-page key + if ( std::strncmp(fc::fkey[i].tname, "kP", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "216z"); // prev-page key - if ( std::strncmp(fc::Fkey[i].tname, "&5", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "193z"); // resume key + if ( std::strncmp(fc::fkey[i].tname, "&5", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "193z"); // resume key - if ( std::strncmp(fc::Fkey[i].tname, "&8", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "195z"); // undo key + if ( std::strncmp(fc::fkey[i].tname, "&8", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "195z"); // undo key - if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 ) - fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad + if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 ) + fc::fkey[i].string = C_STR(CSI "218z"); // center of keypad - if ( std::strncmp(fc::Fkey[i].tname, "kDx", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "249z"); // keypad delete + if ( std::strncmp(fc::fkey[i].tname, "kDx", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "249z"); // keypad delete - if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "250z"); // enter/send key + if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "250z"); // enter/send key - if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "212z"); // keypad slash + if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "212z"); // keypad slash - if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "213z"); // keypad asterisk + if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "213z"); // keypad asterisk - if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "254z"); // keypad minus sign + if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "254z"); // keypad minus sign - if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 ) - fc::Fkey[i].string = C_STR(CSI "253z"); // keypad plus sign + if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 ) + fc::fkey[i].string = C_STR(CSI "253z"); // keypad plus sign } } diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index b8815250..3dc2ca0d 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -45,9 +45,9 @@ namespace finalcut { // static class attributes -FTermDetection::terminalType FTermDetection::terminal_type{}; -FTermDetection::colorEnv FTermDetection::color_env{}; -FTermDetection::secondaryDA FTermDetection::secondary_da{}; +FTermDetection::FTerminalType FTermDetection::terminal_type{}; +FTermDetection::colorEnv FTermDetection::color_env{}; +FTermDetection::secondaryDA FTermDetection::secondary_da{}; FTermData* FTermDetection::fterm_data{nullptr}; FSystem* FTermDetection::fsystem{nullptr}; char FTermDetection::termtype[256]{}; diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 750be957..37ed232f 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -114,7 +114,7 @@ void FTermLinux::setUTF8 (bool enable) } //---------------------------------------------------------------------- -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) bool FTermLinux::setPalette (FColor index, int r, int g, int b) { if ( ! FTerm::isLinuxTerm() ) @@ -174,7 +174,7 @@ void FTermLinux::init() getUnicodeMap(); getScreenFont(); -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) // Enable 16 background colors if ( setBlinkAsIntensity(true) == 0 ) FTermcap::max_color = 16; @@ -246,7 +246,7 @@ void FTermLinux::finish() { if ( FTerm::isLinuxTerm() ) { -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) setBlinkAsIntensity (false); #endif setLinuxCursorStyle (fc::default_cursor); @@ -383,7 +383,7 @@ bool FTermLinux::saveColorMap() if ( ! FTerm::isLinuxTerm() ) return false; -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) return saveVGAPalette(); #else return false; @@ -396,7 +396,7 @@ bool FTermLinux::resetColorMap() if ( ! FTerm::isLinuxTerm() ) return false; -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) return resetVGAPalette(); #else return false; @@ -752,7 +752,7 @@ void FTermLinux::setLinuxCursorStyle (CursorStyle style) FTerm::putstringf (CSI "?%dc", style); } -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) //---------------------------------------------------------------------- inline uInt16 FTermLinux::getInputStatusRegisterOne() { @@ -956,7 +956,7 @@ bool FTermLinux::resetVGAPalette() return true; } -#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) +#endif // defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) //---------------------------------------------------------------------- FKey FTermLinux::shiftKeyCorrection (const FKey& key_id) diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index aaaab8fc..662f00db 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -39,6 +39,11 @@ namespace finalcut // class FTermOpenBSD //---------------------------------------------------------------------- +// constructors and destructor +//---------------------------------------------------------------------- +FTermOpenBSD::~FTermOpenBSD() // destructor +{ } + // public methods of FTermOpenBSD //---------------------------------------------------------------------- #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 2ca8bd99..d16383b4 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -614,7 +614,7 @@ void FTextView::draw() setCursorPos (FPoint(int(getWidth()), int(getHeight()))); updateTerminal(); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 570a9b82..5ed44a1f 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -235,7 +235,7 @@ void FToggleButton::onMouseDown (FMouseEvent* ev) { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -312,7 +312,7 @@ void FToggleButton::onAccel (FAccelEvent* ev) { getStatusBar()->drawMessage(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } processClick(); diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 5ba88569..54365597 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -62,14 +62,14 @@ std::queue* FVTerm::output_buffer{nullptr}; FPoint* FVTerm::term_pos{nullptr}; FSystem* FVTerm::fsystem{nullptr}; FTerm* FVTerm::fterm{nullptr}; -FVTerm::term_area* FVTerm::vterm{nullptr}; -FVTerm::term_area* FVTerm::vdesktop{nullptr}; -FVTerm::term_area* FVTerm::active_area{nullptr}; +FVTerm::FTermArea* FVTerm::vterm{nullptr}; +FVTerm::FTermArea* FVTerm::vdesktop{nullptr}; +FVTerm::FTermArea* FVTerm::active_area{nullptr}; FKeyboard* FVTerm::keyboard{nullptr}; -charData FVTerm::term_attribute{}; -charData FVTerm::next_attribute{}; -charData FVTerm::s_ch{}; -charData FVTerm::i_ch{}; +FChar FVTerm::term_attribute{}; +FChar FVTerm::next_attribute{}; +FChar FVTerm::s_ch{}; +FChar FVTerm::i_ch{}; //---------------------------------------------------------------------- @@ -144,7 +144,7 @@ void FVTerm::setTermXY (int x, int y) if ( move_str ) appendOutputBuffer(move_str); - flush_out(); + flushOutputBuffer(); term_pos->setPoint(x, y); } @@ -158,7 +158,7 @@ void FVTerm::hideCursor (bool enable) if ( visibility_str ) appendOutputBuffer(visibility_str); - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -290,14 +290,14 @@ void FVTerm::updateTerminal() //---------------------------------------------------------------------- void FVTerm::addPreprocessingHandler ( FVTerm* instance - , FVTermPreprocessing function ) + , FPreprocessingFunction function ) { if ( ! print_area ) FVTerm::getPrintArea(); if ( print_area ) { - vterm_preprocessing obj{ instance, function }; + FVTermPreprocessing obj{ instance, function }; delPreprocessingHandler (instance); print_area->preproc_list.push_back(obj); } @@ -338,20 +338,20 @@ int FVTerm::print (const FString& s) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, const FString& s) +int FVTerm::print (FTermArea* area, const FString& s) { if ( s.isNull() || ! area ) return -1; - std::vector term_string{}; + std::vector term_string{}; const wchar_t* p = s.wc_str(); if ( p ) { while ( *p ) { - charData nc{}; // next character - nc.code = *p; + FChar nc{}; // next character + nc.ch = *p; nc.fg_color = next_attribute.fg_color; nc.bg_color = next_attribute.bg_color; nc.attr.byte[0] = next_attribute.attr.byte[0]; @@ -382,14 +382,14 @@ int FVTerm::print (const FTermBuffer& term_buffer) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, const FTermBuffer& term_buffer) +int FVTerm::print (FTermArea* area, const FTermBuffer& term_buffer) { const auto& term_string = term_buffer.getBuffer(); return print (area, term_string); } //---------------------------------------------------------------------- -int FVTerm::print (const std::vector& term_string) +int FVTerm::print (const std::vector& term_string) { if ( term_string.empty() ) return 0; @@ -403,7 +403,7 @@ int FVTerm::print (const std::vector& term_string) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, const std::vector& term_string) +int FVTerm::print (FTermArea* area, const std::vector& term_string) { int len{0}; uInt tabstop = uInt(getTabstop()); @@ -414,11 +414,11 @@ int FVTerm::print (term_area* area, const std::vector& term_string) if ( term_string.empty() ) return 0; - for (auto&& ch : term_string) + for (auto&& fchar : term_string) { bool printable_character{false}; - switch ( ch.code ) + switch ( fchar.ch ) { case '\n': area->cursor_y++; @@ -445,7 +445,7 @@ int FVTerm::print (term_area* area, const std::vector& term_string) default: { - auto nc = ch; // next character + auto nc = fchar; // next character print (area, nc); printable_character = true; } @@ -472,14 +472,14 @@ int FVTerm::print (wchar_t c) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, wchar_t c) +int FVTerm::print (FTermArea* area, wchar_t c) { - charData nc{}; // next character + FChar nc{}; // next character if ( ! area ) return -1; - nc.code = wchar_t(c); + nc.ch = wchar_t(c); nc.fg_color = next_attribute.fg_color; nc.bg_color = next_attribute.bg_color; nc.attr.byte[0] = next_attribute.attr.byte[0]; @@ -490,7 +490,7 @@ int FVTerm::print (term_area* area, wchar_t c) } //---------------------------------------------------------------------- -int FVTerm::print (charData& term_char) +int FVTerm::print (FChar& term_char) { auto area = getPrintArea(); @@ -501,9 +501,9 @@ int FVTerm::print (charData& term_char) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, charData& term_char) +int FVTerm::print (FTermArea* area, FChar& term_char) { - charData& nc = term_char; // next character + FChar& nc = term_char; // next character if ( ! area ) return -1; @@ -525,7 +525,7 @@ int FVTerm::print (term_area* area, charData& term_char) && ay < area->height + area->bottom_shadow ) { int line_len = area->width + area->right_shadow; - auto ac = &area->text[ay * line_len + ax]; // area character + auto ac = &area->data[ay * line_len + ax]; // area character if ( *ac != nc ) // compare with an overloaded operator { @@ -593,7 +593,7 @@ void FVTerm::print (const FColorPair& pair) // protected methods of FVTerm //---------------------------------------------------------------------- -FVTerm::term_area* FVTerm::getPrintArea() +FVTerm::FTermArea* FVTerm::getPrintArea() { // returns the print area of this object @@ -619,13 +619,13 @@ FVTerm::term_area* FVTerm::getPrintArea() //---------------------------------------------------------------------- void FVTerm::createArea ( const FRect& box , const FSize& shadow - , term_area*& area ) + , FTermArea*& area ) { // initialize virtual window try { - area = new term_area; + area = new FTermArea; } catch (const std::bad_alloc& ex) { @@ -640,7 +640,7 @@ void FVTerm::createArea ( const FRect& box //---------------------------------------------------------------------- void FVTerm::resizeArea ( const FRect& box , const FSize& shadow - , term_area* area ) + , FTermArea* area ) { // Resize the virtual window to a new size. @@ -708,7 +708,7 @@ void FVTerm::resizeArea ( const FRect& box } //---------------------------------------------------------------------- -void FVTerm::removeArea (term_area*& area) +void FVTerm::removeArea (FTermArea*& area) { // remove the virtual window @@ -720,10 +720,10 @@ void FVTerm::removeArea (term_area*& area) area->changes = nullptr; } - if ( area->text != 0 ) + if ( area->data != 0 ) { - delete[] area->text; - area->text = nullptr; + delete[] area->data; + area->data = nullptr; } delete area; @@ -764,7 +764,7 @@ void FVTerm::restoreVTerm (const FRect& box) for (int tx{0}; tx < w; tx++) { int xpos = x + tx; - auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character + auto tc = &vterm->data[ypos * vterm->width + xpos]; // terminal character auto sc = generateCharacter(FPoint(xpos, ypos)); // shown character std::memcpy (tc, &sc, sizeof(*tc)); } @@ -780,7 +780,7 @@ void FVTerm::restoreVTerm (const FRect& box) } //---------------------------------------------------------------------- -bool FVTerm::updateVTermCursor (term_area* area) +bool FVTerm::updateVTermCursor (FTermArea* area) { if ( ! area ) return false; @@ -822,7 +822,7 @@ bool FVTerm::updateVTermCursor (term_area* area) //---------------------------------------------------------------------- void FVTerm::setAreaCursor ( const FPoint& pos , bool visible - , term_area* area ) + , FTermArea* area ) { if ( ! area ) return; @@ -833,7 +833,7 @@ void FVTerm::setAreaCursor ( const FPoint& pos } //---------------------------------------------------------------------- -void FVTerm::getArea (const FPoint& pos, term_area* area) +void FVTerm::getArea (const FPoint& pos, FTermArea* area) { // Copies a block from the virtual terminal position to the given area @@ -856,8 +856,8 @@ void FVTerm::getArea (const FPoint& pos, term_area* area) for (int y{0}; y < y_end; y++) // line loop { - auto tc = &vterm->text[(ay + y) * vterm->width + ax]; // terminal character - auto ac = &area->text[y * area->width]; // area character + auto tc = &vterm->data[(ay + y) * vterm->width + ax]; // terminal character + auto ac = &area->data[y * area->width]; // area character std::memcpy (ac, tc, sizeof(*ac) * unsigned(length)); if ( int(area->changes[y].xmin) > 0 ) @@ -869,7 +869,7 @@ void FVTerm::getArea (const FPoint& pos, term_area* area) } //---------------------------------------------------------------------- -void FVTerm::getArea (const FRect& box, term_area* area) +void FVTerm::getArea (const FRect& box, FTermArea* area) { // Copies a block from the virtual terminal rectangle to the given area @@ -903,8 +903,8 @@ void FVTerm::getArea (const FRect& box, term_area* area) for (int _y = 0; _y < y_end; _y++) // line loop { int line_len = area->width + area->right_shadow; - auto tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1]; // terminal character - auto ac = &area->text[(dy + _y) * line_len + dx]; // area character + auto tc = &vterm->data[(y + _y - 1) * vterm->width + x - 1]; // terminal character + auto ac = &area->data[(dy + _y) * line_len + dx]; // area character std::memcpy (ac, tc, sizeof(*ac) * unsigned(length)); if ( int(area->changes[dy + _y].xmin) > dx ) @@ -916,7 +916,7 @@ void FVTerm::getArea (const FRect& box, term_area* area) } //---------------------------------------------------------------------- -void FVTerm::putArea (term_area* area) +void FVTerm::putArea (FTermArea* area) { // Add area changes to the virtual terminal @@ -1001,12 +1001,12 @@ void FVTerm::putArea (term_area* area) } //---------------------------------------------------------------------- -void FVTerm::putArea (const FPoint& pos, term_area* area) +void FVTerm::putArea (const FPoint& pos, FTermArea* area) { // Copies the given area block to the virtual terminal position - charData* tc{}; // terminal character - charData* ac{}; // area character + FChar* tc{}; // terminal character + FChar* ac{}; // area character if ( ! area || ! area->visible ) return; @@ -1042,8 +1042,8 @@ void FVTerm::putArea (const FPoint& pos, term_area* area) if ( area->changes[y].trans_count == 0 ) { // Line has only covered characters - ac = &area->text[y * width + ol]; - tc = &vterm->text[(ay + y) * vterm->width + ax]; + ac = &area->data[y * width + ol]; + tc = &vterm->data[(ay + y) * vterm->width + ax]; putAreaLine (ac, tc, length); } else @@ -1053,8 +1053,8 @@ void FVTerm::putArea (const FPoint& pos, term_area* area) { int cx = ax + x; int cy = ay + y; - ac = &area->text[y * width + ol + x]; - tc = &vterm->text[cy * vterm->width + cx]; + ac = &area->data[y * width + ol + x]; + tc = &vterm->data[cy * vterm->width + cx]; putAreaCharacter (FPoint(cx + 1, cy + 1), area->widget, ac, tc); } } @@ -1070,12 +1070,12 @@ void FVTerm::putArea (const FPoint& pos, term_area* area) } //---------------------------------------------------------------------- -void FVTerm::scrollAreaForward (term_area* area) +void FVTerm::scrollAreaForward (FTermArea* area) { // Scrolls the entire area up line down - charData nc{}; // next character - charData* lc{}; // last character - charData* dc{}; // destination character + FChar nc{}; // next character + FChar* lc{}; // last character + FChar* dc{}; // destination character if ( ! area ) return; @@ -1091,18 +1091,18 @@ void FVTerm::scrollAreaForward (term_area* area) { int pos1 = y * total_width; int pos2 = (y + 1) * total_width; - auto sc = &area->text[pos2]; // source character - dc = &area->text[pos1]; + auto sc = &area->data[pos2]; // source character + dc = &area->data[pos1]; std::memcpy (dc, sc, sizeof(*dc) * unsigned(length)); area->changes[y].xmin = 0; area->changes[y].xmax = uInt(area->width - 1); } // insert a new line below - lc = &area->text[(y_max * total_width) - area->right_shadow - 1]; + lc = &area->data[(y_max * total_width) - area->right_shadow - 1]; std::memcpy (&nc, lc, sizeof(nc)); - nc.code = ' '; - dc = &area->text[y_max * total_width]; + nc.ch = ' '; + dc = &area->data[y_max * total_width]; std::fill_n (dc, area->width, nc); area->changes[y_max].xmin = 0; area->changes[y_max].xmax = uInt(area->width - 1); @@ -1127,13 +1127,13 @@ void FVTerm::scrollAreaForward (term_area* area) } //---------------------------------------------------------------------- -void FVTerm::scrollAreaReverse (term_area* area) +void FVTerm::scrollAreaReverse (FTermArea* area) { // Scrolls the entire area one line down - charData nc{}; // next character - charData* lc{}; // last character - charData* dc{}; // destination character + FChar nc{}; // next character + FChar* lc{}; // last character + FChar* dc{}; // destination character if ( ! area ) return; @@ -1149,18 +1149,18 @@ void FVTerm::scrollAreaReverse (term_area* area) { int pos1 = (y - 1) * total_width; int pos2 = y * total_width; - auto sc = &area->text[pos1]; // source character - dc = &area->text[pos2]; + auto sc = &area->data[pos1]; // source character + dc = &area->data[pos2]; std::memcpy (dc, sc, sizeof(*dc) * unsigned(length)); area->changes[y].xmin = 0; area->changes[y].xmax = uInt(area->width - 1); } // insert a new line above - lc = &area->text[total_width]; + lc = &area->data[total_width]; std::memcpy (&nc, lc, sizeof(nc)); - nc.code = ' '; - dc = &area->text[0]; + nc.ch = ' '; + dc = &area->data[0]; std::fill_n (dc, area->width, nc); area->changes[0].xmin = 0; area->changes[0].xmax = uInt(area->width - 1); @@ -1185,17 +1185,17 @@ void FVTerm::scrollAreaReverse (term_area* area) } //---------------------------------------------------------------------- -void FVTerm::clearArea (term_area* area, int fillchar) +void FVTerm::clearArea (FTermArea* area, int fillchar) { // Clear the area with the current attributes - charData nc{}; // next character + FChar nc{}; // next character // Current attributes with a space character std::memcpy (&nc, &next_attribute, sizeof(nc)); - nc.code = fillchar; + nc.ch = fillchar; - if ( ! (area && area->text) ) + if ( ! (area && area->data) ) { clearTerm (fillchar); return; @@ -1279,7 +1279,7 @@ void FVTerm::finishTerminalUpdate() } //---------------------------------------------------------------------- -void FVTerm::flush_out() +void FVTerm::flushOutputBuffer() { while ( ! output_buffer->empty() ) { @@ -1294,20 +1294,20 @@ void FVTerm::flush_out() // private methods of FVTerm //---------------------------------------------------------------------- -inline void FVTerm::setTextToDefault ( term_area* area +inline void FVTerm::setTextToDefault ( FTermArea* area , const FSize& size ) { - charData default_char; - line_changes unchanged; + FChar default_char; + FLineChanges unchanged; - default_char.code = ' '; + default_char.ch = ' '; default_char.fg_color = fc::Default; default_char.bg_color = fc::Default; default_char.attr.byte[0] = 0; default_char.attr.byte[1] = 0; default_char.attr.byte[2] = 0; - std::fill_n (area->text, size.getArea(), default_char); + std::fill_n (area->data, size.getArea(), default_char); unchanged.xmin = uInt(size.getWidth()); unchanged.xmax = 0; @@ -1317,7 +1317,7 @@ inline void FVTerm::setTextToDefault ( term_area* area } //---------------------------------------------------------------------- -inline bool FVTerm::reallocateTextArea ( term_area* area +inline bool FVTerm::reallocateTextArea ( FTermArea* area , std::size_t height , std::size_t size ) { @@ -1327,13 +1327,13 @@ inline bool FVTerm::reallocateTextArea ( term_area* area if ( area->changes != 0 ) delete[] area->changes; - if ( area->text != 0 ) - delete[] area->text; + if ( area->data != 0 ) + delete[] area->data; try { - area->changes = new line_changes[height]; - area->text = new charData[size]; + area->changes = new FLineChanges[height]; + area->data = new FChar[size]; } catch (const std::bad_alloc& ex) { @@ -1345,16 +1345,16 @@ inline bool FVTerm::reallocateTextArea ( term_area* area } //---------------------------------------------------------------------- -inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size) +inline bool FVTerm::reallocateTextArea (FTermArea* area, std::size_t size) { // Reallocate "size" bytes for the text area - if ( area->text != 0 ) - delete[] area->text; + if ( area->data != 0 ) + delete[] area->data; try { - area->text = new charData[size]; + area->data = new FChar[size]; } catch (const std::bad_alloc& ex) { @@ -1367,7 +1367,7 @@ inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size) //---------------------------------------------------------------------- FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos - , term_area* area ) + , FTermArea* area ) { // Determines the covered state for the given position @@ -1402,7 +1402,7 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos int width = win->width + win->right_shadow; int x = pos.getX(); int y = pos.getY(); - auto tmp = &win->text[(y - win_y) * width + (x - win_x)]; + auto tmp = &win->data[(y - win_y) * width + (x - win_x)]; if ( tmp->attr.bit.trans_shadow ) { @@ -1424,7 +1424,7 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos } //---------------------------------------------------------------------- -void FVTerm::updateOverlappedColor ( term_area* area +void FVTerm::updateOverlappedColor ( FTermArea* area , const FPoint& area_pos , const FPoint& terminal_pos ) { @@ -1436,11 +1436,11 @@ void FVTerm::updateOverlappedColor ( term_area* area int ty = terminal_pos.getY(); int width = area->width + area->right_shadow; // Area character - auto ac = &area->text[y * width + x]; + auto ac = &area->data[y * width + x]; // Terminal character - auto tc = &vterm->text[ty * vterm->width + tx]; + auto tc = &vterm->data[ty * vterm->width + tx]; // New character - charData nc{}; + FChar nc{}; std::memcpy (&nc, ac, sizeof(nc)); // Overlapped character auto oc = getOverlappedCharacter (terminal_pos + FPoint(1, 1), area->widget); @@ -1449,20 +1449,20 @@ void FVTerm::updateOverlappedColor ( term_area* area nc.attr.bit.reverse = false; nc.attr.bit.standout = false; - if ( nc.code == fc::LowerHalfBlock - || nc.code == fc::UpperHalfBlock - || nc.code == fc::LeftHalfBlock - || nc.code == fc::RightHalfBlock - || nc.code == fc::MediumShade - || nc.code == fc::FullBlock ) - nc.code = ' '; + if ( nc.ch == fc::LowerHalfBlock + || nc.ch == fc::UpperHalfBlock + || nc.ch == fc::LeftHalfBlock + || nc.ch == fc::RightHalfBlock + || nc.ch == fc::MediumShade + || nc.ch == fc::FullBlock ) + nc.ch = ' '; nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); std::memcpy (tc, &nc, sizeof(*tc)); } //---------------------------------------------------------------------- -void FVTerm::updateOverlappedCharacter ( term_area* area +void FVTerm::updateOverlappedCharacter ( FTermArea* area , const FPoint& terminal_pos ) { // Restore one character on vterm @@ -1470,7 +1470,7 @@ void FVTerm::updateOverlappedCharacter ( term_area* area // Terminal character int tx = terminal_pos.getX(); int ty = terminal_pos.getY(); - auto tc = &vterm->text[ty * vterm->width + tx]; + auto tc = &vterm->data[ty * vterm->width + tx]; // Overlapped character auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); @@ -1478,7 +1478,7 @@ void FVTerm::updateOverlappedCharacter ( term_area* area } //---------------------------------------------------------------------- -void FVTerm::updateShadedCharacter ( term_area* area +void FVTerm::updateShadedCharacter ( FTermArea* area , const FPoint& area_pos , const FPoint& terminal_pos ) { @@ -1490,9 +1490,9 @@ void FVTerm::updateShadedCharacter ( term_area* area int ty = terminal_pos.getY(); int width = area->width + area->right_shadow; // Area character - auto ac = &area->text[y * width + x]; + auto ac = &area->data[y * width + x]; // Terminal character - auto tc = &vterm->text[ty * vterm->width + tx]; + auto tc = &vterm->data[ty * vterm->width + tx]; // Overlapped character auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget); oc.fg_color = ac->fg_color; @@ -1500,20 +1500,20 @@ void FVTerm::updateShadedCharacter ( term_area* area oc.attr.bit.reverse = false; oc.attr.bit.standout = false; - if ( oc.code == fc::LowerHalfBlock - || oc.code == fc::UpperHalfBlock - || oc.code == fc::LeftHalfBlock - || oc.code == fc::RightHalfBlock - || oc.code == fc::MediumShade - || oc.code == fc::FullBlock ) - oc.code = ' '; + if ( oc.ch == fc::LowerHalfBlock + || oc.ch == fc::UpperHalfBlock + || oc.ch == fc::LeftHalfBlock + || oc.ch == fc::RightHalfBlock + || oc.ch == fc::MediumShade + || oc.ch == fc::FullBlock ) + oc.ch = ' '; oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); std::memcpy (tc, &oc, sizeof(*tc)); } //---------------------------------------------------------------------- -void FVTerm::updateInheritBackground ( term_area* area +void FVTerm::updateInheritBackground ( FTermArea* area , const FPoint& area_pos , const FPoint& terminal_pos ) { @@ -1525,11 +1525,11 @@ void FVTerm::updateInheritBackground ( term_area* area int ty = terminal_pos.getY(); int width = area->width + area->right_shadow; // Area character - auto ac = &area->text[y * width + x]; + auto ac = &area->data[y * width + x]; // Terminal character - auto tc = &vterm->text[ty * vterm->width + tx]; + auto tc = &vterm->data[ty * vterm->width + tx]; // New character - charData nc{}; + FChar nc{}; std::memcpy (&nc, ac, sizeof(nc)); // Covered character auto cc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget); @@ -1539,7 +1539,7 @@ void FVTerm::updateInheritBackground ( term_area* area } //---------------------------------------------------------------------- -void FVTerm::updateCharacter ( term_area* area +void FVTerm::updateCharacter ( FTermArea* area , const FPoint& area_pos , const FPoint& terminal_pos ) { @@ -1551,9 +1551,9 @@ void FVTerm::updateCharacter ( term_area* area int ty = terminal_pos.getY(); int width = area->width + area->right_shadow; // Area character - auto ac = &area->text[y * width + x]; + auto ac = &area->data[y * width + x]; // Terminal character - auto tc = &vterm->text[ty * vterm->width + tx]; + auto tc = &vterm->data[ty * vterm->width + tx]; std::memcpy (tc, ac, sizeof(*tc)); if ( tc->attr.bit.printed && *tc == *ac ) @@ -1563,7 +1563,7 @@ void FVTerm::updateCharacter ( term_area* area } //---------------------------------------------------------------------- -bool FVTerm::updateVTermCharacter ( term_area* area +bool FVTerm::updateVTermCharacter ( FTermArea* area , const FPoint& area_pos , const FPoint& terminal_pos ) { @@ -1571,7 +1571,7 @@ bool FVTerm::updateVTermCharacter ( term_area* area int y = area_pos.getY(); int width = area->width + area->right_shadow; // Area character - auto ac = &area->text[y * width + x]; + auto ac = &area->data[y * width + x]; // Get covered state auto is_covered = isCovered(terminal_pos, area); @@ -1624,26 +1624,26 @@ void FVTerm::updateVTerm() for (auto&& window : *(widget->getWindowList())) { - auto vwin = window->getVWin(); + auto v_win = window->getVWin(); - if ( ! (vwin && vwin->visible) ) + if ( ! (v_win && v_win->visible) ) continue; - if ( vwin->has_changes ) + if ( v_win->has_changes ) { - putArea(vwin); - vwin->has_changes = false; + putArea(v_win); + v_win->has_changes = false; } - else if ( hasChildAreaChanges(vwin) ) + else if ( hasChildAreaChanges(v_win) ) { - putArea(vwin); // and call the child area processing handler there - clearChildAreaChanges(vwin); + putArea(v_win); // and call the child area processing handler there + clearChildAreaChanges(v_win); } } } //---------------------------------------------------------------------- -void FVTerm::callPreprocessingHandler (term_area* area) +void FVTerm::callPreprocessingHandler (FTermArea* area) { // Call preprocessing handler @@ -1659,7 +1659,7 @@ void FVTerm::callPreprocessingHandler (term_area* area) } //---------------------------------------------------------------------- -bool FVTerm::hasChildAreaChanges (term_area* area) +bool FVTerm::hasChildAreaChanges (FTermArea* area) { if ( ! area ) return false; @@ -1676,7 +1676,7 @@ bool FVTerm::hasChildAreaChanges (term_area* area) } //---------------------------------------------------------------------- -void FVTerm::clearChildAreaChanges (term_area* area) +void FVTerm::clearChildAreaChanges (FTermArea* area) { if ( ! area ) return; @@ -1690,7 +1690,7 @@ void FVTerm::clearChildAreaChanges (term_area* area) } //---------------------------------------------------------------------- -bool FVTerm::isInsideArea (const FPoint& pos, term_area* area) +bool FVTerm::isInsideArea (const FPoint& pos, FTermArea* area) { // Check whether the coordinates are within the area @@ -1705,13 +1705,13 @@ bool FVTerm::isInsideArea (const FPoint& pos, term_area* area) } //---------------------------------------------------------------------- -charData FVTerm::generateCharacter (const FPoint& pos) +FChar FVTerm::generateCharacter (const FPoint& pos) { // Generates characters for a given position considering all areas int x = pos.getX(); int y = pos.getY(); - auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character + auto sc = &vdesktop->data[y * vdesktop->width + x]; // shown character if ( ! FWidget::getWindowList() || FWidget::getWindowList()->empty() ) return *sc; @@ -1734,7 +1734,7 @@ charData FVTerm::generateCharacter (const FPoint& pos) if ( geometry.contains(x, y) ) { int line_len = win->width + win->right_shadow; - auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)]; + auto tmp = &win->data[(y - win_y) * line_len + (x - win_x)]; if ( ! tmp->attr.bit.transparent ) // Current character not transparent { @@ -1749,13 +1749,13 @@ charData FVTerm::generateCharacter (const FPoint& pos) s_ch.attr.bit.reverse = false; s_ch.attr.bit.standout = false; - if ( s_ch.code == fc::LowerHalfBlock - || s_ch.code == fc::UpperHalfBlock - || s_ch.code == fc::LeftHalfBlock - || s_ch.code == fc::RightHalfBlock - || s_ch.code == fc::MediumShade - || s_ch.code == fc::FullBlock ) - s_ch.code = ' '; + if ( s_ch.ch == fc::LowerHalfBlock + || s_ch.ch == fc::UpperHalfBlock + || s_ch.ch == fc::LeftHalfBlock + || s_ch.ch == fc::RightHalfBlock + || s_ch.ch == fc::MediumShade + || s_ch.ch == fc::FullBlock ) + s_ch.ch = ' '; sc = &s_ch; } @@ -1776,9 +1776,9 @@ charData FVTerm::generateCharacter (const FPoint& pos) } //---------------------------------------------------------------------- -charData FVTerm::getCharacter ( character_type char_type - , const FPoint& pos - , FVTerm* obj ) +FChar FVTerm::getCharacter ( character_type char_type + , const FPoint& pos + , FVTerm* obj ) { // Gets the overlapped or the covered character for a given position @@ -1799,7 +1799,7 @@ charData FVTerm::getCharacter ( character_type char_type if ( yy >= vterm->height ) yy = vterm->height - 1; - auto cc = &vdesktop->text[yy * vdesktop->width + xx]; // covered character + auto cc = &vdesktop->data[yy * vdesktop->width + xx]; // covered character if ( ! FWidget::getWindowList() || FWidget::getWindowList()->empty() ) return *cc; @@ -1843,14 +1843,14 @@ charData FVTerm::getCharacter ( character_type char_type } //---------------------------------------------------------------------- -charData FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) +FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) { // Gets the covered character for a given position return getCharacter (covered_character, pos, obj); } //---------------------------------------------------------------------- -charData FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) +FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) { // Gets the overlapped character for a given position return getCharacter (overlapped_character, pos, obj); @@ -1877,7 +1877,7 @@ void FVTerm::init (bool disable_alt_screen) } // term_attribute stores the current state of the terminal - term_attribute.code = '\0'; + term_attribute.ch = '\0'; term_attribute.fg_color = fc::Default; term_attribute.bg_color = fc::Default; term_attribute.attr.byte[0] = 0; @@ -1940,7 +1940,7 @@ void FVTerm::finish() if ( FTerm::hasAlternateScreen() ) clearTerm(); - flush_out(); + flushOutputBuffer(); if ( output_buffer ) delete output_buffer; @@ -1957,7 +1957,7 @@ void FVTerm::finish() } //---------------------------------------------------------------------- -void FVTerm::putAreaLine (charData* ac, charData* tc, int length) +void FVTerm::putAreaLine (FChar* ac, FChar* tc, int length) { // copy "length" characters from area to terminal @@ -1966,13 +1966,13 @@ void FVTerm::putAreaLine (charData* ac, charData* tc, int length) //---------------------------------------------------------------------- void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj - , charData* ac - , charData* tc ) + , FChar* ac + , FChar* tc ) { if ( ac->attr.bit.transparent ) // Transparent { // Restore one character on vterm - charData ch = getCoveredCharacter (pos, obj); + FChar ch = getCoveredCharacter (pos, obj); std::memcpy (tc, &ch, sizeof(*tc)); } else // Mot transparent @@ -1980,28 +1980,28 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj if ( ac->attr.bit.trans_shadow ) // Transparent shadow { // Get covered character + add the current color - charData ch = getCoveredCharacter (pos, obj); + FChar ch = getCoveredCharacter (pos, obj); ch.fg_color = ac->fg_color; ch.bg_color = ac->bg_color; ch.attr.bit.reverse = false; ch.attr.bit.standout = false; - if ( ch.code == fc::LowerHalfBlock - || ch.code == fc::UpperHalfBlock - || ch.code == fc::LeftHalfBlock - || ch.code == fc::RightHalfBlock - || ch.code == fc::MediumShade - || ch.code == fc::FullBlock ) - ch.code = ' '; + if ( ch.ch == fc::LowerHalfBlock + || ch.ch == fc::UpperHalfBlock + || ch.ch == fc::LeftHalfBlock + || ch.ch == fc::RightHalfBlock + || ch.ch == fc::MediumShade + || ch.ch == fc::FullBlock ) + ch.ch = ' '; std::memcpy (tc, &ch, sizeof(*tc)); } else if ( ac->attr.bit.inherit_bg ) { // Add the covered background to this character - charData ch{}; + FChar ch{}; std::memcpy (&ch, ac, sizeof(ch)); - charData cc = getCoveredCharacter (pos, obj); + FChar cc = getCoveredCharacter (pos, obj); ch.bg_color = cc.bg_color; std::memcpy (tc, &ch, sizeof(*tc)); } @@ -2011,15 +2011,15 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj } //---------------------------------------------------------------------- -void FVTerm::getAreaCharacter ( const FPoint& pos, term_area* area - , charData*& cc ) +void FVTerm::getAreaCharacter ( const FPoint& pos, FTermArea* area + , FChar*& cc ) { int area_x = area->offset_left; int area_y = area->offset_top; int line_len = area->width + area->right_shadow; int x = pos.getX(); int y = pos.getY(); - auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)]; + auto tmp = &area->data[(y - area_y) * line_len + (x - area_x)]; // Current character not transparent if ( ! tmp->attr.bit.transparent ) @@ -2089,25 +2089,25 @@ bool FVTerm::clearTerm (int fillchar) setTermXY (0, 0); } - flush_out(); + flushOutputBuffer(); return true; } //---------------------------------------------------------------------- -bool FVTerm::clearFullArea (term_area* area, charData& nc) +bool FVTerm::clearFullArea (FTermArea* area, FChar& nc) { // Clear area int area_size = area->width * area->height; - std::fill_n (area->text, area_size, nc); + std::fill_n (area->data, area_size, nc); if ( area != vdesktop ) // Is the area identical to the desktop? return false; // Try to clear the terminal rapidly with a control sequence - if ( clearTerm (nc.code) ) + if ( clearTerm (nc.ch) ) { nc.attr.bit.printed = true; - std::fill_n (vterm->text, area_size, nc); + std::fill_n (vterm->data, area_size, nc); } else { @@ -2125,9 +2125,9 @@ bool FVTerm::clearFullArea (term_area* area, charData& nc) } //---------------------------------------------------------------------- -void FVTerm::clearAreaWithShadow (term_area* area, charData& nc) +void FVTerm::clearAreaWithShadow (FTermArea* area, FChar& nc) { - charData t_char = nc; + FChar t_char = nc; int total_width = area->width + area->right_shadow; t_char.attr.bit.transparent = true; @@ -2135,16 +2135,16 @@ void FVTerm::clearAreaWithShadow (term_area* area, charData& nc) { int pos = y * total_width; // Clear area - std::fill_n (&area->text[pos], total_width, nc); + std::fill_n (&area->data[pos], total_width, nc); // Make right shadow transparent - std::fill_n (&area->text[pos + area->width], area->right_shadow, t_char); + std::fill_n (&area->data[pos + area->width], area->right_shadow, t_char); } // Make bottom shadow transparent for (int y{0}; y < area->bottom_shadow; y++) { int pos = total_width * (y + area->height); - std::fill_n (&area->text[pos], total_width, t_char); + std::fill_n (&area->data[pos], total_width, t_char); } } @@ -2154,11 +2154,11 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y) // Is the line from xmin to the end of the line blank? // => clear to end of line - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& ce = TCAP(fc::t_clr_eol); - auto min_char = &vt->text[y * uInt(vt->width) + xmin]; + auto min_char = &vt->data[y * uInt(vt->width) + xmin]; - if ( ce && min_char->code == ' ' ) + if ( ce && min_char->ch == ' ' ) { uInt beginning_whitespace = 1; bool normal = FTerm::isNormal(min_char); @@ -2166,7 +2166,7 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y) for (uInt x = xmin + 1; x < uInt(vt->width); x++) { - auto ch = &vt->text[y * uInt(vt->width) + x]; + auto ch = &vt->data[y * uInt(vt->width) + x]; if ( *min_char == *ch ) beginning_whitespace++; @@ -2189,11 +2189,11 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y) // Line has leading whitespace // => clear from xmin to beginning of line - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& cb = TCAP(fc::t_clr_bol); - auto first_char = &vt->text[y * uInt(vt->width)]; + auto first_char = &vt->data[y * uInt(vt->width)]; - if ( cb && first_char->code == ' ' ) + if ( cb && first_char->ch == ' ' ) { uInt leading_whitespace = 1; bool normal = FTerm::isNormal(first_char); @@ -2201,7 +2201,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y) for (uInt x{1}; x < uInt(vt->width); x++) { - auto ch = &vt->text[y * uInt(vt->width) + x]; + auto ch = &vt->data[y * uInt(vt->width) + x]; if ( *first_char == *ch ) leading_whitespace++; @@ -2227,11 +2227,11 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y) // Line has trailing whitespace // => clear from xmax to end of line - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& ce = TCAP(fc::t_clr_eol); - auto last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; + auto last_char = &vt->data[(y + 1) * uInt(vt->width) - 1]; - if ( ce && last_char->code == ' ' ) + if ( ce && last_char->ch == ' ' ) { uInt trailing_whitespace = 1; bool normal = FTerm::isNormal(last_char); @@ -2239,7 +2239,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y) for (uInt x = uInt(vt->width) - 1; x > 0 ; x--) { - auto ch = &vt->text[y * uInt(vt->width) + x]; + auto ch = &vt->data[y * uInt(vt->width) + x]; if ( *last_char == *ch ) trailing_whitespace++; @@ -2264,8 +2264,8 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y) { // Skip characters without changes if it is faster than redrawing - term_area*& vt = vterm; - auto print_char = &vt->text[y * uInt(vt->width) + x]; + FTermArea*& vt = vterm; + auto print_char = &vt->data[y * uInt(vt->width) + x]; print_char->attr.bit.printed = true; if ( print_char->attr.bit.no_changes ) @@ -2274,7 +2274,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y) for (uInt i = x + 1; i <= xmax; i++) { - auto ch = &vt->text[y * uInt(vt->width) + i]; + auto ch = &vt->data[y * uInt(vt->width) + i]; if ( ch->attr.bit.no_changes ) count++; @@ -2299,10 +2299,10 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y { for (uInt x = xmin; x <= xmax; x++) { - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& ec = TCAP(fc::t_erase_chars); auto& rp = TCAP(fc::t_repeat_char); - auto print_char = &vt->text[y * uInt(vt->width) + x]; + auto print_char = &vt->data[y * uInt(vt->width) + x]; print_char->attr.bit.printed = true; replaceNonPrintableFullwidth (x, print_char); @@ -2311,7 +2311,7 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y continue; // Erase character - if ( ec && print_char->code == ' ' ) + if ( ec && print_char->ch == ' ' ) { exit_state erase_state = \ eraseCharacters(x, xmax, y, draw_trailing_ws); @@ -2333,27 +2333,27 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y //---------------------------------------------------------------------- inline void FVTerm::replaceNonPrintableFullwidth ( uInt x - , charData*& print_char ) + , FChar*& print_char ) { // Replace non-printable full-width characters that are truncated // from the right or left terminal side if ( x == 0 && isFullWidthPaddingChar(print_char) ) { - print_char->code = fc::SingleLeftAngleQuotationMark; // ‹ + print_char->ch = fc::SingleLeftAngleQuotationMark; // ‹ print_char->attr.bit.fullwidth_padding = false; } else if ( x == uInt(vterm->width - 1) && isFullWidthChar(print_char) ) { - print_char->code = fc::SingleRightAngleQuotationMark; // › + print_char->ch = fc::SingleRightAngleQuotationMark; // › print_char->attr.bit.char_width = 1; } } //---------------------------------------------------------------------- void FVTerm::printCharacter ( uInt& x, uInt y, bool min_and_not_max - , charData*& print_char) + , FChar*& print_char) { // General character output on terminal @@ -2380,10 +2380,10 @@ void FVTerm::printCharacter ( uInt& x, uInt y, bool min_and_not_max //---------------------------------------------------------------------- void FVTerm::printFullWidthCharacter ( uInt& x, uInt y - , charData*& print_char ) + , FChar*& print_char ) { auto vt = vterm; - auto next_char = &vt->text[y * uInt(vt->width) + x + 1]; + auto next_char = &vt->data[y * uInt(vt->width) + x + 1]; if ( print_char->attr.byte[0] == next_char->attr.byte[0] && print_char->attr.byte[1] == next_char->attr.byte[1] @@ -2419,10 +2419,10 @@ void FVTerm::printFullWidthCharacter ( uInt& x, uInt y //---------------------------------------------------------------------- void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y - , charData*& print_char) + , FChar*& print_char) { auto vt = vterm; - auto prev_char = &vt->text[y * uInt(vt->width) + x - 1]; + auto prev_char = &vt->data[y * uInt(vt->width) + x - 1]; if ( print_char->attr.byte[0] == prev_char->attr.byte[0] && print_char->attr.byte[1] == prev_char->attr.byte[1] @@ -2464,10 +2464,10 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y //---------------------------------------------------------------------- void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y - , charData*& print_char ) + , FChar*& print_char ) { auto vt = vterm; - auto prev_char = &vt->text[y * uInt(vt->width) + x - 1]; + auto prev_char = &vt->data[y * uInt(vt->width) + x - 1]; if ( isFullWidthChar(prev_char) && ! isFullWidthPaddingChar(print_char) ) { @@ -2500,7 +2500,7 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y //---------------------------------------------------------------------- inline void FVTerm::skipPaddingCharacter ( uInt& x, uInt y - , charData*& print_char ) + , FChar*& print_char ) { if ( isFullWidthChar(print_char) ) // full-width character { @@ -2516,11 +2516,11 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y { // Erase a number of characters to draw simple whitespaces - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& ec = TCAP(fc::t_erase_chars); - auto print_char = &vt->text[y * uInt(vt->width) + x]; + auto print_char = &vt->data[y * uInt(vt->width) + x]; - if ( ! ec || print_char->code != ' ' ) + if ( ! ec || print_char->ch != ' ' ) return not_used; uInt whitespace{1}; @@ -2528,7 +2528,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y for (uInt i = x + 1; i <= xmax; i++) { - auto ch = &vt->text[y * uInt(vt->width) + i]; + auto ch = &vt->data[y * uInt(vt->width) + i]; if ( *print_char == *ch ) whitespace++; @@ -2578,9 +2578,9 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) { // Repeat one character n-fold - term_area*& vt = vterm; + FTermArea*& vt = vterm; auto& rp = TCAP(fc::t_repeat_char); - auto print_char = &vt->text[y * uInt(vt->width) + x]; + auto print_char = &vt->data[y * uInt(vt->width) + x]; if ( ! rp ) return not_used; @@ -2589,7 +2589,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) for (uInt i = x + 1; i <= xmax; i++) { - auto ch = &vt->text[y * uInt(vt->width) + i]; + auto ch = &vt->data[y * uInt(vt->width) + i]; if ( *print_char == *ch ) repetitions++; @@ -2607,12 +2607,12 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) uInt start_pos = x; if ( repetitions > repeat_char_length - && print_char->code < 128 ) + && print_char->ch < 128 ) { newFontChanges (print_char); charsetChanges (print_char); appendAttributes (print_char); - appendOutputBuffer (tparm(rp, print_char->code, repetitions, 0, 0, 0, 0, 0, 0, 0)); + appendOutputBuffer (tparm(rp, print_char->ch, repetitions, 0, 0, 0, 0, 0, 0, 0)); term_pos->x_ref() += int(repetitions); x = x + repetitions - 1; } @@ -2631,13 +2631,13 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) } //---------------------------------------------------------------------- -inline bool FVTerm::isFullWidthChar (charData*& ch) +inline bool FVTerm::isFullWidthChar (FChar*& ch) { return bool(ch->attr.bit.char_width == 2); } //---------------------------------------------------------------------- -inline bool FVTerm::isFullWidthPaddingChar (charData*& ch) +inline bool FVTerm::isFullWidthPaddingChar (FChar*& ch) { return ch->attr.bit.fullwidth_padding; } @@ -2646,7 +2646,7 @@ inline bool FVTerm::isFullWidthPaddingChar (charData*& ch) void FVTerm::cursorWrap() { // Wrap the cursor - term_area*& vt = vterm; + FTermArea*& vt = vterm; if ( term_pos->getX() >= vt->width ) { @@ -2670,7 +2670,7 @@ void FVTerm::cursorWrap() } //---------------------------------------------------------------------- -bool FVTerm::printWrap (term_area* area) +bool FVTerm::printWrap (FTermArea* area) { bool end_of_area{false}; int width = area->width @@ -2696,26 +2696,26 @@ bool FVTerm::printWrap (term_area* area) } //---------------------------------------------------------------------- -void FVTerm::printPaddingCharacter (term_area* area, charData& term_char) +void FVTerm::printPaddingCharacter (FTermArea* area, FChar& term_char) { // Creates a padding-character from the current character (term_char) // and prints it. It is a placeholder for the column after // a full-width character. - charData pc; // padding character + FChar pc; // padding character // Copy character to padding character std::memcpy (&pc, &term_char, sizeof(pc)); if ( getEncoding() == fc::UTF8 ) { - pc.code = 0; + pc.ch = 0; pc.attr.bit.fullwidth_padding = true; pc.attr.bit.char_width = 0; } else { - pc.code = '.'; + pc.ch = '.'; pc.attr.bit.char_width = 1; } @@ -2728,7 +2728,7 @@ void FVTerm::updateTerminalLine (uInt y) { // Updates pending changes from line y to the terminal - term_area*& vt = vterm; + FTermArea*& vt = vterm; uInt& xmin = vt->changes[y].xmin; uInt& xmax = vt->changes[y].xmax; @@ -2737,9 +2737,9 @@ void FVTerm::updateTerminalLine (uInt y) bool draw_leading_ws = false; bool draw_trailing_ws = false; auto& ce = TCAP(fc::t_clr_eol); - auto first_char = &vt->text[y * uInt(vt->width)]; - auto last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; - auto min_char = &vt->text[y * uInt(vt->width) + xmin]; + auto first_char = &vt->data[y * uInt(vt->width)]; + auto last_char = &vt->data[(y + 1) * uInt(vt->width) - 1]; + auto min_char = &vt->data[y * uInt(vt->width) + xmin]; // Clear rest of line bool is_eol_clean = canClearToEOL (xmin, y); @@ -2848,7 +2848,7 @@ inline void FVTerm::markAsPrinted (uInt pos, uInt line) { // Marks a character as printed - vterm->text[line * uInt(vterm->width) + pos].attr.bit.printed = true; + vterm->data[line * uInt(vterm->width) + pos].attr.bit.printed = true; } //---------------------------------------------------------------------- @@ -2857,19 +2857,19 @@ inline void FVTerm::markAsPrinted (uInt from, uInt to, uInt line) // Marks characters in the specified range [from .. to] as printed for (uInt x = from; x <= to; x++) - vterm->text[line * uInt(vterm->width) + x].attr.bit.printed = true; + vterm->data[line * uInt(vterm->width) + x].attr.bit.printed = true; } //---------------------------------------------------------------------- -inline void FVTerm::newFontChanges (charData*& next_char) +inline void FVTerm::newFontChanges (FChar*& next_char) { // NewFont special cases if ( isNewFont() ) { - switch ( next_char->code ) + switch ( next_char->ch ) { case fc::LowerHalfBlock: - next_char->code = fc::UpperHalfBlock; + next_char->ch = fc::UpperHalfBlock; // fall through case fc::NF_rev_left_arrow2: case fc::NF_rev_right_arrow2: @@ -2902,26 +2902,26 @@ inline void FVTerm::newFontChanges (charData*& next_char) } //---------------------------------------------------------------------- -inline void FVTerm::charsetChanges (charData*& next_char) +inline void FVTerm::charsetChanges (FChar*& next_char) { - wchar_t& code = next_char->code; - next_char->encoded_code = code; + wchar_t& ch = next_char->ch; + next_char->encoded_char = ch; if ( getEncoding() == fc::UTF8 ) return; - wchar_t ch_enc = FTerm::charEncode(code); + wchar_t ch_enc = FTerm::charEncode(ch); - if ( ch_enc == code ) + if ( ch_enc == ch ) return; if ( ch_enc == 0 ) { - next_char->encoded_code = wchar_t(FTerm::charEncode(code, fc::ASCII)); + next_char->encoded_char = wchar_t(FTerm::charEncode(ch, fc::ASCII)); return; } - next_char->encoded_code = ch_enc; + next_char->encoded_char = ch_enc; if ( getEncoding() == fc::VT100 ) next_char->attr.bit.alt_charset = true; @@ -2935,10 +2935,10 @@ inline void FVTerm::charsetChanges (charData*& next_char) if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f { if ( hasUTF8() ) - next_char->encoded_code = int(FTerm::charEncode(code, fc::ASCII)); + next_char->encoded_char = int(FTerm::charEncode(ch, fc::ASCII)); else { - next_char->encoded_code += 0x5f; + next_char->encoded_char += 0x5f; next_char->attr.bit.alt_charset = true; } } @@ -2946,7 +2946,7 @@ inline void FVTerm::charsetChanges (charData*& next_char) } //---------------------------------------------------------------------- -inline void FVTerm::appendCharacter (charData*& next_char) +inline void FVTerm::appendCharacter (FChar*& next_char) { int term_width = vterm->width - 1; int term_height = vterm->height - 1; @@ -2961,17 +2961,17 @@ inline void FVTerm::appendCharacter (charData*& next_char) } //---------------------------------------------------------------------- -inline void FVTerm::appendChar (charData*& next_char) +inline void FVTerm::appendChar (FChar*& next_char) { newFontChanges (next_char); charsetChanges (next_char); appendAttributes (next_char); characterFilter (next_char); - appendOutputBuffer (next_char->encoded_code); + appendOutputBuffer (next_char->encoded_char); } //---------------------------------------------------------------------- -inline void FVTerm::appendAttributes (charData*& next_attr) +inline void FVTerm::appendAttributes (FChar*& next_attr) { auto term_attr = &term_attribute; @@ -2983,7 +2983,7 @@ inline void FVTerm::appendAttributes (charData*& next_attr) } //---------------------------------------------------------------------- -int FVTerm::appendLowerRight (charData*& screen_char) +int FVTerm::appendLowerRight (FChar*& screen_char) { auto& SA = TCAP(fc::t_enter_am_mode); auto& RA = TCAP(fc::t_exit_am_mode); @@ -3040,16 +3040,16 @@ int FVTerm::appendLowerRight (charData*& screen_char) } } - return screen_char->code; + return screen_char->ch; } //---------------------------------------------------------------------- -inline void FVTerm::characterFilter (charData*& next_char) +inline void FVTerm::characterFilter (FChar*& next_char) { charSubstitution& sub_map = fterm->getCharSubstitutionMap(); - if ( sub_map.find(next_char->encoded_code) != sub_map.end() ) - next_char->encoded_code = sub_map[next_char->encoded_code]; + if ( sub_map.find(next_char->encoded_char) != sub_map.end() ) + next_char->encoded_char = sub_map[next_char->encoded_char]; } //---------------------------------------------------------------------- @@ -3072,7 +3072,7 @@ int FVTerm::appendOutputBuffer (int ch) output_buffer->push(ch); if ( output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_SIZE ) - flush_out(); + flushOutputBuffer(); return ch; } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index c77bc25e..5f19dcc7 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -772,8 +772,8 @@ FWidget* FWidget::childWidgetAt (const FPoint& pos) && ! widget->isWindowWidget() && widget->getTermGeometry().contains(pos) ) { - auto child = widget->childWidgetAt(pos); - return ( child != 0 ) ? child : widget; + auto sub_child = widget->childWidgetAt(pos); + return ( sub_child != 0 ) ? sub_child : widget; } } @@ -837,7 +837,7 @@ void FWidget::addCallback ( const FString& cb_signal { // Add a (normal) function pointer as callback - callback_data obj{ cb_signal, nullptr, cb_function, data }; + FCallbackData obj{ cb_signal, nullptr, cb_function, data }; callback_objects.push_back(obj); } @@ -849,7 +849,7 @@ void FWidget::addCallback ( const FString& cb_signal { // Add a member function pointer as callback - callback_data obj{ cb_signal, cb_instance, cb_function, data }; + FCallbackData obj{ cb_signal, cb_instance, cb_function, data }; callback_objects.push_back(obj); } @@ -924,7 +924,7 @@ void FWidget::addAccelerator (FKey key, FWidget* obj) // Adding a keyboard accelerator for the given widget auto widget = static_cast(FWindow::getWindowWidget(obj)); - accelerator accel = { key, obj }; + FAccelerator accel = { key, obj }; if ( ! widget || widget == statusbar || widget == menubar ) widget = getRootWidget(); @@ -990,7 +990,7 @@ void FWidget::redraw() if ( redraw_root_widget == this ) { updateTerminal(); - flush_out(); + flushOutputBuffer(); redraw_root_widget = nullptr; } } @@ -1070,7 +1070,7 @@ void FWidget::show() { finishTerminalUpdate(); updateTerminal(); - flush_out(); + flushOutputBuffer(); show_root_widget = nullptr; } @@ -1201,7 +1201,7 @@ void FWidget::quit() // protected methods of FWidget //---------------------------------------------------------------------- -FVTerm::term_area* FWidget::getPrintArea() +FVTerm::FTermArea* FWidget::getPrintArea() { // returns the print area of this object @@ -1236,7 +1236,7 @@ FVTerm::term_area* FWidget::getPrintArea() //---------------------------------------------------------------------- void FWidget::addPreprocessingHandler ( FVTerm* instance - , FVTermPreprocessing function ) + , FPreprocessingFunction function ) { if ( ! getCurrentPrintArea() ) FWidget::getPrintArea(); @@ -1390,7 +1390,7 @@ void FWidget::hideArea (const FSize& size) print() << FPoint(1, 1 + y) << FString(size.getWidth(), L' '); } - flush_out(); + flushOutputBuffer(); } //---------------------------------------------------------------------- @@ -1400,7 +1400,7 @@ void FWidget::createWidgetAcceleratorList() { try { - accelerator_list = new Accelerators(); + accelerator_list = new FAcceleratorList(); } catch (const std::bad_alloc& ex) { @@ -1911,7 +1911,7 @@ bool FWidget::changeFocus ( FWidget* follower, FWidget* parent redraw(); follower->redraw(); updateTerminal(); - flush_out(); + flushOutputBuffer(); } } @@ -1926,8 +1926,8 @@ void FWidget::draw() void FWidget::drawWindows() { // redraw windows - charData default_char{}; - default_char.code = ' '; + FChar default_char{}; + default_char.ch = ' '; default_char.fg_color = fc::Black; default_char.bg_color = fc::Black; default_char.attr.byte[0] = 0; @@ -1940,10 +1940,10 @@ void FWidget::drawWindows() { if ( window->isShown() ) { - auto win = window->getVWin(); - int w = win->width + win->right_shadow; - int h = win->height + win->bottom_shadow; - std::fill_n (win->text, w * h, default_char); + auto v_win = window->getVWin(); + int w = v_win->width + v_win->right_shadow; + int h = v_win->height + v_win->bottom_shadow; + std::fill_n (v_win->data, w * h, default_char); window->redraw(); } } @@ -1997,435 +1997,4 @@ void detectTermSize() ); } -//---------------------------------------------------------------------- -FKey getHotkey (const FString& text) -{ - // Returns the hotkey character from a string - // e.g. "E&xit" returns 'x' - - if ( text.isEmpty() ) - return 0; - - std::size_t length = text.getLength(); - - for (std::size_t i{0}; i < length; i++) - { - try - { - if ( i + 1 < length && text[i] == '&' ) - return FKey(text[++i]); - } - catch (const std::out_of_range&) - { - return 0; - } - } - return 0; -} - -//---------------------------------------------------------------------- -std::size_t getHotkeyPos (const FString& src, FString& dest) -{ - // Find hotkey position in string - // + generate a new string without the '&'-sign - - constexpr std::size_t NOT_SET = static_cast(-1); - std::size_t hotkeypos{NOT_SET}; - std::size_t i{0}; - - for (auto&& ch : src) - { - if ( ch == L'&' && hotkeypos == NOT_SET && src.getLength() != i + 1 ) - hotkeypos = i; - else - dest += ch; - - i++; - } - - return hotkeypos; -} -//---------------------------------------------------------------------- -void setHotkeyViaString (FWidget* w, const FString& text) -{ - // Set hotkey accelerator via string - - if ( ! w ) - return; - - FKey hotkey = getHotkey(text); - - if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character - hotkey -= 0xfee0; - - if ( hotkey ) - { - if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) ) - { - w->addAccelerator (FKey(std::tolower(int(hotkey)))); - w->addAccelerator (FKey(std::toupper(int(hotkey)))); - // Meta + hotkey - w->addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))); - } - else - w->addAccelerator (hotkey); - } - else - w->delAccelerator(); -} - -//---------------------------------------------------------------------- -void drawShadow (FWidget* w) -{ - if ( w->isMonochron() && ! w->flags.trans_shadow ) - return; - - if ( (w->getEncoding() == fc::VT100 && ! w->flags.trans_shadow) - || (w->getEncoding() == fc::ASCII && ! w->flags.trans_shadow) ) - { - clearShadow(w); - return; - } - - int x1 = 1; - int x2 = int(w->getWidth()); - int y1 = 1; - int y2 = int(w->getHeight()); - - if ( w->flags.trans_shadow ) - { - // transparent shadow - drawTransparentShadow (w, x1, y1, x2, y2); - } - else - { - // non-transparent shadow - drawBlockShadow (w, x1, y1, x2, y2); - } -} - -//---------------------------------------------------------------------- -void drawTransparentShadow (FWidget* w, int x1, int y1, int x2, int y2) -{ - // transparent shadow - - w->setTransparent(); - w->print() << FPoint(x2 + 1, y1) << " "; - w->unsetTransparent(); - w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg); - w->setTransShadow(); - - for (std::size_t y{1}; y < w->getHeight(); y++) - { - w->print() << FPoint(x2 + 1, y1 + int(y)) << " "; - } - - w->unsetTransShadow(); - w->setTransparent(); - w->print() << FPoint(x1, y2 + 1) << " "; - w->unsetTransparent(); - w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg); - w->setTransShadow(); - - for (std::size_t x{2}; x <= w->getWidth() + 1; x++) - w->print (' '); - - w->unsetTransShadow(); - - if ( w->isMonochron() ) - w->setReverse(false); -} - -//---------------------------------------------------------------------- -void drawBlockShadow (FWidget* w, int x1, int y1, int x2, int y2) -{ - // non-transparent shadow - - if ( ! w->hasShadowCharacter() ) - return; - - w->print() << FPoint(x2 + 1, y1); - - if ( w->isWindowWidget() ) - { - w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg); - w->setInheritBackground(); // current background color will be ignored - } - else if ( auto p = w->getParentWidget() ) - w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor()); - - w->print (fc::LowerHalfBlock); // ▄ - - if ( w->isWindowWidget() ) - w->unsetInheritBackground(); - - for (std::size_t y{1}; y < w->getHeight(); y++) - { - w->print() << FPoint(x2 + 1, y1 + int(y)) << fc::FullBlock; // █ - } - - w->print() << FPoint(x1 + 1, y2 + 1); - - if ( w->isWindowWidget() ) - w->setInheritBackground(); - - for (std::size_t x{1}; x <= w->getWidth(); x++) - w->print (fc::UpperHalfBlock); // ▀ - - if ( w->isWindowWidget() ) - w->unsetInheritBackground(); -} - -//---------------------------------------------------------------------- -void clearShadow (FWidget* w) -{ - if ( w->isMonochron() ) - return; - - int width = int(w->getWidth()); - int height = int(w->getHeight()); - - if ( w->isWindowWidget() ) - { - w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg); - w->setInheritBackground(); // current background color will be ignored - } - else if ( auto p = w->getParentWidget() ) - w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor()); - - if ( width <= w->woffset.getX2() ) - { - for (std::size_t y{1}; y <= w->getHeight(); y++) - { - w->print() << FPoint(width + 1, int(y)) << ' '; // clear █ - } - } - - if ( height <= w->woffset.getY2() ) - { - w->print() << FPoint(2, height + 1); - - for (std::size_t i{1}; i <= w->getWidth(); i++) - w->print (' '); // clear ▀ - } - - if ( w->isWindowWidget() ) - w->unsetInheritBackground(); -} - -//---------------------------------------------------------------------- -void drawFlatBorder (FWidget* w) -{ - if ( ! w->isNewFont() ) - return; - - int x1 = 1; - int x2 = int(w->getWidth() + 1); - int y1 = 0; - int y2 = int(w->getHeight() + 1); - - if ( auto p = w->getParentWidget() ) - w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor()); - else - w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg); - - for (std::size_t y{0}; y < w->getHeight(); y++) - { - w->print() << FPoint(x1 - 1, y1 + int(y) + 1); - - if ( w->double_flatline_mask.left[uLong(y)] ) - // left+right line (on left side) - w->print (fc::NF_rev_border_line_right_and_left); - else - // right line (on left side) - w->print (fc::NF_rev_border_line_right); - } - - w->print() << FPoint(x2, y1 + 1); - - for (std::size_t y{0}; y < w->getHeight(); y++) - { - if ( w->double_flatline_mask.right[y] ) - // left+right line (on right side) - w->print (fc::NF_rev_border_line_right_and_left); - else - // left line (on right side) - w->print (fc::NF_border_line_left); - - w->print() << FPoint(x2, y1 + int(y) + 2); - } - - w->print() << FPoint(x1, y1); - - for (std::size_t x{0}; x < w->getWidth(); x++) - { - if ( w->double_flatline_mask.top[x] ) - // top+bottom line (at top) - w->print (fc::NF_border_line_up_and_down); - else - // bottom line (at top) - w->print (fc::NF_border_line_bottom); - } - - w->print() << FPoint(x1, y2); - - for (std::size_t x{0}; x < w->getWidth(); x++) - { - if ( w->double_flatline_mask.bottom[x] ) - // top+bottom line (at bottom) - w->print (fc::NF_border_line_up_and_down); - else - // top line (at bottom) - w->print (fc::NF_border_line_upper); - } -} - -//---------------------------------------------------------------------- -void clearFlatBorder (FWidget* w) -{ - if ( ! w->isNewFont() ) - return; - - int x1 = 1; - int x2 = int(w->getWidth() + 1); - int y1 = 0; - int y2 = int(w->getHeight() + 1); - - if ( auto p = w->getParentWidget() ) - w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor()); - else - w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg); - - // clear on left side - for (std::size_t y{0}; y < w->getHeight(); y++) - { - w->print() << FPoint(x1 - 1, y1 + int(y) + 1); - - if ( w->double_flatline_mask.left[y] ) - w->print (fc::NF_border_line_left); - else - w->print (' '); - } - - // clear on right side - for (std::size_t y{0}; y < w->getHeight(); y++) - { - w->print() << FPoint(x2, y1 + int(y) + 1); - - if ( w->double_flatline_mask.right[y] ) - w->print (fc::NF_rev_border_line_right); - else - w->print (' '); - } - - // clear at top - w->print() << FPoint(x1, y1); - - for (std::size_t x{0}; x < w->getWidth(); x++) - { - if ( w->double_flatline_mask.top[x] ) - w->print (fc::NF_border_line_upper); - else - w->print (' '); - } - - // clear at bottom - w->print() << FPoint(x1, y2); - - for (std::size_t x{0}; x < w->getWidth(); x++) - { - if ( w->double_flatline_mask.bottom[x] ) - w->print (fc::NF_border_line_bottom); - else - w->print (' '); - } -} - -//---------------------------------------------------------------------- -inline void drawBox (FWidget* w, const FRect& r) -{ - // Use box-drawing characters to draw a border - - if ( ! w ) - return; - - w->print() << r.getUpperLeftPos() << fc::BoxDrawingsDownAndRight; // ┌ - - for (int x = r.getX1() + 1; x < r.getX2(); x++) - w->print (fc::BoxDrawingsHorizontal); // ─ - - w->print (fc::BoxDrawingsDownAndLeft); // ┐ - - for (int y = r.getY1() + 1; y < r.getY2(); y++) - { - w->print() << FPoint(r.getX1(), y) - << fc::BoxDrawingsVertical // │ - << FPoint(r.getX2(), y) - << fc::BoxDrawingsVertical; // │ - } - - w->print() << r.getLowerLeftPos() << fc::BoxDrawingsUpAndRight; // └ - - for (int x = r.getX1() + 1; x < r.getX2(); x++) - w->print (fc::BoxDrawingsHorizontal); // ─ - - w->print (fc::BoxDrawingsUpAndLeft); // ┘ -} - -//---------------------------------------------------------------------- -inline void drawNewFontBox (FWidget* w, const FRect& r) -{ - // Use new graphical font characters to draw a border - - w->print() << r.getUpperLeftPos() - << fc::NF_border_corner_middle_upper_left; // ┌ - for (int x = r.getX1() + 1; x < r.getX2(); x++) - w->print (fc::BoxDrawingsHorizontal); // ─ - - w->print (fc::NF_border_corner_middle_upper_right); // ┐ - - for (int y = r.getY1() + 1; y < r.getY2(); y++) - { - w->print() << FPoint(r.getX1(), y) - << fc::NF_border_line_left // border left ⎸ - << FPoint(r.getX2(), y) - << fc::NF_rev_border_line_right; // border right⎹ - } - - w->print() << r.getLowerLeftPos() - << fc::NF_border_corner_middle_lower_left; // └ - - for (int x = r.getX1() + 1; x < r.getX2(); x++) - w->print (fc::BoxDrawingsHorizontal); // ─ - - w->print (fc::NF_border_corner_middle_lower_right); // ┘ -} - -//---------------------------------------------------------------------- -void drawBorder (FWidget* w, FRect r) -{ - if ( r.x1_ref() > r.x2_ref() ) - std::swap (r.x1_ref(), r.x2_ref()); - - if ( r.y1_ref() > r.y2_ref() ) - std::swap (r.y1_ref(), r.y2_ref()); - - if ( r.x1_ref() < 1 ) - r.x1_ref() = 1; - - if ( r.y1_ref() < 1 ) - r.y1_ref() = 1; - - if ( r.x2_ref() > int(w->getWidth()) ) - r.x2_ref() = int(w->getWidth()); - - if ( r.y2_ref() > int(w->getHeight()) ) - r.y2_ref() = int(w->getHeight()); - - if ( w->isNewFont() ) - drawNewFontBox (w, r); - else - drawBox (w, r); -} - } // namespace finalcut diff --git a/src/fwidget_functions.cpp b/src/fwidget_functions.cpp new file mode 100644 index 00000000..03dae7bf --- /dev/null +++ b/src/fwidget_functions.cpp @@ -0,0 +1,428 @@ +/*********************************************************************** +* fwidget_functions.cpp - FWidget helper functions * +* * +* This file is part of the Final Cut widget toolkit * +* * +* Copyright 2019 Markus Gans * +* * +* The 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. * +* * +* The 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 * +* . * +***********************************************************************/ + +#include "final/fwidget.h" +#include "final/fwidgetcolors.h" + +namespace finalcut +{ + +// FWidget non-member functions +//---------------------------------------------------------------------- +FKey getHotkey (const FString& text) +{ + // Returns the hotkey character from a string + // e.g. "E&xit" returns 'x' + + if ( text.isEmpty() ) + return 0; + + std::size_t length = text.getLength(); + + for (std::size_t i{0}; i < length; i++) + { + try + { + if ( i + 1 < length && text[i] == '&' ) + return FKey(text[++i]); + } + catch (const std::out_of_range&) + { + return 0; + } + } + return 0; +} + +//---------------------------------------------------------------------- +std::size_t getHotkeyPos (const FString& src, FString& dest) +{ + // Find hotkey position in string + // + generate a new string without the '&'-sign + + constexpr std::size_t NOT_SET = static_cast(-1); + std::size_t hotkeypos{NOT_SET}; + std::size_t i{0}; + + for (auto&& ch : src) + { + if ( ch == L'&' && hotkeypos == NOT_SET && src.getLength() != i + 1 ) + hotkeypos = i; + else + dest += ch; + + i++; + } + + return hotkeypos; +} +//---------------------------------------------------------------------- +void setHotkeyViaString (FWidget* w, const FString& text) +{ + // Set hotkey accelerator via string + + if ( ! w ) + return; + + FKey hotkey = getHotkey(text); + + if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character + hotkey -= 0xfee0; + + if ( hotkey ) + { + if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) ) + { + w->addAccelerator (FKey(std::tolower(int(hotkey)))); + w->addAccelerator (FKey(std::toupper(int(hotkey)))); + // Meta + hotkey + w->addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))); + } + else + w->addAccelerator (hotkey); + } + else + w->delAccelerator(); +} + +//---------------------------------------------------------------------- +void drawShadow (FWidget* w) +{ + if ( w->isMonochron() && ! w->flags.trans_shadow ) + return; + + if ( (w->getEncoding() == fc::VT100 && ! w->flags.trans_shadow) + || (w->getEncoding() == fc::ASCII && ! w->flags.trans_shadow) ) + { + clearShadow(w); + return; + } + + if ( w->flags.trans_shadow ) + drawTransparentShadow (w); // transparent shadow + else + drawBlockShadow (w); // non-transparent shadow +} + +//---------------------------------------------------------------------- +void drawTransparentShadow (FWidget* w) +{ + // transparent shadow + + std::size_t width = w->getWidth(); + std::size_t height = w->getHeight(); + w->setTransparent(); + w->print() << FPoint(int(width) + 1, 1) << " "; + w->unsetTransparent(); + w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg); + w->setTransShadow(); + + for (std::size_t y{1}; y < height; y++) + { + w->print() << FPoint(int(width) + 1, int(y) + 1) << " "; + } + + w->unsetTransShadow(); + w->setTransparent(); + w->print() << FPoint(1, int(height) + 1) << " "; + w->unsetTransparent(); + w->setColor (w->wcolors.shadow_bg, w->wcolors.shadow_fg); + w->setTransShadow(); + w->print() << FString(width, L' '); + + w->unsetTransShadow(); + + if ( w->isMonochron() ) + w->setReverse(false); +} + +//---------------------------------------------------------------------- +void drawBlockShadow (FWidget* w) +{ + // non-transparent shadow + + if ( ! w->hasShadowCharacter() ) + return; + + std::size_t width = w->getWidth(); + std::size_t height = w->getHeight(); + w->print() << FPoint(int(width) + 1, 1); + + if ( w->isWindowWidget() ) + { + w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg); + w->setInheritBackground(); // current background color will be ignored + } + else if ( auto p = w->getParentWidget() ) + w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor()); + + w->print (fc::LowerHalfBlock); // ▄ + + if ( w->isWindowWidget() ) + w->unsetInheritBackground(); + + for (std::size_t y{1}; y < height; y++) + { + w->print() << FPoint(int(width) + 1, int(y) + 1) << fc::FullBlock; // █ + } + + w->print() << FPoint(2, int(height) + 1); + + if ( w->isWindowWidget() ) + w->setInheritBackground(); + + w->print() << FString(width, fc::UpperHalfBlock); // ▀ + + if ( w->isWindowWidget() ) + w->unsetInheritBackground(); +} + +//---------------------------------------------------------------------- +void clearShadow (FWidget* w) +{ + if ( w->isMonochron() ) + return; + + std::size_t width = w->getWidth(); + std::size_t height = w->getHeight(); + + if ( w->isWindowWidget() ) + { + w->setColor (w->wcolors.shadow_fg, w->wcolors.shadow_bg); + w->setInheritBackground(); // current background color will be ignored + } + else if ( auto p = w->getParentWidget() ) + w->setColor (w->wcolors.shadow_fg, p->getBackgroundColor()); + + if ( int(width) <= w->woffset.getX2() ) + { + for (std::size_t y{1}; y <= height; y++) + { + w->print() << FPoint(int(width) + 1, int(y)) << ' '; // clear █ + } + } + + if ( int(height) <= w->woffset.getY2() ) + { + w->print() << FPoint(2, int(height) + 1) + << FString(width, L' '); // clear ▀ + } + + if ( w->isWindowWidget() ) + w->unsetInheritBackground(); +} + +//---------------------------------------------------------------------- +void drawFlatBorder (FWidget* w) +{ + if ( ! w->isNewFont() ) + return; + + if ( auto p = w->getParentWidget() ) + w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor()); + else + w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg); + + std::size_t width = w->getWidth(); + std::size_t height = w->getHeight(); + + for (std::size_t y{0}; y < height; y++) + { + w->print() << FPoint(0, int(y) + 1); + + if ( w->double_flatline_mask.left[uLong(y)] ) + // left+right line (on left side) + w->print (fc::NF_rev_border_line_right_and_left); + else + // right line (on left side) + w->print (fc::NF_rev_border_line_right); + + w->print() << FPoint(int(width) + 1, int(y) + 1); + + if ( w->double_flatline_mask.right[y] ) + // left+right line (on right side) + w->print (fc::NF_rev_border_line_right_and_left); + else + // left line (on right side) + w->print (fc::NF_border_line_left); + } + + w->print() << FPoint(1, 0); + + for (std::size_t x{0}; x < width; x++) + { + if ( w->double_flatline_mask.top[x] ) + // top+bottom line (at top) + w->print (fc::NF_border_line_up_and_down); + else + // bottom line (at top) + w->print (fc::NF_border_line_bottom); + } + + w->print() << FPoint(1, int(height) + 1); + + for (std::size_t x{0}; x < width; x++) + { + if ( w->double_flatline_mask.bottom[x] ) + // top+bottom line (at bottom) + w->print (fc::NF_border_line_up_and_down); + else + // top line (at bottom) + w->print (fc::NF_border_line_upper); + } +} + +//---------------------------------------------------------------------- +void clearFlatBorder (FWidget* w) +{ + if ( ! w->isNewFont() ) + return; + + if ( auto p = w->getParentWidget() ) + w->setColor (w->wcolors.dialog_fg, p->getBackgroundColor()); + else + w->setColor (w->wcolors.dialog_fg, w->wcolors.dialog_bg); + + std::size_t width = w->getWidth(); + std::size_t height = w->getHeight(); + + for (std::size_t y{0}; y < height; y++) + { + // clear on left side + w->print() << FPoint(0, int(y) + 1); + + if ( w->double_flatline_mask.left[y] ) + w->print (fc::NF_border_line_left); + else + w->print (' '); + + // clear on right side + w->print() << FPoint(int(width) + 1, int(y) + 1); + + if ( w->double_flatline_mask.right[y] ) + w->print (fc::NF_rev_border_line_right); + else + w->print (' '); + } + + // clear at top + w->print() << FPoint(1, 0); + + for (std::size_t x{0}; x < width; x++) + { + if ( w->double_flatline_mask.top[x] ) + w->print (fc::NF_border_line_upper); + else + w->print (' '); + } + + // clear at bottom + w->print() << FPoint(1, int(height) + 1); + + for (std::size_t x{0}; x < width; x++) + { + if ( w->double_flatline_mask.bottom[x] ) + w->print (fc::NF_border_line_bottom); + else + w->print (' '); + } +} + +//---------------------------------------------------------------------- +void drawBorder (FWidget* w, FRect r) +{ + if ( r.x1_ref() > r.x2_ref() ) + std::swap (r.x1_ref(), r.x2_ref()); + + if ( r.y1_ref() > r.y2_ref() ) + std::swap (r.y1_ref(), r.y2_ref()); + + if ( r.x1_ref() < 1 ) + r.x1_ref() = 1; + + if ( r.y1_ref() < 1 ) + r.y1_ref() = 1; + + if ( r.x2_ref() > int(w->getWidth()) ) + r.x2_ref() = int(w->getWidth()); + + if ( r.y2_ref() > int(w->getHeight()) ) + r.y2_ref() = int(w->getHeight()); + + if ( w->isNewFont() ) + drawNewFontBox (w, r); + else + drawBox (w, r); +} + +//---------------------------------------------------------------------- +inline void drawBox (FWidget* w, const FRect& r) +{ + // Use box-drawing characters to draw a border + + if ( ! w ) + return; + + w->print() << r.getUpperLeftPos() + << fc::BoxDrawingsDownAndRight // ┌ + << FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─ + << fc::BoxDrawingsDownAndLeft; // ┐ + + for (int y = r.getY1() + 1; y < r.getY2(); y++) + { + w->print() << FPoint(r.getX1(), y) + << fc::BoxDrawingsVertical // │ + << FPoint(r.getX2(), y) + << fc::BoxDrawingsVertical; // │ + } + + w->print() << r.getLowerLeftPos() + << fc::BoxDrawingsUpAndRight // └ + << FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─ + << fc::BoxDrawingsUpAndLeft; // ┘ +} + +//---------------------------------------------------------------------- +inline void drawNewFontBox (FWidget* w, const FRect& r) +{ + // Use new graphical font characters to draw a border + + w->print() << r.getUpperLeftPos() + << fc::NF_border_corner_middle_upper_left // ┌ + << FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─ + << fc::NF_border_corner_middle_upper_right; // ┐ + + for (int y = r.getY1() + 1; y < r.getY2(); y++) + { + w->print() << FPoint(r.getX1(), y) + << fc::NF_border_line_left // border left ⎸ + << FPoint(r.getX2(), y) + << fc::NF_rev_border_line_right; // border right⎹ + } + + w->print() << r.getLowerLeftPos() + << fc::NF_border_corner_middle_lower_left // └ + << FString(r.getWidth() - 2, fc::BoxDrawingsHorizontal) // ─ + << fc::NF_border_corner_middle_lower_right; // ┘ +} + +} // namespace finalcut diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 84073a79..780c6f6a 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -117,8 +117,8 @@ class FApplication : public FWidget // Methods int exec(); // run - int enter_loop(); - void exit_loop(); + int enterLoop(); + void exitLoop(); static void exit (int = 0); void quit(); static bool sendEvent (const FObject*, const FEvent*); diff --git a/src/include/final/fkey_map.h b/src/include/final/fkey_map.h index d3cd2bce..ceacace7 100644 --- a/src/include/final/fkey_map.h +++ b/src/include/final/fkey_map.h @@ -33,9 +33,9 @@ namespace finalcut namespace fc { -extern fkeymap Fkey[]; -extern fmetakeymap Fmetakey[]; -extern keyname FkeyName[]; +extern FKeyMap fkey[]; +extern FMetakeyMap fmetakey[]; +extern FKeyName fkeyname[]; } // namespace fc diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index dd94a3ce..1bb61c3e 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -106,7 +106,7 @@ class FKeyboard final timeval* getKeyPressedTime(); // Mutators - void setTermcapMap (fc::fkeymap*); + void setTermcapMap (fc::FKeyMap*); void setKeypressTimeout (const uInt64); void enableUTF8(); void disableUTF8(); @@ -170,7 +170,7 @@ class FKeyboard final static timeval time_keypressed; static uInt64 key_timeout; - fc::fkeymap* key_map{nullptr}; + fc::FKeyMap* key_map{nullptr}; FKey key{0}; char read_buf[READ_BUF_SIZE]{'\0'}; char fifo_buf[FIFO_BUF_SIZE]{'\0'}; diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 4bc42422..2e764615 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -149,7 +149,7 @@ class FMouse uChar wheel_down : 1; // 0..1 uChar mouse_moved : 1; // 0..1 uChar : 4; // padding bits - } button; // bit field + } FMouseButton; // bit field enum states { @@ -160,7 +160,7 @@ class FMouse }; // Accessors - button& getButtonState(); + FMouseButton& getButtonState(); FPoint& getNewPos(); uInt16 getMaxWidth(); uInt16 getMaxHeight(); @@ -180,7 +180,7 @@ class FMouse private: // Data members - button b_state{}; + FMouseButton b_state{}; bool mouse_event_occurred{false}; bool input_data_pending{false}; uInt16 max_width{80}; diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h index 9f0edab6..96921ac9 100644 --- a/src/include/final/fobject.h +++ b/src/include/final/fobject.h @@ -126,7 +126,7 @@ class FObject bool delAllTimer(); protected: - struct timer_data + struct FTimerData { int id; timeval interval; @@ -135,10 +135,10 @@ class FObject }; // Typedefs - typedef std::vector TimerList; + typedef std::vector FTimerList; // Accessor - TimerList* getTimerList() const; + FTimerList* getTimerList() const; // Mutator void setWidgetProperty (bool); @@ -161,7 +161,7 @@ class FObject bool has_parent{false}; bool widget_object{false}; static bool timer_modify_lock; - static TimerList* timer_list; + static FTimerList* timer_list; }; @@ -226,7 +226,7 @@ inline bool FObject::isTimerInUpdating() const { return timer_modify_lock; } //---------------------------------------------------------------------- -inline FObject::TimerList* FObject::getTimerList() const +inline FObject::FTimerList* FObject::getTimerList() const { return timer_list; } //---------------------------------------------------------------------- diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index 5c930449..bb5f1fc8 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -126,8 +126,8 @@ class FOptiAttr final FOptiAttr& operator = (const FOptiAttr&) = delete; // Friend operator functions - friend bool operator == (const charData&, const charData&); - friend bool operator != (const charData&, const charData&); + friend bool operator == (const FChar&, const FChar&); + friend bool operator != (const FChar&, const FChar&); // Accessors const FString getClassName() const; @@ -175,12 +175,12 @@ class FOptiAttr final void set_orig_orig_colors (char[]); // Inquiry - static bool isNormal (charData*&); + static bool isNormal (FChar*&); // Methods void initialize(); static FColor vga2ansi (FColor); - char* changeAttribute (charData*&, charData*&); + char* changeAttribute (FChar*&, FChar*&); private: // Typedefs and Enumerations @@ -223,62 +223,62 @@ class FOptiAttr final }; // Mutators - bool setTermBold (charData*&); - bool unsetTermBold (charData*&); - bool setTermDim (charData*&); - bool unsetTermDim (charData*&); - bool setTermItalic (charData*&); - bool unsetTermItalic (charData*&); - bool setTermUnderline (charData*&); - bool unsetTermUnderline (charData*&); - bool setTermBlink (charData*&); - bool unsetTermBlink (charData*&); - bool setTermReverse (charData*&); - bool unsetTermReverse (charData*&); - bool setTermStandout (charData*&); - bool unsetTermStandout (charData*&); - bool setTermInvisible (charData*&); - bool unsetTermInvisible (charData*&); - bool setTermProtected (charData*&); - bool unsetTermProtected (charData*&); - bool setTermCrossedOut (charData*&); - bool unsetTermCrossedOut (charData*&); - bool setTermDoubleUnderline (charData*&); - bool unsetTermDoubleUnderline (charData*&); - bool setTermAttributes ( charData*& + bool setTermBold (FChar*&); + bool unsetTermBold (FChar*&); + bool setTermDim (FChar*&); + bool unsetTermDim (FChar*&); + bool setTermItalic (FChar*&); + bool unsetTermItalic (FChar*&); + bool setTermUnderline (FChar*&); + bool unsetTermUnderline (FChar*&); + bool setTermBlink (FChar*&); + bool unsetTermBlink (FChar*&); + bool setTermReverse (FChar*&); + bool unsetTermReverse (FChar*&); + bool setTermStandout (FChar*&); + bool unsetTermStandout (FChar*&); + bool setTermInvisible (FChar*&); + bool unsetTermInvisible (FChar*&); + bool setTermProtected (FChar*&); + bool unsetTermProtected (FChar*&); + bool setTermCrossedOut (FChar*&); + bool unsetTermCrossedOut (FChar*&); + bool setTermDoubleUnderline (FChar*&); + bool unsetTermDoubleUnderline (FChar*&); + bool setTermAttributes ( FChar*& , bool, bool, bool , bool, bool, bool , bool, bool, bool ); - bool unsetTermAttributes (charData*&); - bool setTermAltCharset (charData*&); - bool unsetTermAltCharset (charData*&); - bool setTermPCcharset (charData*&); - bool unsetTermPCcharset (charData*&); - bool setTermDefaultColor (charData*&); - void setAttributesOn (charData*&); - void setAttributesOff (charData*&); + bool unsetTermAttributes (FChar*&); + bool setTermAltCharset (FChar*&); + bool unsetTermAltCharset (FChar*&); + bool setTermPCcharset (FChar*&); + bool unsetTermPCcharset (FChar*&); + bool setTermDefaultColor (FChar*&); + void setAttributesOn (FChar*&); + void setAttributesOff (FChar*&); // Inquiries - static bool hasColor (charData*&); - static bool hasAttribute (charData*&); - static bool hasNoAttribute (charData*&); + static bool hasColor (FChar*&); + static bool hasAttribute (FChar*&); + static bool hasNoAttribute (FChar*&); // Methods - bool hasColorChanged (charData*&, charData*&); - void resetColor (charData*&); - void prevent_no_color_video_attributes (charData*&, bool = false); - void deactivateAttributes (charData*&, charData*&); - void changeAttributeSGR (charData*&, charData*&); - void changeAttributeSeparately (charData*&, charData*&); - void change_color (charData*&, charData*&); - void change_to_default_color (charData*&, charData*&, FColor&, FColor&); - void change_current_color (charData*&, FColor, FColor); - void resetAttribute (charData*&); - void reset (charData*&); + bool hasColorChanged (FChar*&, FChar*&); + void resetColor (FChar*&); + void prevent_no_color_video_attributes (FChar*&, bool = false); + void deactivateAttributes (FChar*&, FChar*&); + void changeAttributeSGR (FChar*&, FChar*&); + void changeAttributeSeparately (FChar*&, FChar*&); + void change_color (FChar*&, FChar*&); + void change_to_default_color (FChar*&, FChar*&, FColor&, FColor&); + void change_current_color (FChar*&, FColor, FColor); + void resetAttribute (FChar*&); + void reset (FChar*&); bool caused_reset_attributes (char[], uChar = all_tests); bool hasCharsetEquivalence(); - void detectSwitchOn (charData*&, charData*&); - void detectSwitchOff (charData*&, charData*&); + void detectSwitchOn (FChar*&, FChar*&); + void detectSwitchOff (FChar*&, FChar*&); bool switchOn(); bool switchOff(); bool append_sequence (char[]); @@ -320,9 +320,9 @@ class FOptiAttr final capability F_orig_pair{}; capability F_orig_colors{}; - charData on{}; - charData off{}; - charData reset_byte_mask{}; + FChar on{}; + FChar off{}; + FChar reset_byte_mask{}; int max_color{1}; int attr_without_color{0}; @@ -337,10 +337,10 @@ class FOptiAttr final // FOptiAttr inline functions //---------------------------------------------------------------------- -inline bool operator == ( const charData& lhs, - const charData& rhs ) +inline bool operator == ( const FChar& lhs, + const FChar& rhs ) { - return lhs.code == rhs.code + return lhs.ch == rhs.ch && lhs.fg_color == rhs.fg_color && lhs.bg_color == rhs.bg_color && lhs.attr.byte[0] == rhs.attr.byte[0] @@ -350,8 +350,8 @@ inline bool operator == ( const charData& lhs, } //---------------------------------------------------------------------- -inline bool operator != ( const charData& lhs, - const charData& rhs ) +inline bool operator != ( const FChar& lhs, + const FChar& rhs ) { return ! ( lhs == rhs ); } //---------------------------------------------------------------------- diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index bedd5ce9..8f79310d 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -146,7 +146,7 @@ class FScrollView : public FWidget using FVTerm::clearArea; // Accessor - term_area* getPrintArea() override; + FTermArea* getPrintArea() override; // Methods void adjustSize() override; @@ -182,7 +182,7 @@ class FScrollView : public FWidget // Data members FRect scroll_geometry{1, 1, 1, 1}; FRect viewport_geometry{}; - term_area* viewport{nullptr}; // virtual scroll content + FTermArea* viewport{nullptr}; // virtual scroll content FScrollbarPtr vbar{nullptr}; FScrollbarPtr hbar{nullptr}; keyMap key_map{}; @@ -279,7 +279,7 @@ inline void FScrollView::initScrollbar ( FScrollbarPtr& bar , Callback cb_handler ) { finalcut::initScrollbar (bar, o, this, cb_handler); - term_area* area = getPrintArea(); + FTermArea* area = getPrintArea(); bar->setPrintArea(area); } diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 86778ef9..8b36ed69 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -210,7 +210,7 @@ class FTerm final #endif // Inquiries - static bool isNormal (charData*&); + static bool isNormal (FChar*&); static bool isRaw(); static bool hasUTF8(); static bool hasVT100(); @@ -290,8 +290,8 @@ class FTerm final static int putchar_UTF8 (int); static void initScreenSettings(); - static char* changeAttribute ( charData*& - , charData*& ); + static char* changeAttribute ( FChar*& + , FChar*& ); static void changeTermSizeFinished(); static void exitWithMessage (const FString&) #if defined(__clang__) || defined(__GNUC__) @@ -385,17 +385,19 @@ class FTerm final // non-member function forward declarations +// implemented in fterm_functions.cpp //---------------------------------------------------------------------- +uInt env2uint (const char*); wchar_t cp437_to_unicode (uChar); uChar unicode_to_cp437 (wchar_t); FString getFullWidth (const FString&); FString getHalfWidth (const FString&); -std::size_t getColumnWidthToLength (const FString&, std::size_t); FString getColumnSubString (const FString&, std::size_t, std::size_t); +std::size_t getLengthFromColumnWidth (const FString&, std::size_t); std::size_t getColumnWidth (const FString&, std::size_t); std::size_t getColumnWidth (const FString&); std::size_t getColumnWidth (const wchar_t); -std::size_t getColumnWidth (charData&); +std::size_t getColumnWidth (FChar&); std::size_t getColumnWidth (const FTermBuffer&); diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index d3b32ae1..44852e62 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -54,9 +54,9 @@ class FTermBuffer { public: // Typedef - typedef std::vector charDataVector; - typedef charDataVector::iterator iterator; - typedef charDataVector::const_iterator const_iterator; + typedef std::vector FCharVector; + typedef FCharVector::iterator iterator; + typedef FCharVector::const_iterator const_iterator; // Constructor FTermBuffer() = default; @@ -69,19 +69,19 @@ class FTermBuffer // Overloaded operators template FTermBuffer& operator << (const typeT&); - FTermBuffer& operator << (const charDataVector&); + FTermBuffer& operator << (const FCharVector&); FTermBuffer& operator << (const std::string&); FTermBuffer& operator << (const std::wstring&); FTermBuffer& operator << (const FColorPair&); // Non-member operators - friend charDataVector& operator << ( charDataVector& - , const FTermBuffer& ); + friend FCharVector& operator << ( FCharVector& + , const FTermBuffer& ); // Accessors virtual const FString getClassName() const; std::size_t getLength() const; - const charDataVector& getBuffer() const; + const FCharVector& getBuffer() const; // Inquiry bool isEmpty() const; @@ -91,8 +91,8 @@ class FTermBuffer iterator end(); const_iterator begin() const; const_iterator end() const; - charData front() const; - charData back() const; + FChar front() const; + FChar back() const; const FString toString() const; void clear(); template @@ -103,7 +103,7 @@ class FTermBuffer FTermBuffer& write (); private: - charDataVector data{}; + FCharVector data{}; }; @@ -129,7 +129,7 @@ inline FTermBuffer& FTermBuffer::operator << (const typeT& s) } //---------------------------------------------------------------------- -inline FTermBuffer& FTermBuffer::operator << (const charDataVector& vec) +inline FTermBuffer& FTermBuffer::operator << (const FCharVector& vec) { for (auto&& tc : vec) data.push_back(tc); @@ -167,7 +167,7 @@ inline std::size_t FTermBuffer::getLength() const { return data.size(); } //---------------------------------------------------------------------- -inline const FTermBuffer::charDataVector& FTermBuffer::getBuffer() const +inline const FTermBuffer::FCharVector& FTermBuffer::getBuffer() const { return data; } //---------------------------------------------------------------------- @@ -191,11 +191,11 @@ inline FTermBuffer::const_iterator FTermBuffer::end() const { return data.end(); } //---------------------------------------------------------------------- -inline charData FTermBuffer::front() const +inline FChar FTermBuffer::front() const { return data.front(); } //---------------------------------------------------------------------- -inline charData FTermBuffer::back() const +inline FChar FTermBuffer::back() const { return data.back(); } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 9daaa9e3..6861ef90 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -77,7 +77,7 @@ class FTermDetection final uInt8 screen : 1; uInt8 tmux : 1; uInt8 : 5; // padding bits - } terminalType; + } FTerminalType; // Constructors FTermDetection(); @@ -89,7 +89,7 @@ class FTermDetection final const FString getClassName() const; static char* getTermType(); static int getGnomeTerminalID(); - terminalType& getTermTypeStruct(); + FTerminalType& getTermTypeStruct(); #if DEBUG static const FString& getAnswerbackString(); @@ -199,7 +199,7 @@ class FTermDetection final static const FString* sec_da; static FTermData* fterm_data; static FSystem* fsystem; - static terminalType terminal_type; + static FTerminalType terminal_type; static struct colorEnv { @@ -234,7 +234,7 @@ inline int FTermDetection::getGnomeTerminalID() { return gnome_terminal_id; } //---------------------------------------------------------------------- -inline FTermDetection::terminalType& FTermDetection::getTermTypeStruct() +inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct() { return terminal_type; } #if DEBUG diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index f3a66719..20459bf3 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -36,11 +36,18 @@ #endif #if defined(__linux__) - #include // Linux framebuffer console + #include // Linux framebuffer console - #if defined(__x86_64__) || defined(__i386) || defined(__arm__) - #include // is deprecated - #endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) + #if defined(__arm__) && defined(__GLIBC__) && defined(__GLIBC_PREREQ) + // ISA sysctl support on arm processors only up to glibc-2.29 + #if !__GLIBC_PREREQ(2,30) + #define ARM_ISA_SYSCTL + #endif + #endif + + #if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) + #include + #endif // defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) #include #endif // defined(__linux__) @@ -150,7 +157,7 @@ class FTermLinux final void setLinuxCursorStyle (fc::linuxConsoleCursorStyle); // Methods -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) uInt16 getInputStatusRegisterOne(); uChar readAttributeController (uChar); void writeAttributeController (uChar, uChar); @@ -162,7 +169,7 @@ class FTermLinux final bool setVGAPalette (FColor, int, int, int); bool saveVGAPalette(); bool resetVGAPalette(); -#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) +#endif // defined(__x86_64__) || defined(__i386) || defined(ARM_ISA_SYSCTL) FKey shiftKeyCorrection (const FKey&); FKey ctrlKeyCorrection (const FKey&); FKey altKeyCorrection (const FKey&); diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 5273839e..196f3a14 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -81,7 +81,7 @@ class FTermOpenBSD final FTermOpenBSD (const FTermOpenBSD&) = delete; // Destructor - virtual ~FTermOpenBSD() = default; + virtual ~FTermOpenBSD(); // Disable assignment operator (=) FTermOpenBSD& operator = (const FTermOpenBSD&) = delete; diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index f5c61aa2..9f902d45 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -53,9 +53,15 @@ class FTermXTerminal final // Constructors FTermXTerminal(); + // Disable copy constructor + FTermXTerminal (const FTermXTerminal&) = delete; + // Destructor virtual ~FTermXTerminal(); + // Disable assignment operator (=) + FTermXTerminal& operator = (const FTermXTerminal&) = delete; + // Mutators void redefineDefaultColors (bool); void setCursorStyle (fc::xtermCursorStyle); diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index 8954ea67..2f17b5de 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -108,8 +108,8 @@ typedef std::unordered_map charSubstitution; typedef struct { - wchar_t code; // character code - wchar_t encoded_code; // encoded output character + wchar_t ch; // character code + wchar_t encoded_char; // encoded output character FColor fg_color; // foreground color FColor bg_color; // background color @@ -147,7 +147,7 @@ typedef struct uInt8 byte[4]; } attr; -} charData; +} FChar; namespace fc { @@ -158,21 +158,21 @@ typedef struct char* string; char tname[4]; } -fkeymap; +FKeyMap; typedef struct { FKey num; char string[8]; } -fmetakeymap; +FMetakeyMap; typedef struct { FKey num; char string[25]; } -keyname; +FKeyName; } // namespace fc diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 9a685c97..c323346e 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -92,20 +92,20 @@ class FVTerm uInt xmin; // X-position with the first change uInt xmax; // X-position with the last change uInt trans_count; // Number of transparent characters - } line_changes; + } FLineChanges; typedef void (FVTerm::*FPreprocessingHandler)(); - typedef std::function FVTermPreprocessing; + typedef std::function FPreprocessingFunction; - struct term_area; // forward declaration + struct FTermArea; // forward declaration - struct vterm_preprocessing + struct FVTermPreprocessing { FVTerm* instance; - FVTermPreprocessing function; + FPreprocessingFunction function; }; - typedef std::vector FPreprocessing; + typedef std::vector FPreprocessing; enum covered_state { @@ -139,7 +139,7 @@ class FVTerm FVTerm& operator << (fc::SpecialCharacter); FVTerm& operator << (const std::string&); FVTerm& operator << (const FTermBuffer&); - FVTerm& operator << (const std::vector&); + FVTerm& operator << (const std::vector&); FVTerm& operator << (const FPoint&); FVTerm& operator << (const FColorPair&); @@ -147,10 +147,10 @@ class FVTerm virtual const FString getClassName() const; static FColor getTermForegroundColor(); static FColor getTermBackgroundColor(); - term_area*& getVWin(); - const term_area* getVWin() const; + FTermArea*& getVWin(); + const FTermArea* getVWin() const; FPoint getPrintCursor(); - static charData getAttribute(); + static FChar getAttribute(); static int getMaxColor(); static int getTabstop(); static fc::encoding getEncoding(); @@ -290,20 +290,20 @@ class FVTerm void updateTerminal (terminal_update); void updateTerminal(); virtual void addPreprocessingHandler ( FVTerm* - , FVTermPreprocessing ); + , FPreprocessingFunction ); virtual void delPreprocessingHandler (FVTerm*); template int printf (const FString, Args&&...); int print (const FString&); - int print (term_area*, const FString&); + int print (FTermArea*, const FString&); int print (const FTermBuffer&); - int print (term_area*, const FTermBuffer&); - int print (const std::vector&); - int print (term_area*, const std::vector&); + int print (FTermArea*, const FTermBuffer&); + int print (const std::vector&); + int print (FTermArea*, const std::vector&); int print (wchar_t); - int print (term_area*, wchar_t); - int print (charData&); - int print (term_area*, charData&); + int print (FTermArea*, wchar_t); + int print (FChar&); + int print (FTermArea*, FChar&); virtual void print (const FPoint&); virtual void print (const FColorPair&); virtual FVTerm& print(); @@ -312,10 +312,10 @@ class FVTerm protected: // Accessor - virtual term_area* getPrintArea(); - term_area* getChildPrintArea() const; - term_area* getCurrentPrintArea() const; - term_area* getVirtualDesktop() const; + virtual FTermArea* getPrintArea(); + FTermArea* getChildPrintArea() const; + FTermArea* getCurrentPrintArea() const; + FTermArea* getVirtualDesktop() const; std::size_t getLineNumber(); std::size_t getColumnNumber(); static bool charEncodable (wchar_t); @@ -323,9 +323,9 @@ class FVTerm static FMouseControl* getFMouseControl(); // Mutators - void setPrintArea (term_area*); - void setChildPrintArea (term_area*); - void setActiveArea (term_area*); + void setPrintArea (FTermArea*); + void setChildPrintArea (FTermArea*); + void setActiveArea (FTermArea*); static void setInsertCursor (bool); static void setInsertCursor(); static void unsetInsertCursor(); @@ -341,26 +341,26 @@ class FVTerm void createArea ( const FRect& , const FSize& - , term_area*& ); + , FTermArea*& ); void resizeArea ( const FRect& , const FSize& - , term_area* ); - static void removeArea (term_area*&); + , FTermArea* ); + static void removeArea (FTermArea*&); static void restoreVTerm (const FRect&); - bool updateVTermCursor (term_area*); + bool updateVTermCursor (FTermArea*); static void setAreaCursor ( const FPoint& - , bool, term_area* ); - static void getArea (const FPoint&, term_area*); - static void getArea (const FRect&, term_area*); - void putArea (term_area*); - static void putArea (const FPoint&, term_area*); - void scrollAreaForward (term_area*); - void scrollAreaReverse (term_area*); - void clearArea (term_area*, int = ' '); + , bool, FTermArea* ); + static void getArea (const FPoint&, FTermArea*); + static void getArea (const FRect&, FTermArea*); + void putArea (FTermArea*); + static void putArea (const FPoint&, FTermArea*); + void scrollAreaForward (FTermArea*); + void scrollAreaReverse (FTermArea*); + void clearArea (FTermArea*, int = ' '); void processTerminalUpdate(); static void startTerminalUpdate(); static void finishTerminalUpdate(); - static void flush_out(); + static void flushOutputBuffer(); static void initScreenSettings(); static void changeTermSizeFinished(); static void exitWithMessage (const FString&) @@ -388,101 +388,101 @@ class FVTerm static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; // Methods - void setTextToDefault (term_area*, const FSize&); - static bool reallocateTextArea ( term_area* + void setTextToDefault (FTermArea*, const FSize&); + static bool reallocateTextArea ( FTermArea* , std::size_t , std::size_t ); - static bool reallocateTextArea ( term_area* + static bool reallocateTextArea ( FTermArea* , std::size_t ); - static covered_state isCovered (const FPoint&, term_area*); - static void updateOverlappedColor ( term_area* + static covered_state isCovered (const FPoint&, FTermArea*); + static void updateOverlappedColor ( FTermArea* , const FPoint& , const FPoint& ); - static void updateOverlappedCharacter ( term_area* + static void updateOverlappedCharacter ( FTermArea* , const FPoint& ); - static void updateShadedCharacter ( term_area* + static void updateShadedCharacter ( FTermArea* , const FPoint& , const FPoint& ); - static void updateInheritBackground ( term_area* + static void updateInheritBackground ( FTermArea* , const FPoint& , const FPoint& ); - static void updateCharacter ( term_area* + static void updateCharacter ( FTermArea* , const FPoint& , const FPoint& ); - static bool updateVTermCharacter ( term_area* + static bool updateVTermCharacter ( FTermArea* , const FPoint& , const FPoint& ); void updateVTerm(); - static void callPreprocessingHandler (term_area*); - bool hasChildAreaChanges (term_area*); - void clearChildAreaChanges (term_area*); - static bool isInsideArea (const FPoint&, term_area*); - static charData generateCharacter (const FPoint&); - static charData getCharacter ( character_type + static void callPreprocessingHandler (FTermArea*); + bool hasChildAreaChanges (FTermArea*); + void clearChildAreaChanges (FTermArea*); + static bool isInsideArea (const FPoint&, FTermArea*); + static FChar generateCharacter (const FPoint&); + static FChar getCharacter ( character_type , const FPoint& , FVTerm* ); - static charData getCoveredCharacter (const FPoint&, FVTerm*); - static charData getOverlappedCharacter (const FPoint&, FVTerm*); + static FChar getCoveredCharacter (const FPoint&, FVTerm*); + static FChar getOverlappedCharacter (const FPoint&, FVTerm*); void init (bool); static void init_characterLengths (FOptiMove*); void finish(); - static void putAreaLine (charData*, charData*, int); + static void putAreaLine (FChar*, FChar*, int); static void putAreaCharacter ( const FPoint&, FVTerm* - , charData*, charData* ); - static void getAreaCharacter ( const FPoint&, term_area* - , charData*& ); + , FChar*, FChar* ); + static void getAreaCharacter ( const FPoint&, FTermArea* + , FChar*& ); bool clearTerm (int = ' '); - bool clearFullArea (term_area*, charData&); - static void clearAreaWithShadow (term_area*, charData&); + bool clearFullArea (FTermArea*, FChar&); + static void clearAreaWithShadow (FTermArea*, FChar&); static bool canClearToEOL (uInt, uInt); static bool canClearLeadingWS (uInt&, uInt); static bool canClearTrailingWS (uInt&, uInt); bool skipUnchangedCharacters (uInt&, uInt, uInt); void printRange (uInt, uInt, uInt, bool); - void replaceNonPrintableFullwidth (uInt, charData*&); - void printCharacter (uInt&, uInt, bool, charData*&); - void printFullWidthCharacter (uInt&, uInt, charData*&); - void printFullWidthPaddingCharacter (uInt&, uInt, charData*&); - void printHalfCovertFullWidthCharacter (uInt&, uInt, charData*&); - void skipPaddingCharacter (uInt&, uInt, charData*&); + void replaceNonPrintableFullwidth (uInt, FChar*&); + void printCharacter (uInt&, uInt, bool, FChar*&); + void printFullWidthCharacter (uInt&, uInt, FChar*&); + void printFullWidthPaddingCharacter (uInt&, uInt, FChar*&); + void printHalfCovertFullWidthCharacter (uInt&, uInt, FChar*&); + void skipPaddingCharacter (uInt&, uInt, FChar*&); exit_state eraseCharacters (uInt&, uInt, uInt, bool); exit_state repeatCharacter (uInt&, uInt, uInt); - bool isFullWidthChar (charData*&); - bool isFullWidthPaddingChar (charData*&); + bool isFullWidthChar (FChar*&); + bool isFullWidthPaddingChar (FChar*&); static void cursorWrap(); - bool printWrap (term_area*); - void printPaddingCharacter (term_area*, charData&); + bool printWrap (FTermArea*); + void printPaddingCharacter (FTermArea*, FChar&); void updateTerminalLine (uInt); bool updateTerminalCursor(); bool isInsideTerminal (const FPoint&); bool isTermSizeChanged(); static void markAsPrinted (uInt, uInt); static void markAsPrinted (uInt, uInt, uInt); - static void newFontChanges (charData*&); - static void charsetChanges (charData*&); - void appendCharacter (charData*&); - void appendChar (charData*&); - void appendAttributes (charData*&); - int appendLowerRight (charData*&); - static void characterFilter (charData*&); + static void newFontChanges (FChar*&); + static void charsetChanges (FChar*&); + void appendCharacter (FChar*&); + void appendChar (FChar*&); + void appendAttributes (FChar*&); + int appendLowerRight (FChar*&); + static void characterFilter (FChar*&); static void appendOutputBuffer (const std::string&); static void appendOutputBuffer (const char[]); static int appendOutputBuffer (int); // Data members - term_area* print_area{nullptr}; // print area for this object - term_area* child_print_area{nullptr}; // print area for children - term_area* vwin{nullptr}; // virtual window + FTermArea* print_area{nullptr}; // print area for this object + FTermArea* child_print_area{nullptr}; // print area for children + FTermArea* vwin{nullptr}; // virtual window static FSystem* fsystem; static FTerm* fterm; - static term_area* vterm; // virtual terminal - static term_area* vdesktop; // virtual desktop - static term_area* active_area; // active area + static FTermArea* vterm; // virtual terminal + static FTermArea* vdesktop; // virtual desktop + static FTermArea* active_area; // active area static std::queue* output_buffer; - static charData term_attribute; - static charData next_attribute; - static charData s_ch; // shadow character - static charData i_ch; // inherit background character + static FChar term_attribute; + static FChar next_attribute; + static FChar s_ch; // shadow character + static FChar i_ch; // inherit background character static FPoint* term_pos; // terminal cursor position static FKeyboard* keyboard; static bool terminal_update_complete; @@ -499,21 +499,21 @@ class FVTerm //---------------------------------------------------------------------- -// struct FVTerm::term_area +// struct FVTerm::FTermArea //---------------------------------------------------------------------- -struct FVTerm::term_area // define virtual terminal character properties +struct FVTerm::FTermArea // define virtual terminal character properties { public: // Constructor - term_area() = default; + FTermArea() = default; // Disable copy constructor - term_area (const term_area&) = delete; + FTermArea (const FTermArea&) = delete; // Destructor - ~term_area() = default; + ~FTermArea() = default; // Disable assignment operator (=) - term_area& operator = (const term_area&) = delete; + FTermArea& operator = (const FTermArea&) = delete; int offset_left{0}; // Distance from left terminal side int offset_top{0}; // Distance from top of the terminal @@ -525,10 +525,10 @@ struct FVTerm::term_area // define virtual terminal character properties int cursor_y{0}; // Y-position for the next write operation int input_cursor_x{-1}; // X-position input cursor int input_cursor_y{-1}; // Y-position input cursor - FWidget* widget{nullptr}; // Widget that owns this term_area + FWidget* widget{nullptr}; // Widget that owns this FTermArea FPreprocessing preproc_list{}; - line_changes* changes{nullptr}; - charData* text{nullptr}; // Text data for the output + FLineChanges* changes{nullptr}; + FChar* data{nullptr}; // FChar data of the drawing area bool input_cursor_visible{false}; bool has_changes{false}; bool visible{false}; @@ -565,7 +565,7 @@ inline FVTerm& FVTerm::operator << (const std::string& string) //---------------------------------------------------------------------- inline FVTerm& FVTerm::operator << \ - (const std::vector& termString) + (const std::vector& termString) { print (termString); return *this; @@ -598,15 +598,15 @@ inline FColor FVTerm::getTermBackgroundColor() { return next_attribute.bg_color; } //---------------------------------------------------------------------- -inline FVTerm::term_area*& FVTerm::getVWin() +inline FVTerm::FTermArea*& FVTerm::getVWin() { return vwin; } //---------------------------------------------------------------------- -inline const FVTerm::term_area* FVTerm::getVWin() const +inline const FVTerm::FTermArea* FVTerm::getVWin() const { return vwin; } //---------------------------------------------------------------------- -inline charData FVTerm::getAttribute() +inline FChar FVTerm::getAttribute() { return next_attribute; } //---------------------------------------------------------------------- @@ -1062,15 +1062,15 @@ inline void FVTerm::redefineDefaultColors (bool enable) { FTerm::redefineDefaultColors(enable); } //---------------------------------------------------------------------- -inline FVTerm::term_area* FVTerm::getChildPrintArea() const +inline FVTerm::FTermArea* FVTerm::getChildPrintArea() const { return child_print_area; } //---------------------------------------------------------------------- -inline FVTerm::term_area* FVTerm::getCurrentPrintArea() const +inline FVTerm::FTermArea* FVTerm::getCurrentPrintArea() const { return print_area; } //---------------------------------------------------------------------- -inline FVTerm::term_area* FVTerm::getVirtualDesktop() const +inline FVTerm::FTermArea* FVTerm::getVirtualDesktop() const { return vdesktop; } //---------------------------------------------------------------------- @@ -1094,15 +1094,15 @@ inline FMouseControl* FVTerm::getFMouseControl() { return FTerm::getFMouseControl(); } //---------------------------------------------------------------------- -inline void FVTerm::setPrintArea (term_area* area) +inline void FVTerm::setPrintArea (FTermArea* area) { print_area = area; } //---------------------------------------------------------------------- -inline void FVTerm::setChildPrintArea (term_area* area) +inline void FVTerm::setChildPrintArea (FTermArea* area) { child_print_area = area; } //---------------------------------------------------------------------- -inline void FVTerm::setActiveArea (term_area* area) +inline void FVTerm::setActiveArea (FTermArea* area) { active_area = area; } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index ae2ce854..a655a744 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -139,7 +139,7 @@ class FWidget : public FVTerm, public FObject using FVTerm::setColor; using FVTerm::print; - struct accelerator + struct FAccelerator { alignas(8) FKey key; FWidget* object; @@ -147,12 +147,12 @@ class FWidget : public FVTerm, public FObject // Typedefs typedef std::vector FWidgetList; - typedef std::vector Accelerators; + typedef std::vector FAcceleratorList; typedef void (*FCallbackPtr)(FWidget*, FDataPtr); typedef void (FWidget::*FMemberCallback)(FWidget*, FDataPtr); typedef std::function FCallback; - struct widget_flags // Properties of a widget ⚑ + struct FWidgetFlags // Properties of a widget ⚑ { uInt32 shadow : 1; uInt32 trans_shadow : 1; @@ -202,7 +202,7 @@ class FWidget : public FVTerm, public FObject static FStatusBar* getStatusBar(); virtual FWidget* getFirstFocusableWidget (FObjectList); virtual FWidget* getLastFocusableWidget (FObjectList); - Accelerators* getAcceleratorList() const; + FAcceleratorList* getAcceleratorList() const; FString getStatusbarMessage() const; FColor getForegroundColor() const; // get the primary FColor getBackgroundColor() const; // widget colors @@ -232,7 +232,7 @@ class FWidget : public FVTerm, public FObject const FRect& getTermGeometryWithShadow(); std::size_t getDesktopWidth(); std::size_t getDesktopHeight(); - const widget_flags& getFlags() const; + const FWidgetFlags& getFlags() const; FPoint getCursorPos(); FPoint getPrintPos(); @@ -265,7 +265,7 @@ class FWidget : public FVTerm, public FObject void setForegroundColor (FColor); void setBackgroundColor (FColor); void setColor(); - widget_flags& setFlags(); + FWidgetFlags& setFlags(); // Positioning and sizes mutators... virtual void setX (int, bool = true); virtual void setY (int, bool = true); @@ -345,7 +345,7 @@ class FWidget : public FVTerm, public FObject static void quit(); protected: - struct callback_data + struct FCallbackData { FString cb_signal; FWidget* cb_instance; @@ -354,16 +354,16 @@ class FWidget : public FVTerm, public FObject }; // Typedefs - typedef std::vector CallbackObjects; + typedef std::vector FCallbackObjects; // Accessor - term_area* getPrintArea() override; + FTermArea* getPrintArea() override; const FWidgetColors& getFWidgetColors() const; static uInt getModalDialogCounter(); static FWidgetList*& getDialogList(); static FWidgetList*& getAlwaysOnTopList(); static FWidgetList*& getWidgetCloseList(); - void addPreprocessingHandler (FVTerm*, FVTermPreprocessing) override; + void addPreprocessingHandler (FVTerm*, FPreprocessingFunction) override; void delPreprocessingHandler (FVTerm*) override; // Inquiry @@ -466,7 +466,7 @@ class FWidget : public FVTerm, public FObject int right{0}; } padding{}; - struct widget_flags flags{}; + struct FWidgetFlags flags{}; bool ignore_padding{false}; // widget size @@ -486,8 +486,8 @@ class FWidget : public FVTerm, public FObject FColor foreground_color{fc::Default}; FColor background_color{fc::Default}; FString statusbar_message{}; - Accelerators* accelerator_list{nullptr}; - CallbackObjects callback_objects{}; + FAcceleratorList* accelerator_list{nullptr}; + FCallbackObjects callback_objects{}; static FStatusBar* statusbar; static FMenuBar* menubar; @@ -515,8 +515,8 @@ class FWidget : public FVTerm, public FObject // Friend functions friend void detectTermSize(); friend void drawShadow (FWidget*); - friend void drawTransparentShadow (FWidget*, int, int, int, int); - friend void drawBlockShadow (FWidget*, int, int, int, int); + friend void drawTransparentShadow (FWidget*); + friend void drawBlockShadow (FWidget*); friend void clearShadow (FWidget*); friend void drawFlatBorder (FWidget*); friend void clearFlatBorder (FWidget*); @@ -524,18 +524,21 @@ class FWidget : public FVTerm, public FObject // non-member function forward declarations +// implemented in fwidget_functions.cpp //---------------------------------------------------------------------- void detectTermSize(); FKey getHotkey (const FString&); std::size_t getHotkeyPos (const FString& src, FString& dest); void setHotkeyViaString (FWidget*, const FString&); -void drawBorder (FWidget*, FRect); void drawShadow (FWidget*); -void drawTransparentShadow (FWidget*, int, int, int, int); -void drawBlockShadow (FWidget*, int, int, int, int); +void drawTransparentShadow (FWidget*); +void drawBlockShadow (FWidget*); void clearShadow (FWidget*); void drawFlatBorder (FWidget*); void clearFlatBorder (FWidget*); +void drawBorder (FWidget*, FRect); +void drawBox (FWidget*, const FRect&); +void drawNewFontBox (FWidget*, const FRect&); // FWidget inline functions @@ -580,7 +583,7 @@ inline FStatusBar* FWidget::getStatusBar() { return statusbar; } //---------------------------------------------------------------------- -inline FWidget::Accelerators* FWidget::getAcceleratorList() const +inline FWidget::FAcceleratorList* FWidget::getAcceleratorList() const { return accelerator_list; } //---------------------------------------------------------------------- @@ -722,7 +725,7 @@ inline std::size_t FWidget::getDesktopHeight() { return getLineNumber(); } //---------------------------------------------------------------------- -inline const FWidget::widget_flags& FWidget::getFlags() const +inline const FWidget::FWidgetFlags& FWidget::getFlags() const { return flags; } //---------------------------------------------------------------------- @@ -833,7 +836,7 @@ inline void FWidget::setBackgroundColor (FColor color) } //---------------------------------------------------------------------- -inline FWidget::widget_flags& FWidget::setFlags() +inline FWidget::FWidgetFlags& FWidget::setFlags() { return flags; } //---------------------------------------------------------------------- diff --git a/test/fkeyboard-test.cpp b/test/fkeyboard-test.cpp index 902cdb4f..e8acd79c 100644 --- a/test/fkeyboard-test.cpp +++ b/test/fkeyboard-test.cpp @@ -40,9 +40,9 @@ typedef struct char* string; char tname[4]; } -fkeymap; +FKeyMap; -fkeymap Fkey[] = +FKeyMap fkey[] = { { finalcut::fc::Fkey_backspace , C_STR("\177") , "kb" }, // backspace key { finalcut::fc::Fkey_catab , 0 , "ka" }, // clear-all-tabs key @@ -2793,7 +2793,7 @@ void FKeyboardTest::init() CPPUNIT_ASSERT ( key_pressed == 0 ); keyboard->enableUTF8(); keyboard->enableMouseSequences(); - keyboard->setTermcapMap (reinterpret_cast(test::Fkey)); + keyboard->setTermcapMap (reinterpret_cast(test::fkey)); } //---------------------------------------------------------------------- diff --git a/test/fobject-test.cpp b/test/fobject-test.cpp index 21988a8d..cbd7ab8c 100644 --- a/test/fobject-test.cpp +++ b/test/fobject-test.cpp @@ -49,7 +49,7 @@ class FObject_protected : public finalcut::FObject return finalcut::FObject::event(ev); } - TimerList* getTimerList() const + FTimerList* getTimerList() const { return finalcut::FObject::getTimerList(); } diff --git a/test/foptiattr-test.cpp b/test/foptiattr-test.cpp index 818e9e75..98015217 100644 --- a/test/foptiattr-test.cpp +++ b/test/foptiattr-test.cpp @@ -118,7 +118,7 @@ void FOptiAttrTest::classNameTest() //---------------------------------------------------------------------- void FOptiAttrTest::noArgumentTest() { - finalcut::charData* ch = new finalcut::charData(); + finalcut::FChar* ch = new finalcut::FChar(); finalcut::FOptiAttr oa; oa.initialize(); @@ -130,7 +130,7 @@ void FOptiAttrTest::noArgumentTest() CPPUNIT_ASSERT ( oa.isNormal(ch) ); // Null test - finalcut::charData* ch_null = nullptr; + finalcut::FChar* ch_null = nullptr; CPPUNIT_ASSERT ( oa.changeAttribute(ch, ch) == 0 ); CPPUNIT_ASSERT_CSTRING ( oa.changeAttribute(ch, ch_null), C_STR("") ); CPPUNIT_ASSERT_CSTRING ( oa.changeAttribute(ch_null, ch), C_STR("") ); @@ -204,8 +204,8 @@ void FOptiAttrTest::fakeReverseTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Gray text on blue background @@ -299,8 +299,8 @@ void FOptiAttrTest::ansiTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -764,8 +764,8 @@ void FOptiAttrTest::vt100Test() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -1235,8 +1235,8 @@ void FOptiAttrTest::xtermTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -1706,8 +1706,8 @@ void FOptiAttrTest::rxvtTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -2178,8 +2178,8 @@ void FOptiAttrTest::linuxTest() oa.set_orig_orig_colors (C_STR(OSC "R")); oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -2661,8 +2661,8 @@ void FOptiAttrTest::puttyTest() oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -3134,8 +3134,8 @@ void FOptiAttrTest::teratermTest() oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -3609,8 +3609,8 @@ void FOptiAttrTest::ibmColorTest() oa.initialize(); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -4050,8 +4050,8 @@ void FOptiAttrTest::wyse50Test() oa.setTermEnvironment(optiattr_env); - finalcut::charData* from = new finalcut::charData(); - finalcut::charData* to = new finalcut::charData(); + finalcut::FChar* from = new finalcut::FChar(); + finalcut::FChar* to = new finalcut::FChar(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index 88b6a2db..bf08705f 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.cpp @@ -660,91 +660,91 @@ void FTermcapQuirksTest::sunTest() CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_left_cursor].string , C_STR(CSI "%p1%dD") ); - for (std::size_t i = 0; finalcut::fc::Fkey[i].tname[0] != 0; i++) + for (std::size_t i = 0; finalcut::fc::fkey[i].tname[0] != 0; i++) { - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "K2", 2) == 0 ) // center of keypad + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "218z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kb", 2) == 0 ) // backspace key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kb", 2) == 0 ) // backspace key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR("\b") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kD", 2) == 0 - && std::strlen(finalcut::fc::Fkey[i].tname) == 2 ) // delete-character key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kD", 2) == 0 + && std::strlen(finalcut::fc::fkey[i].tname) == 2 ) // delete-character key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR("\177") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "@7", 2) == 0 ) // end key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "@7", 2) == 0 ) // end key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "220z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "k;", 2) == 0 ) // F10 function key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "k;", 2) == 0 ) // F10 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "233z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "F1", 2) == 0 ) // F11 function key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "F1", 2) == 0 ) // F11 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "234z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "F2", 2) == 0 ) // F12 function key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "F2", 2) == 0 ) // F12 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "235z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kh", 2) == 0 ) // home key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kh", 2) == 0 ) // home key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "214z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kI", 2) == 0 ) // insert-character key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kI", 2) == 0 ) // insert-character key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "247z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kN", 2) == 0 ) // next-page key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kN", 2) == 0 ) // next-page key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "222z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "%7", 2) == 0 ) // options key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "%7", 2) == 0 ) // options key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "194z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kP", 2) == 0 ) // prev-page key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kP", 2) == 0 ) // prev-page key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "216z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "&5", 2) == 0 ) // resume key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "&5", 2) == 0 ) // resume key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "193z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "&8", 2) == 0 ) // undo key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "&8", 2) == 0 ) // undo key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "195z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "K2", 2) == 0 ) // center of keypad + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "218z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kDx", 3) == 0 ) // keypad delete - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "kDx", 3) == 0 ) // keypad delete + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "249z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "@8x", 3) == 0 ) // enter/send key - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "@8x", 3) == 0 ) // enter/send key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "250z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP1", 3) == 0 ) // keypad slash - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP1", 3) == 0 ) // keypad slash + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "212z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP2", 3) == 0 ) // keypad asterisk - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP2", 3) == 0 ) // keypad asterisk + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "213z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP3", 3) == 0 ) // keypad minus sign - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP3", 3) == 0 ) // keypad minus sign + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "254z") ); - if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP4", 3) == 0 ) // keypad plus sign - CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + if ( std::strncmp(finalcut::fc::fkey[i].tname, "KP4", 3) == 0 ) // keypad plus sign + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::fkey[i].string , C_STR(CSI "253z") ); }