diff --git a/ChangeLog b/ChangeLog index 3edaf965..d4231d7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ +2019-05-17 Markus Gans + * Move system calls to the new class FSystem + 2019-04-27 Markus Gans - * Add the reserve() method to FListBox to increase the capacity of the list + * Add the reserve() method to FListBox to increase the capacity + of the list * Use shrink_to_fit() to save memory space 2019-03-24 Markus Gans diff --git a/README.md b/README.md index 69fa5553..7d707369 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ *Travis CI:*
     [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut)
*Coverity Scan:*
-     [![Coverity Scan Status](https://scan.coverity.com/projects/6508/badge.svg)](https://scan.coverity.com/projects/6508)
+     [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508)
*LGTM:*
     [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp)
*Class Reference:*
diff --git a/build.sh b/build.sh index 9918a182..deeaebeb 100755 --- a/build.sh +++ b/build.sh @@ -35,7 +35,7 @@ then autoreconf --install --force else echo "Build failed, please install autoconf first" - exit -1 + exit 255 fi fi fi @@ -46,7 +46,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O2" # "-O3 -fno-rtti" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -54,7 +54,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -62,7 +62,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -70,7 +70,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -78,7 +78,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" --with-profiler then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -86,7 +86,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -94,7 +94,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test --with-gcov then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 09187845..05353812 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -38,7 +38,7 @@ class SegmentView : public finalcut::FDialog virtual void draw() override; // Data Members - std::map code; + std::map code{}; finalcut::FString line[3]; finalcut::FLineEdit Input{"0123", this}; finalcut::FButton Exit{"E&xit", this}; diff --git a/fonts/bdf2pcf.sh b/fonts/bdf2pcf.sh index ea1ff421..b2eb6106 100755 --- a/fonts/bdf2pcf.sh +++ b/fonts/bdf2pcf.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh test -f 8x16graph.pcf.gz && rm 8x16graph.pcf.gz bdftopcf -o 8x16graph.pcf 8x16graph.bdf diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 116a20b3..a3ddc952 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if [ $# -gt 0 ] then diff --git a/scripts/cpuprofile.sh b/scripts/cpuprofile.sh index 1d57b7e1..414dd164 100755 --- a/scripts/cpuprofile.sh +++ b/scripts/cpuprofile.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh LD_LIBRARY_PATH=../src/.libs/ LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../examples/.libs/ui.prof ../examples/.libs/ui pprof --gv ../examples/.libs/ui ../examples/.libs/ui.prof diff --git a/scripts/library_calls.sh b/scripts/library_calls.sh index 55e85619..fc0b98bc 100755 --- a/scripts/library_calls.sh +++ b/scripts/library_calls.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Protokoliert Funktionsaufrufe in dynamisch hinzugelinkten Bibliotheken diff --git a/scripts/profile.sh b/scripts/profile.sh index f5771dae..06e95673 100755 --- a/scripts/profile.sh +++ b/scripts/profile.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh DIR="$PWD" cd ../examples/.libs/ || exit diff --git a/scripts/remove_eol_spaces.sh b/scripts/remove_eol_spaces.sh index 72bce211..81007be4 100755 --- a/scripts/remove_eol_spaces.sh +++ b/scripts/remove_eol_spaces.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh find ../src/ \ ../src/include/final/ \ diff --git a/scripts/show_graph_font.sh b/scripts/show_graph_font.sh index f22288e2..31831003 100755 --- a/scripts/show_graph_font.sh +++ b/scripts/show_graph_font.sh @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh xfd -center -columns 16 -fn -misc-8x16graph-medium-r-normal--17-160-75-75-*-80-iso8859-1 diff --git a/src/Makefile.am b/src/Makefile.am index 76985c73..24164cef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,8 @@ libfinal_la_SOURCES = \ flistview.cpp \ fmenu.cpp \ fmouse.cpp \ + fsystem.cpp \ + fsystemimpl.cpp \ fkeyboard.cpp \ fdialoglistmenu.cpp \ fmenubar.cpp \ @@ -112,6 +114,8 @@ finalcutinclude_HEADERS = \ include/final/fscrollview.h \ include/final/fstatusbar.h \ include/final/fstring.h \ + include/final/fsystem.h \ + include/final/fsystemimpl.h \ include/final/ftermcap.h \ include/final/ftermcapquirks.h \ include/final/ftermxterminal.h \ diff --git a/src/Makefile.clang b/src/Makefile.clang index 396fbffc..587de20b 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -39,6 +39,8 @@ INCLUDE_HEADERS = \ fprogressbar.h \ fradiobutton.h \ frect.h \ + fsystem.h \ + fsystemimpl.h \ fscrollbar.h \ fscrollview.h \ fstatusbar.h \ @@ -107,6 +109,8 @@ OBJS = \ ftextview.o \ fstatusbar.o \ fmouse.o \ + fsystem.o \ + fsystemimpl.o \ fkeyboard.o \ ftermcap.o \ fterm.o \ diff --git a/src/Makefile.gcc b/src/Makefile.gcc index 6656d79b..456c30e2 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -43,6 +43,8 @@ INCLUDE_HEADERS = \ fscrollview.h \ fstatusbar.h \ fstring.h \ + fsystem.h \ + fsystemimpl.h \ fmouse.h \ fkeyboard.h \ ftermcap.h \ @@ -107,6 +109,8 @@ OBJS = \ ftextview.o \ fstatusbar.o \ fmouse.o \ + fsystem.o \ + fsystemimpl.o \ fkeyboard.o \ ftermcap.o \ fterm.o \ diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index f8666e83..9ad221bf 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -306,9 +306,9 @@ void FFileDialog::adjustSize() Y = 1 + int((max_height - getHeight()) / 3); setPos(FPoint(X, Y), false); filebrowser.setHeight (h - 8, false); - hidden.setY (int(h) - 4, false); - cancel.setY (int(h) - 4, false); - open.setY (int(h) - 4, false); + hidden_check.setY (int(h) - 4, false); + cancel_btn.setY (int(h) - 4, false); + open_btn.setY (int(h) - 4, false); FDialog::adjustSize(); printPath(directory); } @@ -355,18 +355,18 @@ inline void FFileDialog::widgetSettings (const FPoint& pos) filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6)); printPath (directory); - hidden.setText ("&hidden files"); - hidden.setGeometry (FPoint(2, 10), FSize(16, 1)); + hidden_check.setText ("&hidden files"); + hidden_check.setGeometry (FPoint(2, 10), FSize(16, 1)); - cancel.setText ("&Cancel"); - cancel.setGeometry(FPoint(19, 10), FSize(9, 1)); + cancel_btn.setText ("&Cancel"); + cancel_btn.setGeometry(FPoint(19, 10), FSize(9, 1)); if ( dlg_type == FFileDialog::Save ) - open.setText ("&Save"); + open_btn.setText ("&Save"); else - open.setText ("&Open"); + open_btn.setText ("&Open"); - open.setGeometry(FPoint(30, 10), FSize(9, 1)); + open_btn.setGeometry(FPoint(30, 10), FSize(9, 1)); setGeometry (pos, getSize()); } @@ -391,19 +391,19 @@ void FFileDialog::initCallbacks() F_METHOD_CALLBACK (this, &FFileDialog::cb_processClicked) ); - hidden.addCallback + hidden_check.addCallback ( "toggled", F_METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden) ); - cancel.addCallback + cancel_btn.addCallback ( "clicked", F_METHOD_CALLBACK (this, &FFileDialog::cb_processCancel) ); - open.addCallback + open_btn.addCallback ( "clicked", F_METHOD_CALLBACK (this, &FFileDialog::cb_processOpen) diff --git a/src/fsystem.cpp b/src/fsystem.cpp new file mode 100644 index 00000000..772c4545 --- /dev/null +++ b/src/fsystem.cpp @@ -0,0 +1,42 @@ +/*********************************************************************** +* fsystem.cpp - Abstract class for system calls * +* * +* 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/fsystem.h" + +namespace finalcut +{ + +//---------------------------------------------------------------------- +// class FSystem +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +FSystem::FSystem() +{ } + +//---------------------------------------------------------------------- +FSystem::~FSystem() // destructor +{ } + +} // namespace finalcut + diff --git a/src/fsystemimpl.cpp b/src/fsystemimpl.cpp new file mode 100644 index 00000000..864eae78 --- /dev/null +++ b/src/fsystemimpl.cpp @@ -0,0 +1,42 @@ +/*********************************************************************** +* fsystemimpl.cpp - FSystem implementation * +* * +* 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/fsystemimpl.h" + +namespace finalcut +{ + +//---------------------------------------------------------------------- +// class FSystemImpl +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +FSystemImpl::FSystemImpl() +{ } + +//---------------------------------------------------------------------- +FSystemImpl::~FSystemImpl() // destructor +{ } + +} // namespace finalcut + diff --git a/src/fterm.cpp b/src/fterm.cpp index f83d4113..95b607a5 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1,5 +1,5 @@ /*********************************************************************** -* fterm.cpp - Base class for terminal detection and control * +* fterm.cpp - Base class for terminal control * * * * This file is part of the Final Cut widget toolkit * * * @@ -43,6 +43,7 @@ int (*FTerm::Fputchar)(int); // static class attributes FTerm::initializationValues FTerm::init_values; FTermData* FTerm::data = nullptr; +FSystem* FTerm::fsys = nullptr; FTermcap::tcap_map* FTerm::tcap = nullptr; FOptiMove* FTerm::opti_move = nullptr; FOptiAttr* FTerm::opti_attr = nullptr; @@ -354,12 +355,12 @@ int FTerm::openConsole() if ( fd >= 0 ) // console is already opened return 0; - if ( ! *termfilename ) + if ( ! *termfilename || ! fsys ) return 0; for (std::size_t i = 0; terminal_devices[i] != 0; i++) { - fd = open(terminal_devices[i], O_RDWR, 0); + fd = fsys->open(terminal_devices[i], O_RDWR, 0); data->setTTYFileDescriptor(fd); if ( fd >= 0 ) @@ -373,12 +374,14 @@ int FTerm::openConsole() int FTerm::closeConsole() { int fd = data->getTTYFileDescriptor(); + int ret = -1; if ( fd < 0 ) // console is already closed return 0; - // use 'close' from the global namespace - int ret = ::close (fd); + if ( fsys ) + ret = fsys->close(fd); // close console + data->setTTYFileDescriptor(-1); if ( ret == 0 ) @@ -502,7 +505,11 @@ void FTerm::detectTermSize() } auto& term_geometry = data->getTermGeometry(); - ret = ioctl (fd, TIOCGWINSZ, &win_size); + + if ( fsys ) + ret = fsys->ioControl (fd, TIOCGWINSZ, &win_size); + else + ret = -1; if ( ret != 0 || win_size.ws_col == 0 || win_size.ws_row == 0 ) { @@ -519,8 +526,9 @@ void FTerm::detectTermSize() term_geometry.setRect(1, 1, win_size.ws_col, win_size.ws_row); } - opti_move->setTermSize ( term_geometry.getWidth() - , term_geometry.getHeight() ); + if ( opti_move ) + opti_move->setTermSize ( term_geometry.getWidth() + , term_geometry.getHeight() ); if ( close_after_detect ) closeConsole(); @@ -1398,7 +1406,7 @@ void FTerm::init_term_encoding() int stdout_no = FTermios::getStdOut(); const char* termtype = data->getTermType(); - if ( isatty(stdout_no) + if ( fsys->isTTY(stdout_no) && ! std::strcmp(nl_langinfo(CODESET), "UTF-8") ) { data->setUTF8Console(true); @@ -1408,7 +1416,7 @@ void FTerm::init_term_encoding() setUTF8(true); keyboard->enableUTF8(); } - else if ( isatty(stdout_no) + else if ( fsys->isTTY(stdout_no) && (std::strlen(termtype) > 0) && (TCAP(fc::t_exit_alt_charset_mode) != 0) ) { @@ -1733,6 +1741,7 @@ inline void FTerm::allocationValues() try { data = new FTermData(); + fsys = new FSystemImpl; opti_move = new FOptiMove(); opti_attr = new FOptiAttr(); term_detection = new FTermDetection(); @@ -1796,6 +1805,9 @@ inline void FTerm::deallocationValues() if ( opti_move ) delete opti_move; + if ( fsys ) + delete fsys; + if ( data ) delete data; } @@ -1826,6 +1838,7 @@ void FTerm::init (bool disable_alt_screen) // Terminal detection term_detection->setFTermData(data); + term_detection->setFSystem(fsys); term_detection->detect(); setTermType (term_detection->getTermType()); @@ -1915,6 +1928,7 @@ void FTerm::initOSspecifics() { #if defined(__linux__) linux->setFTermData(data); + linux->setFSystem(fsys); linux->setFTermDetection(term_detection); linux->init(); // Initialize Linux console @@ -1925,6 +1939,8 @@ void FTerm::initOSspecifics() #endif // defined(__linux__) #if defined(__FreeBSD__) || defined(__DragonFly__) + freebsd->setFSystem(fsys); + if ( init_values.meta_sends_escape ) freebsd->enableMetaSendsEscape(); else @@ -1937,6 +1953,8 @@ void FTerm::initOSspecifics() freebsd->init(); // Initialize BSD console #elif defined(__NetBSD__) || defined(__OpenBSD__) + openbsd->setFSystem(fsys); + if ( init_values.meta_sends_escape ) openbsd->enableMetaSendsEscape(); else @@ -1966,7 +1984,7 @@ void FTerm::initBaudRate() uInt baud = FTermios::getBaudRate(); data->setBaudrate(baud); - if ( isatty(stdout_no) ) + if ( fsys->isTTY(stdout_no) ) opti_move->setBaudRate(int(baud)); } @@ -2120,7 +2138,7 @@ void FTerm::signal_handler (int signum) //---------------------------------------------------------------------- uInt env2uint (const char* env) { - FString str(env); + FString str(getenv(env)); if ( str.isEmpty() ) return 0; diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 861dd739..6c63329f 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -32,6 +32,7 @@ FTermDetection::terminalType 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] = { }; char FTermDetection::ttytypename[256] = { }; bool FTermDetection::decscusr_support; @@ -90,6 +91,12 @@ void FTermDetection::setFTermData (FTermData* data) fterm_data = data; } +//---------------------------------------------------------------------- +void FTermDetection::setFSystem (FSystem* fsys) +{ + fsystem = fsys; +} + //---------------------------------------------------------------------- void FTermDetection::setTtyTypeFileName (char ttytype_filename[]) { @@ -180,7 +187,7 @@ bool FTermDetection::getTTYtype() std::FILE *fp; - if ( (fp = std::fopen(ttytypename, "r")) != 0 ) + if ( fsystem && (fp = fsystem->fopen(ttytypename, "r")) != 0 ) { char* p; char str[BUFSIZ]; @@ -210,12 +217,12 @@ bool FTermDetection::getTTYtype() // Save name in termtype std::strncpy (termtype, type, sizeof(termtype)); termtype[sizeof(termtype) - 1] = '\0'; - std::fclose(fp); + fsystem->fclose(fp); return true; } } - std::fclose(fp); + fsystem->fclose(fp); } return false; diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 2d0e902f..ca1a1de8 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-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 * @@ -32,6 +32,7 @@ namespace finalcut FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style = fc::normal_cursor; bool FTermFreeBSD::change_cursorstyle = true; bool FTermFreeBSD::meta_sends_escape = true; + FSystem* FTermFreeBSD::fsystem = nullptr; #endif @@ -52,10 +53,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) { // Set cursor style in a BSD console - if ( ! isFreeBSDConsole() ) - return; - - if ( ! change_cursorstyle ) + if ( ! fsysten || ! isFreeBSDConsole() || ! change_cursorstyle ) return; cursor_style = style; @@ -63,7 +61,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) if ( hidden ) return; - ioctl(0, CONS_CURSORTYPE, &style); + fsysten->ioControl (0, CONS_CURSORTYPE, &style); } //---------------------------------------------------------------------- @@ -73,7 +71,7 @@ bool FTermFreeBSD::isFreeBSDConsole() keymap_t keymap; - if ( ioctl(0, GIO_KEYMAP, &keymap) == 0 ) + if ( fsysten && fsysten->ioControl(0, GIO_KEYMAP, &keymap) == 0 ) return true; else return false; @@ -145,10 +143,11 @@ bool FTermFreeBSD::saveFreeBSDAltKey() // Saving the current mapping for the alt key static constexpr int left_alt = 0x38; - int ret; + int ret = -1; keymap_t keymap; - ret = ioctl(0, GIO_KEYMAP, &keymap); + if ( fsystem ) + ret = fsysten->ioControl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -164,10 +163,11 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) // Remapping the alt key static constexpr int left_alt = 0x38; - int ret; + int ret = -1; keymap_t keymap; - ret = ioctl(0, GIO_KEYMAP, &keymap); + if ( fsystem ) + ret = fsysten->ioControl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -175,7 +175,8 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) // map to meta key keymap.key[left_alt].map[0] = key; - if ( (keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0) ) + if ( (keymap.n_keys > 0) + && fsystem && (fsysten->ioControl(0, PIO_KEYMAP, &keymap) < 0) ) return false; else return true; diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 27aaf96e..1ad11cec 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -45,6 +45,7 @@ namespace finalcut bool FTermLinux::has_saved_palette = false; FTermData* FTermLinux::fterm_data = nullptr; + FSystem* FTermLinux::fsystem = nullptr; FTermDetection* FTermLinux::term_detection = nullptr; fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style; FTermLinux::ColorMap FTermLinux::saved_color_map; @@ -135,12 +136,15 @@ bool FTermLinux::isLinuxConsole() { // Check if it's a Linux console + if ( ! fsystem ) + return false; + char arg = 0; int fd_tty = FTerm::getTTYFileDescriptor(); // get keyboard type an compare - return ( isatty (fd_tty) - && ioctl(fd_tty, KDGKBTYPE, &arg) == 0 + return ( fsystem->isTTY(fd_tty) + && fsystem->ioControl(fd_tty, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84)) ); } @@ -471,31 +475,33 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id) int FTermLinux::getFramebuffer_bpp() { int fd = -1; + const char* fb = C_STR("/dev/fb/0"); struct fb_var_screeninfo fb_var; struct fb_fix_screeninfo fb_fix; - const char* fb = C_STR("/dev/fb/0"); + if ( ! fsystem ) + return -1; - if ( (fd = open(fb, O_RDWR)) < 0 ) + if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) { if ( errno != ENOENT && errno != ENOTDIR ) return -1; fb = C_STR("/dev/fb0"); - if ( (fd = open(fb, O_RDWR)) < 0 ) + if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) return -1; } - if ( ! ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) - && ! ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) + if ( ! fsystem->ioControl(fd, FBIOGET_VSCREENINFO, &fb_var) + && ! fsystem->ioControl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) { - ::close(fd); + fsystem->close(fd); return int(fb_var.bits_per_pixel); } else { - ::close(fd); + fsystem->close(fd); } return -1; @@ -506,8 +512,7 @@ bool FTermLinux::getScreenFont() { struct console_font_op font; int fd_tty = FTerm::getTTYFileDescriptor(); - - int ret; + int ret = -1; if ( fd_tty < 0 ) return false; @@ -534,7 +539,8 @@ bool FTermLinux::getScreenFont() } // font operation - ret = ioctl (fd_tty, KDFONTOP, &font); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, KDFONTOP, &font); if ( ret == 0 ) { @@ -551,7 +557,7 @@ bool FTermLinux::getScreenFont() //---------------------------------------------------------------------- bool FTermLinux::getUnicodeMap() { - int ret; + int ret = -1; int fd_tty = FTerm::getTTYFileDescriptor(); if ( fd_tty < 0 ) @@ -561,7 +567,8 @@ bool FTermLinux::getUnicodeMap() screen_unicode_map.entries = nullptr; // get count - ret = ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, GIO_UNIMAP, &screen_unicode_map); if ( ret != 0 ) { @@ -581,7 +588,8 @@ bool FTermLinux::getUnicodeMap() } // get unicode-to-font mapping from kernel - ret = ioctl(fd_tty, GIO_UNIMAP, &screen_unicode_map); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, GIO_UNIMAP, &screen_unicode_map); if ( ret != 0 ) return false; @@ -601,7 +609,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey() std::memset (&mod_key, 0x00, sizeof(mod_key)); // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) - if ( ioctl(0, TIOCLINUX, &subcode) >= 0 ) + if ( fsystem && fsystem->ioControl(0, TIOCLINUX, &subcode) >= 0 ) { if ( subcode & (1 << KG_SHIFT) ) mod_key.shift = true; @@ -625,8 +633,8 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count , bool direct) { struct console_font_op font; - int ret; int fd_tty = FTerm::getTTYFileDescriptor(); + int ret = -1; if ( fd_tty < 0 ) return -1; @@ -664,7 +672,8 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count } // font operation - ret = ioctl (fd_tty, KDFONTOP, &font); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, KDFONTOP, &font); if ( ret != 0 && errno != ENOSYS && errno != EINVAL ) { @@ -687,8 +696,8 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) { struct unimapinit advice; - int ret; int fd_tty = FTerm::getTTYFileDescriptor(); + int ret = -1; if ( fd_tty < 0 ) return -1; @@ -700,13 +709,15 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) do { // clear the unicode-to-font table - ret = ioctl(fd_tty, PIO_UNIMAPCLR, &advice); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, PIO_UNIMAPCLR, &advice); if ( ret != 0 ) return -1; // put the new unicode-to-font mapping in kernel - ret = ioctl(fd_tty, PIO_UNIMAP, unimap); + if ( fsystem ) + ret = fsystem->ioControl (fd_tty, PIO_UNIMAP, unimap); if ( ret != 0 ) advice.advised_hashlevel++; @@ -725,9 +736,13 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() { // Gets the VGA input-status-register-1 + if ( ! fsystem ) + return 0x3da; + // Miscellaneous output (read port) static constexpr uInt16 misc_read = 0x3cc; - const uInt16 io_base = ( inb(misc_read) & 0x01 ) ? 0x3d0 : 0x3b0; + uChar misc_value = fsystem->inPortByte(misc_read); + const uInt16 io_base = ( misc_value & 0x01 ) ? 0x3d0 : 0x3b0; // 0x3ba : Input status 1 mono/MDA (read port) // 0x3da : Input status 1 color/CGA (read port) return io_base + 0x0a; @@ -738,6 +753,9 @@ uChar FTermLinux::readAttributeController (uChar index) { // Reads a byte from the attribute controller from a given index + if ( ! fsystem ) + return 0; + uChar res; // Attribute controller (write port) static constexpr uInt16 attrib_cntlr_write = 0x3c0; @@ -745,15 +763,15 @@ uChar FTermLinux::readAttributeController (uChar index) static constexpr uInt16 attrib_cntlr_read = 0x3c1; const uInt16 input_status_1 = getInputStatusRegisterOne(); - inb (input_status_1); // switch to index mode - outb (index & 0x1f, attrib_cntlr_write); // selects address register - res = inb (attrib_cntlr_read); // read from data register + fsystem->inPortByte (input_status_1); // switch to index mode + fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register + res = fsystem->inPortByte (attrib_cntlr_read); // read from data register // Disable access to the palette and unblank the display - inb (input_status_1); // switch to index mode + fsystem->inPortByte (input_status_1); // switch to index mode index = (index & 0x1f) | 0x20; // set bit 5 (enable display) - outb (index, attrib_cntlr_write); - inb (attrib_cntlr_read); + fsystem->outPortByte (index, attrib_cntlr_write); + fsystem->inPortByte (attrib_cntlr_read); return res; } @@ -763,19 +781,22 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) { // Writes a byte from the attribute controller from a given index + if ( ! fsystem ) + return; + // Attribute controller (write port) static constexpr uInt16 attrib_cntlr_write = 0x3c0; const uInt16 input_status_1 = getInputStatusRegisterOne(); - inb (input_status_1); // switch to index mode - outb (index & 0x1f, attrib_cntlr_write); // selects address register - outb (data, attrib_cntlr_write); // write to data register + fsystem->inPortByte (input_status_1); // switch to index mode + fsystem->outPortByte (index & 0x1f, attrib_cntlr_write); // selects address register + fsystem->outPortByte (data, attrib_cntlr_write); // write to data register // Disable access to the palette and unblank the display - inb (input_status_1); // switch to index mode + fsystem->inPortByte (input_status_1); // switch to index mode index = (index & 0x1f) | 0x20; // set bit 5 (enable display) - outb (index, attrib_cntlr_write); - outb (data, attrib_cntlr_write); + fsystem->outPortByte (index, attrib_cntlr_write); + fsystem->outPortByte (data, attrib_cntlr_write); } //---------------------------------------------------------------------- @@ -800,6 +821,9 @@ int FTermLinux::setBlinkAsIntensity (bool enable) // Uses blink-bit as background intensity. // That permits 16 colors for background + if ( ! fsystem ) + return -1; + int fd_tty = FTerm::getTTYFileDescriptor(); // Test if the blink-bit is used by the screen font (512 characters) @@ -813,7 +837,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) return -1; // Enable access to VGA I/O ports (from 0x3B4 with num = 0x2C) - if ( ioctl(fd_tty, KDENABIO, 0) < 0 ) + if ( fsystem->ioControl(fd_tty, KDENABIO, 0) < 0 ) return -1; // error on KDENABIO if ( enable ) @@ -822,7 +846,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) setAttributeMode (getAttributeMode() | 0x08); // set bit 3 // Disable access to VGA I/O ports - if ( ioctl(fd_tty, KDDISABIO, 0) < 0 ) + if ( fsystem->ioControl(fd_tty, KDDISABIO, 0) < 0 ) return -1; // error on KDDISABIO return 0; @@ -842,7 +866,7 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b) cmap.color[index].blue = uChar(b); } - if ( ioctl (0, PIO_CMAP, &cmap) ) + if ( fsystem && fsystem->ioControl (0, PIO_CMAP, &cmap) ) return false; else return true; @@ -853,7 +877,7 @@ bool FTermLinux::saveVGAPalette() { // Save the current vga color map - if ( ioctl (0, GIO_CMAP, &saved_color_map) ) + if ( fsystem && fsystem->ioControl (0, GIO_CMAP, &saved_color_map) ) has_saved_palette = false; else has_saved_palette = true; @@ -866,14 +890,17 @@ bool FTermLinux::resetVGAPalette() { // Reset the vga color map + if ( ! fsystem ) + return false; + if ( has_saved_palette ) { - if ( ioctl (0, PIO_CMAP, &saved_color_map) ) + if ( fsystem->ioControl (0, PIO_CMAP, &saved_color_map) ) return false; } else { - rgb defaultColor[16] = + constexpr rgb defaultColor[16] = { {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, @@ -892,7 +919,7 @@ bool FTermLinux::resetVGAPalette() cmap.color[index].blue = defaultColor[index].blue; } - if ( ioctl (0, PIO_CMAP, &cmap) ) + if ( fsystem->ioControl (0, PIO_CMAP, &cmap) ) return false; } diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index 413c7b24..f22976a7 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-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 * @@ -27,8 +27,9 @@ namespace finalcut // static class attributes #if defined(__NetBSD__) || defined(__OpenBSD__) - kbd_t FTermOpenBSD::bsd_keyboard_encoding = 0; - bool FTermOpenBSD::meta_sends_escape = true; + kbd_t FTermOpenBSD::bsd_keyboard_encoding = 0; + bool FTermOpenBSD::meta_sends_escape = true; + FSystem* FTermOpenBSD::fsystem = nullptr; #endif @@ -45,7 +46,8 @@ bool FTermOpenBSD::isBSDConsole() static kbd_t kbdencoding; - if ( ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) + if ( fsystem + && fsysten->ioControl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) return true; else return false; @@ -85,7 +87,10 @@ void FTermOpenBSD::finish() bool FTermOpenBSD::saveBSDConsoleEncoding() { static kbd_t k_encoding; - int ret = ioctl(0, WSKBDIO_GETENCODING, &k_encoding); + int ret = -1; + + if ( fsystem ) + ret = fsysten->ioControl (0, WSKBDIO_GETENCODING, &k_encoding); if ( ret < 0 ) return false; @@ -98,7 +103,8 @@ bool FTermOpenBSD::saveBSDConsoleEncoding() //---------------------------------------------------------------------- bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) { - if ( ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) + if ( fsysten + && fsysten->ioControl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) return false; else return true; diff --git a/src/include/final/fconfig.h b/src/include/final/fconfig.h index a1ab15de..1c5275ff 100644 --- a/src/include/final/fconfig.h +++ b/src/include/final/fconfig.h @@ -50,9 +50,7 @@ #endif /* Define to 1 if GPM mouse is enabled */ -#ifndef F_HAVE_LIBGPM -#define F_HAVE_LIBGPM 1 -#endif +/* #undef HAVE_LIBGPM */ /* Define to 1 if you have the header file. */ #ifndef F_HAVE_LINUX_FB_H diff --git a/src/include/final/ffiledialog.h b/src/include/final/ffiledialog.h index 4419c111..27b53b9e 100644 --- a/src/include/final/ffiledialog.h +++ b/src/include/final/ffiledialog.h @@ -199,9 +199,9 @@ class FFileDialog : public FDialog FString filter_pattern{}; FLineEdit filename{this}; FListBox filebrowser{this}; - FCheckBox hidden{this}; - FButton cancel{this}; - FButton open{this}; + FCheckBox hidden_check{this}; + FButton cancel_btn{this}; + FButton open_btn{this}; DialogType dlg_type{FFileDialog::Open}; bool show_hidden{false}; diff --git a/src/include/final/fsystem.h b/src/include/final/fsystem.h new file mode 100644 index 00000000..f351fce3 --- /dev/null +++ b/src/include/final/fsystem.h @@ -0,0 +1,75 @@ +/*********************************************************************** +* fsystem.h - Abstract class for system calls * +* * +* 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 * +* . * +***********************************************************************/ + +/* Standalone class + * ════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▏ + * ▕ FSystem ▏ + * ▕▁▁▁▁▁▁▁▁▁▏ + */ + +#ifndef FSYSTEM_H +#define FSYSTEM_H + +#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) + #error "Only can be included directly." +#endif + +#include "final/ftypes.h" + +namespace finalcut +{ + +//---------------------------------------------------------------------- +// class FSystem +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FSystem +{ + public: + // Constructor + FSystem(); + + // Destructor + virtual ~FSystem(); + + // Methods + virtual uChar inPortByte (uShort) = 0; + virtual void outPortByte (uChar, uShort) = 0; + virtual int isTTY (int) = 0; + virtual int ioControl (int, uLong, ...) = 0; + virtual int open (const char*, int, ...) = 0; + virtual int close (int) = 0; + virtual FILE* fopen (const char*, const char*) = 0; + virtual int fclose (FILE*) = 0; +}; +#pragma pack(pop) + +} // namespace finalcut + +#endif // FSYSTEM_H + + diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h new file mode 100644 index 00000000..f2e330c2 --- /dev/null +++ b/src/include/final/fsystemimpl.h @@ -0,0 +1,125 @@ +/*********************************************************************** +* fsystemimpl.h - FSystem implementation * +* * +* 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 * +* . * +***********************************************************************/ + +/* Standalone class + * ════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FSystemImpl ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + */ + +#ifndef FSYSTEMIMPL_H +#define FSYSTEMIMPL_H + +#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) + #error "Only can be included directly." +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "final/fc.h" +#include "final/fsystem.h" + +namespace finalcut +{ + +//---------------------------------------------------------------------- +// class FSystemImpl +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FSystemImpl : public FSystem +{ + public: + // Constructor + FSystemImpl(); + + // Destructor + virtual ~FSystemImpl(); + + // Methods + virtual uChar inPortByte (uShort port) + { + return ::inb (port); + } + + virtual void outPortByte (uChar value, uShort port) + { + ::outb (value, port); + } + + virtual int isTTY (int fd) + { + return ::isatty(fd); + } + + virtual int ioControl (int fd, uLong request, ...) + { + va_list args; + va_start (args, request); + void* argp = va_arg (args, void*); + int ret = ::ioctl (fd, request, argp); + va_end (args); + return ret; + } + + virtual int open (const char* pathname, int flags, ...) + { + va_list args; + va_start (args, flags); + mode_t mode = va_arg (args, mode_t); + int ret = ::open (pathname, flags, mode); + va_end (args); + return ret; + } + + virtual int close (int fildes) + { + return ::close(fildes); + } + + virtual FILE* fopen (const char* path, const char* mode) + { + return std::fopen (path, mode); + } + + virtual int fclose (FILE* fp) + { + return std::fclose (fp); + } +}; +#pragma pack(pop) + +} // namespace finalcut + +#endif // FSYSTEMIMPL_H + + diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index ff51b708..6c7cd655 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -1,5 +1,5 @@ /*********************************************************************** -* fterm.h - Base class for terminal detection and control * +* fterm.h - Base class for terminal control * * * * This file is part of the Final Cut widget toolkit * * * @@ -124,6 +124,8 @@ #include "final/fpoint.h" #include "final/frect.h" #include "final/fstring.h" +#include "final/fsystem.h" +#include "final/fsystemimpl.h" #include "final/ftermcap.h" #include "final/ftermcapquirks.h" #include "final/ftermdata.h" @@ -189,6 +191,8 @@ class FTerm final characterSub& getCharSubstitutionMap(); #if DEBUG + static FTermData* getFTermData(); + static FTermDetection* getFTermDetection(); FTermDebugData& getFTermDebugData(); #endif @@ -393,6 +397,7 @@ class FTerm final // Data Members static FTermData* data; + static FSystem* fsys; static FTermcap::tcap_map* tcap; static FOptiMove* opti_move; static FOptiAttr* opti_attr; @@ -459,6 +464,14 @@ inline FTerm::characterSub& FTerm::getCharSubstitutionMap() { return data->getCharSubstitutionMap(); } #if DEBUG +//---------------------------------------------------------------------- +inline FTermData* FTerm::getFTermData() +{ return data; } + +//---------------------------------------------------------------------- +inline FTermDetection* FTerm::getFTermDetection() +{ return term_detection; } + //---------------------------------------------------------------------- inline FTermDebugData& FTerm::getFTermDebugData() { return *debug_data; } diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index 8e965b7a..bce63091 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -61,13 +61,13 @@ class FTermData final typedef std::unordered_map characterSub; // Constructors - FTermData() = default; + FTermData() {} // Disable copy constructor FTermData (const FTermData&) = delete; // Destructor - ~FTermData() = default; + ~FTermData() {} // Disable assignment operator (=) FTermData& operator = (const FTermData&) = delete; diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 15d525a5..7efd73bd 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -43,6 +43,7 @@ #include "final/fc.h" #include "final/fconfig.h" +#include "final/fsystem.h" #include "final/ftermdata.h" #include "final/ftermios.h" #include "final/ftypes.h" @@ -154,6 +155,7 @@ class FTermDetection final static void setTmuxTerm (bool); static void setTerminalDetection (bool); static void setFTermData (FTermData*); + static void setFSystem (FSystem*); static void setTtyTypeFileName (char[]); // Methods @@ -210,6 +212,7 @@ class FTermDetection final static const FString* answer_back; static const FString* sec_da; static FTermData* fterm_data; + static FSystem* fsystem; static terminalType terminal_type; static struct colorEnv diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 18ca2c48..6e9496aa 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -36,6 +36,7 @@ #endif #include "final/fc.h" +#include "final/fsystem.h" #include "final/ftypes.h" #if defined(__FreeBSD__) || defined(__DragonFly__) @@ -82,6 +83,7 @@ class FTermFreeBSD final static bool isFreeBSDConsole(); // Mutators + static void setFSystem (FSystem*); static void setCursorStyle (CursorStyle, bool); static void enableChangeCursorStyle(); static void disableChangeCursorStyle(); @@ -106,6 +108,7 @@ class FTermFreeBSD final static CursorStyle cursor_style; static bool change_cursorstyle; static bool meta_sends_escape; + static FSystem* fsystem; }; #pragma pack(pop) @@ -116,6 +119,10 @@ inline const char* FTermFreeBSD::getClassName() const //---------------------------------------------------------------------- #if defined(__FreeBSD__) || defined(__DragonFly__) +inline void FTermFreeBSD::setFSystem (FSystem* fsys) +{ fsystem = fsys; } + +//---------------------------------------------------------------------- inline void FTermFreeBSD::enableChangeCursorStyle() { change_cursorstyle = true; } diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 45c931ae..2f108c68 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -53,6 +53,7 @@ #include "final/fc.h" #include "final/fcharmap.h" +#include "final/fsystem.h" #include "final/ftermdetection.h" #include "final/ftypes.h" @@ -88,6 +89,7 @@ class FTermLinux final // Mutators static void setFTermData (FTermData*); + static void setFSystem (FSystem*); static void setFTermDetection (FTermDetection*); static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool); static bool setPalette (FColor, int, int, int); @@ -181,6 +183,7 @@ class FTermLinux final static bool half_block_character; static bool has_saved_palette; static FTermData* fterm_data; + static FSystem* fsystem; static FTermDetection* term_detection; static fc::linuxConsoleCursorStyle linux_console_cursor_style; @@ -207,6 +210,10 @@ inline int FTermLinux::getFramebufferBpp() inline void FTermLinux::setFTermData (FTermData* data) { fterm_data = data; } +//---------------------------------------------------------------------- +inline void FTermLinux::setFSystem (FSystem* fsys) +{ fsystem = fsys; } + //---------------------------------------------------------------------- inline void FTermLinux::setFTermDetection (FTermDetection* td) { term_detection = td; } diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 937f2511..36cac577 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -36,6 +36,7 @@ #endif #include +#include "final/fsystem.h" #if defined(__NetBSD__) || defined(__OpenBSD__) #include @@ -74,6 +75,7 @@ class FTermOpenBSD final static bool isBSDConsole(); // Mutators + static void setFSystem (FSystem*); static void disableMetaSendsEscape(); static void enableMetaSendsEscape(); @@ -92,6 +94,7 @@ class FTermOpenBSD final // Data Members static kbd_t bsd_keyboard_encoding; static bool meta_sends_escape; + static FSystem* fsystem; #endif // defined(__NetBSD__) || defined(__OpenBSD__) }; #pragma pack(pop) @@ -103,6 +106,10 @@ inline const char* FTermOpenBSD::getClassName() const //---------------------------------------------------------------------- #if defined(__NetBSD__) || defined(__OpenBSD__) +inline void FTermOpenBSD::setFSystem (FSystem* fsys) +{ fsystem = fsys; } + +//---------------------------------------------------------------------- inline void FTermOpenBSD::enableMetaSendsEscape() { meta_sends_escape = true; } diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index ec30f938..12020637 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-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 * @@ -40,6 +40,7 @@ namespace { typedef unsigned char uChar; +typedef unsigned short uShort; typedef unsigned int uInt; typedef unsigned long uLong; typedef uint8_t uInt8;