From 54dbbbcf4e4e7c7aeeeab1feaae5aafcce069444 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 10 Feb 2019 22:38:00 +0100 Subject: [PATCH 01/70] Build on Solaris --- doc/build_solaris.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/build_solaris.txt diff --git a/doc/build_solaris.txt b/doc/build_solaris.txt new file mode 100644 index 00000000..ec912bd8 --- /dev/null +++ b/doc/build_solaris.txt @@ -0,0 +1,12 @@ +Install gcc5g++ on Solaris +https://www.opencsw.org/packages/gcc5g++/ + +pkgadd -d http://get.opencsw.org/now +/opt/csw/bin/pkgutil -U +/opt/csw/bin/pkgutil -y -i gcc5g++ +/usr/sbin/pkgchk -L CSWgcc5g++ # list files + + + +PATH=/opt/csw/bin:$PATH + From 2270f4cde5ae0254cd00d46af30d48f13130bcc8 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 24 Feb 2019 00:25:36 +0100 Subject: [PATCH 02/70] Three new methods in FLineEdit --- ChangeLog | 6 +++ doc/first-steps.md | 16 +++---- examples/termcap.cpp | 4 +- examples/ui.cpp | 2 +- src/flineedit.cpp | 85 ++++++++++++++++++++++++++------- src/flistview.cpp | 5 +- src/fsize.cpp | 2 +- src/ftermbuffer.cpp | 10 ++-- src/ftermlinux.cpp | 2 +- src/fvterm.cpp | 60 +++++++++++++---------- src/include/final/flineedit.h | 27 ++++++++++- src/include/final/fsize.h | 4 +- src/include/final/ftermbuffer.h | 49 +++++++++++++------ src/include/final/fvterm.h | 23 +++++++-- 14 files changed, 205 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index f90263c0..50387185 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-02-24 Markus Gans + * FLineEdit now has the ability to define a character input filter + via regular expression (regex) + * Now FLineEdit can define a maximum character length for the input + * The cursor position can now be set directly in FLineEdit + 2019-02-07 Markus Gans * Add a "dynamic layout" Chapter into the first steps document diff --git a/doc/first-steps.md b/doc/first-steps.md index 457d83a3..ffd34414 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -702,8 +702,8 @@ class dialogWidget : public FDialog { setText ("Dialog"); setResizeable(); - btn.setGeometry (FPoint(1, 1), FSize(12, 1), false); - line.setGeometry (FPoint(2, 3), FSize(12, 1), false); + button.setGeometry (FPoint(1, 1), FSize(12, 1), false); + input.setGeometry (FPoint(2, 3), FSize(12, 1), false); // Set dialog geometry and calling adjustSize() setGeometry (FPoint(25, 5), FSize(40, 12)); setMinimumSize (FSize(25, 9)); @@ -727,12 +727,12 @@ class dialogWidget : public FDialog void adjustWidgets() { - auto bx = int(getWidth() - btn.getWidth() - 3); + auto bx = int(getWidth() - button.getWidth() - 3); auto by = int(getHeight() - 4); - btn.setPos (FPoint(bx, by), false); - line.setWidth (getWidth() - 4); + button.setPos (FPoint(bx, by), false); + input.setWidth (getWidth() - 4); auto ly = int(getHeight() / 2) - 1; - line.setY (ly, false); + input.setY (ly, false); } virtual void adjustSize() override @@ -764,8 +764,8 @@ class dialogWidget : public FDialog << "top"; } - FLineEdit line{"Middle", this}; - FButton btn{"&Bottom", this}; + FLineEdit input{"Middle", this}; + FButton button{"&Bottom", this}; }; int main (int argc, char* argv[]) diff --git a/examples/termcap.cpp b/examples/termcap.cpp index 6f18cbf2..0df88474 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -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 * @@ -313,7 +313,7 @@ int main (int argc, char* argv[]) // Pointer to the global virtual terminal object terminal = static_cast(&TermApp); - finalcut::FTermcap::tcap_map* tcap = nullptr; + finalcut::FTermcap::tcap_map* tcap; tcap = finalcut::FTermcap::getTermcapMap(); std::cout << "--------\r\nFTermcap\r\n--------\r\n\n"; diff --git a/examples/ui.cpp b/examples/ui.cpp index d9751249..694bfdf1 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -269,7 +269,7 @@ class MyDialog : public finalcut::FDialog MyDialog& operator = (const MyDialog&) = delete; private: - // Method + // Methods void initMenu(); void initMenuCallbacks(); void initFileMenuCallbacks(); diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 89fdd4f9..b60bb43a 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -20,6 +20,8 @@ * . * ***********************************************************************/ +#include + #include "final/fapplication.h" #include "final/flineedit.h" #include "final/fstatusbar.h" @@ -244,13 +246,41 @@ bool FLineEdit::setShadow (bool enable) //---------------------------------------------------------------------- void FLineEdit::setText (const FString& txt) { - text_offset = 0; - cursor_pos = 0; - if ( txt ) - text = txt; + { + if ( txt.getLength() > max_length ) + text = txt.left(max_length); + else + text = txt; + } else text = ""; + + keyEnd(); +} + +//---------------------------------------------------------------------- +void FLineEdit::setMaxLength (std::size_t max) +{ + max_length = max; + + if ( text.getLength() > max_length ) + text = text.left(max_length); + + keyEnd(); +} + +//---------------------------------------------------------------------- +void FLineEdit::setCursorPosition (std::size_t pos) +{ + cursor_pos = pos; + + if ( cursor_pos > text.getLength() ) + keyEnd(); + else if ( cursor_pos >= getWidth() - 1 ) + text_offset = text.getLength() - getWidth() + 2; + else + text_offset = 0; } //---------------------------------------------------------------------- @@ -766,6 +796,8 @@ inline void FLineEdit::keyEnd() if ( cursor_pos >= getWidth() - 1 ) text_offset = len - getWidth() + 2; + else + text_offset = 0; } //---------------------------------------------------------------------- @@ -792,11 +824,12 @@ inline void FLineEdit::keyBackspace() if ( text.getLength() > 0 && cursor_pos > 0 ) { text.remove(cursor_pos - 1, 1); - processChanged(); cursor_pos--; if ( text_offset > 0 ) text_offset--; + + processChanged(); } } @@ -820,41 +853,57 @@ inline void FLineEdit::keyEnter() //---------------------------------------------------------------------- inline bool FLineEdit::keyInput (FKey key) { + if ( text.getLength() >= max_length ) + { + beep(); + return true; + } + if ( key >= 0x20 && key <= 0x10fff ) { std::size_t len = text.getLength(); + wchar_t c = characterFilter(wchar_t(key)); - if ( cursor_pos == len ) - { - text += wchar_t(key); - processChanged(); - } + if ( c == L'\0' ) + return false; + else if ( cursor_pos == len ) + text += c; else if ( len > 0 ) { if ( insert_mode ) - text.insert(wchar_t(key), cursor_pos); + text.insert(c, cursor_pos); else - text.overwrite(wchar_t(key), cursor_pos); - - processChanged(); + text.overwrite(c, cursor_pos); } else - { - text = wchar_t(key); - processChanged(); - } + text = c; cursor_pos++; if ( cursor_pos >= getWidth() - 1 ) text_offset++; + processChanged(); return true; } else return false; } +//---------------------------------------------------------------------- +inline wchar_t FLineEdit::characterFilter (const wchar_t c) +{ + if ( input_filter.empty() ) + return c; + + wchar_t character[2]{c, L'\0'}; + + if ( regex_match(character, std::wregex(input_filter)) ) + return c; + else + return L'\0'; +} + //---------------------------------------------------------------------- void FLineEdit::processActivate() { diff --git a/src/flistview.cpp b/src/flistview.cpp index 149a05c9..c1946e3d 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1611,10 +1611,7 @@ void FListView::drawListLine ( const FListViewItem* item { for (std::size_t col = 0; col < item->column_list.size(); ) { - static constexpr std::size_t leading_space = 1; - static constexpr std::size_t checkbox_space = 4; static constexpr std::size_t ellipsis_length = 2; - const auto& text = item->column_list[col]; std::size_t width = std::size_t(header[col].width); std::size_t txt_length = text.getLength(); @@ -1626,6 +1623,7 @@ void FListView::drawListLine ( const FListViewItem* item if ( tree_view && col == 1 ) { + static constexpr std::size_t checkbox_space = 4; width -= (indent + 1); if ( item->isCheckable() ) @@ -1639,6 +1637,7 @@ void FListView::drawListLine ( const FListViewItem* item if ( align_offset + txt_length <= width ) { // Insert text and trailing space + static constexpr std::size_t leading_space = 1; line += text.left(width); line += FString ( leading_space + width - align_offset - txt_length, L' '); diff --git a/src/fsize.cpp b/src/fsize.cpp index cb8189c8..fa99cb21 100644 --- a/src/fsize.cpp +++ b/src/fsize.cpp @@ -44,7 +44,7 @@ FSize& FSize::operator = (const FSize& s) //---------------------------------------------------------------------- FSize& FSize::operator += (const FSize& s) { - std::size_t max = std::numeric_limits::max(); + constexpr std::size_t max = std::numeric_limits::max(); width = ( width < max - s.width) ? width + s.width : max; height = ( height < max - s.height) ? height + s.height : max; return *this; diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index eed29505..b65b8fd4 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -96,18 +96,14 @@ int FTermBuffer::write (wchar_t c) //---------------------------------------------------------------------- void FTermBuffer::write (const FColorPair& pair) { - charData nc; // next character - nc = FVTerm::getAttribute(); - nc.fg_color = pair.fg_color; - nc.bg_color = pair.bg_color; + FVTerm::setColor(pair.fg_color, pair.bg_color); } // FTermBuffer non-member operators //---------------------------------------------------------------------- -std::vector& operator << \ - ( std::vector& termString - , const FTermBuffer& buf ) +FTermBuffer::charDataVector& operator << ( FTermBuffer::charDataVector& termString + , const FTermBuffer& buf ) { if ( ! buf.data.empty() ) termString.assign(buf.data.begin(), buf.data.end()); diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index d0781753..460e0d3a 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -504,7 +504,6 @@ int FTermLinux::getFramebuffer_bpp() //---------------------------------------------------------------------- bool FTermLinux::getScreenFont() { - static constexpr std::size_t data_size = 4 * 32 * 512; struct console_font_op font; int fd_tty = FTerm::getTTYFileDescriptor(); @@ -525,6 +524,7 @@ bool FTermLinux::getScreenFont() // initialize with 0 try { + static constexpr std::size_t data_size = 4 * 32 * 512; font.data = new uChar[data_size](); } catch (const std::bad_alloc& ex) diff --git a/src/fvterm.cpp b/src/fvterm.cpp index a700ebd6..d5436c18 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -26,6 +26,7 @@ #include "final/fapplication.h" #include "final/fterm.h" +#include "final/ftermbuffer.h" #include "final/fvterm.h" #include "final/fwidget.h" #include "final/fwindow.h" @@ -79,12 +80,18 @@ FVTerm::FVTerm (bool initialize, bool disable_alt_screen) FVTerm::~FVTerm() // destructor { if ( init_object == this ) - { finish(); - } } +// Overloaded operators +//---------------------------------------------------------------------- +FVTerm& FVTerm::operator << (const FTermBuffer& term_buffer) +{ + print (term_buffer); + return *this; +} + // public methods of FVTerm //---------------------------------------------------------------------- FPoint FVTerm::getPrintCursor() @@ -317,12 +324,7 @@ int FVTerm::print (const FString& s) auto area = getPrintArea(); if ( ! area ) - { - if ( vdesktop ) - area = vdesktop; - else - return -1; - } + return -1; return print (area, s); } @@ -357,6 +359,27 @@ int FVTerm::print (term_area* area, const FString& s) return 0; } +//---------------------------------------------------------------------- +int FVTerm::print (const FTermBuffer& term_buffer) +{ + if ( term_buffer.isEmpty() ) + return -1; + + auto area = getPrintArea(); + + if ( ! area ) + return -1; + + return print (area, term_buffer); +} + +//---------------------------------------------------------------------- +int FVTerm::print (term_area* 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) { @@ -366,12 +389,7 @@ int FVTerm::print (const std::vector& term_string) auto area = getPrintArea(); if ( ! area ) - { - if ( vdesktop ) - area = vdesktop; - else - return -1; - } + return -1; return print (area, term_string); } @@ -440,12 +458,7 @@ int FVTerm::print (wchar_t c) auto area = getPrintArea(); if ( ! area ) - { - if ( vdesktop ) - area = vdesktop; - else - return -1; - } + return -1; return print (area, c); } @@ -474,12 +487,7 @@ int FVTerm::print (charData& term_char) auto area = getPrintArea(); if ( ! area ) - { - if ( vdesktop ) - area = vdesktop; - else - return -1; - } + return -1; return print (area, term_char); } diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index 63d3f556..fd58ffed 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2012-2018 Markus Gans * +* Copyright 2012-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 * @@ -105,10 +105,16 @@ class FLineEdit : public FWidget // Accessors virtual const char* getClassName() const override; FString getText() const; + std::size_t getMaxLength() const; + std::size_t getCursorPosition() const; int getLabelOrientation(); // Mutators void setText (const FString&); + void setInputFilter (const FString&); + void clearInputFilter(); + void setMaxLength (std::size_t); + void setCursorPosition (std::size_t); void setLabelText (const FString&); void setLabelOrientation(const label_o); virtual bool setEnable(bool) override; @@ -167,6 +173,7 @@ class FLineEdit : public FWidget void keyInsert(); void keyEnter(); bool keyInput (FKey); + wchar_t characterFilter (const wchar_t); void processActivate(); void processChanged(); @@ -175,12 +182,14 @@ class FLineEdit : public FWidget FString label_text{""}; FLabel* label{}; label_o label_orientation{FLineEdit::label_left}; + std::wstring input_filter{}; dragScroll drag_scroll{FLineEdit::noScroll}; bool scroll_timer{false}; int scroll_repeat{100}; bool insert_mode{true}; std::size_t cursor_pos{0}; std::size_t text_offset{0}; + std::size_t max_length{std::numeric_limits::max()}; }; #pragma pack(pop) @@ -194,10 +203,26 @@ inline const char* FLineEdit::getClassName() const inline FString FLineEdit::getText() const { return text; } +//---------------------------------------------------------------------- +inline std::size_t FLineEdit::getMaxLength() const +{ return max_length; } + +//---------------------------------------------------------------------- +inline std::size_t FLineEdit::getCursorPosition() const +{ return cursor_pos; } + //---------------------------------------------------------------------- inline int FLineEdit::getLabelOrientation() { return int(label_orientation); } +//---------------------------------------------------------------------- +inline void FLineEdit::setInputFilter (const FString& regex_string) +{ input_filter = regex_string.wc_str(); } + +//---------------------------------------------------------------------- +inline void FLineEdit::clearInputFilter() +{ input_filter.clear(); } + //---------------------------------------------------------------------- inline bool FLineEdit::setEnable() { return setEnable(true); } diff --git a/src/include/final/fsize.h b/src/include/final/fsize.h index c97150e1..1efd77e1 100644 --- a/src/include/final/fsize.h +++ b/src/include/final/fsize.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -141,7 +141,7 @@ inline bool operator > (const FSize& s1, const FSize& s2) //---------------------------------------------------------------------- inline FSize operator + (const FSize& s1, const FSize& s2) { - std::size_t max = std::numeric_limits::max(); + constexpr std::size_t max = std::numeric_limits::max(); std::size_t w = ( s1.width < max - s2.width) ? s1.width + s2.width : max; std::size_t h = ( s1.height < max - s2.height) ? s1.height + s2.height : max; return FSize(w, h); diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index 1db499bd..e2455838 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -57,6 +57,7 @@ class FTermBuffer public: // Typedef typedef FOptiAttr::charData charData; + typedef std::vector charDataVector; // Constructor FTermBuffer() = default; @@ -65,17 +66,20 @@ class FTermBuffer virtual ~FTermBuffer(); // Overloaded operators - template - FTermBuffer& operator << (const type&); + template + FTermBuffer& operator << (const typeT&); + FTermBuffer& operator << (const std::string&); + FTermBuffer& operator << (const std::wstring&); FTermBuffer& operator << (const FColorPair&); // Non-member operators - friend std::vector& operator << ( std::vector& - , const FTermBuffer& ); + friend charDataVector& operator << ( charDataVector& + , const FTermBuffer& ); // Accessors virtual const char* getClassName() const; std::size_t getLength() const; + const charDataVector& getBuffer() const; // Inquiry bool isEmpty() const; @@ -87,23 +91,38 @@ class FTermBuffer int write (wchar_t); void write (const FColorPair&); FTermBuffer& write (); - std::vector getBuffer(); private: - std::vector data{}; + charDataVector data{}; }; #pragma pack(pop) // FTermBuffer inline functions //---------------------------------------------------------------------- -template -inline FTermBuffer& FTermBuffer::operator << (const type& s) +template +inline FTermBuffer& FTermBuffer::operator << (const typeT& s) { - FString str(s); std::wostringstream outstream; - outstream << str; - write (outstream.str()); + outstream << s; + + if ( ! outstream.str().empty() ) + write (outstream.str()); + + return *this; +} + +//---------------------------------------------------------------------- +inline FTermBuffer& FTermBuffer::operator << (const std::string& string) +{ + write (string); + return *this; +} + +//---------------------------------------------------------------------- +inline FTermBuffer& FTermBuffer::operator << (const std::wstring& wstring) +{ + write (wstring); return *this; } @@ -122,6 +141,10 @@ inline const char* FTermBuffer::getClassName() const inline std::size_t FTermBuffer::getLength() const { return data.size(); } +//---------------------------------------------------------------------- +inline const FTermBuffer::charDataVector& FTermBuffer::getBuffer() const +{ return data; } + //---------------------------------------------------------------------- inline bool FTermBuffer::isEmpty() const { return data.empty(); } @@ -134,10 +157,6 @@ inline void FTermBuffer::clear() inline FTermBuffer& FTermBuffer::write() { return *this; } -//---------------------------------------------------------------------- -inline std::vector FTermBuffer::getBuffer() -{ return data; } - } // namespace finalcut #endif // FTERMBUFFER_H diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 51547487..b4859773 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -70,8 +70,10 @@ namespace finalcut { // class forward declaration +class FTermBuffer; class FWidget; + //---------------------------------------------------------------------- // class FVTerm //---------------------------------------------------------------------- @@ -130,8 +132,10 @@ class FVTerm FVTerm& operator = (const FVTerm&) = delete; // Overloaded operators - template - FVTerm& operator << (const type&); + template + FVTerm& operator << (const typeT&); + FVTerm& operator << (const std::string&); + FVTerm& operator << (const FTermBuffer&); FVTerm& operator << (const std::vector&); FVTerm& operator << (const FPoint&); FVTerm& operator << (const FColorPair&); @@ -162,7 +166,7 @@ class FVTerm void showCursor(); void setPrintCursor (const FPoint&); FColor rgb2ColorIndex (uInt8, uInt8, uInt8); - void setColor (FColor, FColor); + static void setColor (FColor, FColor); static void setNormal(); static bool setBold (bool); @@ -291,6 +295,8 @@ class FVTerm int printf (const FString, ...); int print (const FString&); int print (term_area*, 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 (wchar_t); @@ -535,8 +541,8 @@ struct FVTerm::term_area // define virtual terminal character properties // FVTerm inline functions //---------------------------------------------------------------------- -template -inline FVTerm& FVTerm::operator << (const type& s) +template +inline FVTerm& FVTerm::operator << (const typeT& s) { std::wostringstream outstream; outstream << s; @@ -547,6 +553,13 @@ inline FVTerm& FVTerm::operator << (const type& s) return *this; } +//---------------------------------------------------------------------- +inline FVTerm& FVTerm::operator << (const std::string& string) +{ + print (string); + return *this; +} + //---------------------------------------------------------------------- inline FVTerm& FVTerm::operator << \ (const std::vector& termString) From b0febda5b4e6d5ec61d2c7d159563150e3c41ccb Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 24 Feb 2019 20:21:12 +0100 Subject: [PATCH 03/70] Added the 7-segment example --- ChangeLog | 2 + examples/7segment | 210 ++++++++++++++++++++++++++++++++++++++++++ examples/7segment.cpp | 207 +++++++++++++++++++++++++++++++++++++++++ examples/Makefile.am | 2 + src/fstring.cpp | 4 +- 5 files changed, 423 insertions(+), 2 deletions(-) create mode 100755 examples/7segment create mode 100644 examples/7segment.cpp diff --git a/ChangeLog b/ChangeLog index 50387185..09ffe79d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ via regular expression (regex) * Now FLineEdit can define a maximum character length for the input * The cursor position can now be set directly in FLineEdit + * Added the 7-segment example to demonstrate the use of FTermBuffer + and FLineEdit input filters 2019-02-07 Markus Gans * Add a "dynamic layout" Chapter into the first steps document diff --git a/examples/7segment b/examples/7segment new file mode 100755 index 00000000..acd32646 --- /dev/null +++ b/examples/7segment @@ -0,0 +1,210 @@ +#! /bin/bash + +# 7segment - temporary wrapper script for .libs/7segment +# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2 +# +# The 7segment program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.6' + notinst_deplibs=' /usr/local/src/MyProgs/finalcut/src/.libs/libfinal.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ that is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options that match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ../libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "7segment:7segment:$LINENO: libtool wrapper (GNU libtool) 2.4.6 Debian-2.4.6-2" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "7segment:7segment:$LINENO: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "7segment:7segment:$LINENO: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program='7segment' + progdir="$thisdir/.libs" + + + if test -f "$progdir/$program"; then + # Add our own library path to LD_LIBRARY_PATH + LD_LIBRARY_PATH="/usr/local/src/MyProgs/finalcut/src/.libs:$LD_LIBRARY_PATH" + + # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH + # The second colon is a workaround for a bug in BeOS R4 sed + LD_LIBRARY_PATH=`$ECHO "$LD_LIBRARY_PATH" | /bin/sed 's/::*$//'` + + export LD_LIBRARY_PATH + + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: '$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/examples/7segment.cpp b/examples/7segment.cpp new file mode 100644 index 00000000..7ca2c021 --- /dev/null +++ b/examples/7segment.cpp @@ -0,0 +1,207 @@ +#include + +using finalcut::FColorPair; +using finalcut::FPoint; +using finalcut::FSize; + + +//---------------------------------------------------------------------- +// class TextWindow +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class SegmentView : public finalcut::FDialog +{ + public: + explicit SegmentView (finalcut::FWidget* = nullptr); + + private: + // Typedef + typedef struct + { + unsigned char a : 1; + unsigned char b : 1; + unsigned char c : 1; + unsigned char d : 1; + unsigned char e : 1; + unsigned char f : 1; + unsigned char g : 1; + unsigned char : 1; // padding bit + } sevenSegment; + + // Methods + void hexEncoding(); + void get7Segment (const wchar_t); + virtual void draw() override; + + // Data Members + std::map code; + finalcut::FString line[3]; + finalcut::FLineEdit Input{"0123", this}; + finalcut::FButton Exit{"E&xit", this}; +}; +#pragma pack(pop) + +//---------------------------------------------------------------------- +SegmentView::SegmentView (finalcut::FWidget* parent) + : FDialog(parent) +{ + // Set encoding + hexEncoding(); + + // Dialog settings + setText ("Seven-segment display"); + setGeometry (FPoint(25, 5), FSize(42, 15)); + + // Input field + Input.setGeometry (FPoint(2, 2), FSize(12, 1)); + Input.setLabelText (L"&Hex value"); + Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)"); + Input.setLabelOrientation(finalcut::FLineEdit::label_above); + Input.setMaxLength(9); + Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]"); + + // Exit button + Exit.setGeometry(FPoint(28, 11), FSize(10, 1)); + + // Add some function callbacks + Input.addCallback + ( + "changed", + [] (finalcut::FWidget*, FDataPtr data) + { + auto dialog = static_cast(data); + dialog->redraw(); + }, + this + ); + + Exit.addCallback + ( + "clicked", + F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) + ); +} + +//---------------------------------------------------------------------- +void SegmentView::hexEncoding() +{ + code['0'] = sevenSegment{1, 1, 1, 1, 1, 1, 0}; + code['1'] = sevenSegment{0, 1, 1, 0, 0, 0, 0}; + code['2'] = sevenSegment{1, 1, 0, 1, 1, 0, 1}; + code['3'] = sevenSegment{1, 1, 1, 1, 0, 0, 1}; + code['4'] = sevenSegment{0, 1, 1, 0, 0, 1, 1}; + code['5'] = sevenSegment{1, 0, 1, 1, 0, 1, 1}; + code['6'] = sevenSegment{1, 0, 1, 1, 1, 1, 1}; + code['7'] = sevenSegment{1, 1, 1, 0, 0, 0, 0}; + code['8'] = sevenSegment{1, 1, 1, 1, 1, 1, 1}; + code['9'] = sevenSegment{1, 1, 1, 1, 0, 1, 1}; + code['A'] = sevenSegment{1, 1, 1, 0, 1, 1, 1}; + code['B'] = sevenSegment{0, 0, 1, 1, 1, 1, 1}; + code['C'] = sevenSegment{1, 0, 0, 1, 1, 1, 0}; + code['D'] = sevenSegment{0, 1, 1, 1, 1, 0, 1}; + code['E'] = sevenSegment{1, 0, 0, 1, 1, 1, 1}; + code['F'] = sevenSegment{1, 0, 0, 0, 1, 1, 1}; +} + +//---------------------------------------------------------------------- +void SegmentView::get7Segment (const wchar_t c) +{ + sevenSegment& s = code[c]; + constexpr char h[2]{' ', '_'}; + constexpr char v[2]{' ', '|'}; + + for (int i = 0; i < 3; i++) + line[i].clear(); + + switch ( c ) + { + case ':': + line[0] = ' '; + line[1] = '.'; + line[2] = '.'; + break; + + case '.': + line[0] = ' '; + line[1] = ' '; + line[2] = '.'; + break; + + case 'H': + line[0] = " "; + line[1] = "|_|"; + line[2] = "| |"; + break; + + case 'L': + line[0] = " "; + line[1] = "| "; + line[2] = "|_ "; + break; + + case 'P': + line[0] = " _ "; + line[1] = "|_|"; + line[2] = "| "; + break; + + case 'U': + line[0] = " "; + line[1] = "| |"; + line[2] = "|_|"; + break; + + default: + // Hexadecimal digit from 0 up to f + line[0] << ' ' << h[s.a] << ' '; + line[1] << v[s.f] << h[s.g] << v[s.b]; + line[2] << v[s.e] << h[s.d] << v[s.c]; + } +} + +//---------------------------------------------------------------------- +void SegmentView::draw() +{ + std::vector tbuffer{3}; + finalcut::FTermBuffer left_space{}; + + FDialog::draw(); + setColor(finalcut::fc::LightGray, finalcut::fc::Black); + FWidget::drawBorder(3, 6, 40, 11); + + for (auto&& ch : Input.getText().toUpper()) + { + FColorPair color(finalcut::fc::LightRed, finalcut::fc::Black); + get7Segment(ch); + + for (std::size_t i = 0; i < 3; i++) + tbuffer[i] << color << line[i] << " "; + } + + std::size_t length = tbuffer[0].getLength(); + + if ( length < 36 ) + left_space << finalcut::FString(36 - length, ' '); + + print() << FPoint (4, 7) << left_space << tbuffer[0] + << FPoint (4, 8) << left_space << tbuffer[1] + << FPoint (4, 9) << left_space << tbuffer[2] + << FPoint (4, 10) << finalcut::FString(36, ' '); +} + + +//---------------------------------------------------------------------- +// main part +//---------------------------------------------------------------------- + +int main (int argc, char* argv[]) +{ + finalcut::FApplication app(argc, argv); + SegmentView dialog(&app); + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} diff --git a/examples/Makefile.am b/examples/Makefile.am index f0a0304e..73a0df1c 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -11,6 +11,7 @@ noinst_PROGRAMS = \ hello \ dialog \ input-dialog \ + 7segment \ choice \ listbox \ listview \ @@ -35,6 +36,7 @@ noinst_PROGRAMS = \ hello_SOURCES = hello.cpp dialog_SOURCES = dialog.cpp input_dialog_SOURCES = input-dialog.cpp +7segment_SOURCES = 7segment.cpp choice_SOURCES = choice.cpp listbox_SOURCES = listbox.cpp listview_SOURCES = listview.cpp diff --git a/src/fstring.cpp b/src/fstring.cpp index d0db046f..616734a1 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -1091,7 +1091,7 @@ bool FString::operator == (const FString& s) const if ( ! (string || s.string) ) return true; - if ( bool(string) != bool(s.string) ) + if ( bool(string) != bool(s.string) || length != s.length ) return false; return ( std::wcscmp(string, s.string) == 0 ); @@ -1103,7 +1103,7 @@ bool FString::operator != (const FString& s) const if ( ! (string || s.string) ) return false; - if ( bool(string) != bool(s.string) ) + if ( bool(string) != bool(s.string) || length != s.length ) return true; return ( std::wcscmp(string, s.string) != 0 ); From cefd894c40ff4cbf472b5994d856586eeaca008f Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 24 Feb 2019 20:59:48 +0100 Subject: [PATCH 04/70] .gitignore --- .gitignore | 1 + examples/7segment | 210 ---------------------------------------------- 2 files changed, 1 insertion(+), 210 deletions(-) delete mode 100755 examples/7segment diff --git a/.gitignore b/.gitignore index 1be54131..02e5572c 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ examples/windows examples/term-attributes examples/transparent examples/input-dialog +examples/7segment examples/choice examples/listbox examples/listview diff --git a/examples/7segment b/examples/7segment deleted file mode 100755 index acd32646..00000000 --- a/examples/7segment +++ /dev/null @@ -1,210 +0,0 @@ -#! /bin/bash - -# 7segment - temporary wrapper script for .libs/7segment -# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2 -# -# The 7segment program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s|\([`"$\\]\)|\\\1|g' - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command="" - -# This environment variable determines our operation mode. -if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then - # install mode needs the following variables: - generated_by_libtool_version='2.4.6' - notinst_deplibs=' /usr/local/src/MyProgs/finalcut/src/.libs/libfinal.la' -else - # When we are sourced in execute mode, $file and $ECHO are already set. - if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then - file="$0" - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - ECHO="printf %s\\n" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ that is used only on -# windows platforms, and (c) all begin with the string --lt- -# (application programs are unlikely to have options that match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's ../libtool value, followed by no. -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=$0 - shift - for lt_opt - do - case "$lt_opt" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` - test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. - lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` - cat "$lt_dump_D/$lt_dump_F" - exit 0 - ;; - --lt-*) - $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n "$lt_option_debug"; then - echo "7segment:7segment:$LINENO: libtool wrapper (GNU libtool) 2.4.6 Debian-2.4.6-2" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - $ECHO "7segment:7segment:$LINENO: newargv[$lt_dump_args_N]: $lt_arg" - lt_dump_args_N=`expr $lt_dump_args_N + 1` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ - - if test -n "$lt_option_debug"; then - $ECHO "7segment:7segment:$LINENO: newargv[0]: $progdir/$program" 1>&2 - func_lt_dump_args ${1+"$@"} 1>&2 - fi - exec "$progdir/$program" ${1+"$@"} - - $ECHO "$0: cannot exec $program $*" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from $@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case " $* " in - *\ --lt-*) - for lt_wr_arg - do - case $lt_wr_arg in - --lt-*) ;; - *) set x "$@" "$lt_wr_arg"; shift;; - esac - shift - done ;; - esac - func_exec_program_core ${1+"$@"} -} - - # Parse options - func_parse_lt_options "$0" ${1+"$@"} - - # Find the directory that this script lives in. - thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` - test "x$thisdir" = "x$file" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` - while test -n "$file"; do - destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` - - # If there was a directory component, then change thisdir. - if test "x$destdir" != "x$file"; then - case "$destdir" in - [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; - *) thisdir="$thisdir/$destdir" ;; - esac - fi - - file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` - file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no - if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then - # special case for '.' - if test "$thisdir" = "."; then - thisdir=`pwd` - fi - # remove .libs from thisdir - case "$thisdir" in - *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; - .libs ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=`cd "$thisdir" && pwd` - test -n "$absdir" && thisdir="$absdir" - - program='7segment' - progdir="$thisdir/.libs" - - - if test -f "$progdir/$program"; then - # Add our own library path to LD_LIBRARY_PATH - LD_LIBRARY_PATH="/usr/local/src/MyProgs/finalcut/src/.libs:$LD_LIBRARY_PATH" - - # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH - # The second colon is a workaround for a bug in BeOS R4 sed - LD_LIBRARY_PATH=`$ECHO "$LD_LIBRARY_PATH" | /bin/sed 's/::*$//'` - - export LD_LIBRARY_PATH - - if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then - # Run the actual program with our arguments. - func_exec_program ${1+"$@"} - fi - else - # The program doesn't exist. - $ECHO "$0: error: '$progdir/$program' does not exist" 1>&2 - $ECHO "This script is just a wrapper for $program." 1>&2 - $ECHO "See the libtool documentation for more information." 1>&2 - exit 1 - fi -fi From e3fb0c4a564e85b84928da622394de5812c7db4b Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 25 Feb 2019 23:35:27 +0100 Subject: [PATCH 05/70] Drawing of the progress bar has been improved --- src/fprogressbar.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 819557d8..c0dc7be7 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -161,8 +161,7 @@ void FProgressbar::drawProgressLabel() void FProgressbar::drawProgressBar() { std::size_t len = 0; - print() << FPoint(1, 1) - << FColorPair(wc.progressbar_bg, wc.progressbar_fg); + print() << FPoint(1, 1); if ( percentage > 0 && percentage <= 100 ) len = drawProgressIndicator(); @@ -182,14 +181,12 @@ std::size_t FProgressbar::drawProgressIndicator() // Draw the progress indicator if ( isMonochron() ) - setReverse(false); + setReverse(true); double length = double(bar_length * percentage) / 100; auto len = std::size_t(trunc(length)); - print() << FString (len, L' '); - - if ( isMonochron() ) - setReverse(true); + print() << FColorPair (wc.progressbar_fg, wc.progressbar_fg) + << FString (len, fc::FullBlock); // █ if ( len >= bar_length ) return len; From 93f464f30e3647d5a231eb1fe61742d229fd587c Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 28 Feb 2019 02:18:30 +0100 Subject: [PATCH 06/70] Add an lambda expression callback example to the first steps document --- ChangeLog | 3 +++ doc/first-steps.md | 60 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 09ffe79d..5c15cb1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-02-28 Markus Gans + * Add an lambda expression callback example to the first steps document + 2019-02-24 Markus Gans * FLineEdit now has the ability to define a character input filter via regular expression (regex) diff --git a/doc/first-steps.md b/doc/first-steps.md index ffd34414..136d7a99 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -13,6 +13,7 @@ Table of Contents - [Signals and Callbacks](#signals-and-callbacks) - [Default signals](#the-final-cut-widgets-emit-the-following-default-signals) - [Callback function](#example-of-a-callback-function) +- [Callback lambda expression](#example-of-an-lambda-expression-callback) - [Callback method](#example-of-a-callback-function) - [Custom signals](#send-custom-signals) - [Dynamic layout](#dynamic-layout) @@ -479,6 +480,64 @@ g++ -O2 -lfinal callback-function.cpp -o callback-function ```   +### Example of an lambda expression callback: ### + +**File:** *callback-lambda.cpp* + +```cpp +#include + +using namespace finalcut; + +int main (int argc, char* argv[]) +{ + FApplication app(argc, argv); + FDialog dialog(&app); + dialog.setText ("Lambda expression as callback"); + dialog.setGeometry (FRect(25, 5, 45, 9)); + FButton button ("&bottom", &dialog); + button.setGeometry (FPoint(15, 5), FSize(14, 1)); + + // Connect the button signal "clicked" with the lambda expression + button.addCallback + ( + "clicked", + [] (FWidget* w, FDataPtr d) + { + FButton& button = *(static_cast(w)); + + if ( button.getY() != 2 ) + { + button.setPos (FPoint(15, 2)); + button.setText("&top"); + } + else + { + button.setPos (FPoint(15, 5)); + button.setText("&bottom"); + } + + static_cast(d)->redraw(); + }, + &dialog + ); + + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} +``` +*(Note: You can close the dialog with the mouse, +Shift+F10 or Ctrl+^)* + + +After entering the source code in *callback-lambda.cpp* you can compile +the above program with gcc: +```cpp +g++ -O2 -lfinal callback-lambda.cpp -o callback-lambda +``` +  + ### Example of a callback method: ### **File:** *callback-method.cpp* @@ -786,4 +845,3 @@ the above program with gcc: ```cpp g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment ``` - From 439b8310ef9410ae686fe269355797e14c47bdd8 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 24 Mar 2019 20:15:17 +0100 Subject: [PATCH 07/70] Add a "scroll view" chapter to the first steps document --- ChangeLog | 5 +- doc/Makefile.am | 4 ++ doc/first-steps.md | 123 +++++++++++++++++++++++++++++++++- src/flineedit.cpp | 9 ++- src/flistbox.cpp | 2 +- src/flistview.cpp | 4 +- src/include/final/flineedit.h | 7 +- 7 files changed, 148 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c15cb1e..e1f2767b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-03-24 Markus Gans + * Add a "scroll view" chapter to the first steps document + 2019-02-28 Markus Gans * Add an lambda expression callback example to the first steps document @@ -10,7 +13,7 @@ and FLineEdit input filters 2019-02-07 Markus Gans - * Add a "dynamic layout" Chapter into the first steps document + * Add a "dynamic layout" chapter into the first steps document 2019-01-30 Markus Gans * Printing an FColorPair object can change the foreground and diff --git a/doc/Makefile.am b/doc/Makefile.am index 90b9f8dd..5843c239 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -9,7 +9,9 @@ EXTRA_DIST = \ class-diagram.txt \ console_codes-manual.sh \ console_ioctl-manual.sh \ + faq.md \ fileopen-dialog.png \ + first-steps.md \ ncurses.supp \ newfont1.png \ newfont2.png \ @@ -29,7 +31,9 @@ doc_DATA = \ class-diagram.txt \ console_codes-manual.sh \ console_ioctl-manual.sh \ + faq.md \ fileopen-dialog.png \ + first-steps.md \ ncurses.supp \ newfont1.png \ newfont2.png \ diff --git a/doc/first-steps.md b/doc/first-steps.md index 136d7a99..6c56a369 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -534,7 +534,7 @@ int main (int argc, char* argv[]) After entering the source code in *callback-lambda.cpp* you can compile the above program with gcc: ```cpp -g++ -O2 -lfinal callback-lambda.cpp -o callback-lambda +g++ -O2 -lfinal -std=c++11 callback-lambda.cpp -o callback-lambda ```   @@ -845,3 +845,124 @@ the above program with gcc: ```cpp g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment ``` + + +Scroll view +----------- + +The scroll view of the `FScrollView` class allows users to view content +that is larger than the visible area. The `FScrollView` widget displays +the horizontal and vertical scroll bar by default, only if the content size +requires it. You can controll this behavior by the two methods +`setHorizontalScrollBarMode()` and `setVerticalScrollBarMode()`. + +```cpp +setHorizontalScrollBarMode (fc::scrollBarMode) +setVerticalScrollBarMode (fc::scrollBarMode) +``` + +You pass the scroll bar visibility mode as a value of the enum type +`fc::scrollBarMode`. + +```cpp +enum scrollBarMode +{ + Auto = 0, // Shows a scroll bar when area is larger than viewport + Hidden = 1, // Never shows a scroll bar + Scroll = 2 // Always shows a scroll bar +}; +``` + +You can add widgets to an `FScrollView` object as child objects and place +them (with a widget positioning method) on the scrollable area. If a client +widget gets the focus, it automatically scrolls the viewport to the focused +widget. You can use the methods `scrollTo()`, `scrollToX()`, `scrollToY()` +and `scrollBy()` to set the scroll position of the viewport directly. + +The `FButtonGroup` widget uses `FScrollView` to display more buttons +in the frame than the height allows. + +**File:** *scrollview.cpp* +```cpp +#include +#include + +using namespace finalcut; + +class dialogWidget : public FDialog +{ + public: + explicit dialogWidget (FWidget* parent = nullptr) + : FDialog(parent) + { + setText ("Dialog"); + setGeometry (FPoint(28, 2), FSize(24, 21)); + scrollview.setGeometry(FPoint(1, 1), FSize(22, 11)); + scrollview.setScrollSize(FSize(60, 27)); + setColor (wc.label_inactive_fg, wc.dialog_bg); + scrollview.clearArea(); + FColorPair red (fc::LightRed, wc.dialog_bg); + FColorPair black (fc::Black, wc.dialog_bg); + FColorPair cyan (fc::Cyan, wc.dialog_bg); + + static std::vector d + { + {"NW", FPoint(3, 13), FPoint(1, 1), black}, + {"N", FPoint(10, 13), FPoint(21, 1), red}, + {"NE", FPoint(17, 13), FPoint(41, 1), black}, + {"W", FPoint(3, 15), FPoint(1, 10), black}, + {"*", FPoint(10, 15), FPoint(21, 10), black}, + {"E", FPoint(17, 15), FPoint(41, 10), black}, + {"SW", FPoint(3, 17), FPoint(1, 19), black}, + {"S", FPoint(10, 17), FPoint(21, 19), cyan}, + {"SE", FPoint(17, 17), FPoint(41, 19), black} + }; + + for (auto&& b : d) + { + scrollview.print() << std::get<2>(b) + FPoint(10, 5) + << std::get<3>(b) << std::get<0>(b); + auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview); + edit->setGeometry(std::get<2>(b) + FPoint(1, 1), FSize(17, 1)); + auto btn = new FButton(std::get<0>(b), this); + btn->setGeometry(std::get<1>(b), FSize(4, 1)); + btn->unsetShadow(); + btn->addCallback + ( + "clicked", + F_METHOD_CALLBACK (this, &dialogWidget::cb_button), + static_cast(&std::get<2>(b)) + ); + }; + } + + private: + typedef std::tuple direction; + + void cb_button (FWidget*, FDataPtr data) + { + FPoint* p = static_cast(data); + scrollview.scrollTo(*p); + } + + FScrollView scrollview{this}; +}; + +int main (int argc, char* argv[]) +{ + FApplication app(argc, argv); + dialogWidget dialog(&app); + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} +``` +*(Note: You can close the window with the mouse, +Shift+F10 or Ctrl+^)* + + +After entering the source code in *scrollview.cpp* you can compile +the above program with gcc: +```cpp +g++ -O2 -lfinal -std=c++11 scrollview.cpp -o scrollview +``` diff --git a/src/flineedit.cpp b/src/flineedit.cpp index b60bb43a..184e92e3 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -292,12 +292,19 @@ void FLineEdit::setLabelText (const FString& ltxt) } //---------------------------------------------------------------------- -void FLineEdit::setLabelOrientation(const label_o o) +void FLineEdit::setLabelOrientation (const label_o o) { label_orientation = o; adjustLabel(); } +//---------------------------------------------------------------------- +void FLineEdit::setGeometry ( const FPoint& pos, const FSize& size + , bool adjust ) +{ + FWidget::setGeometry(pos, size, adjust); + keyEnd(); +} //---------------------------------------------------------------------- void FLineEdit::hide() { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 2ce836d3..51eb7490 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -161,7 +161,7 @@ void FListBox::showInsideBrackets ( std::size_t index //---------------------------------------------------------------------- void FListBox::setGeometry ( const FPoint& pos, const FSize& size - , bool adjust) + , bool adjust ) { // Set the widget geometry diff --git a/src/flistview.cpp b/src/flistview.cpp index c1946e3d..e11eb8f6 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1623,11 +1623,13 @@ void FListView::drawListLine ( const FListViewItem* item if ( tree_view && col == 1 ) { - static constexpr std::size_t checkbox_space = 4; width -= (indent + 1); if ( item->isCheckable() ) + { + static constexpr std::size_t checkbox_space = 4; width -= checkbox_space; + } } // Insert alignment spaces diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index fd58ffed..b108d673 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -75,6 +75,9 @@ class FLineEdit : public FWidget label_left = 1 }; + // Using-declaration + using FWidget::setGeometry; + // Constructor explicit FLineEdit (FWidget* = nullptr); explicit FLineEdit (const FString&, FWidget* = nullptr); @@ -116,7 +119,9 @@ class FLineEdit : public FWidget void setMaxLength (std::size_t); void setCursorPosition (std::size_t); void setLabelText (const FString&); - void setLabelOrientation(const label_o); + void setLabelOrientation (const label_o); + virtual void setGeometry ( const FPoint&, const FSize& + , bool = true ) override; virtual bool setEnable(bool) override; virtual bool setEnable() override; virtual bool unsetEnable() override; From e3b226b10d3ee87bb09a247cc1665103305d0463 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 24 Mar 2019 20:17:54 +0100 Subject: [PATCH 08/70] Add a "scroll view" chapter to the first steps document --- doc/first-steps.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/first-steps.md b/doc/first-steps.md index 6c56a369..93d6aaab 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -17,6 +17,7 @@ Table of Contents - [Callback method](#example-of-a-callback-function) - [Custom signals](#send-custom-signals) - [Dynamic layout](#dynamic-layout) +- [Scroll view](#scroll-view) @@ -857,8 +858,8 @@ requires it. You can controll this behavior by the two methods `setHorizontalScrollBarMode()` and `setVerticalScrollBarMode()`. ```cpp -setHorizontalScrollBarMode (fc::scrollBarMode) -setVerticalScrollBarMode (fc::scrollBarMode) +setHorizontalScrollBarMode (fc::scrollBarMode); +setVerticalScrollBarMode (fc::scrollBarMode); ``` You pass the scroll bar visibility mode as a value of the enum type From 7f206e88f0f91382e6c388891eaa39bfd12aec4e Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 26 Apr 2019 21:06:04 +0200 Subject: [PATCH 09/70] Using namespace aliases finalcut::fc in some exemple programs --- examples/7segment.cpp | 5 +- examples/calculator.cpp | 52 +++++----- examples/checklist.cpp | 13 +-- examples/listview.cpp | 19 ++-- examples/mandelbrot.cpp | 5 +- examples/menu.cpp | 31 +++--- examples/mouse.cpp | 59 ++++++------ examples/scrollview.cpp | 9 +- examples/string-operations.cpp | 6 +- examples/term-attributes.cpp | 27 +++--- examples/termcap.cpp | 169 +++++++++++++++++---------------- examples/timer.cpp | 10 +- examples/transparent.cpp | 5 +- examples/treeview.cpp | 11 ++- examples/ui.cpp | 47 ++++----- examples/windows.cpp | 17 ++-- src/ftermlinux.cpp | 6 +- test/fstring-test.cpp | 40 ++++---- 18 files changed, 273 insertions(+), 258 deletions(-) diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 7ca2c021..09187845 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -1,5 +1,6 @@ #include +namespace fc = finalcut::fc; using finalcut::FColorPair; using finalcut::FPoint; using finalcut::FSize; @@ -169,12 +170,12 @@ void SegmentView::draw() finalcut::FTermBuffer left_space{}; FDialog::draw(); - setColor(finalcut::fc::LightGray, finalcut::fc::Black); + setColor(fc::LightGray, fc::Black); FWidget::drawBorder(3, 6, 40, 11); for (auto&& ch : Input.getText().toUpper()) { - FColorPair color(finalcut::fc::LightRed, finalcut::fc::Black); + FColorPair color(fc::LightRed, fc::Black); get7Segment(ch); for (std::size_t i = 0; i < 3; i++) diff --git a/examples/calculator.cpp b/examples/calculator.cpp index ed5d7735..63397660 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -30,6 +30,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; using finalcut::FColorPair; @@ -77,9 +78,9 @@ void Button::setChecked (bool enable) if ( checked ) { - setBackgroundColor(finalcut::fc::Cyan); - setFocusForegroundColor(finalcut::fc::White); - setFocusBackgroundColor(finalcut::fc::Cyan); + setBackgroundColor(fc::Cyan); + setFocusForegroundColor(fc::White); + setFocusBackgroundColor(fc::Cyan); } else { @@ -97,8 +98,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev) FKey key = ev->key(); // catch the enter key - if ( key == finalcut::fc::Fkey_return - || key == finalcut::fc::Fkey_enter ) + if ( key == fc::Fkey_return || key == fc::Fkey_enter ) return; finalcut::FButton::onKeyPress(ev); @@ -275,8 +275,8 @@ Calc::Calc (FWidget* parent) btn->setFlat(); btn->setNoUnderline(); btn->setText(getButtonText(key)); - btn->setDoubleFlatLine(finalcut::fc::top); - btn->setDoubleFlatLine(finalcut::fc::bottom); + btn->setDoubleFlatLine(fc::top); + btn->setDoubleFlatLine(fc::bottom); if ( isNewFont() ) btn->unsetClickAnimation(); @@ -291,7 +291,7 @@ Calc::Calc (FWidget* parent) calculator_buttons[button(key)] = btn; } - calculator_buttons[On]->addAccelerator(finalcut::fc::Fkey_dc); // Del key + calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // Del key calculator_buttons[On]->setFocus(); calculator_buttons[Pi]->addAccelerator('p'); calculator_buttons[Power]->addAccelerator('^'); @@ -300,8 +300,8 @@ Calc::Calc (FWidget* parent) calculator_buttons[Multiply]->addAccelerator('*'); calculator_buttons[Decimal_point]->addAccelerator(','); calculator_buttons[Change_sign]->addAccelerator('#'); - calculator_buttons[Equals]->addAccelerator(finalcut::fc::Fkey_return); - calculator_buttons[Equals]->addAccelerator(finalcut::fc::Fkey_enter); + calculator_buttons[Equals]->addAccelerator(fc::Fkey_return); + calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter); } //---------------------------------------------------------------------- @@ -337,7 +337,7 @@ void Calc::drawDispay() if ( isMonochron() ) setReverse(false); - print() << FColorPair(finalcut::fc::Black, finalcut::fc::LightGray) + print() << FColorPair(fc::Black, fc::LightGray) << FPoint(3, 3) << display << ' ' << FColorPair(wc.dialog_fg, wc.dialog_bg); @@ -346,11 +346,11 @@ void Calc::drawDispay() if ( isNewFont() ) { - wchar_t bottom_line = finalcut::fc::NF_border_line_bottom; - wchar_t top_bottom_line = finalcut::fc::NF_border_line_up_and_down; - wchar_t top_line = finalcut::fc::NF_border_line_upper; - wchar_t right_line = finalcut::fc::NF_rev_border_line_right; - wchar_t left_line = finalcut::fc::NF_border_line_left; + wchar_t bottom_line = fc::NF_border_line_bottom; + wchar_t top_bottom_line = fc::NF_border_line_up_and_down; + wchar_t top_line = fc::NF_border_line_upper; + wchar_t right_line = fc::NF_rev_border_line_right; + wchar_t left_line = fc::NF_border_line_left; print() << FPoint(3, 2) << finalcut::FString(33, bottom_line); print() << FPoint(2, 3) << right_line; print() << FPoint(36, 3) << left_line; @@ -365,9 +365,9 @@ void Calc::drawDispay() } else { - wchar_t vertical_and_right = finalcut::fc::BoxDrawingsVerticalAndRight; - wchar_t horizontal = finalcut::fc::BoxDrawingsHorizontal; - wchar_t vertical_and_left = finalcut::fc::BoxDrawingsVerticalAndLeft; + wchar_t vertical_and_right = fc::BoxDrawingsVerticalAndRight; + wchar_t horizontal = fc::BoxDrawingsHorizontal; + wchar_t vertical_and_left = fc::BoxDrawingsVerticalAndLeft; finalcut::FString separator = finalcut::FString(vertical_and_right) + finalcut::FString(35, horizontal) + finalcut::FString(vertical_and_left); @@ -838,8 +838,8 @@ void Calc::tangent (lDouble& x) void Calc::draw() { setBold(); - setColor (finalcut::fc::Blue, finalcut::fc::Cyan); - clearArea (vdesktop, finalcut::fc::MediumShade); + setColor (fc::Blue, fc::Cyan); + clearArea (vdesktop, fc::MediumShade); unsetBold(); finalcut::FDialog::draw(); drawDispay(); @@ -995,8 +995,8 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev) switch ( key ) { - case finalcut::fc::Fkey_erase: - case finalcut::fc::Fkey_backspace: + case fc::Fkey_erase: + case fc::Fkey_backspace: if ( len > 0 ) { lDouble& x = getValue(); @@ -1019,10 +1019,10 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev) ev->accept(); break; - case finalcut::fc::Fkey_escape: - case finalcut::fc::Fkey_escape_mintty: + case fc::Fkey_escape: + case fc::Fkey_escape_mintty: { - finalcut::FAccelEvent a_ev( finalcut::fc::Accelerator_Event + finalcut::FAccelEvent a_ev( fc::Accelerator_Event , getFocusWidget() ); calculator_buttons[On]->onAccel(&a_ev); } diff --git a/examples/checklist.cpp b/examples/checklist.cpp index f3a3fa9d..9d1e8d0f 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -27,6 +27,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -86,12 +87,12 @@ CheckList::CheckList (finalcut::FWidget* parent) listView.addColumn ("Priority", 12); // Set the type of sorting - listView.setColumnSortType (1, finalcut::fc::by_name); - listView.setColumnSortType (2, finalcut::fc::by_name); + listView.setColumnSortType (1, fc::by_name); + listView.setColumnSortType (2, fc::by_name); // Statusbar at the bottom finalcut::FString separator; - separator << ' ' << finalcut::fc::BoxDrawingsVertical << ' '; + separator << ' ' << fc::BoxDrawingsVertical << ' '; listView.setStatusbarMessage ( finalcut::FString() << " exit" << separator << " select an item" << separator @@ -147,8 +148,8 @@ void CheckList::onKeyPress (finalcut::FKeyEvent* ev) return; if ( ev->key() == 'q' - || ev->key() == finalcut::fc::Fkey_escape - || ev->key() == finalcut::fc::Fkey_escape_mintty ) + || ev->key() == fc::Fkey_escape + || ev->key() == fc::Fkey_escape_mintty ) { close(); ev->accept(); @@ -174,7 +175,7 @@ void CheckList::cb_showList (finalcut::FWidget*, FDataPtr) const auto item = static_cast(*iter); if ( item->isChecked() ) - shopping_list << finalcut::fc::Bullet << ' ' + shopping_list << fc::Bullet << ' ' << item->getText(1) << '\n'; ++iter; diff --git a/examples/listview.cpp b/examples/listview.cpp index e688b7b6..25374913 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -27,6 +27,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -84,19 +85,19 @@ Listview::Listview (finalcut::FWidget* parent) listView.addColumn ("Pressure", 10); // Set right alignment for the third, fourth, and fifth column - listView.setColumnAlignment (3, finalcut::fc::alignRight); - listView.setColumnAlignment (4, finalcut::fc::alignRight); - listView.setColumnAlignment (5, finalcut::fc::alignRight); + listView.setColumnAlignment (3, fc::alignRight); + listView.setColumnAlignment (4, fc::alignRight); + listView.setColumnAlignment (5, fc::alignRight); // Set the type of sorting - listView.setColumnSortType (1, finalcut::fc::by_name); - listView.setColumnSortType (2, finalcut::fc::by_name); - listView.setColumnSortType (3, finalcut::fc::by_number); - listView.setColumnSortType (4, finalcut::fc::by_number); - listView.setColumnSortType (5, finalcut::fc::by_number); + listView.setColumnSortType (1, fc::by_name); + listView.setColumnSortType (2, fc::by_name); + listView.setColumnSortType (3, fc::by_number); + listView.setColumnSortType (4, fc::by_number); + listView.setColumnSortType (5, fc::by_number); // Sort in ascending order by the 1st column - listView.setColumnSort (1, finalcut::fc::ascending); + listView.setColumnSort (1, fc::ascending); // Sorting follows later automatically on insert(). // Otherwise you could start the sorting directly with sort() diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index fcec73af..e32a8fd6 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -22,6 +22,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -109,9 +110,9 @@ void Mandelbrot::draw() } if ( iter < max_iter ) - setColor(finalcut::fc::Black, iter % 16); + setColor(fc::Black, iter % 16); else - setColor(finalcut::fc::Black, 0); + setColor(fc::Black, 0); print(' '); } diff --git a/examples/menu.cpp b/examples/menu.cpp index 6d2d682a..fb736af0 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -22,6 +22,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -66,7 +67,7 @@ class Menu : public finalcut::FDialog void cb_message (finalcut::FWidget*, FDataPtr); // Data Members - finalcut::FString line{13, finalcut::fc::BoxDrawingsHorizontal}; + finalcut::FString line{13, fc::BoxDrawingsHorizontal}; finalcut::FMenuBar Menubar{this}; finalcut::FMenu File{"&File", &Menubar}; finalcut::FMenu Edit{"&Edit", &Menubar}; @@ -82,17 +83,17 @@ class Menu : public finalcut::FDialog finalcut::FMenuItem Print{"&Print", &File}; finalcut::FMenuItem Line2{&File}; finalcut::FMenuItem Quit{"&Quit", &File}; - finalcut::FMenuItem Undo{finalcut::fc::Fckey_z, "&Undo", &Edit}; - finalcut::FMenuItem Redo{finalcut::fc::Fckey_y, "&Redo", &Edit}; + finalcut::FMenuItem Undo{fc::Fckey_z, "&Undo", &Edit}; + finalcut::FMenuItem Redo{fc::Fckey_y, "&Redo", &Edit}; finalcut::FMenuItem Line3{&Edit}; - finalcut::FMenuItem Cut{finalcut::fc::Fckey_x, "Cu&t", &Edit}; - finalcut::FMenuItem Copy{finalcut::fc::Fckey_c, "&Copy", &Edit}; - finalcut::FMenuItem Paste{finalcut::fc::Fckey_v, "&Paste", &Edit}; + finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit}; + finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit}; + finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit}; finalcut::FMenuItem Line4{&Edit}; - finalcut::FMenuItem Search{finalcut::fc::Fckey_f, "&Search", &Edit}; - finalcut::FMenuItem Next{finalcut::fc::Fkey_f3, "Search &next", &Edit}; + finalcut::FMenuItem Search{fc::Fckey_f, "&Search", &Edit}; + finalcut::FMenuItem Next{fc::Fkey_f3, "Search &next", &Edit}; finalcut::FMenuItem Line5{&Edit}; - finalcut::FMenuItem SelectAll{finalcut::fc::Fckey_a, "Select &all", &Edit}; + finalcut::FMenuItem SelectAll{fc::Fckey_a, "Select &all", &Edit}; finalcut::FMenu Color{"&Color", &Choice}; finalcut::FMenu Style{"&Style", &Choice}; finalcut::FMenu Border{"&Border", &Choice}; @@ -166,20 +167,20 @@ Menu::~Menu() void Menu::configureFileMenuItems() { // "File" menu items - New.addAccelerator (finalcut::fc::Fckey_n); // Ctrl + N + New.addAccelerator (fc::Fckey_n); // Ctrl + N New.setStatusbarMessage ("Create a new file"); - Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O + Open.addAccelerator (fc::Fckey_o); // Ctrl + O Open.setStatusbarMessage ("Locate and open a text file"); - Save.addAccelerator (finalcut::fc::Fckey_s); // Ctrl + S + Save.addAccelerator (fc::Fckey_s); // Ctrl + S Save.setStatusbarMessage ("Save the file"); SaveAs.setStatusbarMessage ("Save the current file under a different name"); - Close.addAccelerator (finalcut::fc::Fckey_w); // Ctrl + W + Close.addAccelerator (fc::Fckey_w); // Ctrl + W Close.setStatusbarMessage ("Close the current file"); Line1.setSeparator(); - Print.addAccelerator (finalcut::fc::Fckey_p); // Ctrl + P + Print.addAccelerator (fc::Fckey_p); // Ctrl + P Print.setStatusbarMessage ("Print the current file"); Line2.setSeparator(); - Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X + Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit.setStatusbarMessage ("Exit the program"); // Add quit menu item callback diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 2d4731ae..4d8d3294 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -22,6 +22,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; using finalcut::FColorPair; @@ -61,8 +62,8 @@ class ColorChooser : public finalcut::FWidget virtual void onMouseDown (finalcut::FMouseEvent*) override; // Data Members - FColor fg_color{finalcut::fc::White}; - FColor bg_color{finalcut::fc::Black}; + FColor fg_color{fc::White}; + FColor bg_color{fc::Black}; finalcut::FLabel headline{this}; }; #pragma pack(pop) @@ -88,7 +89,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent) // Text label headline.setGeometry (FPoint(1, 1), FSize(8, 1)); headline.setEmphasis(); - headline.setAlignment (finalcut::fc::alignCenter); + headline.setAlignment (fc::alignCenter); headline << "Color"; } @@ -102,7 +103,7 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev) int mouse_x = ev->getX(); int mouse_y = ev->getY(); - if ( ev->getButton() == finalcut::fc::MiddleButton ) + if ( ev->getButton() == fc::MiddleButton ) return; for (int c = 0; c < 16; c++) @@ -113,9 +114,9 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev) if ( mouse_x >= xmin && mouse_x <= xmax && mouse_y == y ) { - if ( ev->getButton() == finalcut::fc::LeftButton ) + if ( ev->getButton() == fc::LeftButton ) bg_color = FColor(c); - else if ( ev->getButton() == finalcut::fc::RightButton ) + else if ( ev->getButton() == fc::RightButton ) fg_color = FColor(c); redraw(); @@ -135,15 +136,15 @@ void ColorChooser::draw() print() << FPoint(2 + (c / 8) * 3, 3 + c % 8); if ( c < 6 ) - setColor (finalcut::fc::LightGray, c); + setColor (fc::LightGray, c); else if ( c > 8 ) - setColor (finalcut::fc::DarkGray, c); + setColor (fc::DarkGray, c); else - setColor (finalcut::fc::White, c); + setColor (fc::White, c); if ( c == bg_color ) { - print() << ' ' << finalcut::fc::Times << ' '; + print() << ' ' << fc::Times << ' '; } else print (" "); @@ -201,8 +202,8 @@ class Brushes : public finalcut::FWidget // Data Members wchar_t brush{L' '}; - FColor fg_color{finalcut::fc::White}; - FColor bg_color{finalcut::fc::Black}; + FColor fg_color{fc::White}; + FColor bg_color{fc::Black}; finalcut::FLabel headline{this}; }; #pragma pack(pop) @@ -228,7 +229,7 @@ Brushes::Brushes (finalcut::FWidget* parent) // Text label headline.setGeometry(FPoint(1, 1), FSize(8, 1)); headline.setEmphasis(); - headline.setAlignment (finalcut::fc::alignCenter); + headline.setAlignment (fc::alignCenter); headline << "Brush"; } @@ -245,7 +246,7 @@ void Brushes::draw() finalcut::FWidget::drawBorder (1, 2, 8, 4); print() << FPoint(2, 3) << FColorPair(fg_color, bg_color) << " " - << finalcut::FString(3, finalcut::fc::MediumShade); + << finalcut::FString(3, fc::MediumShade); if ( brush == L' ' ) pos = 0; @@ -254,9 +255,9 @@ void Brushes::draw() setColor(); print() << FPoint(3 + pos, 2) - << finalcut::fc::BlackDownPointingTriangle + << fc::BlackDownPointingTriangle << FPoint(3 + pos, 4) - << finalcut::fc::BlackUpPointingTriangle; + << fc::BlackUpPointingTriangle; } //---------------------------------------------------------------------- @@ -265,7 +266,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev) int mouse_x = ev->getX(); int mouse_y = ev->getY(); - if ( ev->getButton() != finalcut::fc::LeftButton ) + if ( ev->getButton() != fc::LeftButton ) return; if ( mouse_x >= 2 && mouse_x <= 4 && mouse_y == 3 ) @@ -275,7 +276,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev) } else if ( mouse_x >= 5 && mouse_x <= 7 && mouse_y == 3 ) { - brush = finalcut::fc::MediumShade; + brush = fc::MediumShade; redraw(); } } @@ -427,24 +428,24 @@ void MouseDraw::draw() for (int y = 2; y < y_max; y++) { print() << FPoint(10, y) - << finalcut::fc::NF_rev_border_line_right; + << fc::NF_rev_border_line_right; } print() << FPoint(10, y_max) - << finalcut::fc::NF_rev_border_corner_lower_right; + << fc::NF_rev_border_corner_lower_right; } else { print() << FPoint(10, 2) - << finalcut::fc::BoxDrawingsDownAndHorizontal; + << fc::BoxDrawingsDownAndHorizontal; for (int y = 3; y < y_max; y++) { - print() << FPoint(10, y) << finalcut::fc::BoxDrawingsVertical; + print() << FPoint(10, y) << fc::BoxDrawingsVertical; } print() << FPoint(10, y_max) - << finalcut::fc::BoxDrawingsUpAndHorizontal; + << fc::BoxDrawingsUpAndHorizontal; } drawCanvas(); @@ -521,13 +522,13 @@ void MouseDraw::onMouseDown (finalcut::FMouseEvent* ev) { finalcut::FDialog::onMouseDown(ev); - if ( ev->getButton() != finalcut::fc::LeftButton - && ev->getButton() != finalcut::fc::RightButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::RightButton ) return; drawBrush ( ev->getX() , ev->getY() - , ev->getButton() == finalcut::fc::RightButton ); + , ev->getButton() == fc::RightButton ); } //---------------------------------------------------------------------- @@ -535,13 +536,13 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev) { FDialog::onMouseMove(ev); - if ( ev->getButton() != finalcut::fc::LeftButton - && ev->getButton() != finalcut::fc::RightButton ) + if ( ev->getButton() != fc::LeftButton + && ev->getButton() != fc::RightButton ) return; drawBrush ( ev->getX() , ev->getY() - , ev->getButton() == finalcut::fc::RightButton); + , ev->getButton() == fc::RightButton); } //---------------------------------------------------------------------- diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index b22ea30f..a062d946 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -22,6 +22,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -62,10 +63,10 @@ class Scrollview : public finalcut::FScrollView void cb_go_north (finalcut::FWidget*, FDataPtr); // Data Members - wchar_t pointer_right{finalcut::fc::BlackRightPointingPointer}; - wchar_t pointer_down{finalcut::fc::BlackDownPointingTriangle}; - wchar_t pointer_left{finalcut::fc::BlackLeftPointingPointer}; - wchar_t pointer_up{finalcut::fc::BlackUpPointingTriangle}; + wchar_t pointer_right{fc::BlackRightPointingPointer}; + wchar_t pointer_down{fc::BlackDownPointingTriangle}; + wchar_t pointer_left{fc::BlackLeftPointingPointer}; + wchar_t pointer_up{fc::BlackUpPointingTriangle}; finalcut::FButton go_east{pointer_right, this}; finalcut::FButton go_south{pointer_down, this}; finalcut::FButton go_west{pointer_left, this}; diff --git a/examples/string-operations.cpp b/examples/string-operations.cpp index 9c11d116..0d44ae8a 100644 --- a/examples/string-operations.cpp +++ b/examples/string-operations.cpp @@ -534,7 +534,7 @@ void convertNumberToStringExample() { // Test: convert integer and double value to a string finalcut::FString num1, num2, num3; - num1.setNumber(137); + num1.setNumber(137u); num2.setNumber(-512); num3.setNumber(3.141592653589793238L, 12); std::cout << " setNumber: " @@ -553,11 +553,11 @@ void formatedNumberExample() finalcut::FString fnum1, fnum2; #if defined(__LP64__) || defined(_LP64) // 64-bit architecture - fnum1.setFormatedNumber(0xffffffffffffffff, '\''); + fnum1.setFormatedNumber(0xffffffffffffffffu, '\''); fnum2.setFormatedNumber(-9223372036854775807); #else // 32-bit architecture - fnum1.setFormatedNumber(0xffffffff, '\''); + fnum1.setFormatedNumber(0xffffffffu, '\''); fnum2.setFormatedNumber(-2147483647); #endif std::cout << "setFormatedNumber: " diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index e0e9fce3..9512eaa5 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -23,6 +23,7 @@ #include #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; using finalcut::FColorPair; @@ -83,10 +84,10 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent) next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4) , FSize(10, 1) ); - next_button.addAccelerator (finalcut::fc::Fkey_right); + next_button.addAccelerator (fc::Fkey_right); back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4) , FSize(10, 1) ); - back_button.addAccelerator (finalcut::fc::Fkey_left); + back_button.addAccelerator (fc::Fkey_left); // Add function callbacks next_button.addCallback @@ -126,9 +127,9 @@ void AttribDlg::onWheel (finalcut::FWheelEvent* ev) { int wheel = ev->getWheel(); - if ( wheel == finalcut::fc::WheelUp ) + if ( wheel == fc::WheelUp ) cb_next(); - else if ( wheel == finalcut::fc::WheelDown ) + else if ( wheel == fc::WheelDown ) cb_back(); } @@ -145,8 +146,8 @@ void AttribDlg::cb_next (finalcut::FWidget*, FDataPtr) return; if ( bgcolor == FColor(getMaxColor() - 1) ) - bgcolor = finalcut::fc::Default; - else if ( bgcolor == finalcut::fc::Default ) + bgcolor = fc::Default; + else if ( bgcolor == fc::Default ) bgcolor = 0; else bgcolor++; @@ -161,8 +162,8 @@ void AttribDlg::cb_back (finalcut::FWidget*, FDataPtr) return; if ( bgcolor == 0 ) - bgcolor = finalcut::fc::Default; - else if ( bgcolor == finalcut::fc::Default ) + bgcolor = fc::Default; + else if ( bgcolor == fc::Default ) bgcolor = FColor(getMaxColor() - 1); else bgcolor--; @@ -275,9 +276,9 @@ void AttribDemo::printAltCharset() print() << FPoint(1, 1) << "alternate charset: "; - if ( parent->bgcolor == finalcut::fc::Default ) + if ( parent->bgcolor == fc::Default ) { - setColor (finalcut::fc::Default, finalcut::fc::Default); + setColor (fc::Default, fc::Default); } else { @@ -285,9 +286,9 @@ void AttribDemo::printAltCharset() || (parent->bgcolor >= 16 && parent->bgcolor <= 231 && (parent->bgcolor - 16) % 36 <= 17) || (parent->bgcolor >= 232 && parent->bgcolor <= 243) ) - setColor (finalcut::fc::White, parent->bgcolor); + setColor (fc::White, parent->bgcolor); else - setColor (finalcut::fc::Black, parent->bgcolor); + setColor (fc::Black, parent->bgcolor); } setAltCharset(); @@ -455,7 +456,7 @@ void AttribDemo::draw() FColor bg = static_cast(getParent())->bgcolor; print (" Background color:"); - if ( bg == finalcut::fc::Default ) + if ( bg == fc::Default ) print (" default"); else printf ( " %d", bg); diff --git a/examples/termcap.cpp b/examples/termcap.cpp index 0df88474..e79de144 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -26,6 +26,7 @@ #include +namespace fc = finalcut::fc; // Global FVTerm object static finalcut::FVTerm* terminal; @@ -54,7 +55,7 @@ struct data struct termcap_string { const std::string name; - const finalcut::fc::termcaps cap; + const fc::termcaps cap; }; static termcap_string strings[]; @@ -66,88 +67,88 @@ struct data //---------------------------------------------------------------------- data::termcap_string data::strings[] = { - { "t_bell", finalcut::fc::t_bell }, - { "t_erase_chars", finalcut::fc::t_erase_chars }, - { "t_clear_screen", finalcut::fc::t_clear_screen }, - { "t_clr_eos", finalcut::fc::t_clr_eos }, - { "t_clr_eol", finalcut::fc::t_clr_eol }, - { "t_clr_bol", finalcut::fc::t_clr_bol }, - { "t_cursor_home", finalcut::fc::t_cursor_home }, - { "t_cursor_to_ll", finalcut::fc::t_cursor_to_ll }, - { "t_carriage_return", finalcut::fc::t_carriage_return }, - { "t_tab", finalcut::fc::t_tab }, - { "t_back_tab", finalcut::fc::t_back_tab }, - { "t_insert_padding", finalcut::fc::t_insert_padding }, - { "t_insert_character", finalcut::fc::t_insert_character }, - { "t_parm_ich", finalcut::fc::t_parm_ich }, - { "t_repeat_char", finalcut::fc::t_repeat_char }, - { "t_initialize_color", finalcut::fc::t_initialize_color }, - { "t_initialize_pair", finalcut::fc::t_initialize_pair }, - { "t_set_a_foreground", finalcut::fc::t_set_a_foreground }, - { "t_set_a_background", finalcut::fc::t_set_a_background }, - { "t_set_foreground", finalcut::fc::t_set_foreground }, - { "t_set_background", finalcut::fc::t_set_background }, - { "t_set_color_pair", finalcut::fc::t_set_color_pair }, - { "t_orig_pair", finalcut::fc::t_orig_pair }, - { "t_orig_colors", finalcut::fc::t_orig_colors }, - { "t_no_color_video", finalcut::fc::t_no_color_video }, - { "t_cursor_address", finalcut::fc::t_cursor_address }, - { "t_column_address", finalcut::fc::t_column_address }, - { "t_row_address", finalcut::fc::t_row_address }, - { "t_cursor_visible", finalcut::fc::t_cursor_visible }, - { "t_cursor_invisible", finalcut::fc::t_cursor_invisible }, - { "t_cursor_normal", finalcut::fc::t_cursor_normal }, - { "t_cursor_up", finalcut::fc::t_cursor_up }, - { "t_cursor_down", finalcut::fc::t_cursor_down }, - { "t_cursor_left", finalcut::fc::t_cursor_left }, - { "t_cursor_right", finalcut::fc::t_cursor_right }, - { "t_parm_up_cursor", finalcut::fc::t_parm_up_cursor }, - { "t_parm_down_cursor", finalcut::fc::t_parm_down_cursor }, - { "t_parm_left_cursor", finalcut::fc::t_parm_left_cursor }, - { "t_parm_right_cursor", finalcut::fc::t_parm_right_cursor }, - { "t_save_cursor", finalcut::fc::t_save_cursor }, - { "t_restore_cursor", finalcut::fc::t_restore_cursor }, - { "t_scroll_forward", finalcut::fc::t_scroll_forward }, - { "t_scroll_reverse", finalcut::fc::t_scroll_reverse }, - { "t_enter_ca_mode", finalcut::fc::t_enter_ca_mode }, - { "t_exit_ca_mode", finalcut::fc::t_exit_ca_mode }, - { "t_enable_acs", finalcut::fc::t_enable_acs }, - { "t_enter_bold_mode", finalcut::fc::t_enter_bold_mode }, - { "t_exit_bold_mode", finalcut::fc::t_exit_bold_mode }, - { "t_enter_dim_mode", finalcut::fc::t_enter_dim_mode }, - { "t_exit_dim_mode", finalcut::fc::t_exit_dim_mode }, - { "t_enter_italics_mode", finalcut::fc::t_enter_italics_mode }, - { "t_exit_italics_mode", finalcut::fc::t_exit_italics_mode }, - { "t_enter_underline_mode", finalcut::fc::t_enter_underline_mode }, - { "t_exit_underline_mode", finalcut::fc::t_exit_underline_mode }, - { "t_enter_blink_mode", finalcut::fc::t_enter_blink_mode }, - { "t_exit_blink_mode", finalcut::fc::t_exit_blink_mode }, - { "t_enter_reverse_mode", finalcut::fc::t_enter_reverse_mode }, - { "t_exit_reverse_mode", finalcut::fc::t_exit_reverse_mode }, - { "t_enter_standout_mode", finalcut::fc::t_enter_standout_mode }, - { "t_exit_standout_mode", finalcut::fc::t_exit_standout_mode }, - { "t_enter_secure_mode", finalcut::fc::t_enter_secure_mode }, - { "t_exit_secure_mode", finalcut::fc::t_exit_secure_mode }, - { "t_enter_protected_mode", finalcut::fc::t_enter_protected_mode }, - { "t_exit_protected_mode", finalcut::fc::t_exit_protected_mode }, - { "t_enter_crossed_out_mode", finalcut::fc::t_enter_crossed_out_mode }, - { "t_exit_crossed_out_mode", finalcut::fc::t_exit_crossed_out_mode }, - { "t_enter_dbl_underline_mode", finalcut::fc::t_enter_dbl_underline_mode }, - { "t_exit_dbl_underline_mode", finalcut::fc::t_exit_dbl_underline_mode }, - { "t_set_attributes", finalcut::fc::t_set_attributes }, - { "t_exit_attribute_mode", finalcut::fc::t_exit_attribute_mode }, - { "t_enter_alt_charset_mode", finalcut::fc::t_enter_alt_charset_mode }, - { "t_exit_alt_charset_mode", finalcut::fc::t_exit_alt_charset_mode }, - { "t_enter_pc_charset_mode", finalcut::fc::t_enter_pc_charset_mode }, - { "t_exit_pc_charset_mode", finalcut::fc::t_exit_pc_charset_mode }, - { "t_enter_insert_mode", finalcut::fc::t_enter_insert_mode }, - { "t_exit_insert_mode", finalcut::fc::t_exit_insert_mode }, - { "t_enter_am_mode", finalcut::fc::t_enter_am_mode }, - { "t_exit_am_mode", finalcut::fc::t_exit_am_mode }, - { "t_acs_chars", finalcut::fc::t_acs_chars }, - { "t_keypad_xmit", finalcut::fc::t_keypad_xmit }, - { "t_keypad_local", finalcut::fc::t_keypad_local }, - { "t_key_mouse", finalcut::fc::t_key_mouse } + { "t_bell", fc::t_bell }, + { "t_erase_chars", fc::t_erase_chars }, + { "t_clear_screen", fc::t_clear_screen }, + { "t_clr_eos", fc::t_clr_eos }, + { "t_clr_eol", fc::t_clr_eol }, + { "t_clr_bol", fc::t_clr_bol }, + { "t_cursor_home", fc::t_cursor_home }, + { "t_cursor_to_ll", fc::t_cursor_to_ll }, + { "t_carriage_return", fc::t_carriage_return }, + { "t_tab", fc::t_tab }, + { "t_back_tab", fc::t_back_tab }, + { "t_insert_padding", fc::t_insert_padding }, + { "t_insert_character", fc::t_insert_character }, + { "t_parm_ich", fc::t_parm_ich }, + { "t_repeat_char", fc::t_repeat_char }, + { "t_initialize_color", fc::t_initialize_color }, + { "t_initialize_pair", fc::t_initialize_pair }, + { "t_set_a_foreground", fc::t_set_a_foreground }, + { "t_set_a_background", fc::t_set_a_background }, + { "t_set_foreground", fc::t_set_foreground }, + { "t_set_background", fc::t_set_background }, + { "t_set_color_pair", fc::t_set_color_pair }, + { "t_orig_pair", fc::t_orig_pair }, + { "t_orig_colors", fc::t_orig_colors }, + { "t_no_color_video", fc::t_no_color_video }, + { "t_cursor_address", fc::t_cursor_address }, + { "t_column_address", fc::t_column_address }, + { "t_row_address", fc::t_row_address }, + { "t_cursor_visible", fc::t_cursor_visible }, + { "t_cursor_invisible", fc::t_cursor_invisible }, + { "t_cursor_normal", fc::t_cursor_normal }, + { "t_cursor_up", fc::t_cursor_up }, + { "t_cursor_down", fc::t_cursor_down }, + { "t_cursor_left", fc::t_cursor_left }, + { "t_cursor_right", fc::t_cursor_right }, + { "t_parm_up_cursor", fc::t_parm_up_cursor }, + { "t_parm_down_cursor", fc::t_parm_down_cursor }, + { "t_parm_left_cursor", fc::t_parm_left_cursor }, + { "t_parm_right_cursor", fc::t_parm_right_cursor }, + { "t_save_cursor", fc::t_save_cursor }, + { "t_restore_cursor", fc::t_restore_cursor }, + { "t_scroll_forward", fc::t_scroll_forward }, + { "t_scroll_reverse", fc::t_scroll_reverse }, + { "t_enter_ca_mode", fc::t_enter_ca_mode }, + { "t_exit_ca_mode", fc::t_exit_ca_mode }, + { "t_enable_acs", fc::t_enable_acs }, + { "t_enter_bold_mode", fc::t_enter_bold_mode }, + { "t_exit_bold_mode", fc::t_exit_bold_mode }, + { "t_enter_dim_mode", fc::t_enter_dim_mode }, + { "t_exit_dim_mode", fc::t_exit_dim_mode }, + { "t_enter_italics_mode", fc::t_enter_italics_mode }, + { "t_exit_italics_mode", fc::t_exit_italics_mode }, + { "t_enter_underline_mode", fc::t_enter_underline_mode }, + { "t_exit_underline_mode", fc::t_exit_underline_mode }, + { "t_enter_blink_mode", fc::t_enter_blink_mode }, + { "t_exit_blink_mode", fc::t_exit_blink_mode }, + { "t_enter_reverse_mode", fc::t_enter_reverse_mode }, + { "t_exit_reverse_mode", fc::t_exit_reverse_mode }, + { "t_enter_standout_mode", fc::t_enter_standout_mode }, + { "t_exit_standout_mode", fc::t_exit_standout_mode }, + { "t_enter_secure_mode", fc::t_enter_secure_mode }, + { "t_exit_secure_mode", fc::t_exit_secure_mode }, + { "t_enter_protected_mode", fc::t_enter_protected_mode }, + { "t_exit_protected_mode", fc::t_exit_protected_mode }, + { "t_enter_crossed_out_mode", fc::t_enter_crossed_out_mode }, + { "t_exit_crossed_out_mode", fc::t_exit_crossed_out_mode }, + { "t_enter_dbl_underline_mode", fc::t_enter_dbl_underline_mode }, + { "t_exit_dbl_underline_mode", fc::t_exit_dbl_underline_mode }, + { "t_set_attributes", fc::t_set_attributes }, + { "t_exit_attribute_mode", fc::t_exit_attribute_mode }, + { "t_enter_alt_charset_mode", fc::t_enter_alt_charset_mode }, + { "t_exit_alt_charset_mode", fc::t_exit_alt_charset_mode }, + { "t_enter_pc_charset_mode", fc::t_enter_pc_charset_mode }, + { "t_exit_pc_charset_mode", fc::t_exit_pc_charset_mode }, + { "t_enter_insert_mode", fc::t_enter_insert_mode }, + { "t_exit_insert_mode", fc::t_exit_insert_mode }, + { "t_enter_am_mode", fc::t_enter_am_mode }, + { "t_exit_am_mode", fc::t_exit_am_mode }, + { "t_acs_chars", fc::t_acs_chars }, + { "t_keypad_xmit", fc::t_keypad_xmit }, + { "t_keypad_local", fc::t_keypad_local }, + { "t_key_mouse", fc::t_key_mouse } }; // data inline functions @@ -297,7 +298,7 @@ void string(finalcut::FTermcap::tcap_map*& tcap) for (int n = 0; n <= data::getNumberOfItems(); n++ ) { const std::string name = data::strings[n].name; - const finalcut::fc::termcaps cap = data::strings[n].cap; + const fc::termcaps cap = data::strings[n].cap; tcapString (name, tcap[cap].string); } } diff --git a/examples/timer.cpp b/examples/timer.cpp index dc06d182..be47482b 100644 --- a/examples/timer.cpp +++ b/examples/timer.cpp @@ -22,6 +22,8 @@ #include +namespace fc = finalcut::fc; + //---------------------------------------------------------------------- // class Timer @@ -52,8 +54,8 @@ Timer::Timer (finalcut::FWidget* parent) delTimer (id); addTimer (250); // 250-millisecond timer - wc.term_fg = finalcut::fc::Default; - wc.term_bg = finalcut::fc::Default; + wc.term_fg = fc::Default; + wc.term_bg = fc::Default; } //---------------------------------------------------------------------- @@ -100,8 +102,8 @@ int main (int argc, char* argv[]) { // Create the application object finalcut::FApplication app(argc, argv); - app.setForegroundColor(finalcut::fc::Default); - app.setBackgroundColor(finalcut::fc::Default); + app.setForegroundColor(fc::Default); + app.setBackgroundColor(fc::Default); // Create a timer object t Timer t(&app); diff --git a/examples/transparent.cpp b/examples/transparent.cpp index efd93745..8054f719 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -22,6 +22,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -98,9 +99,9 @@ void Transparent::draw() else if ( type == inherit_background ) { if ( getMaxColor() > 8 ) - setColor(finalcut::fc::Blue, finalcut::fc::Black); + setColor(fc::Blue, fc::Black); else - setColor(finalcut::fc::Green, finalcut::fc::Black); + setColor(fc::Green, fc::Black); setInheritBackground(); } diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 9de90baa..686f5da4 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -27,6 +27,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -314,13 +315,13 @@ Treeview::Treeview (finalcut::FWidget* parent) listView.addColumn ("Density/km²"); // Set right alignment for the second and third column - listView.setColumnAlignment (2, finalcut::fc::alignRight); - listView.setColumnAlignment (3, finalcut::fc::alignRight); + listView.setColumnAlignment (2, fc::alignRight); + listView.setColumnAlignment (3, fc::alignRight); // Set the type of sorting - listView.setColumnSortType (1, finalcut::fc::by_name); - listView.setColumnSortType (2, finalcut::fc::user_defined); - listView.setColumnSortType (3, finalcut::fc::user_defined); + listView.setColumnSortType (1, fc::by_name); + listView.setColumnSortType (2, fc::user_defined); + listView.setColumnSortType (3, fc::user_defined); listView.setUserAscendingCompare(sortAscending); listView.setUserDescendingCompare(sortDescending); diff --git a/examples/ui.cpp b/examples/ui.cpp index 694bfdf1..8178c539 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -26,6 +26,7 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -325,21 +326,21 @@ class MyDialog : public finalcut::FDialog finalcut::FMenuItem File2{"/etc/fstab", &Recent}; finalcut::FMenuItem File3{"/etc/passwd", &Recent}; // "Edit" menu items - finalcut::FMenuItem Undo{finalcut::fc::Fckey_z, "Undo", &Edit}; - finalcut::FMenuItem Redo{finalcut::fc::Fckey_y, "Redo", &Edit}; + finalcut::FMenuItem Undo{fc::Fckey_z, "Undo", &Edit}; + finalcut::FMenuItem Redo{fc::Fckey_y, "Redo", &Edit}; finalcut::FMenuItem Line2{&Edit}; - finalcut::FMenuItem Cut{finalcut::fc::Fckey_x, "Cu&t", &Edit}; - finalcut::FMenuItem Copy{finalcut::fc::Fckey_c, "&Copy", &Edit}; - finalcut::FMenuItem Paste{finalcut::fc::Fckey_v, "&Paste", &Edit}; - finalcut::FMenuItem Clear{finalcut::fc::Fkey_dc, "C&lear", &Edit}; + finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit}; + finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit}; + finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit}; + finalcut::FMenuItem Clear{fc::Fkey_dc, "C&lear", &Edit}; // "View" menu items finalcut::FMenuItem Env{"&Terminal...", &View}; finalcut::FMenuItem Drive{"&Drive symbols...", &View}; // Statusbar finalcut::FStatusBar Statusbar{this}; - finalcut::FStatusKey key_F1{finalcut::fc::Fkey_f1, "About", &Statusbar}; - finalcut::FStatusKey key_F2{finalcut::fc::Fkey_f2, "View", &Statusbar}; - finalcut::FStatusKey key_F3{finalcut::fc::Fkey_f3, "Quit", &Statusbar}; + finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar}; + finalcut::FStatusKey key_F2{fc::Fkey_f2, "View", &Statusbar}; + finalcut::FStatusKey key_F3{fc::Fkey_f3, "Quit", &Statusbar}; // Dialog widgets finalcut::FButton MyButton1{this}; finalcut::FButton MyButton2{this}; @@ -393,11 +394,11 @@ void MyDialog::initMenu() Help.setStatusbarMessage ("Show version and copyright information"); // "File" menu items - Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O + Open.addAccelerator (fc::Fckey_o); // Ctrl + O Open.setStatusbarMessage ("Locate and open a text file"); Recent.setStatusbarMessage ("View text file"); Line1.setSeparator(); - Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X + Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit.setStatusbarMessage ("Exit the program"); // "Edit" menu items @@ -584,14 +585,14 @@ void MyDialog::initFlatButtons() MyButton1.setStatusbarMessage ("Sine function"); MyButton1.setNoUnderline(); MyButton1.setFlat(); - MyButton1.setDoubleFlatLine (finalcut::fc::bottom); + MyButton1.setDoubleFlatLine (fc::bottom); MyButton2.setGeometry(FPoint(3, 5), FSize(5, 1)); MyButton2.setText (L"&COS"); MyButton2.setStatusbarMessage ("Cosine function"); MyButton2.setNoUnderline(); MyButton2.setFlat(); - MyButton2.setDoubleFlatLine (finalcut::fc::top); + MyButton2.setDoubleFlatLine (fc::top); MyButton3.setGeometry(FPoint(10, 3), FSize(5, 3)); MyButton3.setText (L"&="); @@ -692,7 +693,7 @@ void MyDialog::initLabels() // Text labels headline.setGeometry(FPoint(21, 3), FSize(10, 1)); headline.setEmphasis(); - headline.setAlignment (finalcut::fc::alignCenter); + headline.setAlignment (fc::alignCenter); headline = L"List items"; tagged.setGeometry(FPoint(21, 4), FSize(7, 1)); @@ -701,7 +702,7 @@ void MyDialog::initLabels() tagged_count << 0; sum.setGeometry(FPoint(21, 5), FSize(7, 3)); - sum.setAlignment (finalcut::fc::alignRight); + sum.setAlignment (fc::alignRight); sum_count.setGeometry(FPoint(29, 5), FSize(5, 3)); sum_count << myList.getCount(); @@ -779,7 +780,7 @@ void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, FDataPtr) void MyDialog::cb_about (finalcut::FWidget*, FDataPtr) { constexpr char libver[] = F_VERSION; - const finalcut::FString line(2, finalcut::fc::BoxDrawingsHorizontal); + const finalcut::FString line(2, fc::BoxDrawingsHorizontal); finalcut::FMessageBox info ( "About" , line + L" The Final Cut " + line + "\n\n" @@ -802,7 +803,7 @@ void MyDialog::cb_terminfo (finalcut::FWidget*, FDataPtr) << " Type: " << getTermType() << "\n" << " Name: " << getTermFileName() << "\n" << " Mode: " << getEncodingString() << "\n" - << " Size: " << x << finalcut::fc::Times + << " Size: " << x << fc::Times << y << "\n" << "Colors: " << getMaxColor() , finalcut::FMessageBox::Ok, 0, 0, this @@ -850,12 +851,12 @@ void MyDialog::cb_drives (finalcut::FWidget*, FDataPtr) } else { - net.setForegroundColor (finalcut::fc::White); - net.setBackgroundColor (finalcut::fc::DarkGray); - drive.setForegroundColor (finalcut::fc::White); - drive.setBackgroundColor (finalcut::fc::DarkGray); - cd.setForegroundColor (finalcut::fc::White); - cd.setBackgroundColor (finalcut::fc::DarkGray); + net.setForegroundColor (fc::White); + net.setBackgroundColor (fc::DarkGray); + drive.setForegroundColor (fc::White); + drive.setBackgroundColor (fc::DarkGray); + cd.setForegroundColor (fc::White); + cd.setBackgroundColor (fc::DarkGray); } info2.exec(); diff --git a/examples/windows.cpp b/examples/windows.cpp index 1cd2e8f6..85948441 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -23,6 +23,7 @@ #include #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; @@ -71,8 +72,8 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent) : finalcut::FDialog(parent) { wchar_t arrow_up, arrow_down; - arrow_up = finalcut::fc::BlackUpPointingTriangle; - arrow_down = finalcut::fc::BlackDownPointingTriangle; + arrow_up = fc::BlackUpPointingTriangle; + arrow_down = fc::BlackDownPointingTriangle; left_arrow = arrow_up; left_arrow.setForegroundColor (wc.label_inactive_fg); @@ -92,7 +93,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent) top_left_label.setGeometry (FPoint(1, 1), FSize(6, 1)); top_right_label = "zoom"; - top_right_label.setAlignment (finalcut::fc::alignRight); + top_right_label.setAlignment (fc::alignRight); top_right_label.setForegroundColor (wc.label_inactive_fg); top_right_label.setEmphasis(); top_right_label.setGeometry (FPoint(int(getClientWidth()) - 5, 1), FSize(6, 1)); @@ -101,7 +102,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent) "corner\n"; bottom_label_text += arrow_down; bottom_label = bottom_label_text; - bottom_label.setAlignment (finalcut::fc::alignRight); + bottom_label.setAlignment (fc::alignRight); bottom_label.setForegroundColor (wc.label_inactive_fg); bottom_label.setEmphasis(); bottom_label.setGeometry (FPoint(13, 3), FSize(6, 3)); @@ -224,7 +225,7 @@ class Window : public finalcut::FDialog // Data Members std::vector windows{}; - finalcut::FString drop_down_symbol{finalcut::fc::BlackDownPointingTriangle}; + finalcut::FString drop_down_symbol{fc::BlackDownPointingTriangle}; finalcut::FMenuBar Menubar{this}; finalcut::FMenu File{"&File", &Menubar}; finalcut::FDialogListMenu DglList{drop_down_symbol, &Menubar}; @@ -295,12 +296,12 @@ void Window::configureFileMenuItems() New.setStatusbarMessage ("Create the windows"); Close.setStatusbarMessage ("Close the windows"); Line1.setSeparator(); - Next.addAccelerator (finalcut::fc::Fmkey_npage); // Meta/Alt + PgDn + Next.addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn Next.setStatusbarMessage ("Switch to the next window"); - Previous.addAccelerator (finalcut::fc::Fmkey_ppage); // Meta/Alt + PgUp + Previous.addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp Previous.setStatusbarMessage ("Switch to the previous window"); Line2.setSeparator(); - Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X + Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit.setStatusbarMessage ("Exit the program"); // Add menu item callback diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 460e0d3a..637894e4 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -600,7 +600,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey() // fill bit field with 0 std::memset (&mod_key, 0x00, sizeof(mod_key)); - // TIOCLINUX, subcode = 6 + // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) if ( ioctl(0, TIOCLINUX, &subcode) >= 0 ) { if ( subcode & (1 << KG_SHIFT) ) @@ -728,8 +728,8 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() // Miscellaneous output (read port) static constexpr uInt16 misc_read = 0x3cc; const uInt16 io_base = ( inb(misc_read) & 0x01 ) ? 0x3d0 : 0x3b0; - // 0x3ba : Input status 1 MDA (read port) - // 0x3da : Input status 1 CGA (read port) + // 0x3ba : Input status 1 mono/MDA (read port) + // 0x3da : Input status 1 color/CGA (read port) return io_base + 0x0a; } diff --git a/test/fstring-test.cpp b/test/fstring-test.cpp index 2a8b60ef..9daf9d1a 100644 --- a/test/fstring-test.cpp +++ b/test/fstring-test.cpp @@ -855,7 +855,7 @@ void FStringTest::streamInsertionTest() CPPUNIT_ASSERT ( out == L"-1234567" ); out.clear(); - out << uInt(12345678); + out << uInt(12345678u); CPPUNIT_ASSERT ( out == L"12345678" ); out.clear(); @@ -863,7 +863,7 @@ void FStringTest::streamInsertionTest() CPPUNIT_ASSERT ( out == L"-34721053343141" ); out.clear(); - out << uLong(4670148723459); + out << uLong(4670148723459u); CPPUNIT_ASSERT ( out == L"4670148723459" ); out.clear(); @@ -1048,7 +1048,7 @@ void FStringTest::formatTest() #if defined(__LP64__) || defined(_LP64) // 64-bit architecture - fnum1.setFormatedNumber(0xffffffffffffffff, '\''); + fnum1.setFormatedNumber(0xffffffffffffffffu, '\''); CPPUNIT_ASSERT ( fnum1 == "18'446'744'073'709'551'615" ); fnum2.setFormatedNumber(-9223372036854775807); @@ -1057,17 +1057,17 @@ void FStringTest::formatTest() fnum2.setFormatedNumber(long(9223372036854775807), '\0'); CPPUNIT_ASSERT ( fnum2 == "9 223 372 036 854 775 807" ); - fnum2.setFormatedNumber(uLong(9223372036854775807), '\0'); + fnum2.setFormatedNumber(uLong(9223372036854775807u), '\0'); CPPUNIT_ASSERT ( fnum2 == "9 223 372 036 854 775 807" ); fnum2.setFormatedNumber(sInt64(9223372036854775807), '\0'); CPPUNIT_ASSERT ( fnum2 == "9 223 372 036 854 775 807" ); - fnum2.setFormatedNumber(uInt64(9223372036854775807), '\0'); + fnum2.setFormatedNumber(uInt64(9223372036854775807u), '\0'); CPPUNIT_ASSERT ( fnum2 == "9 223 372 036 854 775 807" ); #else // 32-bit architecture - fnum1.setFormatedNumber(0xffffffff, '\''); + fnum1.setFormatedNumber(0xffffffffu, '\''); CPPUNIT_ASSERT ( fnum1 == "4'294'967'295" ); fnum2.setFormatedNumber(-2147483647); @@ -1076,26 +1076,26 @@ void FStringTest::formatTest() fnum2.setFormatedNumber(long(2147483647), '\0'); CPPUNIT_ASSERT ( fnum2 == "2 147 483 647" ); - fnum2.setFormatedNumber(uLong(2147483647), '\0'); + fnum2.setFormatedNumber(uLong(2147483647u), '\0'); CPPUNIT_ASSERT ( fnum2 == "2 147 483 647" ); fnum2.setFormatedNumber(sInt32(2147483647), '\0'); CPPUNIT_ASSERT ( fnum2 == "2 147 483 647" ); - fnum2.setFormatedNumber(uInt32(2147483647), '\0'); + fnum2.setFormatedNumber(uInt32(2147483647u), '\0'); CPPUNIT_ASSERT ( fnum2 == "2 147 483 647" ); #endif fnum1.setFormatedNumber(sInt16(-2048), '_'); CPPUNIT_ASSERT ( fnum1 == "-2_048" ); - fnum2.setFormatedNumber(uInt16(65535)); + fnum2.setFormatedNumber(uInt16(65535u)); CPPUNIT_ASSERT ( fnum2 == "65 535" ); fnum1.setFormatedNumber(sInt8(-123), '*'); CPPUNIT_ASSERT ( fnum1 == "-123" ); - fnum2.setFormatedNumber(uInt8(255)); + fnum2.setFormatedNumber(uInt8(255u)); CPPUNIT_ASSERT ( fnum2 == "255" ); } @@ -1106,13 +1106,13 @@ void FStringTest::convertToNumberTest() CPPUNIT_ASSERT ( str.toShort() == -127 ); str = "255"; - CPPUNIT_ASSERT ( str.toUShort() == 255 ); + CPPUNIT_ASSERT ( str.toUShort() == 255u ); str = "-32768"; CPPUNIT_ASSERT ( str.toInt() == -32768 ); str = "65535"; - CPPUNIT_ASSERT ( str.toUInt() == 65535 ); + CPPUNIT_ASSERT ( str.toUInt() == 65535u ); str = "-2147483647"; CPPUNIT_ASSERT ( str.toLong() == -2147483647 ); @@ -1121,10 +1121,10 @@ void FStringTest::convertToNumberTest() CPPUNIT_ASSERT ( str.toLong() == 987654321 ); str = "4294967295"; - CPPUNIT_ASSERT ( str.toULong() == 4294967295 ); + CPPUNIT_ASSERT ( str.toULong() == 4294967295u ); str = "+1234567890"; - CPPUNIT_ASSERT ( str.toULong() == 1234567890 ); + CPPUNIT_ASSERT ( str.toULong() == 1234567890u ); str = "3.14159"; CPPUNIT_ASSERT ( str.toFloat() == 3.14159f ); @@ -1143,17 +1143,17 @@ void FStringTest::convertToNumberTest() void FStringTest::convertFromNumberTest() { constexpr sInt8 n1 = -12; - constexpr uInt8 n2 = 12; + constexpr uInt8 n2 = 12u; constexpr sInt16 n3 = -1234; - constexpr uInt16 n4 = 1234; + constexpr uInt16 n4 = 1234u; constexpr int n5 = -12345; - constexpr uInt n6 = 12345; + constexpr uInt n6 = 12345u; constexpr sInt32 n7 = -12345; - constexpr uInt32 n8 = 12345; + constexpr uInt32 n8 = 12345u; constexpr long n9 = -12345678; - constexpr uLong n10 = 12345678; + constexpr uLong n10 = 12345678u; constexpr sInt64 n11 = -12345678; - constexpr uInt64 n12 = 12345678; + constexpr uInt64 n12 = 12345678u; constexpr float n13 = 1234.56f; constexpr double n14 = 1234.5678; constexpr lDouble n15 = 12345.67890L; From cc720dc7db12639a741f04deee356846346ece5d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 26 Apr 2019 23:48:38 +0200 Subject: [PATCH 10/70] Travis CI - Work around incomplete ca-chain of scan.coverity.com See also https://travis-ci.community/t/certificate-issue-during-coverity-build/3153 --- .travis.yml | 3 +++ src/fbuttongroup.cpp | 2 +- src/fmenu.cpp | 8 ++++---- src/fobject.cpp | 2 +- src/include/final/fbuttongroup.h | 2 +- src/include/final/fmenu.h | 8 ++++---- src/include/final/fmenubar.h | 4 ++-- src/include/final/fobject.h | 6 +++--- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97176338..ad616d2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,9 @@ matrix: - uname -a - whoami - sudo apt-get install gpm libgpm-dev libcppunit-dev autoconf-archive + # Work around broken certificate of scan.coverity.com + - sudo curl -s -L https://entrust.com/root-certificates/entrust_l1k.cer -o /usr/local/share/ca-certificates/entrust_l1k.crt + - sudo update-ca-certificates script: - autoreconf -v --install --force - ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index d03f396e..ab892929 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -461,7 +461,7 @@ void FButtonGroup::drawLabel() // private methods of FButtonGroup //---------------------------------------------------------------------- -bool FButtonGroup::isRadioButton (FToggleButton* button) const +bool FButtonGroup::isRadioButton (const FToggleButton* button) const { if ( ! button ) return false; diff --git a/src/fmenu.cpp b/src/fmenu.cpp index a95ed734..76d2bac4 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -345,25 +345,25 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, FDataPtr) // private methods of FMenu //---------------------------------------------------------------------- -bool FMenu::isWindowsMenu (FWidget* w) const +bool FMenu::isWindowsMenu (const FWidget* w) const { return w->isDialogWidget(); } //---------------------------------------------------------------------- -bool FMenu::isMenuBar (FWidget* w) const +bool FMenu::isMenuBar (const FWidget* w) const { return w->isInstanceOf("FMenuBar"); } //---------------------------------------------------------------------- -bool FMenu::isMenu (FWidget* w) const +bool FMenu::isMenu (const FWidget* w) const { return w->isInstanceOf("FMenu"); } //---------------------------------------------------------------------- -bool FMenu::isRadioMenuItem (FWidget* w) const +bool FMenu::isRadioMenuItem (const FWidget* w) const { return w->isInstanceOf("FRadioMenuItem"); } diff --git a/src/fobject.cpp b/src/fobject.cpp index 9d9fc352..b9da7b89 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -113,7 +113,7 @@ FObject* FObject::getChild (int index) const } //---------------------------------------------------------------------- -bool FObject::isChild (FObject* obj) const +bool FObject::isChild (const FObject* obj) const { // Find out if obj is a child object of mine diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index a5b91de3..7d50c92b 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -129,7 +129,7 @@ class FButtonGroup : public FScrollView static constexpr std::size_t NOT_SET = static_cast(-1); // Inquiries - bool isRadioButton (FToggleButton*) const; + bool isRadioButton (const FToggleButton*) const; // Methods void init(); diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index 49917e80..5f5f8da7 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -161,10 +161,10 @@ class FMenu : public FWindow, public FMenuList void setSuperMenu (FWidget*); // Inquiries - bool isWindowsMenu (FWidget*) const; - bool isMenuBar (FWidget*) const; - bool isMenu (FWidget*) const; - bool isRadioMenuItem (FWidget*) const; + bool isWindowsMenu (const FWidget*) const; + bool isMenuBar (const FWidget*) const; + bool isMenu (const FWidget*) const; + bool isRadioMenuItem (const FWidget*) const; bool isSubMenu() const; bool isMouseOverMenu (const FPoint&); bool isMouseOverSubMenu (const FPoint&); diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index 41c5b35b..144bf90c 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -121,7 +121,7 @@ class FMenuBar : public FWindow, public FMenuList } menuText; // Inquiry - bool isMenu (FMenuItem*) const; + bool isMenu (const FMenuItem*) const; // Methods void init(); @@ -168,7 +168,7 @@ inline const char* FMenuBar::getClassName() const { return "FMenuBar"; } //---------------------------------------------------------------------- -inline bool FMenuBar::isMenu (FMenuItem* mi) const +inline bool FMenuBar::isMenu (const FMenuItem* mi) const { return mi->hasMenu(); } } // namespace finalcut diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h index 39b7db61..ca93937c 100644 --- a/src/include/final/fobject.h +++ b/src/include/final/fobject.h @@ -98,8 +98,8 @@ class FObject // Inquiries bool hasParent() const; bool hasChildren() const; - bool isChild (FObject*) const; - bool isDirectChild (FObject*) const; + bool isChild (const FObject*) const; + bool isDirectChild (const FObject*) const; bool isWidget() const; bool isInstanceOf (const char[]) const; bool isTimerInUpdating() const; @@ -205,7 +205,7 @@ inline bool FObject::hasChildren() const { return bool( ! children_list.empty() ); } //---------------------------------------------------------------------- -inline bool FObject::isDirectChild (FObject* obj) const +inline bool FObject::isDirectChild (const FObject* obj) const { return bool( obj->getParent() == this ); } //---------------------------------------------------------------------- From ec502d208adcc29b581e5bbdf912fd62eb5c6eb1 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 27 Apr 2019 00:38:15 +0200 Subject: [PATCH 11/70] Add the reserve() method to FListBox to increase the capacity of the list --- ChangeLog | 3 +++ examples/ui.cpp | 1 + src/include/final/flistbox.h | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index e1f2767b..7d0d9eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-04-27 Markus Gans + * Add the reserve() method to FListBox to increase the capacity of the list + 2019-03-24 Markus Gans * Add a "scroll view" chapter to the first steps document diff --git a/examples/ui.cpp b/examples/ui.cpp index 8178c539..44c5572d 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -568,6 +568,7 @@ void MyDialog::initWidgets() myList.setText ("Items"); myList.setStatusbarMessage ("99 items in a list"); myList.setMultiSelection(); + myList.reserve(100); for (int z = 1; z < 100; z++) myList.insert (finalcut::FString() << z << L" placeholder"); diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index b3a6dbd9..bd3c57ff 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -221,6 +221,7 @@ class FListBox : public FWidget , bool = false , FDataPtr = nullptr ); void remove (std::size_t); + void reserve (std::size_t); void clear(); // Event handlers @@ -471,6 +472,10 @@ inline bool FListBox::hasBrackets(std::size_t index) inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const { return bool(iter->brackets > 0); } +//---------------------------------------------------------------------- +inline void FListBox::reserve (std::size_t new_cap) +{ itemlist.reserve(new_cap); } + //---------------------------------------------------------------------- template inline void FListBox::insert ( Iterator first From 83fbc0a4f5ebce04a5c63c748f0061d4caab8ecb Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 27 Apr 2019 01:23:30 +0200 Subject: [PATCH 12/70] Use shrink_to_fit() to save memory space --- ChangeLog | 1 + src/ffiledialog.cpp | 1 + src/flistbox.cpp | 1 + src/fmenulist.cpp | 1 + src/fobject.cpp | 1 + src/fstatusbar.cpp | 1 + src/ftextview.cpp | 1 + src/include/final/ftermbuffer.h | 5 ++++- 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7d0d9eae..3edaf965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2019-04-27 Markus Gans * 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 * Add a "scroll view" chapter to the first steps document diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 7ebe99ab..f8666e83 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -444,6 +444,7 @@ void FFileDialog::clear() std::free (entry.name); dir_entries.clear(); + dir_entries.shrink_to_fit(); } //---------------------------------------------------------------------- diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 51eb7490..ef8438ad 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -286,6 +286,7 @@ void FListBox::clear() { std::size_t size; itemlist.clear(); + itemlist.shrink_to_fit(); current = 0; xoffset = 0; yoffset = 0; diff --git a/src/fmenulist.cpp b/src/fmenulist.cpp index 067e609a..6836272b 100644 --- a/src/fmenulist.cpp +++ b/src/fmenulist.cpp @@ -93,6 +93,7 @@ void FMenuList::remove (int pos) void FMenuList::clear() { item_list.clear(); + item_list.shrink_to_fit(); } //---------------------------------------------------------------------- diff --git a/src/fobject.cpp b/src/fobject.cpp index b9da7b89..ed969f20 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -359,6 +359,7 @@ bool FObject::delAllTimer() timer_modify_lock = true; timer_list->clear(); + timer_list->shrink_to_fit(); timer_modify_lock = false; return true; } diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 2cdaf1c7..f62a704a 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -306,6 +306,7 @@ void FStatusBar::remove (int pos) void FStatusBar::clear() { key_list.clear(); + key_list.shrink_to_fit(); } //---------------------------------------------------------------------- diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 15a24a43..97259c57 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -274,6 +274,7 @@ void FTextView::clear() { std::size_t size; data.clear(); + data.shrink_to_fit(); xoffset = 0; yoffset = 0; maxLineWidth = 0; diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index e2455838..9005e54a 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -151,7 +151,10 @@ inline bool FTermBuffer::isEmpty() const //---------------------------------------------------------------------- inline void FTermBuffer::clear() -{ data.clear(); } +{ + data.clear(); + data.shrink_to_fit(); +} //---------------------------------------------------------------------- inline FTermBuffer& FTermBuffer::write() From 5bd8590dee1a563309d3c2e203e176a7b3e5c8ea Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 28 Apr 2019 20:57:08 +0200 Subject: [PATCH 13/70] Revision of some comments --- src/ftermlinux.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 637894e4..27aaf96e 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -746,13 +746,15 @@ uChar FTermLinux::readAttributeController (uChar index) const uInt16 input_status_1 = getInputStatusRegisterOne(); inb (input_status_1); // switch to index mode - outb (index & 0x1f, attrib_cntlr_write); - res = inb (attrib_cntlr_read); + outb (index & 0x1f, attrib_cntlr_write); // selects address register + res = inb (attrib_cntlr_read); // read from data register - inb (input_status_1); // switch to data mode + // Disable access to the palette and unblank the display + inb (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); + return res; } @@ -766,10 +768,11 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) const uInt16 input_status_1 = getInputStatusRegisterOne(); inb (input_status_1); // switch to index mode - outb (index & 0x1f, attrib_cntlr_write); - outb (data, attrib_cntlr_write); + outb (index & 0x1f, attrib_cntlr_write); // selects address register + outb (data, attrib_cntlr_write); // write to data register - inb (input_status_1); // switch to data mode + // Disable access to the palette and unblank the display + inb (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); From fa66a7091e68ac989483b7c2596aa3e3c7d1f815 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 17 May 2019 15:48:09 +0200 Subject: [PATCH 14/70] Move system calls to the new class FSystem --- ChangeLog | 6 +- README.md | 2 +- build.sh | 16 ++-- examples/7segment.cpp | 2 +- fonts/bdf2pcf.sh | 2 +- scripts/cppcheck.sh | 2 +- scripts/cpuprofile.sh | 2 +- scripts/library_calls.sh | 2 +- scripts/profile.sh | 2 +- scripts/remove_eol_spaces.sh | 2 +- scripts/show_graph_font.sh | 2 +- src/Makefile.am | 4 + src/Makefile.clang | 4 + src/Makefile.gcc | 4 + src/ffiledialog.cpp | 26 +++--- src/fsystem.cpp | 42 ++++++++++ src/fsystemimpl.cpp | 42 ++++++++++ src/fterm.cpp | 42 +++++++--- src/ftermdetection.cpp | 13 ++- src/ftermfreebsd.cpp | 25 +++--- src/ftermlinux.cpp | 109 +++++++++++++++---------- src/ftermopenbsd.cpp | 18 +++-- src/include/final/fconfig.h | 4 +- src/include/final/ffiledialog.h | 6 +- src/include/final/fsystem.h | 75 +++++++++++++++++ src/include/final/fsystemimpl.h | 125 +++++++++++++++++++++++++++++ src/include/final/fterm.h | 15 +++- src/include/final/ftermdata.h | 4 +- src/include/final/ftermdetection.h | 3 + src/include/final/ftermfreebsd.h | 7 ++ src/include/final/ftermlinux.h | 7 ++ src/include/final/ftermopenbsd.h | 7 ++ src/include/final/ftypes.h | 3 +- 33 files changed, 510 insertions(+), 115 deletions(-) create mode 100644 src/fsystem.cpp create mode 100644 src/fsystemimpl.cpp create mode 100644 src/include/final/fsystem.h create mode 100644 src/include/final/fsystemimpl.h 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; From 6811b32e8abff8b04ab58777d5983c9060fa279a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 17 May 2019 22:29:22 +0200 Subject: [PATCH 15/70] macOS build fix --- src/include/final/fconfig.h | 4 +++- src/include/final/fsystemimpl.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/include/final/fconfig.h b/src/include/final/fconfig.h index 1c5275ff..a1ab15de 100644 --- a/src/include/final/fconfig.h +++ b/src/include/final/fconfig.h @@ -50,7 +50,9 @@ #endif /* Define to 1 if GPM mouse is enabled */ -/* #undef HAVE_LIBGPM */ +#ifndef F_HAVE_LIBGPM +#define F_HAVE_LIBGPM 1 +#endif /* Define to 1 if you have the header file. */ #ifndef F_HAVE_LINUX_FB_H diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index f2e330c2..6a1b8592 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -35,13 +35,19 @@ #error "Only can be included directly." #endif +#if defined(__linux__) + #if defined(__x86_64__) || defined(__i386) || defined(__arm__) + #include // is deprecated + #endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) +#endif // defined(__linux__) + +#include +#include +#include + #include #include #include -#include -#include -#include -#include #include "final/fc.h" #include "final/fsystem.h" From 66fe27e5bce187609217e176c20706fcd712b495 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 17 May 2019 22:44:44 +0200 Subject: [PATCH 16/70] macOS build fix --- src/include/final/fsystemimpl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index 6a1b8592..c3e2800b 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -74,12 +74,20 @@ class FSystemImpl : public FSystem // Methods virtual uChar inPortByte (uShort port) { +#if defined(__linux__) +#if defined(__x86_64__) || defined(__i386) || defined(__arm__) return ::inb (port); +#endif +#endif } virtual void outPortByte (uChar value, uShort port) { +#if defined(__linux__) +#if defined(__x86_64__) || defined(__i386) || defined(__arm__) ::outb (value, port); +#endif +#endif } virtual int isTTY (int fd) @@ -101,7 +109,7 @@ class FSystemImpl : public FSystem { va_list args; va_start (args, flags); - mode_t mode = va_arg (args, mode_t); + mode_t mode = static_cast(va_arg (args, int)); int ret = ::open (pathname, flags, mode); va_end (args); return ret; From 75ec596323a09c4d9baa05e6514b9b175b50e051 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 17 May 2019 22:52:01 +0200 Subject: [PATCH 17/70] macOS build fix --- src/include/final/fsystemimpl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index c3e2800b..4c30b7df 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -77,7 +77,11 @@ class FSystemImpl : public FSystem #if defined(__linux__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__) return ::inb (port); +#else + return 0; #endif +#else + return 0; #endif } From c4d9b33628aef4dae2fafe8354541bc352c6881d Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Sun, 26 May 2019 23:35:39 +0200 Subject: [PATCH 18/70] Fix a segfault when processing input to empty FListView If the application has a list view with no items and the user clicks the widget or sends any key (space, plus, minus etc) which acts on the items, the application will segfault as the item returned from `getCurrentItem()` is `nullptr` and there's no check made for this condition. Instead of checking whether current item `!= nullptr` just check whether the item list is empty and avoid running any code at all in such case. --- src/flistview.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/flistview.cpp b/src/flistview.cpp index e11eb8f6..8b04996f 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -995,6 +995,9 @@ void FListView::onMouseDown (FMouseEvent* ev) } else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List { + if ( itemlist.empty () ) + return; + int indent = 0; int new_pos = first_visible_line.getPosition() + mouse_y - 2; @@ -1057,6 +1060,9 @@ void FListView::onMouseUp (FMouseEvent* ev) } else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List { + if (itemlist.empty ()) + return; + int indent = 0; auto item = getCurrentItem(); @@ -1164,6 +1170,9 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev) if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) ) return; + if ( itemlist.empty () ) + return; + auto item = getCurrentItem(); if ( tree_view && item->isExpandable() ) @@ -2184,6 +2193,9 @@ void FListView::processChanged() //---------------------------------------------------------------------- inline void FListView::keySpace() { + if ( itemlist.empty () ) + return; + auto item = getCurrentItem(); if ( item->isCheckable() ) @@ -2193,6 +2205,9 @@ inline void FListView::keySpace() //---------------------------------------------------------------------- inline void FListView::keyLeft (int& first_line_position_before) { + if ( itemlist.empty () ) + return; + int position_before = current_iter.getPosition(); auto item = getCurrentItem(); @@ -2247,6 +2262,9 @@ inline void FListView::keyLeft (int& first_line_position_before) //---------------------------------------------------------------------- inline void FListView::keyRight (int& first_line_position_before) { + if ( itemlist.empty () ) + return; + int xoffset_end = int(max_line_width) - int(getClientWidth()); auto item = getCurrentItem(); @@ -2291,6 +2309,9 @@ inline void FListView::keyEnd() //---------------------------------------------------------------------- inline bool FListView::keyPlus() { + if ( itemlist.empty () ) + return false; + auto item = getCurrentItem(); if ( tree_view && item->isExpandable() && ! item->isExpand() ) @@ -2306,6 +2327,9 @@ inline bool FListView::keyPlus() //---------------------------------------------------------------------- inline bool FListView::keyMinus() { + if ( itemlist.empty () ) + return false; + auto item = getCurrentItem(); if ( tree_view && item->isExpandable() && item->isExpand() ) From 22e47adbcbdd74b65e8e2a1ecaccac1eec9b9686 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 27 May 2019 00:50:11 +0200 Subject: [PATCH 19/70] Use the Singleton design pattern to get a single object instance via FTerm --- ChangeLog | 4 + examples/termcap.cpp | 13 +- src/Makefile.am | 1 + src/Makefile.clang | 2 + src/Makefile.gcc | 2 + src/fapplication.cpp | 6 +- src/fkeyboard.cpp | 11 +- src/fmenu.cpp | 2 +- src/fterm.cpp | 38 ++--- src/ftermcap.cpp | 23 +-- src/ftermcapquirks.cpp | 25 +-- src/ftermdebugdata.cpp | 48 ++++++ src/ftermdetection.cpp | 14 +- src/ftermfreebsd.cpp | 2 + src/ftermlinux.cpp | 17 +- src/ftermopenbsd.cpp | 2 + src/ftermxterminal.cpp | 9 +- src/fvterm.cpp | 8 +- src/include/final/fkeyboard.h | 12 +- src/include/final/fterm.h | 265 ++++++++++++++++++++++++++--- src/include/final/ftermcap.h | 54 +++--- src/include/final/ftermcapquirks.h | 5 - src/include/final/ftermdebugdata.h | 22 +-- src/include/final/ftermdetection.h | 2 - src/include/final/ftermfreebsd.h | 5 - src/include/final/ftermlinux.h | 15 -- src/include/final/ftermopenbsd.h | 5 - src/include/final/ftermxterminal.h | 7 +- src/include/final/fvterm.h | 13 +- test/ftermcapquirks-test.cpp | 86 ++++------ test/ftermdetection-test.cpp | 65 +++---- 31 files changed, 463 insertions(+), 320 deletions(-) create mode 100644 src/ftermdebugdata.cpp diff --git a/ChangeLog b/ChangeLog index d4231d7c..3cc7db78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-05-27 Markus Gans + * Use the Singleton design pattern to get a single object instance + via FTerm + 2019-05-17 Markus Gans * Move system calls to the new class FSystem diff --git a/examples/termcap.cpp b/examples/termcap.cpp index e79de144..ecdf5cf2 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -38,7 +38,7 @@ void tcapString (const std::string&, const char[]); void debug (finalcut::FApplication&); void booleans(); void numeric(); -void string(finalcut::FTermcap::tcap_map*&); +void string(); //---------------------------------------------------------------------- @@ -291,15 +291,17 @@ void numeric() } //---------------------------------------------------------------------- -void string(finalcut::FTermcap::tcap_map*& tcap) +void string() { std::cout << "\r\n[String]\r\n"; + finalcut::FTermcap::tcap_map (&tcap_strings)[] \ + = finalcut::FTermcap::strings; for (int n = 0; n <= data::getNumberOfItems(); n++ ) { const std::string name = data::strings[n].name; const fc::termcaps cap = data::strings[n].cap; - tcapString (name, tcap[cap].string); + tcapString (name, tcap_strings[cap].string); } } @@ -314,9 +316,6 @@ int main (int argc, char* argv[]) // Pointer to the global virtual terminal object terminal = static_cast(&TermApp); - finalcut::FTermcap::tcap_map* tcap; - tcap = finalcut::FTermcap::getTermcapMap(); - std::cout << "--------\r\nFTermcap\r\n--------\r\n\n"; std::cout << "Terminal: " << TermApp.getTermType() << "\r\n"; @@ -324,5 +323,5 @@ int main (int argc, char* argv[]) booleans(); numeric(); - string(tcap); + string(); } diff --git a/src/Makefile.am b/src/Makefile.am index 24164cef..f51c7827 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,6 +51,7 @@ libfinal_la_SOURCES = \ ftermfreebsd.cpp \ ftermopenbsd.cpp \ ftermlinux.cpp \ + ftermdebugdata.cpp \ ftermdetection.cpp \ ftermios.cpp \ fterm.cpp \ diff --git a/src/Makefile.clang b/src/Makefile.clang index 587de20b..526b8775 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -50,6 +50,7 @@ INCLUDE_HEADERS = \ ftermcap.h \ fterm.h \ ftermdata.h \ + ftermdebugdata.h \ ftermios.h \ ftermdetection.h \ ftermcapquirks.h \ @@ -114,6 +115,7 @@ OBJS = \ fkeyboard.o \ ftermcap.o \ fterm.o \ + ftermdebugdata.o \ ftermios.o \ ftermdetection.o \ ftermcapquirks.o \ diff --git a/src/Makefile.gcc b/src/Makefile.gcc index 456c30e2..88aec393 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -50,6 +50,7 @@ INCLUDE_HEADERS = \ ftermcap.h \ fterm.h \ ftermdata.h \ + ftermdebugdata.h \ ftermios.h \ ftermdetection.h \ ftermcapquirks.h \ @@ -114,6 +115,7 @@ OBJS = \ fkeyboard.o \ ftermcap.o \ fterm.o \ + ftermdebugdata.o \ ftermios.o \ ftermdetection.o \ ftermcapquirks.o \ diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 63b9611e..5eaee5b9 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2013-2018 Markus Gans * +* Copyright 2013-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 * @@ -362,7 +362,7 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) void FApplication::init (uInt64 key_time, uInt64 dblclick_time) { // Initialize keyboard - keyboard = FVTerm::getKeyboard(); + keyboard = FVTerm::getFKeyboard(); // Set the keyboard keypress timeout if ( keyboard ) @@ -377,7 +377,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time) } // Initialize mouse control - mouse = FVTerm::getMouseControl(); + mouse = FVTerm::getFMouseControl(); // Set stdin number for a gpm-mouse if ( mouse ) diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index a3e907bd..0e4c0251 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.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 * @@ -30,6 +30,7 @@ #include "final/fkeyboard.h" #include "final/fkey_map.h" +#include "final/fterm.h" #include "final/ftermios.h" namespace finalcut @@ -112,6 +113,14 @@ void FKeyboard::setTermcapMap (fc::fkeymap* keymap) key_map = keymap; } +//---------------------------------------------------------------------- +void FKeyboard::init() +{ +#if defined(__linux__) + linux = FTerm::getFTermLinux(); +#endif +} + //---------------------------------------------------------------------- bool& FKeyboard::unprocessedInput() { diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 76d2bac4..ebe78901 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -558,7 +558,7 @@ int FMenu::adjustX (int x_pos) // Is menu outside on the right of the screen? if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) ) { - x_pos = int(getDesktopWidth() - max_item_width + 1); + x_pos = int(getDesktopWidth() - max_item_width - 1); // Menu to large for the screen if ( x_pos < 1 ) x_pos = 1; diff --git a/src/fterm.cpp b/src/fterm.cpp index 95b607a5..51911349 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -44,7 +44,6 @@ int (*FTerm::Fputchar)(int); 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; FTermDetection* FTerm::term_detection = nullptr; @@ -338,6 +337,9 @@ bool FTerm::setOldFont() //---------------------------------------------------------------------- int FTerm::openConsole() { + if ( ! data ) + data = FTerm::getFTermData(); + int fd = data->getTTYFileDescriptor(); const char* termfilename = data->getTermFileName(); @@ -373,6 +375,9 @@ int FTerm::openConsole() //---------------------------------------------------------------------- int FTerm::closeConsole() { + if ( ! data ) + data = FTerm::getFTermData(); + int fd = data->getTTYFileDescriptor(); int ret = -1; @@ -490,6 +495,9 @@ void FTerm::detectTermSize() { // Detect the terminal width and height + if ( ! data ) + data = FTerm::getFTermData(); + struct winsize win_size; bool close_after_detect = false; int fd = data->getTTYFileDescriptor(); @@ -958,14 +966,13 @@ void FTerm::init_global_values (bool disable_alt_screen) data->useAlternateScreen(! disable_alt_screen); // Initialize xterm object - xterm->setFTermDetection(term_detection); + xterm->init(); if ( ! init_values.terminal_detection ) term_detection->setTerminalDetection (false); #if DEBUG - debug_data->setFTermDetection(term_detection); - debug_data->setFTermData(data); + debug_data->init(); #endif } @@ -1182,9 +1189,7 @@ void FTerm::init_teraterm_charmap() //---------------------------------------------------------------------- void FTerm::init_keyboard() { -#if defined(__linux__) - keyboard->setFTermLinux (linux); -#endif + keyboard->init(); } //---------------------------------------------------------------------- @@ -1192,13 +1197,7 @@ void FTerm::init_termcap() { // Initialize the terminal capabilities - FTermcap termcap; - termcap.setFTermData(data); - termcap.setFTermDetection(term_detection); - termcap.init(); - - // Share the terminal capabilities - tcap = termcap.getTermcapMap(); + FTermcap::init(); } //---------------------------------------------------------------------- @@ -1207,8 +1206,6 @@ void FTerm::init_quirks() // Initialize terminal quirks FTermcapQuirks quirks; - quirks.setFTermData (data); - quirks.setFTermDetection (term_detection); quirks.terminalFixup(); // Fix terminal quirks } @@ -1837,8 +1834,6 @@ void FTerm::init (bool disable_alt_screen) initBaudRate(); // Terminal detection - term_detection->setFTermData(data); - term_detection->setFSystem(fsys); term_detection->detect(); setTermType (term_detection->getTermType()); @@ -1927,9 +1922,6 @@ void FTerm::init (bool disable_alt_screen) void FTerm::initOSspecifics() { #if defined(__linux__) - linux->setFTermData(data); - linux->setFSystem(fsys); - linux->setFTermDetection(term_detection); linux->init(); // Initialize Linux console #if DEBUG @@ -1939,8 +1931,6 @@ void FTerm::initOSspecifics() #endif // defined(__linux__) #if defined(__FreeBSD__) || defined(__DragonFly__) - freebsd->setFSystem(fsys); - if ( init_values.meta_sends_escape ) freebsd->enableMetaSendsEscape(); else @@ -1953,8 +1943,6 @@ 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 diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index b1d644fb..b6966bcd 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -24,6 +24,7 @@ #include #include +#include "final/fterm.h" #include "final/ftermcap.h" namespace finalcut @@ -59,21 +60,11 @@ FTermDetection* FTermcap::term_detection = nullptr; */ // public methods of FTermcap -//---------------------------------------------------------------------- -void FTermcap::setFTermData (FTermData* data) -{ - fterm_data = data; -} - -//---------------------------------------------------------------------- -void FTermcap::setFTermDetection (FTermDetection* td) -{ - term_detection = td; -} - //---------------------------------------------------------------------- void FTermcap::init() { + fterm_data = FTerm::getFTermData(); + term_detection = FTerm::getFTermDetection(); termcap(); } @@ -225,8 +216,8 @@ void FTermcap::termcapStrings (char*& buffer) // Get termcap strings // Read termcap output strings - for (std::size_t i = 0; tcap[i].tname[0] != 0; i++) - tcap[i].string = tgetstr(tcap[i].tname, &buffer); + for (std::size_t i = 0; strings[i].tname[0] != 0; i++) + strings[i].string = tgetstr(strings[i].tname, &buffer); } //---------------------------------------------------------------------- @@ -326,7 +317,7 @@ void FTermcap::termcapKeysVt100 (char*& buffer) // private Data Member of FTermcap - termcap capabilities //---------------------------------------------------------------------- -FTermcap::tcap_map FTermcap::tcap[] = +FTermcap::tcap_map FTermcap::strings[] = { // .------------- term string // | .-------- Tcap-code diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 9cf10be6..ce6e7afb 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -28,7 +28,6 @@ namespace finalcut { // static class attributes -FTermcap::tcap_map* FTermcapQuirks::tcap = nullptr; FTermData* FTermcapQuirks::fterm_data = nullptr; FTermDetection* FTermcapQuirks::term_detection = nullptr; @@ -40,9 +39,7 @@ FTermDetection* FTermcapQuirks::term_detection = nullptr; // constructors and destructor //---------------------------------------------------------------------- FTermcapQuirks::FTermcapQuirks() -{ - tcap = FTermcap::getTermcapMap(); -} +{ } //---------------------------------------------------------------------- FTermcapQuirks::~FTermcapQuirks() // destructor @@ -51,22 +48,10 @@ FTermcapQuirks::~FTermcapQuirks() // destructor // public methods of FTermcapQuirks //---------------------------------------------------------------------- -void FTermcapQuirks::setFTermData (FTermData* data) -{ - fterm_data = data; -} - -//---------------------------------------------------------------------- -void FTermcapQuirks::setFTermDetection (FTermDetection* td) -{ - term_detection = td; -} - - -// private methods of FTermcapQuirks -//---------------------------------------------------------------------- void FTermcapQuirks::terminalFixup() { + fterm_data = FTerm::getFTermData(); + term_detection = FTerm::getFTermDetection(); auto& td = term_detection; if ( td->isCygwinTerminal() ) @@ -118,8 +103,10 @@ void FTermcapQuirks::terminalFixup() ecma48(); } -#if defined(__FreeBSD__) || defined(__DragonFly__) + +// private methods of FTermcapQuirks //---------------------------------------------------------------------- +#if defined(__FreeBSD__) || defined(__DragonFly__) void FTermcapQuirks::freebsd() { // FreeBSD console fixes diff --git a/src/ftermdebugdata.cpp b/src/ftermdebugdata.cpp new file mode 100644 index 00000000..a8a60ac6 --- /dev/null +++ b/src/ftermdebugdata.cpp @@ -0,0 +1,48 @@ +/*********************************************************************** +* ftermdebugdata.cpp - Debug data class for FTerm * +* * +* 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/fterm.h" +#include "final/ftermdata.h" +#include "final/ftermdetection.h" +#include "final/ftermdebugdata.h" + +namespace finalcut +{ + +// static class attributes +FTermData* FTermDebugData::data = nullptr; +FTermDetection* FTermDebugData::term_detection = nullptr; + +//---------------------------------------------------------------------- +// class FClassName +//---------------------------------------------------------------------- + +// public methods of FClassName +//---------------------------------------------------------------------- +void FTermDebugData::init() +{ + data = FTerm::getFTermData(); + term_detection = FTerm::getFTermDetection(); +} + +} // namespace finalcut + diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 6c63329f..76852a4e 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -85,18 +85,6 @@ FTermDetection::~FTermDetection() // destructor // public methods of FTermDetection -//---------------------------------------------------------------------- -void FTermDetection::setFTermData (FTermData* data) -{ - fterm_data = data; -} - -//---------------------------------------------------------------------- -void FTermDetection::setFSystem (FSystem* fsys) -{ - fsystem = fsys; -} - //---------------------------------------------------------------------- void FTermDetection::setTtyTypeFileName (char ttytype_filename[]) { @@ -110,6 +98,8 @@ void FTermDetection::setTtyTypeFileName (char ttytype_filename[]) //---------------------------------------------------------------------- void FTermDetection::detect() { + fterm_data = FTerm::getFTermData(); + fsystem = FTerm::getFSystem(); deallocation(); // Set the variable 'termtype' to the predefined type of the terminal diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index ca1a1de8..e2ef752e 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -85,6 +85,8 @@ void FTermFreeBSD::init() if ( ! isFreeBSDConsole() ) return; + fsystem = FTerm::getFSystem(); + if ( meta_sends_escape ) { // save current left alt key mapping diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 1ad11cec..fce78caa 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -137,7 +137,7 @@ bool FTermLinux::isLinuxConsole() // Check if it's a Linux console if ( ! fsystem ) - return false; + fsystem = FTerm::getFSystem(); char arg = 0; int fd_tty = FTerm::getTTYFileDescriptor(); @@ -153,6 +153,9 @@ void FTermLinux::init() { // initialize Linux console + fterm_data = FTerm::getFTermData(); + fsystem = FTerm::getFSystem(); + term_detection = FTerm::getFTermDetection(); screen_unicode_map.entries = nullptr; screen_font.data = nullptr; @@ -480,7 +483,7 @@ int FTermLinux::getFramebuffer_bpp() struct fb_fix_screeninfo fb_fix; if ( ! fsystem ) - return -1; + fsystem = FTerm::getFSystem(); if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) { @@ -737,7 +740,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() // Gets the VGA input-status-register-1 if ( ! fsystem ) - return 0x3da; + fsystem = FTerm::getFSystem(); // Miscellaneous output (read port) static constexpr uInt16 misc_read = 0x3cc; @@ -754,7 +757,7 @@ uChar FTermLinux::readAttributeController (uChar index) // Reads a byte from the attribute controller from a given index if ( ! fsystem ) - return 0; + fsystem = FTerm::getFSystem(); uChar res; // Attribute controller (write port) @@ -782,7 +785,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) // Writes a byte from the attribute controller from a given index if ( ! fsystem ) - return; + fsystem = FTerm::getFSystem(); // Attribute controller (write port) static constexpr uInt16 attrib_cntlr_write = 0x3c0; @@ -822,7 +825,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) // That permits 16 colors for background if ( ! fsystem ) - return -1; + fsystem = FTerm::getFSystem(); int fd_tty = FTerm::getTTYFileDescriptor(); @@ -891,7 +894,7 @@ bool FTermLinux::resetVGAPalette() // Reset the vga color map if ( ! fsystem ) - return false; + fsystem = FTerm::getFSystem(); if ( has_saved_palette ) { diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index f22976a7..aa0c90ef 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -61,6 +61,8 @@ void FTermOpenBSD::init() if ( ! isBSDConsole() ) return; + fsystem = FTerm::getFSystem(); + if ( meta_sends_escape ) { // save current left alt key mapping diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index 0a6750af..d3789c22 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -41,7 +41,6 @@ const FString* FTermXTerminal::cursor_color = nullptr; const FString* FTermXTerminal::mouse_foreground_color = nullptr; const FString* FTermXTerminal::mouse_background_color = nullptr; const FString* FTermXTerminal::highlight_background_color = nullptr; -FTermcap::tcap_map* FTermXTerminal::tcap = nullptr; FTermDetection* FTermXTerminal::term_detection = nullptr; fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style; @@ -58,8 +57,6 @@ FTermXTerminal::FTermXTerminal() mouse_support = \ meta_sends_esc = \ xterm_default_colors = false; - - tcap = FTermcap::getTermcapMap(); } //---------------------------------------------------------------------- @@ -229,6 +226,12 @@ void FTermXTerminal::metaSendsESC (bool enable) disableXTermMetaSendsESC(); } +//---------------------------------------------------------------------- +void FTermXTerminal::init() +{ + term_detection = FTerm::getFTermDetection(); +} + //---------------------------------------------------------------------- void FTermXTerminal::setDefaults() { diff --git a/src/fvterm.cpp b/src/fvterm.cpp index d5436c18..663f91b8 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -54,7 +54,6 @@ FTerm* FVTerm::fterm = nullptr; FVTerm::term_area* FVTerm::vterm = nullptr; FVTerm::term_area* FVTerm::vdesktop = nullptr; FVTerm::term_area* FVTerm::active_area = nullptr; -FTermcap::tcap_map* FVTerm::tcap = nullptr; FKeyboard* FVTerm::keyboard = nullptr; FVTerm::charData FVTerm::term_attribute; FVTerm::charData FVTerm::next_attribute; @@ -1873,9 +1872,6 @@ void FVTerm::init (bool disable_alt_screen) // next_attribute contains the state of the next printed character std::memcpy (&next_attribute, &term_attribute, sizeof(next_attribute)); - // Receive the terminal capabilities - tcap = FTermcap::getTermcapMap(); - // Create virtual terminal FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); createVTerm (term_geometry.getSize()); @@ -1886,8 +1882,8 @@ void FVTerm::init (bool disable_alt_screen) vdesktop->visible = true; active_area = vdesktop; - // Initialize keyboard - keyboard = FTerm::getKeyboard(); + // Get FKeyboard object + keyboard = FTerm::getFKeyboard(); // Hide the input cursor hideCursor(); diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index 437e839d..efdea002 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -116,11 +116,6 @@ class FKeyboard final void disableUTF8(); void enableMouseSequences(); void disableMouseSequences(); - -#if defined(__linux__) - void setFTermLinux (FTermLinux*); -#endif - void setPressCommand (FKeyboardCommand); void setReleaseCommand (FKeyboardCommand); void setEscPressedCommand (FKeyboardCommand); @@ -129,6 +124,7 @@ class FKeyboard final bool isInputDataPending(); // Methods + static void init(); bool& unprocessedInput(); bool isKeyPressed(); void clearKeyBuffer(); @@ -229,12 +225,6 @@ inline void FKeyboard::enableMouseSequences() inline void FKeyboard::disableMouseSequences() { mouse_support = false; } -#if defined(__linux__) -//---------------------------------------------------------------------- -inline void FKeyboard::setFTermLinux (FTermLinux* linux_obj) -{ linux = linux_obj; } -#endif - //---------------------------------------------------------------------- inline void FKeyboard::setPressCommand (FKeyboardCommand cmd) { keypressed_cmd = cmd; } diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 6c7cd655..75f81d70 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -176,12 +176,9 @@ class FTerm final // Accessors virtual const char* getClassName() const; - static FKeyboard* getKeyboard(); - static FMouseControl* getMouseControl(); static std::size_t getLineNumber(); static std::size_t getColumnNumber(); static const FString getKeyName (FKey); - static FOptiMove* getFOptiMove(); static int getTTYFileDescriptor(); static char* getTermType(); static char* getTermFileName(); @@ -190,9 +187,24 @@ class FTerm final initializationValues& getInitValues(); characterSub& getCharSubstitutionMap(); -#if DEBUG static FTermData* getFTermData(); + static FSystem* getFSystem(); + static FOptiMove* getFOptiMove(); + static FOptiAttr* getFOptiAttr(); static FTermDetection* getFTermDetection(); + static FTermXTerminal* getFTermXTerminal(); + static FKeyboard* getFKeyboard(); + static FMouseControl* getFMouseControl(); + +#if defined(__linux__) + static FTermLinux* getFTermLinux(); +#elif defined(__FreeBSD__) || defined(__DragonFly__) + static FTermFreeBSD* getFTermFreeBSD(); +#elif defined(__NetBSD__) || defined(__OpenBSD__) + static FTermOpenBSD* getFTermOpenBSD(); +#endif + +#if DEBUG FTermDebugData& getFTermDebugData(); #endif @@ -231,6 +243,7 @@ class FTerm final static bool canChangeColorPalette(); // Mutators + static void setFSystem (FSystem*); static void setTermType (const char[]); static void setInsertCursor (bool); static void redefineDefaultColors (bool); @@ -398,7 +411,6 @@ class FTerm final // Data Members static FTermData* data; static FSystem* fsys; - static FTermcap::tcap_map* tcap; static FOptiMove* opti_move; static FOptiAttr* opti_attr; static FTermDetection* term_detection; @@ -427,17 +439,9 @@ class FTerm final inline const char* FTerm::getClassName() const { return "FTerm"; } -//---------------------------------------------------------------------- -inline FKeyboard* FTerm::getKeyboard() -{ return ( keyboard ) ? keyboard : 0; } - -//---------------------------------------------------------------------- -inline FMouseControl* FTerm::getMouseControl() -{ return ( mouse ) ? mouse : 0; } - //---------------------------------------------------------------------- inline int FTerm::getTTYFileDescriptor() -{ return data->getTTYFileDescriptor(); } +{ return ( data ) ? data->getTTYFileDescriptor() : 0; } //---------------------------------------------------------------------- inline char* FTerm::getTermType() @@ -463,18 +467,235 @@ inline FTerm::initializationValues& FTerm::getInitValues() inline FTerm::characterSub& FTerm::getCharSubstitutionMap() { return data->getCharSubstitutionMap(); } -#if DEBUG //---------------------------------------------------------------------- inline FTermData* FTerm::getFTermData() -{ return data; } +{ + if ( data == 0 ) + { + try + { + data = new FTermData; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return data; +} + +//---------------------------------------------------------------------- +inline FSystem* FTerm::getFSystem() +{ + if ( fsys == 0 ) + { + try + { + fsys = new FSystemImpl; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return fsys; +} + +//---------------------------------------------------------------------- +inline FOptiMove* FTerm::getFOptiMove() +{ + if ( opti_move == 0 ) + { + try + { + opti_move = new FOptiMove; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return opti_move; +} + +//---------------------------------------------------------------------- +inline FOptiAttr* FTerm::getFOptiAttr() +{ + if ( opti_attr == 0 ) + { + try + { + opti_attr = new FOptiAttr; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return opti_attr; +} //---------------------------------------------------------------------- inline FTermDetection* FTerm::getFTermDetection() -{ return term_detection; } +{ + if ( term_detection == 0 ) + { + try + { + term_detection = new FTermDetection; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + return term_detection; +} +//---------------------------------------------------------------------- +inline FTermXTerminal* FTerm::getFTermXTerminal() +{ + if ( xterm == 0 ) + { + try + { + xterm = new FTermXTerminal; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return xterm; +} +//---------------------------------------------------------------------- +inline FKeyboard* FTerm::getFKeyboard() +{ + if ( keyboard == 0 ) + { + try + { + keyboard = new FKeyboard; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return keyboard; +} +//---------------------------------------------------------------------- +inline FMouseControl* FTerm::getFMouseControl() +{ + if ( mouse == 0 ) + { + try + { + mouse = new FMouseControl; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return mouse; +} + +#if defined(__linux__) +//---------------------------------------------------------------------- +inline FTermLinux* FTerm::getFTermLinux() +{ + if ( linux == 0 ) + { + try + { + linux = new FTermLinux; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return linux; +} + +#elif defined(__FreeBSD__) || defined(__DragonFly__) +//---------------------------------------------------------------------- +inline FTermFreeBSD* FTerm::getFTermFreeBSD() +{ + if ( freebsd == 0 ) + { + try + { + freebsd = new FTermFreeBSD; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return freebsd; +} + +#elif defined(__NetBSD__) || defined(__OpenBSD__) +//---------------------------------------------------------------------- +inline FTermOpenBSD* FTerm::getFTermOpenBSD() +{ + if ( openbsd == 0 ) + { + try + { + openbsd = new FTermOpenBSD; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return openbsd; +} +#endif + +#if DEBUG //---------------------------------------------------------------------- inline FTermDebugData& FTerm::getFTermDebugData() -{ return *debug_data; } +{ + if ( debug_data == 0 ) + { + try + { + debug_data = new FTermDebugData; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return *debug_data; +} #endif // DEBUG //---------------------------------------------------------------------- @@ -581,6 +802,10 @@ inline bool FTerm::hasHalfBlockCharacter() inline bool FTerm::hasAlternateScreen() { return data->hasAlternateScreen(); } +//---------------------------------------------------------------------- +inline void FTerm::setFSystem (FSystem* fsystem) +{ fsys = fsystem; } + //---------------------------------------------------------------------- inline bool FTerm::setUTF8() { return setUTF8(true); } @@ -589,10 +814,6 @@ inline bool FTerm::setUTF8() inline bool FTerm::unsetUTF8() { return setUTF8(false); } -//---------------------------------------------------------------------- -inline FOptiMove* FTerm::getFOptiMove() -{ return opti_move; } - //---------------------------------------------------------------------- inline void FTerm::changeTermSizeFinished() { data->setTermResized(false); } diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index b94d9416..a29ad82c 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -64,7 +64,8 @@ // FTermcap string macro -#define TCAP(...) tcap[__VA_ARGS__].string +//#define TCAP(...) tcap_strings[__VA_ARGS__].string +#define TCAP(...) FTermcap::strings[__VA_ARGS__].string namespace finalcut { @@ -93,46 +94,37 @@ class FTermcap final ~FTermcap() = default; // Accessors - const char* getClassName() const; - - static tcap_map* getTermcapMap() - { - return tcap; - } - - // Mutator - static void setFTermData (FTermData*); - static void setFTermDetection (FTermDetection*); + const char* getClassName() const; // Methods static void init(); // Data Members - static bool background_color_erase; - static bool can_change_color_palette; - static bool automatic_left_margin; - static bool automatic_right_margin; - static bool eat_nl_glitch; - static bool ansi_default_color; - static bool osc_support; - static bool no_utf8_acs_chars; - static int max_color; - static int tabstop; - static int attr_without_color; + static bool background_color_erase; + static bool can_change_color_palette; + static bool automatic_left_margin; + static bool automatic_right_margin; + static bool eat_nl_glitch; + static bool ansi_default_color; + static bool osc_support; + static bool no_utf8_acs_chars; + static int max_color; + static int tabstop; + static int attr_without_color; + static tcap_map strings[]; private: // Methods - static void termcap(); - static void termcapError (int); - static void termcapVariables (char*&); - static void termcapBoleans(); - static void termcapNumerics(); - static void termcapStrings (char*&); - static void termcapKeys (char*&); - static void termcapKeysVt100 (char*&); + static void termcap(); + static void termcapError (int); + static void termcapVariables (char*&); + static void termcapBoleans(); + static void termcapNumerics(); + static void termcapStrings (char*&); + static void termcapKeys (char*&); + static void termcapKeysVt100 (char*&); // Data Member - static tcap_map tcap[]; static FTermData* fterm_data; static FTermDetection* term_detection; }; diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index 0f74b1c9..a22c72e6 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -63,10 +63,6 @@ class FTermcapQuirks final // Accessor virtual const char* getClassName() const; - // Mutator - static void setFTermData (FTermData*); - static void setFTermDetection (FTermDetection*); - // Methods static void terminalFixup(); @@ -88,7 +84,6 @@ class FTermcapQuirks final static void ecma48(); // Data Members - static FTermcap::tcap_map* tcap; static FTermData* fterm_data; static FTermDetection* term_detection; }; diff --git a/src/include/final/ftermdebugdata.h b/src/include/final/ftermdebugdata.h index 407c77b5..91081897 100644 --- a/src/include/final/ftermdebugdata.h +++ b/src/include/final/ftermdebugdata.h @@ -38,6 +38,9 @@ namespace finalcut { +// class forward declaration +class FTerm; + #if DEBUG //---------------------------------------------------------------------- // class FTermDebugData @@ -67,25 +70,16 @@ class FTermDebugData final #if defined(__linux__) int getFramebufferBpp(); #endif - // Mutators - void setFTermDetection (FTermDetection*); - void setFTermData (FTermData*); + + // Methods + static void init(); private: // Data Members - FTermDetection* term_detection{nullptr}; - FTermData* data{nullptr}; + static FTermData* data; + static FTermDetection* term_detection; }; -// FTermDebugData inline functions -//---------------------------------------------------------------------- -inline void FTermDebugData::setFTermDetection (FTermDetection* obj) -{ term_detection = obj; } - -//---------------------------------------------------------------------- -inline void FTermDebugData::setFTermData (FTermData* obj) -{ data = obj; } - //---------------------------------------------------------------------- inline const FString& FTermDebugData::getAnswerbackString() { return term_detection->getAnswerbackString(); } diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 7efd73bd..6da6905a 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -154,8 +154,6 @@ class FTermDetection final static void setScreenTerm (bool); static void setTmuxTerm (bool); static void setTerminalDetection (bool); - static void setFTermData (FTermData*); - static void setFSystem (FSystem*); static void setTtyTypeFileName (char[]); // Methods diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 6e9496aa..331352b9 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -83,7 +83,6 @@ class FTermFreeBSD final static bool isFreeBSDConsole(); // Mutators - static void setFSystem (FSystem*); static void setCursorStyle (CursorStyle, bool); static void enableChangeCursorStyle(); static void disableChangeCursorStyle(); @@ -119,10 +118,6 @@ 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 2f108c68..aab81be2 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -88,9 +88,6 @@ class FTermLinux final static int getFramebufferBpp(); // 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); static void setUTF8 (bool); @@ -206,18 +203,6 @@ inline const char* FTermLinux::getClassName() const inline int FTermLinux::getFramebufferBpp() { return framebuffer_bpp; } -//---------------------------------------------------------------------- -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; } - //---------------------------------------------------------------------- inline bool FTermLinux::hasShadowCharacter() { return shadow_character; } diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 36cac577..966a471d 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -75,7 +75,6 @@ class FTermOpenBSD final static bool isBSDConsole(); // Mutators - static void setFSystem (FSystem*); static void disableMetaSendsEscape(); static void enableMetaSendsEscape(); @@ -106,10 +105,6 @@ 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/ftermxterminal.h b/src/include/final/ftermxterminal.h index 394bc32b..54ededbe 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -60,7 +60,6 @@ class FTermXTerminal final virtual ~FTermXTerminal(); // Mutators - static void setFTermDetection (FTermDetection*); static void redefineDefaultColors (bool); static void setCursorStyle (fc::xtermCursorStyle); static void setFont (const FString&); @@ -94,6 +93,7 @@ class FTermXTerminal final static bool hasTitle(); // Methods + static void init(); static void setDefaults(); static void resetColorMap(); static void resetForeground(); @@ -150,7 +150,6 @@ class FTermXTerminal final static const FString* mouse_foreground_color; static const FString* mouse_background_color; static const FString* highlight_background_color; - static FTermcap::tcap_map* tcap; static FTermDetection* term_detection; static fc::xtermCursorStyle cursor_style; }; @@ -161,10 +160,6 @@ class FTermXTerminal final inline const char* FTermXTerminal::getClassName() const { return "FTermXTerminal"; } -//---------------------------------------------------------------------- -inline void FTermXTerminal::setFTermDetection (FTermDetection* td) -{ term_detection = td; } - //---------------------------------------------------------------------- inline void FTermXTerminal::redefineDefaultColors (bool enable) { xterm_default_colors = enable; } diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index b4859773..a74adddb 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -324,8 +324,8 @@ class FVTerm std::size_t getLineNumber(); std::size_t getColumnNumber(); static bool charEncodable (wchar_t); - static FKeyboard* getKeyboard(); - static FMouseControl* getMouseControl(); + static FKeyboard* getFKeyboard(); + static FMouseControl* getFMouseControl(); FTerm::initializationValues& getInitValues(); // Mutators @@ -482,7 +482,6 @@ class FVTerm static charData s_ch; // shadow character static charData i_ch; // inherit background character static FPoint* term_pos; // terminal cursor position - static FTermcap::tcap_map* tcap; static FKeyboard* keyboard; static bool terminal_update_complete; static bool terminal_update_pending; @@ -1076,12 +1075,12 @@ inline bool FVTerm::charEncodable (wchar_t c) { return FTerm::charEncodable(c); } //---------------------------------------------------------------------- -inline FKeyboard* FVTerm::getKeyboard() -{ return FTerm::getKeyboard(); } +inline FKeyboard* FVTerm::getFKeyboard() +{ return FTerm::getFKeyboard(); } //---------------------------------------------------------------------- -inline FMouseControl* FVTerm::getMouseControl() -{ return FTerm::getMouseControl(); } +inline FMouseControl* FVTerm::getFMouseControl() +{ return FTerm::getFMouseControl(); } //---------------------------------------------------------------------- inline FTerm::initializationValues& FVTerm::getInitValues() diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index ebbf99ef..de0a7dfb 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.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 * @@ -227,20 +227,16 @@ void FTermcapQuirksTest::classNameTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::generalTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; finalcut::FTermcap::tabstop = -1; finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcap::can_change_color_palette = false; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::tabstop == 8 ); @@ -294,20 +290,18 @@ void FTermcapQuirksTest::generalTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::xtermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; finalcut::FTermcap::can_change_color_palette = false; detect.setXTerminal (true); data.setTermType ("xterm"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::can_change_color_palette ); @@ -327,16 +321,16 @@ void FTermcapQuirksTest::xtermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::freebsdTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setFreeBSDTerm (true); data.setTermType ("xterm-16color"); quirks.setFTermData(&data); @@ -366,20 +360,18 @@ void FTermcapQuirksTest::freebsdTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::cygwinTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::background_color_erase = false; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setCygwinTerminal (true); data.setTermType ("cygwin"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::background_color_erase == true ); @@ -393,21 +385,19 @@ void FTermcapQuirksTest::cygwinTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::linuxTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::max_color = 8; finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setLinuxTerm (true); data.setTermType ("linux"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); // 8 colors @@ -467,19 +457,17 @@ void FTermcapQuirksTest::linuxTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::rxvtTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setRxvtTerminal (true); data.setTermType ("rxvt"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); // rxvt @@ -510,20 +498,18 @@ void FTermcapQuirksTest::rxvtTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::vteTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setGnomeTerminal (true); data.setTermType ("gnome-256color"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 0 ); @@ -536,23 +522,21 @@ void FTermcapQuirksTest::vteTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::puttyTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::background_color_erase = false; finalcut::FTermcap::can_change_color_palette = false; finalcut::FTermcap::osc_support = false; finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setPuttyTerminal (true); data.setTermType ("putty"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::background_color_erase == true ); @@ -628,20 +612,18 @@ void FTermcapQuirksTest::puttyTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::teratermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::eat_nl_glitch = false; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setTeraTerm (true); data.setTermType ("teraterm"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true ); @@ -660,20 +642,18 @@ void FTermcapQuirksTest::teratermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::sunTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcap::eat_nl_glitch = false; finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; detect.setSunTerminal (true); data.setTermType ("sun-color"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true ); @@ -780,20 +760,18 @@ void FTermcapQuirksTest::sunTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::screenTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); + finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection(); finalcut::FTermcapQuirks quirks; - finalcut::FTermDetection detect; finalcut::FTermcap::can_change_color_palette = false; detect.setScreenTerm (true); data.setTermType ("screen-256color"); - quirks.setFTermData(&data); - quirks.setFTermDetection (&detect); quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::can_change_color_palette ); diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index 1263f179..f3f664a6 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.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 * @@ -471,11 +471,10 @@ void FTermDetectionTest::classNameTest() //---------------------------------------------------------------------- void FTermDetectionTest::ansiTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; setenv ("TERM", "ansi", 1); data.setTermFileName(C_STR("ansi")); - detect.setFTermData(&data); pid_t pid = forkProcess(); @@ -541,10 +540,9 @@ void FTermDetectionTest::ansiTest() //---------------------------------------------------------------------- void FTermDetectionTest::xtermTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -603,10 +601,9 @@ void FTermDetectionTest::xtermTest() //---------------------------------------------------------------------- void FTermDetectionTest::rxvtTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("rxvt-cygwin-native")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -666,10 +663,9 @@ void FTermDetectionTest::rxvtTest() //---------------------------------------------------------------------- void FTermDetectionTest::urxvtTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("rxvt-unicode-256color")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -728,10 +724,9 @@ void FTermDetectionTest::urxvtTest() //---------------------------------------------------------------------- void FTermDetectionTest::mltermTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("mlterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -798,10 +793,9 @@ void FTermDetectionTest::mltermTest() //---------------------------------------------------------------------- void FTermDetectionTest::puttyTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -861,10 +855,9 @@ void FTermDetectionTest::puttyTest() //---------------------------------------------------------------------- void FTermDetectionTest::kdeKonsoleTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm-256color")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -923,10 +916,9 @@ void FTermDetectionTest::kdeKonsoleTest() //---------------------------------------------------------------------- void FTermDetectionTest::gnomeTerminalTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm-256color")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -986,10 +978,9 @@ void FTermDetectionTest::gnomeTerminalTest() //---------------------------------------------------------------------- void FTermDetectionTest::newerVteTerminalTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm-256color")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1049,10 +1040,9 @@ void FTermDetectionTest::newerVteTerminalTest() //---------------------------------------------------------------------- void FTermDetectionTest::ktermTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("kterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1119,10 +1109,9 @@ void FTermDetectionTest::ktermTest() //---------------------------------------------------------------------- void FTermDetectionTest::teraTermTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1182,10 +1171,9 @@ void FTermDetectionTest::teraTermTest() //---------------------------------------------------------------------- void FTermDetectionTest::cygwinTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("cygwin")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1245,10 +1233,9 @@ void FTermDetectionTest::cygwinTest() //---------------------------------------------------------------------- void FTermDetectionTest::minttyTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm-256color")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1308,10 +1295,9 @@ void FTermDetectionTest::minttyTest() //---------------------------------------------------------------------- void FTermDetectionTest::linuxTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("linux")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1378,10 +1364,9 @@ void FTermDetectionTest::linuxTest() //---------------------------------------------------------------------- void FTermDetectionTest::freebsdTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("xterm")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1451,10 +1436,9 @@ void FTermDetectionTest::freebsdTest() //---------------------------------------------------------------------- void FTermDetectionTest::netbsdTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("wsvt25")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1522,10 +1506,9 @@ void FTermDetectionTest::netbsdTest() //---------------------------------------------------------------------- void FTermDetectionTest::openbsdTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("vt220")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1593,10 +1576,9 @@ void FTermDetectionTest::openbsdTest() //---------------------------------------------------------------------- void FTermDetectionTest::sunTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("sun-color")); - detect.setFTermData(&data); pid_t pid = forkProcess(); @@ -1662,10 +1644,9 @@ void FTermDetectionTest::sunTest() //---------------------------------------------------------------------- void FTermDetectionTest::screenTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("screen")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1731,10 +1712,9 @@ void FTermDetectionTest::screenTest() //---------------------------------------------------------------------- void FTermDetectionTest::tmuxTest() { - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; data.setTermFileName(C_STR("screen")); - detect.setFTermData(&data); detect.setTerminalDetection(true); pid_t pid = forkProcess(); @@ -1836,9 +1816,8 @@ void FTermDetectionTest::ttytypeTest() ttytype << "vt100" << "\t" << "ttyp6" << std::endl; ttytype.close(); - finalcut::FTermData data; + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - detect.setFTermData(&data); detect.setTerminalDetection(true); detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype")); From 5e436e91dcfb787cba8906b0f69044e9752ba2b2 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 27 May 2019 01:10:10 +0200 Subject: [PATCH 20/70] Use the Singleton design pattern to get a single object instance via FTerm --- src/include/final/ftermcap.h | 1 - test/ftermcapquirks-test.cpp | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index a29ad82c..c632d702 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -64,7 +64,6 @@ // FTermcap string macro -//#define TCAP(...) tcap_strings[__VA_ARGS__].string #define TCAP(...) FTermcap::strings[__VA_ARGS__].string namespace finalcut diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index de0a7dfb..614439ff 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.cpp @@ -227,7 +227,7 @@ void FTermcapQuirksTest::classNameTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::generalTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -290,7 +290,7 @@ void FTermcapQuirksTest::generalTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::xtermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -321,7 +321,7 @@ void FTermcapQuirksTest::xtermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::freebsdTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -360,7 +360,7 @@ void FTermcapQuirksTest::freebsdTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::cygwinTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -385,7 +385,7 @@ void FTermcapQuirksTest::cygwinTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::linuxTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -457,7 +457,7 @@ void FTermcapQuirksTest::linuxTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::rxvtTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -498,7 +498,7 @@ void FTermcapQuirksTest::rxvtTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::vteTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -522,7 +522,7 @@ void FTermcapQuirksTest::vteTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::puttyTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -612,7 +612,7 @@ void FTermcapQuirksTest::puttyTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::teratermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -642,7 +642,7 @@ void FTermcapQuirksTest::teratermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::sunTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -760,7 +760,7 @@ void FTermcapQuirksTest::sunTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::screenTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings(); + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) From 622eb7089caed242b72a213382e729c1757541a5 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 27 May 2019 01:35:32 +0200 Subject: [PATCH 21/70] debug switch build fix --- src/ftermdebugdata.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ftermdebugdata.cpp b/src/ftermdebugdata.cpp index a8a60ac6..bd5424ee 100644 --- a/src/ftermdebugdata.cpp +++ b/src/ftermdebugdata.cpp @@ -27,7 +27,8 @@ namespace finalcut { - + +#if DEBUG // static class attributes FTermData* FTermDebugData::data = nullptr; FTermDetection* FTermDebugData::term_detection = nullptr; @@ -43,6 +44,7 @@ void FTermDebugData::init() data = FTerm::getFTermData(); term_detection = FTerm::getFTermDetection(); } +#endif // DEBUG } // namespace finalcut From c93c0b6e33ceeecfe31d769de4b52bf0d2ac6b06 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 27 May 2019 09:55:29 +0200 Subject: [PATCH 22/70] Further segfault bug fixes in FListView --- ChangeLog | 3 +++ src/flistview.cpp | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cc7db78..0348a3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * Use the Singleton design pattern to get a single object instance via FTerm +2019-05-26 Marek Habersack + * Fix a segfault when processing input to empty FListView + 2019-05-17 Markus Gans * Move system calls to the new class FSystem diff --git a/src/flistview.cpp b/src/flistview.cpp index 8b04996f..d2385af5 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -995,7 +995,7 @@ void FListView::onMouseDown (FMouseEvent* ev) } else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return; int indent = 0; @@ -1060,7 +1060,7 @@ void FListView::onMouseUp (FMouseEvent* ev) } else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List { - if (itemlist.empty ()) + if ( itemlist.empty() ) return; int indent = 0; @@ -1170,7 +1170,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev) if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) ) return; - if ( itemlist.empty () ) + if ( itemlist.empty() ) return; auto item = getCurrentItem(); @@ -2035,7 +2035,7 @@ void FListView::mouseHeaderClicked() //---------------------------------------------------------------------- void FListView::wheelUp (int pagesize) { - if ( current_iter.getPosition() == 0 ) + if ( itemlist.empty() || current_iter.getPosition() == 0 ) return; if ( first_visible_line.getPosition() >= pagesize ) @@ -2059,6 +2059,9 @@ void FListView::wheelUp (int pagesize) //---------------------------------------------------------------------- void FListView::wheelDown (int pagesize) { + if ( itemlist.empty() ) + return; + int element_count = int(getCount()); if ( current_iter.getPosition() + 1 == element_count ) @@ -2181,6 +2184,9 @@ FObject::FObjectIterator FListView::appendItem (FListViewItem* item) //---------------------------------------------------------------------- void FListView::processClick() { + if ( itemlist.empty() ) + return; + emitCallback("clicked"); } @@ -2193,7 +2199,7 @@ void FListView::processChanged() //---------------------------------------------------------------------- inline void FListView::keySpace() { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return; auto item = getCurrentItem(); @@ -2205,7 +2211,7 @@ inline void FListView::keySpace() //---------------------------------------------------------------------- inline void FListView::keyLeft (int& first_line_position_before) { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return; int position_before = current_iter.getPosition(); @@ -2262,7 +2268,7 @@ inline void FListView::keyLeft (int& first_line_position_before) //---------------------------------------------------------------------- inline void FListView::keyRight (int& first_line_position_before) { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return; int xoffset_end = int(max_line_width) - int(getClientWidth()); @@ -2290,6 +2296,9 @@ inline void FListView::keyRight (int& first_line_position_before) //---------------------------------------------------------------------- inline void FListView::keyHome() { + if ( itemlist.empty() ) + return; + current_iter -= current_iter.getPosition(); int difference = first_visible_line.getPosition(); first_visible_line -= difference; @@ -2299,6 +2308,9 @@ inline void FListView::keyHome() //---------------------------------------------------------------------- inline void FListView::keyEnd() { + if ( itemlist.empty() ) + return; + int element_count = int(getCount()); current_iter += element_count - current_iter.getPosition() - 1; int difference = element_count - last_visible_line.getPosition() - 1; @@ -2309,7 +2321,7 @@ inline void FListView::keyEnd() //---------------------------------------------------------------------- inline bool FListView::keyPlus() { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return false; auto item = getCurrentItem(); @@ -2327,7 +2339,7 @@ inline bool FListView::keyPlus() //---------------------------------------------------------------------- inline bool FListView::keyMinus() { - if ( itemlist.empty () ) + if ( itemlist.empty() ) return false; auto item = getCurrentItem(); @@ -2352,6 +2364,9 @@ void FListView::setRelativePosition (int ry) //---------------------------------------------------------------------- void FListView::stepForward() { + if ( itemlist.empty() ) + return; + if ( current_iter == last_visible_line ) { ++last_visible_line; @@ -2371,6 +2386,9 @@ void FListView::stepForward() //---------------------------------------------------------------------- void FListView::stepBackward() { + if ( itemlist.empty() ) + return; + if ( current_iter == first_visible_line && current_iter != itemlist.begin() ) { @@ -2385,6 +2403,9 @@ void FListView::stepBackward() //---------------------------------------------------------------------- void FListView::stepForward (int distance) { + if ( itemlist.empty() ) + return; + int element_count = int(getCount()); if ( current_iter.getPosition() + 1 == element_count ) @@ -2418,7 +2439,7 @@ void FListView::stepForward (int distance) //---------------------------------------------------------------------- void FListView::stepBackward (int distance) { - if ( current_iter.getPosition() == 0 ) + if ( itemlist.empty() || current_iter.getPosition() == 0 ) return; if ( current_iter.getPosition() - distance >= 0 ) From 7c46d52ef42fc9dbc6d6e65ed6810afed240c465 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 2 Jun 2019 19:11:17 +0200 Subject: [PATCH 23/70] Avoid drawing the scroll bars if the widget is non-visible --- ChangeLog | 7 +++++-- src/flistbox.cpp | 41 +++++++++++++++++++++++++---------------- src/flistview.cpp | 41 +++++++++++++++++++++++++---------------- src/fscrollview.cpp | 6 ++++++ src/ftermdebugdata.cpp | 2 +- src/ftermlinux.cpp | 4 +++- 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0348a3bd..6f17285e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-06-02 Markus Gans + * Avoid drawing the scroll bars if the widget is non-visible + 2019-05-27 Markus Gans * Use the Singleton design pattern to get a single object instance via FTerm @@ -120,7 +123,7 @@ the switch statement with a vector of lambda expressions 2018-12-09 Markus Gans - * Better handling of the scrollbar maximum + * Better handling of the scroll bar maximum * Deactivate copy constructor and assignment operator with "= delete" * Use nullptr instead of 0 to initialize a pointer values @@ -136,7 +139,7 @@ * Fix compile in optimization level 2 for newer gcc 2018-11-27 Markus Gans - * Correct vertical scrollbar position after sorting in FListView + * Correct vertical scroll bar position after sorting in FListView 2018-11-25 Markus Gans * Version 0.5.0 diff --git a/src/flistbox.cpp b/src/flistbox.cpp index ef8438ad..3589f6e4 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -737,15 +737,18 @@ void FListBox::adjustSize() hbar->setWidth (width + nf_offset, false); hbar->resize(); - if ( isHorizontallyScrollable() ) - hbar->show(); - else - hbar->hide(); + if ( isShown() ) + { + if ( isHorizontallyScrollable() ) + hbar->show(); + else + hbar->hide(); - if ( isVerticallyScrollable() ) - vbar->show(); - else - vbar->hide(); + if ( isVerticallyScrollable() ) + vbar->show(); + else + vbar->hide(); + } } @@ -1180,10 +1183,13 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets) hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4)); hbar->calculateSliderValues(); - if ( isHorizontallyScrollable() ) - hbar->show(); - else - hbar->hide(); + if ( isShown() ) + { + if ( isHorizontallyScrollable() ) + hbar->show(); + else + hbar->hide(); + } } } @@ -1197,10 +1203,13 @@ void FListBox::recalculateVerticalBar (std::size_t element_count) vbar->setPageSize (int(element_count), int(getHeight()) - 2); vbar->calculateSliderValues(); - if ( isVerticallyScrollable() ) - vbar->show(); - else - vbar->hide(); + if ( isShown() ) + { + if ( isVerticallyScrollable() ) + vbar->show(); + else + vbar->hide(); + } } //---------------------------------------------------------------------- diff --git a/src/flistview.cpp b/src/flistview.cpp index d2385af5..09a6b7dc 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1361,15 +1361,18 @@ void FListView::adjustSize() hbar->setWidth (width, false); hbar->resize(); - if ( isHorizontallyScrollable() ) - hbar->show(); - else - hbar->hide(); + if ( isShown() ) + { + if ( isHorizontallyScrollable() ) + hbar->show(); + else + hbar->hide(); - if ( isVerticallyScrollable() ) - vbar->show(); - else - vbar->hide(); + if ( isVerticallyScrollable() ) + vbar->show(); + else + vbar->hide(); + } } @@ -1966,10 +1969,13 @@ void FListView::recalculateHorizontalBar (std::size_t len) hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset) - 4); hbar->calculateSliderValues(); - if ( isHorizontallyScrollable() ) - hbar->show(); - else - hbar->hide(); + if ( isShown() ) + { + if ( isHorizontallyScrollable() ) + hbar->show(); + else + hbar->hide(); + } } } @@ -1983,10 +1989,13 @@ void FListView::recalculateVerticalBar (std::size_t element_count) vbar->setPageSize (int(element_count), int(getHeight()) - 2); vbar->calculateSliderValues(); - if ( isVerticallyScrollable() ) - vbar->show(); - else - vbar->hide(); + if ( isShown() ) + { + if ( isVerticallyScrollable() ) + vbar->show(); + else + vbar->hide(); + } } //---------------------------------------------------------------------- diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index d7633d48..5d080512 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -814,6 +814,9 @@ void FScrollView::calculateScrollbarPos() //---------------------------------------------------------------------- void FScrollView::setHorizontalScrollBarVisibility() { + if ( ! isShown() ) + return; + switch ( hMode ) { case fc::Auto: @@ -836,6 +839,9 @@ void FScrollView::setHorizontalScrollBarVisibility() //---------------------------------------------------------------------- void FScrollView::setVerticalScrollBarVisibility() { + if ( ! isShown() ) + return; + switch ( vMode ) { case fc::Auto: diff --git a/src/ftermdebugdata.cpp b/src/ftermdebugdata.cpp index bd5424ee..44014157 100644 --- a/src/ftermdebugdata.cpp +++ b/src/ftermdebugdata.cpp @@ -27,7 +27,7 @@ namespace finalcut { - + #if DEBUG // static class attributes FTermData* FTermDebugData::data = nullptr; diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index fce78caa..134691ad 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -1237,13 +1237,15 @@ inline void FTermLinux::initSpecialCharacter() //---------------------------------------------------------------------- sInt16 FTermLinux::getFontPos (wchar_t ucs) { + constexpr sInt16 NOT_FOUND = -1; + for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++) { if ( screen_unicode_map.entries[n].unicode == ucs ) return sInt16(screen_unicode_map.entries[n].fontpos); } - return -1; + return NOT_FOUND; } //---------------------------------------------------------------------- From b9ef1200e8af71bbce16ef083011da22c0eeb6a8 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 2 Jun 2019 19:14:06 +0200 Subject: [PATCH 24/70] Avoid drawing the scroll bars if the widget is non-visible --- src/ftextview.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 97259c57..017b52dd 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -556,15 +556,18 @@ void FTextView::adjustSize() hbar->setValue (xoffset); hbar->resize(); - if ( last_line < int(height) + nf_offset - 1 ) - vbar->hide(); - else - vbar->show(); + if ( isShown() ) + { + if ( last_line < int(height) + nf_offset - 1 ) + vbar->hide(); + else + vbar->show(); - if ( max_width < int(width) - nf_offset - 1 ) - hbar->hide(); - else - hbar->show(); + if ( max_width < int(width) - nf_offset - 1 ) + hbar->hide(); + else + hbar->show(); + } } From 52c5b412f77cb2b6dc959f623e765a519f22ae25 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 12 Jun 2019 11:37:34 +0200 Subject: [PATCH 25/70] Fixes problem with scroll bar view after first draw --- ChangeLog | 3 ++ examples/7segment.cpp | 17 ++++++----- src/flistbox.cpp | 12 ++++++-- src/flistview.cpp | 12 ++++++-- src/fscrollview.cpp | 45 ++++++++++++++++++++---------- src/fterm.cpp | 10 +++++-- src/ftermfreebsd.cpp | 10 +++---- src/ftermios.cpp | 5 +++- src/ftermlinux.cpp | 32 ++++++++++----------- src/ftermopenbsd.cpp | 6 ++-- src/fvterm.cpp | 2 +- src/include/final/fmouse.h | 1 - src/include/final/fsystem.h | 2 +- src/include/final/fsystemimpl.h | 2 +- src/include/final/ftermdetection.h | 12 ++++---- 15 files changed, 108 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f17285e..7cd585aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-06-12 Markus Gans + * Fixes problem with scroll bar view after first draw + 2019-06-02 Markus Gans * Avoid drawing the scroll bars if the widget is non-visible diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 05353812..904b2508 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -110,10 +110,6 @@ void SegmentView::hexEncoding() //---------------------------------------------------------------------- void SegmentView::get7Segment (const wchar_t c) { - sevenSegment& s = code[c]; - constexpr char h[2]{' ', '_'}; - constexpr char v[2]{' ', '|'}; - for (int i = 0; i < 3; i++) line[i].clear(); @@ -157,9 +153,16 @@ void SegmentView::get7Segment (const wchar_t c) default: // Hexadecimal digit from 0 up to f - line[0] << ' ' << h[s.a] << ' '; - line[1] << v[s.f] << h[s.g] << v[s.b]; - line[2] << v[s.e] << h[s.d] << v[s.c]; + if ( code.find(c) != code.end() ) + { + sevenSegment& s = code[c]; + constexpr char h[2]{' ', '_'}; + constexpr char v[2]{' ', '|'}; + + line[0] << ' ' << h[s.a] << ' '; + line[1] << v[s.f] << h[s.g] << v[s.b]; + line[2] << v[s.e] << h[s.d] << v[s.c]; + } } } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 3589f6e4..7343d05f 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -832,8 +832,16 @@ void FListBox::draw() if ( isMonochron() ) setReverse(false); - vbar->redraw(); - hbar->redraw(); + if ( ! hbar->isShown() && isHorizontallyScrollable() ) + hbar->show(); + else + vbar->redraw(); + + if ( ! vbar->isShown() && isVerticallyScrollable() ) + vbar->show(); + else + hbar->redraw(); + drawList(); if ( flags.focus && getStatusBar() ) diff --git a/src/flistview.cpp b/src/flistview.cpp index 09a6b7dc..cc09e0a8 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1491,8 +1491,16 @@ void FListView::draw() if ( isMonochron() ) setReverse(false); - vbar->redraw(); - hbar->redraw(); + if ( ! hbar->isShown() && isHorizontallyScrollable() ) + hbar->show(); + else + vbar->redraw(); + + if ( ! vbar->isShown() && isVerticallyScrollable() ) + vbar->show(); + else + hbar->redraw(); + drawList(); if ( flags.focus && getStatusBar() ) diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 5d080512..66c65ede 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -75,7 +75,9 @@ void FScrollView::setScrollWidth (std::size_t width) hbar->setMaximum (int(width - getViewportWidth())); hbar->setPageSize (int(width), int(getViewportWidth())); hbar->calculateSliderValues(); - setHorizontalScrollBarVisibility(); + + if ( isShown() ) + setHorizontalScrollBarVisibility(); } //---------------------------------------------------------------------- @@ -102,7 +104,9 @@ void FScrollView::setScrollHeight (std::size_t height) vbar->setMaximum (int(height - getViewportHeight())); vbar->setPageSize (int(height), int(getViewportHeight())); vbar->calculateSliderValues(); - setVerticalScrollBarVisibility(); + + if ( isShown() ) + setVerticalScrollBarVisibility(); } //---------------------------------------------------------------------- @@ -143,12 +147,16 @@ void FScrollView::setScrollSize (const FSize& size) hbar->setMaximum (int(width - getViewportWidth())); hbar->setPageSize (int(width), int(getViewportWidth())); hbar->calculateSliderValues(); - setHorizontalScrollBarVisibility(); vbar->setMaximum (int(height - getViewportHeight())); vbar->setPageSize (int(height), int(getViewportHeight())); vbar->calculateSliderValues(); - setVerticalScrollBarVisibility(); + + if ( isShown() ) + { + setHorizontalScrollBarVisibility(); + setVerticalScrollBarVisibility(); + } } //---------------------------------------------------------------------- @@ -296,14 +304,18 @@ bool FScrollView::setBorder (bool enable) void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode) { hMode = mode; - setHorizontalScrollBarVisibility(); + + if ( isShown() ) + setHorizontalScrollBarVisibility(); } //---------------------------------------------------------------------- void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode) { vMode = mode; - setVerticalScrollBarVisibility(); + + if ( isShown() ) + setVerticalScrollBarVisibility(); } //---------------------------------------------------------------------- @@ -428,6 +440,13 @@ void FScrollView::draw() setViewportPrint(); copy2area(); + + if ( ! hbar->isShown() ) + setHorizontalScrollBarVisibility(); + + if ( ! vbar->isShown() ) + setVerticalScrollBarVisibility(); + vbar->redraw(); hbar->redraw(); } @@ -639,7 +658,6 @@ void FScrollView::adjustSize() hbar->setWidth (width - 2, false); hbar->setValue (xoffset); hbar->resize(); - setHorizontalScrollBarVisibility(); vbar->setMaximum (int(getScrollHeight() - getViewportHeight())); vbar->setPageSize (int(getScrollHeight()), int(getViewportHeight())); @@ -647,7 +665,12 @@ void FScrollView::adjustSize() vbar->setHeight (height - 2, false); vbar->setValue (yoffset); vbar->resize(); - setVerticalScrollBarVisibility(); + + if ( isShown() ) + { + setHorizontalScrollBarVisibility(); + setVerticalScrollBarVisibility(); + } } //---------------------------------------------------------------------- @@ -814,9 +837,6 @@ void FScrollView::calculateScrollbarPos() //---------------------------------------------------------------------- void FScrollView::setHorizontalScrollBarVisibility() { - if ( ! isShown() ) - return; - switch ( hMode ) { case fc::Auto: @@ -839,9 +859,6 @@ void FScrollView::setHorizontalScrollBarVisibility() //---------------------------------------------------------------------- void FScrollView::setVerticalScrollBarVisibility() { - if ( ! isShown() ) - return; - switch ( vMode ) { case fc::Auto: diff --git a/src/fterm.cpp b/src/fterm.cpp index 51911349..daebdc49 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -515,7 +515,7 @@ void FTerm::detectTermSize() auto& term_geometry = data->getTermGeometry(); if ( fsys ) - ret = fsys->ioControl (fd, TIOCGWINSZ, &win_size); + ret = fsys->ioctl (fd, TIOCGWINSZ, &win_size); else ret = -1; @@ -962,7 +962,7 @@ void FTerm::init_global_values (bool disable_alt_screen) // Preset to false data->setNewFont(false); - // Sets alternative screen usage + // Sets alternate screen usage data->useAlternateScreen(! disable_alt_screen); // Initialize xterm object @@ -1693,6 +1693,8 @@ inline void FTerm::disableApplicationEscKey() //---------------------------------------------------------------------- void FTerm::useAlternateScreenBuffer() { + // Switch to the alternate screen + if ( ! hasAlternateScreen() ) return; @@ -1714,6 +1716,8 @@ void FTerm::useAlternateScreenBuffer() //---------------------------------------------------------------------- void FTerm::useNormalScreenBuffer() { + // Switch to the normal screen + if ( ! hasAlternateScreen() ) return; @@ -1880,6 +1884,7 @@ void FTerm::init (bool disable_alt_screen) // Enter 'keyboard_transmit' mode enableKeypad(); + // Switch to the alternate screen useAlternateScreenBuffer(); // Enable alternate charset @@ -2032,6 +2037,7 @@ void FTerm::finish() if ( isXTerminal() ) xterm->metaSendsESC(false); + // Switch to the normal screen useNormalScreenBuffer(); // leave 'keyboard_transmit' mode diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index e2ef752e..50123e3c 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -61,7 +61,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) if ( hidden ) return; - fsysten->ioControl (0, CONS_CURSORTYPE, &style); + fsysten->ioctl (0, CONS_CURSORTYPE, &style); } //---------------------------------------------------------------------- @@ -71,7 +71,7 @@ bool FTermFreeBSD::isFreeBSDConsole() keymap_t keymap; - if ( fsysten && fsysten->ioControl(0, GIO_KEYMAP, &keymap) == 0 ) + if ( fsysten && fsysten->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) return true; else return false; @@ -149,7 +149,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey() keymap_t keymap; if ( fsystem ) - ret = fsysten->ioControl (0, GIO_KEYMAP, &keymap); + ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -169,7 +169,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) keymap_t keymap; if ( fsystem ) - ret = fsysten->ioControl (0, GIO_KEYMAP, &keymap); + ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -178,7 +178,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) keymap.key[left_alt].map[0] = key; if ( (keymap.n_keys > 0) - && fsystem && (fsysten->ioControl(0, PIO_KEYMAP, &keymap) < 0) ) + && fsystem && (fsysten->ioctl(0, PIO_KEYMAP, &keymap) < 0) ) return false; else return true; diff --git a/src/ftermios.cpp b/src/ftermios.cpp index cb18c3f1..d11f0633 100644 --- a/src/ftermios.cpp +++ b/src/ftermios.cpp @@ -230,7 +230,10 @@ uInt FTermios::getBaudRate() outspeed[B115200] = 115200; // 115,200 baud outspeed[B230400] = 230400; // 230,400 baud - return outspeed[cfgetospeed(&term_init)]; + if ( outspeed.find(cfgetospeed(&term_init)) != outspeed.end() ) + return outspeed[cfgetospeed(&term_init)]; + + return 0; } } // namespace finalcut diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 134691ad..0fff2872 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -144,7 +144,7 @@ bool FTermLinux::isLinuxConsole() // get keyboard type an compare return ( fsystem->isTTY(fd_tty) - && fsystem->ioControl(fd_tty, KDGKBTYPE, &arg) == 0 + && fsystem->ioctl(fd_tty, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84)) ); } @@ -496,8 +496,8 @@ int FTermLinux::getFramebuffer_bpp() return -1; } - if ( ! fsystem->ioControl(fd, FBIOGET_VSCREENINFO, &fb_var) - && ! fsystem->ioControl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) + if ( ! fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) + && ! fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) { fsystem->close(fd); return int(fb_var.bits_per_pixel); @@ -543,7 +543,7 @@ bool FTermLinux::getScreenFont() // font operation if ( fsystem ) - ret = fsystem->ioControl (fd_tty, KDFONTOP, &font); + ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); if ( ret == 0 ) { @@ -571,7 +571,7 @@ bool FTermLinux::getUnicodeMap() // get count if ( fsystem ) - ret = fsystem->ioControl (fd_tty, GIO_UNIMAP, &screen_unicode_map); + ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); if ( ret != 0 ) { @@ -592,7 +592,7 @@ bool FTermLinux::getUnicodeMap() // get unicode-to-font mapping from kernel if ( fsystem ) - ret = fsystem->ioControl (fd_tty, GIO_UNIMAP, &screen_unicode_map); + ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); if ( ret != 0 ) return false; @@ -612,7 +612,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey() std::memset (&mod_key, 0x00, sizeof(mod_key)); // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) - if ( fsystem && fsystem->ioControl(0, TIOCLINUX, &subcode) >= 0 ) + if ( fsystem && fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 ) { if ( subcode & (1 << KG_SHIFT) ) mod_key.shift = true; @@ -676,7 +676,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count // font operation if ( fsystem ) - ret = fsystem->ioControl (fd_tty, KDFONTOP, &font); + ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); if ( ret != 0 && errno != ENOSYS && errno != EINVAL ) { @@ -713,14 +713,14 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) { // clear the unicode-to-font table if ( fsystem ) - ret = fsystem->ioControl (fd_tty, PIO_UNIMAPCLR, &advice); + ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice); if ( ret != 0 ) return -1; // put the new unicode-to-font mapping in kernel if ( fsystem ) - ret = fsystem->ioControl (fd_tty, PIO_UNIMAP, unimap); + ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap); if ( ret != 0 ) advice.advised_hashlevel++; @@ -840,7 +840,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) return -1; // Enable access to VGA I/O ports (from 0x3B4 with num = 0x2C) - if ( fsystem->ioControl(fd_tty, KDENABIO, 0) < 0 ) + if ( fsystem->ioctl(fd_tty, KDENABIO, 0) < 0 ) return -1; // error on KDENABIO if ( enable ) @@ -849,7 +849,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) setAttributeMode (getAttributeMode() | 0x08); // set bit 3 // Disable access to VGA I/O ports - if ( fsystem->ioControl(fd_tty, KDDISABIO, 0) < 0 ) + if ( fsystem->ioctl(fd_tty, KDDISABIO, 0) < 0 ) return -1; // error on KDDISABIO return 0; @@ -869,7 +869,7 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b) cmap.color[index].blue = uChar(b); } - if ( fsystem && fsystem->ioControl (0, PIO_CMAP, &cmap) ) + if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &cmap) ) return false; else return true; @@ -880,7 +880,7 @@ bool FTermLinux::saveVGAPalette() { // Save the current vga color map - if ( fsystem && fsystem->ioControl (0, GIO_CMAP, &saved_color_map) ) + if ( fsystem && fsystem->ioctl (0, GIO_CMAP, &saved_color_map) ) has_saved_palette = false; else has_saved_palette = true; @@ -898,7 +898,7 @@ bool FTermLinux::resetVGAPalette() if ( has_saved_palette ) { - if ( fsystem->ioControl (0, PIO_CMAP, &saved_color_map) ) + if ( fsystem->ioctl (0, PIO_CMAP, &saved_color_map) ) return false; } else @@ -922,7 +922,7 @@ bool FTermLinux::resetVGAPalette() cmap.color[index].blue = defaultColor[index].blue; } - if ( fsystem->ioControl (0, PIO_CMAP, &cmap) ) + if ( fsystem->ioctl (0, PIO_CMAP, &cmap) ) return false; } diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index aa0c90ef..792680c1 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -47,7 +47,7 @@ bool FTermOpenBSD::isBSDConsole() static kbd_t kbdencoding; if ( fsystem - && fsysten->ioControl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) + && fsysten->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) return true; else return false; @@ -92,7 +92,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding() int ret = -1; if ( fsystem ) - ret = fsysten->ioControl (0, WSKBDIO_GETENCODING, &k_encoding); + ret = fsysten->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); if ( ret < 0 ) return false; @@ -106,7 +106,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding() bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) { if ( fsysten - && fsysten->ioControl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) + && fsysten->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) return false; else return true; diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 663f91b8..ce2e51bb 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2797,7 +2797,7 @@ inline void FVTerm::characterFilter (charData*& next_char) { FTerm::characterSub& sub_map = fterm->getCharSubstitutionMap(); - if ( sub_map[next_char->encoded_code] ) + if ( sub_map.find(next_char->encoded_code) != sub_map.end() ) next_char->encoded_code = sub_map[next_char->encoded_code]; } diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index fd22986f..d3d2ddf6 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -511,7 +511,6 @@ class FMouseControl // Data Member std::map mouse_protocol{}; - std::map::iterator iter{}; FPoint zero_point{0, 0}; bool use_gpm_mouse{false}; bool use_xterm_mouse{false}; diff --git a/src/include/final/fsystem.h b/src/include/final/fsystem.h index f351fce3..2e2e80df 100644 --- a/src/include/final/fsystem.h +++ b/src/include/final/fsystem.h @@ -60,7 +60,7 @@ class FSystem virtual uChar inPortByte (uShort) = 0; virtual void outPortByte (uChar, uShort) = 0; virtual int isTTY (int) = 0; - virtual int ioControl (int, uLong, ...) = 0; + virtual int ioctl (int, uLong, ...) = 0; virtual int open (const char*, int, ...) = 0; virtual int close (int) = 0; virtual FILE* fopen (const char*, const char*) = 0; diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index 4c30b7df..cadab4b6 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -99,7 +99,7 @@ class FSystemImpl : public FSystem return ::isatty(fd); } - virtual int ioControl (int fd, uLong request, ...) + virtual int ioctl (int fd, uLong request, ...) { va_list args; va_start (args, request); diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 6da6905a..d071ea30 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -159,13 +159,6 @@ class FTermDetection final // Methods static void detect(); - // Data Members -#if DEBUG - static char termtype_256color[256]; - static char termtype_Answerback[256]; - static char termtype_SecDA[256]; -#endif - private: // Methods static void deallocation(); @@ -201,6 +194,11 @@ class FTermDetection final static char* secDA_Analysis_vte (char[]); // Data Members +#if DEBUG + static char termtype_256color[256]; + static char termtype_Answerback[256]; + static char termtype_SecDA[256]; +#endif static char termtype[256]; static char ttytypename[256]; static bool decscusr_support; From 4cd92ea36e259e30a65c9236e918eb00cdedffd3 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 19 Jun 2019 16:28:55 +0200 Subject: [PATCH 26/70] Add a unit test for FTermLinux with a Linux console emulation and a dedicated FSystem test instance --- ChangeLog | 4 + doc/vga.txt | 516 +++++++++++ src/fterm.cpp | 8 - src/ftermlinux.cpp | 18 +- src/include/final/ftermlinux.h | 12 - test/Makefile.am | 3 + test/conemu.h | 1103 +++++++++++++++++++++++ test/fmouse-test.cpp | 14 +- test/fobject-test.cpp | 20 +- test/ftermdetection-test.cpp | 1263 +++----------------------- test/ftermlinux-test.cpp | 1525 ++++++++++++++++++++++++++++++++ 11 files changed, 3314 insertions(+), 1172 deletions(-) create mode 100644 doc/vga.txt create mode 100644 test/conemu.h create mode 100644 test/ftermlinux-test.cpp diff --git a/ChangeLog b/ChangeLog index 7cd585aa..4272404b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-06-19 Markus Gans + * Add a unit test for FTermLinux with a Linux console emulation + and a dedicated FSystem test instance + 2019-06-12 Markus Gans * Fixes problem with scroll bar view after first draw diff --git a/doc/vga.txt b/doc/vga.txt new file mode 100644 index 00000000..a1ae9e9a --- /dev/null +++ b/doc/vga.txt @@ -0,0 +1,516 @@ +3C0h: Attribute Controller: Address register +bit 0-4 Address of data register to write to port 3C0h or read from port 3C1h + (Reads only on VGA). + 5 If set screen output is enabled and the palette can not be modified, + if clear screen output is disabled and the palette can be modified. + + +Port 3C0h is special in that it is both address and data-write register. +Data reads happen from port 3C1h. An internal flip-flop remembers whether it +is currently acting as address or data register. +Accesses to the attribute controller must be separated by at least 250ns. +Reading port 3dAh will reset the flip-flop to address mode. + + +3C0h index 0-Fh (r/W): Attribute: Palette +bit 0 (EGA) Primary Blue + 1 (EGA) Primary Green + 2 (EGA) Primary Red + 3 (EGA) Secondary Blue + 4 (EGA) Secondary Green + 5 (EGA) Secondary Red + 0-5 (VGA) Index into the 256 color DAC table. + May be modified by 3C0h index 10h and 14h. + +3C0h index 10h (r/W): Attribute: Mode Control Register +bit 0 Graphics mode if set, Alphanumeric mode else. + 1 Monochrome mode if set, color mode else. + 2 9-bit wide characters if set. + The 9th bit of characters C0h-DFh will be the same as + the 8th bit. Otherwise it will be the background color. + 3 If set Attribute bit 7 is blinking, else high intensity. + 5 (VGA Only) If set the PEL panning register (3C0h index 13h) is + temporarily set to 0 from when the line compare causes a wrap around + until the next vertical retrace when the register is automatically + reloaded with the old value, else the PEL panning register ignores + line compares. + 6 (VGA Only) If set pixels are 8 bits wide. Used in 256 color modes. + 7 (VGA Only) If set bit 4-5 of the index into the DAC table are taken + from port 3C0h index 14h bit 0-1, else the bits in the palette + register are used. + +3C0h index 11h (r/W): Attribute: Overscan Color Register. +bit 0-5 Color of screen border. Color is defined as in the palette registers. +Note: The EGA requires the Overscan color to be 0 in high resolution modes. + +3C0h index 12h (r/W): Attribute: Color Plane Enable Register +bit 0 Bit plane 0 is enabled if set. + 1 Bit plane 1 is enabled if set. + 2 Bit plane 2 is enabled if set. + 3 Bit plane 3 is enabled if set. + 4-5 Video Status MUX. Diagnostics use only. + Two attribute bits appear on bits 4 and 5 of the Input + Status Register 1 (3dAh). + Value EGA VGA + 0 Red/Blue Bit 2/Bit 0 + 1 Blue'/Green Bit 5/Bit 4 + 2 Red'/Green' Bit 3/Bit 1 + 3 Bit 7/Bit 6 + +3C0h index 13h (r/W): Attribute: Horizontal PEL Panning Register +bit 0-3 Indicates number of pixels to shift the display left + Value 9bit textmode 256color mode Other modes + 0 1 0 0 + 1 2 n/a 1 + 2 3 1 2 + 3 4 n/a 3 + 4 5 2 4 + 5 6 n/a 5 + 6 7 3 6 + 7 8 n/a 7 + 8 0 n/a n/a + +3C0h index 14h (r/W): Attribute: Color Select Register (VGA Only) +bit 0-1 If 3C0h index 10h bit 7 is set these 2 bits are used as bits 4-5 of + the index into the DAC table. + 2-3 These 2 bits are used as bit 6-7 of the index into the DAC table + except in 256 color mode. +Note: this register does not affect 256 color modes. + +3C2h (R): Input Status #0 Register +bit 4 Status of the switch selected by the Miscellaneous Output + Register 3C2h bit 2-3. Switch high if set. + 5 (EGA Only) Pin 19 of the Feature Connector (FEAT0) is high if set + 6 (EGA Only) Pin 17 of the Feature Connector (FEAT1) is high if set + 7 (EGA Only ??) If set IRQ 2 has happened due to Vertical Retrace. + Should be cleared by IRQ 2 interrupt routine by clearing port 3d4h + index 11h bit 4. + +3C2h (W): Miscellaneous Output Register +bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base + Address=3Bxh. + 1 Enable CPU Access to video memory if set + 2-3 Clock Select + 0: 14MHz(EGA) 25MHz(VGA) + 1: 16MHz(EGA) 28MHz(VGA) + 2: External(EGA) Reserved(VGA) + 4 (EGA Only) Disable internal video drivers if set + 5 When in Odd/Even modes Select High 64k bank if set + 6 Horizontal Sync Polarity. Negative if set + 7 Vertical Sync Polarity. Negative if set + Bit 6-7 indicates the number of lines on the display: + 0=200(EGA) Reserved(VGA) + 1= 400(VGA) + 2=350(EGA) 350(VGA) + 3= 480(VGA). +Note: Set to all zero on a hardware reset. +Note: On the VGA this register can be read from port 3CCh. + +3C3h (W): Video Subsystem Enable Register +bit 0 Enables the VGA display if set + +3C4h index 0 (r/W): Sequencer: Reset +bit 0 (EGA) Asynchronous Reset if clear + 0 (VGA) Synchronous Reset just as bit 1 + 1 Synchronous Reset if clear + +3C4h index 1 (r/W): Sequencer: Clocking Mode +bit 0 If set character clocks are 8 dots wide, else 9. + 1 (EGA Only) If set the CRTC uses 2/5 of the clock cycles, else 4/5. + 2 If set loads video serializers every other character + clock cycle, else every one. + 3 If set the Dot Clock is Master Clock/2, else same as + Master Clock (See 3C2h bit 2-3). (Doubles pixels). + 4 (VGA Only) If set loads video serializers every fourth character + clock cycle, else every one. + 5 (VGA Only) if set turns off screen and gives all memory cycles to the + CPU interface. + +3C4h index 2 (r/W): Sequencer: Map Mask Register +bit 0 Enable writes to plane 0 if set + 1 Enable writes to plane 1 if set + 2 Enable writes to plane 2 if set + 3 Enable writes to plane 3 if set + +3C4h index 3 (r/W): Sequencer: Character Map Select Register +bit 0-1 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character + attribute is clear. + 2-3 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character + attribute is set. + 0,1,4 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character + attribute is clear. + 2,3,5 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character + attribute is set. +Note: Character Maps are placed at: + Map no. (EGA/VGA) Map no. (VGA) + 0 0k 4 8k + 1 16k 5 24k + 2 32k 6 40k + 3 48k 7 56k + +3C4h index 4 (r/W): Sequencer: Memory Mode Register +bit 0 Set if in an alphanumeric mode, clear in graphics modes. + 1 Set if more than 64kbytes on the adapter. + 2 Enables Odd/Even addressing mode if set. Odd/Even mode places all odd + bytes in plane 1&3, and all even bytes in plane 0&2. + 3 (VGA Only) If set address bit 0-1 selects video memory planes + (256 color mode), rather than the Map Mask and Read Map Select + Registers. + +3C4h index 7 (R/W): Sequencer Horizontal Character Counter Reset Register. + (VGA Only) +Note: Undocumented by IBM. May not be available in all clones. + A write to this register will cause the Horizontal Character Counter + to be held reset (=0) until a write happens to any of the Sequencer + registers index 0..6. + The Vertical Line counter is clocked by a signal derived from the + Horizontal Display Enable (which does not occur if the Horizontal + Character Counter is held reset). + Thus a write to index 7 during Vertical Retrace can stop the display + timing and allow software to start the next frame reasonably + synchronous to an external event. + +3C6h (R/W): PEL Mask (VGA Only) +bit 0-7 This register is anded with the palette index sent for each dot. + Should be set to FFh. + +3C7h (R): DAC State Register (VGA Only) +bit 0-1 0 indicates the DAC is in Read Mode and 3 indicates write mode. + +3C7h (W): PEL Address Read Mode (VGA Only) +bit 0-7 The PEL data register (0..255) to be read from 3C9h. +Note: After reading the 3 bytes at 3C9h this register will increment, + pointing to the next data register. + +3C8h (R/W): PEL Address Write Mode (VGA Only) +bit 0-7 The PEL data register (0..255) to be written to 3C9h. +Note: After writing the 3 bytes at 3C9h this register will increment, pointing + to the next data register. + +3C9h (R/W): PEL Data Register (VGA Only) +bit 0-5 Color value +Note: Each read or write of this register will cycle through first the + registers for Red, Blue and Green, then increment the appropriate + address register, thus the entire palette can be loaded by writing 0 to + the PEL Address Write Mode register 3C8h and then writing all 768 bytes + of the palette to this register. + +3CAh (R): Feature Control Register (VGA Only) +Bit 3 Vertical Sync Select. If set Vertical Sync to the monitor is the + logical OR of the vertical sync and the vertical display enable. +Note: This register is written to port 3dAh and read from 3CAh. + +3CAh (W): Graphics 2 Position (EGA Only) +bit 0-1 Select which bit planes should be controlled by Graphics Controller + #2. Always set to 1. + +3CCh (R): Miscellaneous Output Register (VGA Only) +bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base + Address=3Bxh. + 1 Enable CPU Access to video memory if set + 2-3 Clock Select. 0= 25MHz, 1= 28MHz, 2= Reserved + 5 When in Odd/Even modes Select High 64k bank if set + 6 Horizontal Sync Polarity. Negative if set + 7 Vertical Sync Polarity. Negative if set + Bit 6-7 indicates the number of lines on the display: + 0=Reserved, 1=400, 2=350, 3=480. +Note: This register is written to port 3C2h and read from port 3CCh. + +3CCh (W): Graphics 1 Position (EGA Only) +bit 0-1 Select which bit planes should be controlled by Graphics Controller + #1. Always set to 0. + +3CEh index 0 (r/W): Graphics: Set/Reset Register +bit 0 If in Write Mode 0 and bit 0 of 3CEh index 1 is set a write to + display memory will set all the bits in plane 0 of the byte to this + bit, if the corresponding bit is set in the Map Mask Register (3CEh + index 8). + 1 Same for plane 1 and bit 1 of 3CEh index 1. + 2 Same for plane 2 and bit 2 of 3CEh index 1. + 3 Same for plane 3 and bit 3 of 3CEh index 1. + +3CEh index 1 (r/W): Graphics: Enable Set/Reset Register +bit 0 If set enables Set/reset of plane 0 in Write Mode 0. + 1 Same for plane 1. + 2 Same for plane 2. + 3 Same for plane 3. + +3CEh index 2 (r/W): Graphics: Color Compare Register +bit 0-3 In Read Mode 1 each pixel at the address of the byte read is compared + to this color and the corresponding bit in the output set to 1 if + they match, 0 if not. The Color Don't Care Register (3CEh index 7) + can exclude bitplanes from the comparison. + +3CEh index 3 (r/W): Graphics: Data Rotate +bit 0-2 Number of positions to rotate data right before it is written to + display memory. Only active in Write Mode 0. + 3-4 In Write Mode 2 this field controls the relation between the data + written from the CPU, the data latched from the previous read and the + data written to display memory: + 0: CPU Data is written unmodified + 1: CPU data is ANDed with the latched data + 2: CPU data is ORed with the latch data. + 3: CPU data is XORed with the latched data. + +3CEh index 4 (r/W): Graphics: Read Map Select Register +bit 0-1 Number of the plane Read Mode 0 will read from. + +3CEh index 5 (r/W): Graphics: Mode Register +bit 0-1 Write Mode: Controls how data from the CPU is transformed before + being written to display memory: + 0: Mode 0 works as a Read-Modify-Write operation. + First a read access loads the data latches of the EGA/VGA with + the value in video memory at the addressed location. Then a + write access will provide the destination address and the CPU + data byte. The data written is modified by the function code in + the Data Rotate register (3CEh index 3) as a function of the CPU + data and the latches, then data is rotated as specified by the + same register. + 1: Mode 1 is used for video to video transfers. + A read access will load the data latches with the contents of + the addressed byte of video memory. A write access will write + the contents of the latches to the addressed byte. Thus a single + MOVSB instruction can copy all pixels in the source address byte + to the destination address. + 2: Mode 2 writes a color to all pixels in the addressed byte of + video memory. Bit 0 of the CPU data is written to plane 0 et + cetera. Individual bits can be enabled or disabled through the + Bit Mask register (3CEh index 8). + 3: (VGA Only) Mode 3 can be used to fill an area with a color and + pattern. The CPU data is rotated according to 3CEh index 3 bits + 0-2 and anded with the Bit Mask Register (3CEh index 8). For + each bit in the result the corresponding pixel is set to the + color in the Set/Reset Register (3CEh index 0 bits 0-3) if the + bit is set and to the contents of the processor latch if the bit + is clear. + 2 (EGA Only) Forces all outputs to a high impedance state if set. + 3 Read Mode + 0: Data is read from one of 4 bit planes depending on the Read Map + Select Register (3CEh index 4). + 1: Data returned is a comparison between the 8 pixels occupying the + read byte and the color in the Color Compare Register (3CEh + index 2). A bit is set if the color of the corresponding pixel + matches the register. + 4 Enables Odd/Even mode if set (See 3C4h index 4 bit 2). + 5 Enables CGA style 4 color pixels using even/odd bit pairs if set. + 6 (VGA Only) Enables 256 color mode if set. + +3CEh index 6 (r/W): Graphics: Miscellaneous Register +bit 0 Indicates Graphics Mode if set, Alphanumeric mode else. + 1 Enables Odd/Even mode if set. + 2-3 Memory Mapping: + 0: use A000h-BFFFh + 1: use A000h-AFFFh EGA/VGA Graphics modes + 2: use B000h-B7FFh Monochrome modes + 3: use B800h-BFFFh CGA modes + +3CEh index 7 (r/W): Graphics: Color Don't Care Register +bit 0 Ignore bit plane 0 in Read mode 1 if clear. + 1 Ignore bit plane 1 in Read mode 1 if clear. + 2 Ignore bit plane 2 in Read mode 1 if clear. + 3 Ignore bit plane 3 in Read mode 1 if clear. + +3CEh index 8 (r/W): Graphics: Bit Mask Register +bit 0-7 Each bit if set enables writing to the corresponding bit of a byte in + display memory. + +3d4h index 0 (r/W): CRTC: Horizontal Total Register +bit 0-7 (EGA) Horizontal Total Character Clocks-2 + 0-7 (VGA) Horizontal Total Character Clocks-5 + +3d4h index 1 (r/W): CRTC: Horizontal Display End Register +bit 0-7 Number of Character Clocks Displayed -1 + +3d4h index 2 (r/W): CRTC: Start Horizontal Blanking Register +bit 0-7 The count at which Horizontal Blanking starts + +3d4h index 3 (r/W): CRTC: End Horizontal Blanking Register +bit 0-4 Horizontal Blanking ends when the last 5 (6 for VGA) bits of the + character counter equals this field. + (VGA) The sixth bit is found in port 3d4h index 5 bit 7. + 5-6 Number of character clocks to delay start of display after Horizontal + Total has been reached. + 7 (VGA Only) Access to Vertical Retrace registers if set. If clear + reads to 3d4h index 10h and 11h access the Lightpen read back + registers ?? + +3d4h index 4 (r/W): CRTC: Start Horizontal Retrace Register +bit 0-7 Horizontal Retrace starts when the Character Counter reaches this + value. + +3d4h index 5 (r/W): CRTC: End Horizontal Retrace Register +bit 0-4 Horizontal Retrace ends when the last 5 bits of the character counter + equals this value. + 5-6 Number of character clocks to delay start of display after Horizontal + Retrace. + 7 (EGA) Provides Smooth Scrolling in Odd/Even mode. When set display + starts from an odd byte. + 7 (VGA) bit 5 of the End Horizontal Blanking count (See 3d4h index 3 + bit 0-4). + +3d4h index 6 (r/W): CRTC: Vertical Total Register +bit 0-7 Lower 8 bits of the Vertical Total. Bit 8 is found in 3d4h index 7 + bit 0. (VGA) Bit 9 is found in 3d4h index 7 bit 5. +Note: For the VGA this value is the number of scan lines in the display -2. + +3d4h index 7 (r/W): CRTC: Overflow Register +bit 0 Bit 8 of Vertical Total (3d4h index 6) + 1 Bit 8 of Vertical Display End (3d4h index 12h) + 2 Bit 8 of Vertical Retrace Start (3d4h index 10h) + 3 Bit 8 of Start Vertical Blanking (3d4h index 15h) + 4 Bit 8 of Line Compare Register (3d4h index 18h) + 5 (VGA) Bit 9 of Vertical Total (3d4h index 6) + 6 (VGA) Bit 9 of Vertical Display End (3d4h index 12h) + 7 (VGA) Bit 9 of Vertical Retrace Start (3d4h index 10h) + +3d4h index 8 (r/W): CRTC: Preset Row Scan Register +bit 0-4 Number of lines we have scrolled down in the first character row. + Provides Smooth Vertical Scrolling. + 5-6 (VGA Only) Number of bytes to skip at the start of scanline. Provides + Smooth Horizontal Scrolling together with the Horizontal Panning + Register (3C0h index 13h). + +3d4h index 9 (r/W): CRTC: Maximum Scan Line Register +bit 0-4 Number of scan lines in a character row -1. In graphics modes this is + the number of times (-1) the line is displayed before passing on to + the next line (0: normal, 1: double, 2: triple...). + This is independent of bit 7, except in CGA modes which seems to + require this field to be 1 and bit 7 to be set to work. + 5 (VGA) Bit 9 of Start Vertical Blanking + 6 (VGA) Bit 9 of Line Compare Register + 7 (VGA) Doubles each scan line if set. + I.e. displays 200 lines on a 400 display. + +3d4h index Ah (r/W): CRTC: Cursor Start Register +bit 0-4 First scanline of cursor within character. + 5 (VGA) Turns Cursor off if set + +3d4h index Bh (r/W): CRTC: Cursor End Register +bit 0-4 Last scanline of cursor within character + 5-6 Delay of cursor data in character clocks. + +3d4h index Ch (r/W): CRTC: Start Address High Register +bit 0-7 Upper 8 bits of the start address of the display buffer + +3d4h index Dh (r/W): CRTC: Start Address Low Register +bit 0-7 Lower 8 bits of the start address of the display buffer + +3d4h index Eh (r/W): CRTC: Cursor Location High Register +bit 0-7 Upper 8 bits of the address of the cursor + +3d4h index Fh (r/W): CRTC: Cursor Location Low Register +bit 0-7 Lower 8 bits of the address of the cursor + +3d4h index 10h (R): CRTC: Light Pen High Register (EGA Only) +bit 0-7 (EGA Only) Upper 8 bits of the address of the lightpen position. + +3d4h index 10h (r/W): CRTC: Vertical Retrace Start Register +bit 0-7 Lower 8 bits of Vertical Retrace Start. Vertical Retrace starts when + the line counter reaches this value. Bit 8 is found in 3d4h index 7 + bit 2. (VGA Only) Bit 9 is found in 3d4h index 7 bit 7. + +3d4h index 11h (R): CRTC: Light Pen Low Register (EGA Only) +bit 0-7 (EGA Only) Lower 8 bits of the address of the lightpen position. + +3d4h index 11h (r/W): CRTC: Vertical Retrace End Register +bit 0-3 Vertical Retrace ends when the last 4 bits of the line counter equals + this value. + 4 if clear Clears pending Vertical Interrupts. + 5 Vertical Interrupts (IRQ 2) disabled if set. Can usually be left + disabled, but some systems (including PS/2) require it to be enabled. + 6 (VGA Only) If set selects 5 refresh cycles per scanline rather + than 3. + 7 (VGA Only) Disables writing to registers 0-7 if set 3d4h index 7 + bit 4 is not affected by this bit. + +3d4h index 12h (r/W): CRTC: Vertical Display End Register +bit 0-7 Lower 8 bits of Vertical Display End. The display ends when the line + counter reaches this value. Bit 8 is found in 3d4h index 7 bit 1. + (VGA Only) Bit 9 is found in 3d4h index 7 bit 6. + +3d4h index 13h (r/W): CRTC: Offset register +bit 0-7 Number of bytes in a scanline / K. Where K is 2 for byte mode, 4 for + word mode and 8 for Double Word mode. + +3d4h index 14h (r/W): CRTC: Underline Location Register +bit 0-4 Position of underline within Character cell. + 5 (VGA Only) If set memory address is only changed every fourth + character clock. + 6 (VGA Only) Double Word mode addressing if set + +3d4h index 15h (r/W): CRTC: Start Vertical Blank Register +bit 0-7 Lower 8 bits of Vertical Blank Start. Vertical blanking starts when + the line counter reaches this value. Bit 8 is found in 3d4h index 7 + bit 3. + +3d4h index 16h (r/W): CRTC: End Vertical Blank Register +bit 0-4 (EGA) Vertical blanking stops when the lower 5 bits of the line + counter equals this field. + 0-6 (VGA) Vertical blanking stops when the lower 7 bits of the line + counter equals this field. + +3d4h index 17h (r/W): CRTC: Mode Control Register +bit 0 If clear use CGA compatible memory addressing system + by substituting character row scan counter bit 0 for address bit 13, + thus creating 2 banks for even and odd scan lines. + 1 If clear use Hercules compatible memory addressing system by + substituting character row scan counter bit 1 for address bit 14, + thus creating 4 banks. + 2 If set increase scan line counter only every second line. + 3 If set increase memory address counter only every other character + clock. + 4 (EGA Only) If set disable the EGA output drivers. This bit is used + for other purposes in some Super VGA chips. + 5 When in Word Mode bit 15 is rotated to bit 0 if this bit is set else + bit 13 is rotated into bit 0. + 6 If clear system is in word mode. Addresses are rotated 1 position up + bringing either bit 13 or 15 into bit 0. + 7 Clearing this bit will reset the display system until the bit is set + again. + +3d4h index 18h (r/W): CRTC: Line Compare Register +bit 0-7 Lower 8 bits of the Line Compare. When the Line counter reaches this + value, the display address wraps to 0. Provides Split Screen + facilities. Bit 8 is found in 3d4h index 7 bit 4. + (VGA Only) Bit 9 is found in 3d4h index 9 bit 6. + +3d4h index 22h (R): Memory Latch Register (VGA - Undoc) +bit 0-7 Reads the contents of the Graphics Controller Memory Data Latch for + the plane selected by 3C0h index 4 bit 0-1 (Read Map Select). +Note: This register is not documented by IBM and may not be available on all + clones. + +3d4h index 24h (R): Attribute Controller Toggle Register. (VGA - Undoc) +bit 0-4 Attribute Controller Index. + The current value of the Attribute Index Register. + 5 Palette Address Source. Same as 3C0h bit 5. + 7 If set next read or write to 3C0h will access the data register. +Note: This register is not documented by IBM and may not be available on all + clones. + +3d4h index 30h-3Fh (W): Clear Vertical Display Enable. (VGA - Undoc) +bit 0 Setting this bit will clear the Vertical Display Enable thus blanking + the display for the rest of the frame and giving the CPU total access + to display memory until the start of the next frame. +Note: This register is not documented by IBM and may not be available on all + clones. + +3dAh (R): Input Status #1 Register +bit 0 Either Vertical or Horizontal Retrace active if set + 1 (EGA Only) Light Pen has triggered if set + 2 (EGA Only) Light Pen switch is open if set + 3 Vertical Retrace in progress if set + 4-5 (EGA Only) Shows two of the 6 color outputs, depending on 3C0h index + 12h bit 4-5: + Attr: Bit 4-5: Out bit 4 Out bit 5 + 0 Blue Red + 1 I Blue Green + 2 I Red I Green + +3dAh (W): Feature Control Register +bit 0 (EGA Only) Output to pin 21 of the Feature Connector. + 1 (EGA Only) Output to pin 20 of the Feature Connector. + 3 (VGA Only) Vertical Sync Select. If set Vertical Sync to the monitor + is the logical OR of the vertical sync and the vertical display + enable. +Note: On the VGA this register can be read from port 3CAh. diff --git a/src/fterm.cpp b/src/fterm.cpp index daebdc49..5db43829 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -316,12 +316,6 @@ bool FTerm::setOldFont() else if ( isLinuxTerm() ) { retval = linux->loadOldFont(fc::character); - - if ( retval ) - { - data->supportShadowCharacter (linux->hasShadowCharacter()); - data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter()); - } } #endif // defined(__linux__) @@ -916,8 +910,6 @@ void FTerm::initScreenSettings() // Important: Do not use setNewFont() or setVGAFont() after // the console character mapping has been initialized linux->initCharMap (fc::character); - data->supportShadowCharacter (linux->hasShadowCharacter()); - data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter()); #elif defined(__FreeBSD__) || defined(__DragonFly__) freebsd->initCharMap (fc::character); #endif diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 0fff2872..bc2062c0 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -40,8 +40,6 @@ namespace finalcut bool FTermLinux::new_font; bool FTermLinux::vga_font; - bool FTermLinux::shadow_character = true; - bool FTermLinux::half_block_character = true; bool FTermLinux::has_saved_palette = false; FTermData* FTermLinux::fterm_data = nullptr; @@ -158,6 +156,8 @@ void FTermLinux::init() term_detection = FTerm::getFTermDetection(); screen_unicode_map.entries = nullptr; screen_font.data = nullptr; + fterm_data->supportShadowCharacter (true); + fterm_data->supportHalfBlockCharacter (true); if ( FTerm::openConsole() == 0 ) { @@ -279,7 +279,10 @@ bool FTermLinux::loadVGAFont() vga_font = false; if ( vga_font ) - shadow_character = half_block_character = true; + { + fterm_data->supportShadowCharacter (true); + fterm_data->supportHalfBlockCharacter (true); + } return vga_font; } @@ -316,7 +319,10 @@ bool FTermLinux::loadNewFont() new_font = false; if ( vga_font ) - shadow_character = half_block_character = true; + { + fterm_data->supportShadowCharacter (true); + fterm_data->supportHalfBlockCharacter (true); + } return new_font; } @@ -1221,7 +1227,7 @@ inline void FTermLinux::initSpecialCharacter() || FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII) || FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) ) { - shadow_character = false; + fterm_data->supportShadowCharacter (false); } wchar_t c4 = fc::RightHalfBlock; @@ -1230,7 +1236,7 @@ inline void FTermLinux::initSpecialCharacter() if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII) || FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) ) { - half_block_character = false; + fterm_data->supportHalfBlockCharacter (false); } } diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index aab81be2..4b444074 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -94,8 +94,6 @@ class FTermLinux final // Inquiries static bool isLinuxConsole(); - static bool hasShadowCharacter(); - static bool hasHalfBlockCharacter(); static bool isVGAFontUsed(); static bool isNewFontUsed(); @@ -176,8 +174,6 @@ class FTermLinux final #if defined(__linux__) static bool vga_font; static bool new_font; - static bool shadow_character; - static bool half_block_character; static bool has_saved_palette; static FTermData* fterm_data; static FSystem* fsystem; @@ -203,14 +199,6 @@ inline const char* FTermLinux::getClassName() const inline int FTermLinux::getFramebufferBpp() { return framebuffer_bpp; } -//---------------------------------------------------------------------- -inline bool FTermLinux::hasShadowCharacter() -{ return shadow_character; } - -//---------------------------------------------------------------------- -inline bool FTermLinux::hasHalfBlockCharacter() -{ return half_block_character; } - //---------------------------------------------------------------------- inline bool FTermLinux::isVGAFontUsed() { return vga_font; } diff --git a/test/Makefile.am b/test/Makefile.am index 1cedd8b6..da1e79e9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,6 +13,7 @@ noinst_PROGRAMS = \ ftermdata_test \ ftermdetection_test \ ftermcapquirks_test \ + ftermlinux_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ @@ -27,6 +28,7 @@ fkeyboard_test_SOURCES = fkeyboard-test.cpp ftermdata_test_SOURCES = ftermdata-test.cpp ftermdetection_test_SOURCES = ftermdetection-test.cpp ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp +ftermlinux_test_SOURCES = ftermlinux-test.cpp foptimove_test_SOURCES = foptimove-test.cpp foptiattr_test_SOURCES = foptiattr-test.cpp fcolorpair_test_SOURCES = fcolorpair-test.cpp @@ -41,6 +43,7 @@ TESTS = fobject_test \ ftermdata_test \ ftermdetection_test \ ftermcapquirks_test \ + ftermlinux_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ diff --git a/test/conemu.h b/test/conemu.h new file mode 100644 index 00000000..b106631e --- /dev/null +++ b/test/conemu.h @@ -0,0 +1,1103 @@ +/*********************************************************************** +* conemu.h - Emulator for various consoles and terminals * +* * +* 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 test class + * ═════════════════════ + * + * ▕▔▔▔▔▔▔▔▔▏ + * ▕ ConEmu ▏ + * ▕▁▁▁▁▁▁▁▁▏ + */ + +#ifndef CONEMU_H +#define CONEMU_H + +#include +#include + +#include + +namespace test +{ + +//---------------------------------------------------------------------- +// class ConEmu +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class ConEmu +{ + public: + // Enumeration + enum console + { + ansi, + xterm, + rxvt, + urxvt, + mlterm, + putty, + kde_konsole, + gnome_terminal, + newer_vte_terminal, + kterm, + tera_term, + cygwin, + mintty, + linux_con, + freebsd_con, + netbsd_con, + openbsd_con, + sun_con, + screen, + tmux + }; + + // Constructors + ConEmu() + { + // Map shared memory + void* ptr = mmap ( NULL + , sizeof(*shared_state) + , PROT_READ | PROT_WRITE + , MAP_SHARED | MAP_ANONYMOUS, -1 + , 0 ); + shared_state = static_cast(ptr); + *shared_state = false; + } + + // Disable copy constructor + ConEmu (const ConEmu&) = delete; + + // Destructor + ~ConEmu() + { + closeMasterPTY(); + closeSlavePTY(); + // Unmap shared memory + munmap (shared_state, sizeof(*shared_state)); + } + + // Disable assignment operator (=) + ConEmu& operator = (const ConEmu&) = delete; + + protected: + // Mutators + void enableConEmuDebug (bool); + + // Inquiries + bool isConEmuChildProcess (pid_t); + + // Methods + void printConEmuDebug(); + void closeConEmuStdStreams(); + pid_t forkConEmu(); + void startConEmuTerminal (console); + + private: + // Accessors + char* getAnswerback (console); + char* getDSR (console); + char* getDECID (console); + char* getDA (console); + char* getDA1 (console); + char* getSEC_DA (console); + + // Methods + bool openMasterPTY(); + bool openSlavePTY(); + void closeMasterPTY(); + void closeSlavePTY(); + void parseTerminalBuffer (std::size_t, console); + + // Data Members + int fd_stdin{fileno(stdin)}; + int fd_stdout{fileno(stdout)}; + int fd_stderr{fileno(stderr)}; + int fd_master{-1}; + int fd_slave{-1}; + bool debug{false}; + char buffer[2048]{}; + static bool* shared_state; + static char* colorname[]; +}; +#pragma pack(pop) + +// static class attributes +bool* ConEmu::shared_state = nullptr; + + +// private Data Member of ConEmu +//---------------------------------------------------------------------- +char* ConEmu::colorname[] = +{ + C_STR("0000/0000/0000"), // 0 + C_STR("bbbb/0000/0000"), // 1 + C_STR("0000/bbbb/0000"), // 2 + C_STR("bbbb/bbbb/0000"), // 3 + C_STR("0000/0000/bbbb"), // 4 + C_STR("bbbb/0000/bbbb"), // 5 + C_STR("0000/bbbb/bbbb"), // 6 + C_STR("bbbb/bbbb/bbbb"), // 7 + C_STR("5555/5555/5555"), // 8 + C_STR("ffff/5555/5555"), // 9 + C_STR("5555/ffff/5555"), // 10 + C_STR("ffff/ffff/5555"), // 11 + C_STR("5555/5555/ffff"), // 12 + C_STR("ffff/5555/ffff"), // 13 + C_STR("5555/ffff/ffff"), // 14 + C_STR("ffff/ffff/ffff"), // 15 + C_STR("0000/0000/0000"), // 16 + C_STR("0000/0000/5f5f"), // 17 + C_STR("0000/0000/8787"), // 18 + C_STR("0000/0000/afaf"), // 19 + C_STR("0000/0000/d7d7"), // 20 + C_STR("0000/0000/ffff"), // 21 + C_STR("0000/5f5f/0000"), // 22 + C_STR("0000/5f5f/5f5f"), // 23 + C_STR("0000/5f5f/8787"), // 24 + C_STR("0000/5f5f/afaf"), // 25 + C_STR("0000/5f5f/d7d7"), // 26 + C_STR("0000/5f5f/ffff"), // 27 + C_STR("0000/8787/0000"), // 28 + C_STR("0000/8787/5f5f"), // 29 + C_STR("0000/8787/8787"), // 30 + C_STR("0000/8787/afaf"), // 31 + C_STR("0000/8787/d7d7"), // 32 + C_STR("0000/8787/ffff"), // 33 + C_STR("0000/afaf/0000"), // 34 + C_STR("0000/afaf/5f5f"), // 35 + C_STR("0000/afaf/8787"), // 36 + C_STR("0000/afaf/afaf"), // 37 + C_STR("0000/afaf/d7d7"), // 38 + C_STR("0000/afaf/ffff"), // 39 + C_STR("0000/d7d7/0000"), // 40 + C_STR("0000/d7d7/5f5f"), // 41 + C_STR("0000/d7d7/8787"), // 42 + C_STR("0000/d7d7/afaf"), // 43 + C_STR("0000/d7d7/d7d7"), // 44 + C_STR("0000/d7d7/ffff"), // 45 + C_STR("0000/ffff/0000"), // 46 + C_STR("0000/ffff/5f5f"), // 47 + C_STR("0000/ffff/8787"), // 48 + C_STR("0000/ffff/afaf"), // 49 + C_STR("0000/ffff/d7d7"), // 50 + C_STR("0000/ffff/ffff"), // 51 + C_STR("5f5f/0000/0000"), // 52 + C_STR("5f5f/0000/5f5f"), // 53 + C_STR("5f5f/0000/8787"), // 54 + C_STR("5f5f/0000/afaf"), // 55 + C_STR("5f5f/0000/d7d7"), // 56 + C_STR("5f5f/0000/ffff"), // 57 + C_STR("5f5f/5f5f/0000"), // 58 + C_STR("5f5f/5f5f/5f5f"), // 59 + C_STR("5f5f/5f5f/8787"), // 60 + C_STR("5f5f/5f5f/afaf"), // 61 + C_STR("5f5f/5f5f/d7d7"), // 62 + C_STR("5f5f/5f5f/ffff"), // 63 + C_STR("5f5f/8787/0000"), // 64 + C_STR("5f5f/8787/5f5f"), // 65 + C_STR("5f5f/8787/8787"), // 66 + C_STR("5f5f/8787/afaf"), // 67 + C_STR("5f5f/8787/d7d7"), // 68 + C_STR("5f5f/8787/ffff"), // 69 + C_STR("5f5f/afaf/0000"), // 70 + C_STR("5f5f/afaf/5f5f"), // 71 + C_STR("5f5f/afaf/8787"), // 72 + C_STR("5f5f/afaf/afaf"), // 73 + C_STR("5f5f/afaf/d7d7"), // 74 + C_STR("5f5f/afaf/ffff"), // 75 + C_STR("5f5f/d7d7/0000"), // 76 + C_STR("5f5f/d7d7/5f5f"), // 77 + C_STR("5f5f/d7d7/8787"), // 78 + C_STR("5f5f/d7d7/afaf"), // 79 + C_STR("5f5f/d7d7/d7d7"), // 80 + C_STR("5f5f/d7d7/ffff"), // 81 + C_STR("5f5f/ffff/0000"), // 82 + C_STR("5f5f/ffff/5f5f"), // 83 + C_STR("5f5f/ffff/8787"), // 84 + C_STR("5f5f/ffff/afaf"), // 85 + C_STR("5f5f/ffff/d7d7"), // 86 + C_STR("5f5f/ffff/ffff"), // 87 + C_STR("8787/0000/0000"), // 88 + C_STR("8787/0000/5f5f"), // 89 + C_STR("8787/0000/8787"), // 90 + C_STR("8787/0000/afaf"), // 91 + C_STR("8787/0000/d7d7"), // 92 + C_STR("8787/0000/ffff"), // 93 + C_STR("8787/5f5f/0000"), // 94 + C_STR("8787/5f5f/5f5f"), // 95 + C_STR("8787/5f5f/8787"), // 96 + C_STR("8787/5f5f/afaf"), // 97 + C_STR("8787/5f5f/d7d7"), // 98 + C_STR("8787/5f5f/ffff"), // 99 + C_STR("8787/8787/0000"), // 100 + C_STR("8787/8787/5f5f"), // 101 + C_STR("8787/8787/8787"), // 102 + C_STR("8787/8787/afaf"), // 103 + C_STR("8787/8787/d7d7"), // 104 + C_STR("8787/8787/ffff"), // 105 + C_STR("8787/afaf/0000"), // 106 + C_STR("8787/afaf/5f5f"), // 107 + C_STR("8787/afaf/8787"), // 108 + C_STR("8787/afaf/afaf"), // 109 + C_STR("8787/afaf/d7d7"), // 110 + C_STR("8787/afaf/ffff"), // 111 + C_STR("8787/d7d7/0000"), // 112 + C_STR("8787/d7d7/5f5f"), // 113 + C_STR("8787/d7d7/8787"), // 114 + C_STR("8787/d7d7/afaf"), // 115 + C_STR("8787/d7d7/d7d7"), // 116 + C_STR("8787/d7d7/ffff"), // 117 + C_STR("8787/ffff/0000"), // 118 + C_STR("8787/ffff/5f5f"), // 119 + C_STR("8787/ffff/8787"), // 120 + C_STR("8787/ffff/afaf"), // 121 + C_STR("8787/ffff/d7d7"), // 122 + C_STR("8787/ffff/ffff"), // 123 + C_STR("afaf/0000/0000"), // 124 + C_STR("afaf/0000/5f5f"), // 125 + C_STR("afaf/0000/8787"), // 126 + C_STR("afaf/0000/afaf"), // 127 + C_STR("afaf/0000/d7d7"), // 128 + C_STR("afaf/0000/ffff"), // 129 + C_STR("afaf/5f5f/0000"), // 130 + C_STR("afaf/5f5f/5f5f"), // 131 + C_STR("afaf/5f5f/8787"), // 132 + C_STR("afaf/5f5f/afaf"), // 133 + C_STR("afaf/5f5f/d7d7"), // 134 + C_STR("afaf/5f5f/ffff"), // 135 + C_STR("afaf/8787/0000"), // 136 + C_STR("afaf/8787/5f5f"), // 137 + C_STR("afaf/8787/8787"), // 138 + C_STR("afaf/8787/afaf"), // 139 + C_STR("afaf/8787/d7d7"), // 140 + C_STR("afaf/8787/ffff"), // 141 + C_STR("afaf/afaf/0000"), // 142 + C_STR("afaf/afaf/5f5f"), // 143 + C_STR("afaf/afaf/8787"), // 144 + C_STR("afaf/afaf/afaf"), // 145 + C_STR("afaf/afaf/d7d7"), // 146 + C_STR("afaf/afaf/ffff"), // 147 + C_STR("afaf/d7d7/0000"), // 148 + C_STR("afaf/d7d7/5f5f"), // 149 + C_STR("afaf/d7d7/8787"), // 150 + C_STR("afaf/d7d7/afaf"), // 151 + C_STR("afaf/d7d7/d7d7"), // 152 + C_STR("afaf/d7d7/ffff"), // 153 + C_STR("afaf/ffff/0000"), // 154 + C_STR("afaf/ffff/5f5f"), // 155 + C_STR("afaf/ffff/8787"), // 156 + C_STR("afaf/ffff/afaf"), // 157 + C_STR("afaf/ffff/d7d7"), // 158 + C_STR("afaf/ffff/ffff"), // 159 + C_STR("d7d7/0000/0000"), // 160 + C_STR("d7d7/0000/5f5f"), // 161 + C_STR("d7d7/0000/8787"), // 162 + C_STR("d7d7/0000/afaf"), // 163 + C_STR("d7d7/0000/d7d7"), // 164 + C_STR("d7d7/0000/ffff"), // 165 + C_STR("d7d7/5f5f/0000"), // 166 + C_STR("d7d7/5f5f/5f5f"), // 167 + C_STR("d7d7/5f5f/8787"), // 168 + C_STR("d7d7/5f5f/afaf"), // 169 + C_STR("d7d7/5f5f/d7d7"), // 170 + C_STR("d7d7/5f5f/ffff"), // 171 + C_STR("d7d7/8787/0000"), // 172 + C_STR("d7d7/8787/5f5f"), // 173 + C_STR("d7d7/8787/8787"), // 174 + C_STR("d7d7/8787/afaf"), // 175 + C_STR("d7d7/8787/d7d7"), // 176 + C_STR("d7d7/8787/ffff"), // 177 + C_STR("d7d7/afaf/0000"), // 178 + C_STR("d7d7/afaf/5f5f"), // 179 + C_STR("d7d7/afaf/8787"), // 180 + C_STR("d7d7/afaf/afaf"), // 181 + C_STR("d7d7/afaf/d7d7"), // 182 + C_STR("d7d7/afaf/ffff"), // 183 + C_STR("d7d7/d7d7/0000"), // 184 + C_STR("d7d7/d7d7/5f5f"), // 185 + C_STR("d7d7/d7d7/8787"), // 186 + C_STR("d7d7/d7d7/afaf"), // 187 + C_STR("d7d7/d7d7/d7d7"), // 188 + C_STR("d7d7/d7d7/ffff"), // 189 + C_STR("d7d7/ffff/0000"), // 190 + C_STR("d7d7/ffff/5f5f"), // 191 + C_STR("d7d7/ffff/8787"), // 192 + C_STR("d7d7/ffff/afaf"), // 193 + C_STR("d7d7/ffff/d7d7"), // 194 + C_STR("d7d7/ffff/ffff"), // 195 + C_STR("ffff/0000/0000"), // 196 + C_STR("ffff/0000/5f5f"), // 197 + C_STR("ffff/0000/8787"), // 198 + C_STR("ffff/0000/afaf"), // 199 + C_STR("ffff/0000/d7d7"), // 200 + C_STR("ffff/0000/ffff"), // 201 + C_STR("ffff/5f5f/0000"), // 202 + C_STR("ffff/5f5f/5f5f"), // 203 + C_STR("ffff/5f5f/8787"), // 204 + C_STR("ffff/5f5f/afaf"), // 205 + C_STR("ffff/5f5f/d7d7"), // 206 + C_STR("ffff/5f5f/ffff"), // 207 + C_STR("ffff/8787/0000"), // 208 + C_STR("ffff/8787/5f5f"), // 209 + C_STR("ffff/8787/8787"), // 210 + C_STR("ffff/8787/afaf"), // 211 + C_STR("ffff/8787/d7d7"), // 212 + C_STR("ffff/8787/ffff"), // 213 + C_STR("ffff/afaf/0000"), // 214 + C_STR("ffff/afaf/5f5f"), // 215 + C_STR("ffff/afaf/8787"), // 216 + C_STR("ffff/afaf/afaf"), // 217 + C_STR("ffff/afaf/d7d7"), // 218 + C_STR("ffff/afaf/ffff"), // 219 + C_STR("ffff/d7d7/0000"), // 220 + C_STR("ffff/d7d7/5f5f"), // 221 + C_STR("ffff/d7d7/8787"), // 222 + C_STR("ffff/d7d7/afaf"), // 223 + C_STR("ffff/d7d7/d7d7"), // 224 + C_STR("ffff/d7d7/ffff"), // 225 + C_STR("ffff/ffff/0000"), // 226 + C_STR("ffff/ffff/5f5f"), // 227 + C_STR("ffff/ffff/8787"), // 228 + C_STR("ffff/ffff/afaf"), // 229 + C_STR("ffff/ffff/d7d7"), // 230 + C_STR("ffff/ffff/ffff"), // 231 + C_STR("0808/0808/0808"), // 232 + C_STR("1212/1212/1212"), // 233 + C_STR("1c1c/1c1c/1c1c"), // 234 + C_STR("2626/2626/2626"), // 235 + C_STR("3030/3030/3030"), // 236 + C_STR("3a3a/3a3a/3a3a"), // 237 + C_STR("4444/4444/4444"), // 238 + C_STR("4e4e/4e4e/4e4e"), // 239 + C_STR("5858/5858/5858"), // 240 + C_STR("6262/6262/6262"), // 241 + C_STR("6c6c/6c6c/6c6c"), // 242 + C_STR("7676/7676/7676"), // 243 + C_STR("8080/8080/8080"), // 244 + C_STR("8a8a/8a8a/8a8a"), // 245 + C_STR("9494/9494/9494"), // 246 + C_STR("9e9e/9e9e/9e9e"), // 247 + C_STR("a8a8/a8a8/a8a8"), // 248 + C_STR("b2b2/b2b2/b2b2"), // 249 + C_STR("bcbc/bcbc/bcbc"), // 250 + C_STR("c6c6/c6c6/c6c6"), // 251 + C_STR("d0d0/d0d0/d0d0"), // 252 + C_STR("dada/dada/dada"), // 253 + C_STR("e4e4/e4e4/e4e4"), // 254 + C_STR("eeee/eeee/eeee"), // 255 + 0 +}; + + +// ConEmu inline functions + +// protected methods of ConEmu +//---------------------------------------------------------------------- +inline void ConEmu::enableConEmuDebug (bool enable) +{ + debug = enable; +} + +//---------------------------------------------------------------------- +inline bool ConEmu::isConEmuChildProcess (pid_t pid) +{ + return bool( pid == 0 ); +} + +//---------------------------------------------------------------------- +inline void ConEmu::printConEmuDebug() +{ + // Printing terminal debug information for some escape sequences + + if ( ! debug ) + return; + + setenv ("DSR", "\\033[5n", 1); + setenv ("CURSOR_POS", "\\033[6n", 1); + setenv ("DECID", "\\033Z", 1); + setenv ("DA", "\\033[c", 1); + setenv ("DA1", "\\033[1c", 1); + setenv ("SEC_DA", "\\033[>c", 1); + setenv ("ANSWERBACK", "\\005", 1); + setenv ("TITLE", "\\033[21t", 1); + setenv ("COLOR16", "\\033]4;15;?\\a", 1); + setenv ("COLOR88", "\\033]4;87;?\\a", 1); + setenv ("COLOR256", "\\033]4;254;?\\a", 1); + + setenv ("GO_MIDDLE", "\\033[80D\\033[15C", 1); + setenv ("GO_RIGHT", "\\033[79D\\033[40C", 1); + + finalcut::FString line (69, '-'); + std::cout << std::endl << line << std::endl; + std::cout << "Probe Escape sequence Reply"; + std::cout << std::endl << line << std::endl; + + // Command line + constexpr char debug_command[] = "/bin/bash -c ' \ + for i in DSR CURSOR_POS DECID DA DA1 SEC_DA ANSWERBACK \ + TITLE COLOR16 COLOR88 COLOR256; \ + do \ + eval \"echo -en \\\"$i${GO_MIDDLE}\\\"; \ + echo -n \\\"\\${$i}\\\"; \ + echo -en \\\"${GO_RIGHT}\\${$i}\\\"\"; \ + sleep 0.5; \ + echo -e \"\\r\"; \ + done'"; + system(debug_command); +} + +//---------------------------------------------------------------------- +inline void ConEmu::closeConEmuStdStreams() +{ + close(fd_stdin); // stdin + close(fd_stdout); // stdout + close(fd_stderr); // stderr +} + +//---------------------------------------------------------------------- +inline pid_t ConEmu::forkConEmu() +{ + // Initialize buffer with '\0' + std::fill_n (buffer, sizeof(buffer), '\0'); + + if ( ! openMasterPTY() ) + return -1; + + if ( ! openSlavePTY() ) + return -1; + + pid_t pid = fork(); // Create a child process + + if ( pid < 0) // Fork failed + return -1; + + if ( isConEmuChildProcess(pid) ) // Child process + { + struct termios term_settings; + closeMasterPTY(); + + // Creates a session and makes the current process to the leader + setsid(); + +#ifdef TIOCSCTTY + // Set controlling tty + if ( ioctl(fd_slave, TIOCSCTTY, 0) == -1 ) + { + *shared_state = true; + return -1; + } +#endif + + // Get current terminal settings + if ( tcgetattr(fd_slave, &term_settings) == -1 ) + { + *shared_state = true; + return -1; + } + + // Set raw mode on the slave side of the PTY + cfmakeraw (&term_settings); + tcsetattr (fd_slave, TCSANOW, &term_settings); + +#ifdef TIOCSWINSZ + // Set slave tty window size + struct winsize size; + size.ws_row = 25; + size.ws_col = 80; + + if ( ioctl(fd_slave, TIOCSWINSZ, &size) == -1) + { + *shared_state = true; + return -1; + } +#endif + + closeConEmuStdStreams(); + + fd_stdin = dup(fd_slave); // PTY becomes stdin (0) + fd_stdout = dup(fd_slave); // PTY becomes stdout (1) + fd_stderr = dup(fd_slave); // PTY becomes stderr (2) + + closeSlavePTY(); + + // The child process is now ready for input + *shared_state = true; + } + else + { + constexpr int timeout = 150; // 1.5 seconds + int i = 0; + + // Wait until the child process is ready for input + while ( ! *shared_state && i < timeout ) + { + // Wait 10 ms (= 10,000,000 ns) + nanosleep ((const struct timespec[]){{0, 10000000L}}, NULL); + i++; + } + + *shared_state = false; + } + + return pid; +} + + + +//---------------------------------------------------------------------- +inline void ConEmu::startConEmuTerminal (console con) +{ + closeSlavePTY(); + + while ( 1 ) + { + fd_set ifds; + struct timeval tv; + ssize_t len; + + FD_ZERO(&ifds); + FD_SET(fd_stdin, &ifds); + FD_SET(fd_master, &ifds); + tv.tv_sec = 0; + tv.tv_usec = 750000; // 750 ms + + // Wait for data from stdin or the master side of PTY + if ( select(fd_master + 1, &ifds, 0, 0, &tv) < 0 ) + break; + + // Data on standard input + if ( FD_ISSET(fd_stdin, &ifds) ) + { + len = read (fd_stdin, buffer, sizeof(buffer)); + + if ( len > 0 && std::size_t(len) < sizeof(buffer) ) + { + buffer[len] = '\0'; + write (fd_master, buffer, len); // Send data to the master side + } + } + + // Data on the master side of PTY + if ( FD_ISSET(fd_master, &ifds) ) + { + len = read (fd_master, buffer, sizeof(buffer)); + + if ( len == -1 || std::size_t(len) >= sizeof(buffer) ) + break; + else if ( len > 0 ) + { + buffer[len] = '\0'; + parseTerminalBuffer (len, con); + } + } + } +} + + +// private methods of ConEmu +//---------------------------------------------------------------------- +inline char* ConEmu::getAnswerback (console con) +{ + static char* Answerback[] = + { + 0, // Ansi, + 0, // XTerm + 0, // Rxvt + 0, // Urxvt + 0, // mlterm - Multi Lingual TERMinal + C_STR("PuTTY"), // PuTTY + 0, // KDE Konsole + 0, // GNOME Terminal + 0, // VTE Terminal >= 0.53.0 + 0, // kterm, + 0, // Tera Term + 0, // Cygwin + 0, // Mintty + 0, // Linux console + 0, // FreeBSD console + 0, // NetBSD console + 0, // OpenBSD console + 0, // Sun console + 0, // screen + 0 // tmux + }; + + return Answerback[con]; +} + +//---------------------------------------------------------------------- +inline char* ConEmu::getDSR (console con) +{ + static char* DSR[] = + { + 0, // Ansi, + C_STR("\033[0n"), // XTerm + C_STR("\033[0n"), // Rxvt + C_STR("\033[0n"), // Urxvt + C_STR("\033[0n"), // mlterm - Multi Lingual TERMinal + C_STR("\033[0n"), // PuTTY + C_STR("\033[0n"), // KDE Konsole + C_STR("\033[0n"), // GNOME Terminal + C_STR("\033[0n"), // VTE Terminal >= 0.53.0 + C_STR("\033[0n"), // kterm, + C_STR("\033[0n"), // Tera Term + 0, // Cygwin + C_STR("\033[0n"), // Mintty + C_STR("\033[0n"), // Linux console + C_STR("\033[0n"), // FreeBSD console + C_STR("\033[0n"), // NetBSD console + C_STR("\033[0n"), // OpenBSD console + 0, // Sun console + C_STR("\033[0n"), // screen + C_STR("\033[0n") // tmux + }; + + return DSR[con]; +} + +//---------------------------------------------------------------------- +inline char* ConEmu::getDECID (console con) +{ + static char* DECID[] = + { + 0, // Ansi, + C_STR("\033[?63;1;2;6;4;6;9;15;22c"), // XTerm + C_STR("\033[?1;2c"), // Rxvt + C_STR("\033[?1;2c"), // Urxvt + C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal + C_STR("\033[?6c"), // PuTTY + C_STR("\033[?1;2c"), // KDE Konsole + C_STR("\033[?62;c"), // GNOME Terminal + C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 + C_STR("\033[?1;2c"), // kterm, + C_STR("\033[?1;2c"), // Tera Term + 0, // Cygwin + C_STR("\033[?1;2;6;22c"), // Mintty + C_STR("\033[?6c"), // Linux console + 0, // FreeBSD console + 0, // NetBSD console + 0, // OpenBSD console + 0, // Sun console + C_STR("\033[?1;2c"), // screen + 0 // tmux + }; + + return DECID[con]; +} + +//---------------------------------------------------------------------- +inline char* ConEmu::getDA (console con) +{ + static char* DA[] = + { + 0, // Ansi, + C_STR("\033[?63;1;2;6;4;6;9;15;22c"), // XTerm + C_STR("\033[?1;2c"), // Rxvt + C_STR("\033[?1;2c"), // Urxvt + C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal + C_STR("\033[?6c"), // PuTTY + C_STR("\033[?1;2c"), // KDE Konsole + C_STR("\033[?62;c"), // GNOME Terminal + C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 + C_STR("\033[?1;2c"), // kterm, + C_STR("\033[?1;2c"), // Tera Term + C_STR("\033[?6c"), // Cygwin + C_STR("\033[?1;2;6;22c"), // Mintty + C_STR("\033[?6c"), // Linux console + C_STR("\033[?1;2c"), // FreeBSD console + C_STR("\033[?62;6c"), // NetBSD console + C_STR("\033[?62;6c"), // OpenBSD console + 0, // Sun console + C_STR("\033[?1;2c"), // screen + C_STR("\033[?1;2c") // tmux + }; + + return DA[con]; +} + +//---------------------------------------------------------------------- +inline char* ConEmu::getDA1 (console con) +{ + static char* DA1[] = + { + 0, // Ansi, + 0, // XTerm + C_STR("\033[?1;2c"), // Rxvt + C_STR("\033[?1;2c"), // Urxvt + C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal + C_STR("\033[?6c"), // PuTTY + C_STR("\033[?1;2c"), // KDE Konsole + C_STR("\033[?62;c"), // GNOME Terminal + C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 + 0, // kterm, + C_STR("\033[?1;2c"), // Tera Term + C_STR("\033[?6c"), // Cygwin + C_STR("\033[?1;2;6;22c"), // Mintty + 0, // Linux console + 0, // FreeBSD console + 0, // NetBSD console + 0, // OpenBSD console + 0, // Sun console + 0, // screen + 0 // tmux + }; + + return DA1[con]; +} + +//---------------------------------------------------------------------- +inline char* ConEmu::getSEC_DA (console con) +{ + static char* SEC_DA[] = + { + 0, // Ansi, + C_STR("\033[>19;312;0c"), // XTerm + C_STR("\033[>82;20710;0c"), // Rxvt + C_STR("\033[>85;95;0c"), // Urxvt + C_STR("\033[>24;279;0c"), // mlterm - Multi Lingual TERMinal + C_STR("\033[>0;136;0c"), // PuTTY + C_STR("\033[>0;115;0c"), // KDE Konsole + C_STR("\033[>1;5202;0c"), // GNOME Terminal + C_STR("\033[>65;5300;1c"), // VTE Terminal >= 0.53.0 + C_STR("\033[?1;2c"), // kterm, + C_STR("\033[>32;278;0c"), // Tera Term + C_STR("\033[>67;200502;0c"), // Cygwin + C_STR("\033[>77;20402;0c"), // Mintty + 0, // Linux console + 0, // FreeBSD console + 0, // NetBSD console + 0, // OpenBSD console + 0, // Sun console + C_STR("\033[>83;40201;0c"), // screen + C_STR("\033[>84;0;0c") // tmux + }; + + return SEC_DA[con]; +} + +//---------------------------------------------------------------------- +inline bool ConEmu::openMasterPTY() +{ + int result; + + // Open a pseudoterminal device + fd_master = posix_openpt(O_RDWR); + + if ( fd_master < 0 ) + return false; + + // Change the slave pseudoterminal access rights + result = grantpt(fd_master); + + if ( result != 0 ) + return false; + + // Unlock the pseudoterminal master/slave pair + result = unlockpt(fd_master); + + if ( result != 0 ) + return false; + + return true; +} + +//---------------------------------------------------------------------- +inline bool ConEmu::openSlavePTY() +{ + closeSlavePTY(); + + // Get PTY filename + const char* pty_name = ptsname(fd_master); + + if ( pty_name == 0 ) + return false; + + // Open the slave PTY + fd_slave = open(pty_name, O_RDWR); + + if ( fd_slave < 0 ) + return false; + + return true; +} + +//---------------------------------------------------------------------- +inline void ConEmu::closeMasterPTY() +{ + if ( fd_master <= 0 ) + return; + + close (fd_master); + fd_master = -1; +} + +//---------------------------------------------------------------------- +inline void ConEmu::closeSlavePTY() +{ + if ( fd_slave <= 0 ) + return; + + close (fd_slave); + fd_slave = -1; +} + +//---------------------------------------------------------------------- +inline void ConEmu::parseTerminalBuffer (std::size_t length, console con) +{ + for (std::size_t i = 0; i < length; i++) + { + if ( buffer[i] == ENQ[0] ) // Enquiry character + { + char* answer = getAnswerback(con); + + if ( answer ) + write(fd_master, answer, std::strlen(answer)); + } + else if ( i < length - 1 // Terminal ID (DECID) + && buffer[i] == '\033' + && buffer[i + 1] == 'Z' ) + { + char* DECID = getDECID(con); + + if ( DECID ) + write (fd_master, DECID, std::strlen(DECID)); + + i += 2; + } + else if ( i < length - 3 // Device status report (DSR) + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == '5' + && buffer[i + 3] == 'n' ) + { + char* DSR = getDSR(con); + + if ( DSR ) + write (fd_master, DSR, std::strlen(DSR)); + + i += 4; + } + else if ( i < length - 3 // Report cursor position (CPR) + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == '6' + && buffer[i + 3] == 'n' ) + { + write (fd_master, "\033[25;80R", 8); // row 25 ; column 80 + i += 4; + } + else if ( i < length - 2 // Device attributes (DA) + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == 'c' ) + { + char* DA = getDA(con); + + if ( DA ) + write (fd_master, DA, std::strlen(DA)); + + i += 3; + } + else if ( i < length - 3 // Device attributes (DA1) + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == '1' + && buffer[i + 3] == 'c' ) + { + char* DA1 = getDA1(con); + + if ( DA1 ) + write (fd_master, DA1, std::strlen(DA1)); + i += 4; + } + else if ( i < length - 3 // Secondary device attributes (SEC_DA) + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == '>' + && buffer[i + 3] == 'c' ) + { + char* SEC_DA = getSEC_DA(con); + + if ( SEC_DA ) + write (fd_master, SEC_DA, std::strlen(SEC_DA)); + + i += 4; + } + else if ( i < length - 4 // Report xterm window's title + && buffer[i] == '\033' + && buffer[i + 1] == '[' + && buffer[i + 2] == '2' + && buffer[i + 3] == '1' + && buffer[i + 4] == 't' ) + { + if ( con == urxvt ) + write (fd_master, "\033]l", 3); + else if ( con == tera_term ) + write (fd_master, "\033]l\033\\", 5); + else if ( con == screen ) + write (fd_master, "\033]lbash\033\\", 9); + else if ( con != ansi + && con != rxvt + && con != mlterm + && con != kde_konsole + && con != kterm + && con != cygwin + && con != mintty + && con != linux_con + && con != freebsd_con + && con != netbsd_con + && con != openbsd_con + && con != sun_con + && con != tmux ) + write (fd_master, "\033]lTITLE\033\\", 10); + + i += 5; + } + else if ( i < length - 7 // Get xterm color name 0-9 + && buffer[i] == '\033' + && buffer[i + 1] == ']' + && buffer[i + 2] == '4' + && buffer[i + 3] == ';' + && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' + && buffer[i + 5] == ';' + && buffer[i + 6] == '?' + && buffer[i + 7] == '\a' ) + { + if ( con != ansi + && con != rxvt + && con != kde_konsole + && con != kterm + && con != cygwin + && con != mintty + && con != linux_con + && con != freebsd_con + && con != netbsd_con + && con != openbsd_con + && con != sun_con + && con != screen + && con != tmux ) + { + int n = buffer[i + 4] - '0'; + write (fd_master, "\033]4;", 4); + write (fd_master, &buffer[i + 4], 1); + write (fd_master, ";rgb:", 5); + write (fd_master, colorname[n], 14); + write (fd_master, "\a", 1); + } + + i += 8; + } + else if ( i < length - 8 // Get xterm color name 0-9 + && buffer[i] == '\033' + && buffer[i + 1] == ']' + && buffer[i + 2] == '4' + && buffer[i + 3] == ';' + && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' + && buffer[i + 5] >= '0' && buffer[i + 5] <= '9' + && buffer[i + 6] == ';' + && buffer[i + 7] == '?' + && buffer[i + 8] == '\a' ) + { + if ( con != ansi + && con != rxvt + && con != kde_konsole + && con != kterm + && con != cygwin + && con != mintty + && con != linux_con + && con != freebsd_con + && con != netbsd_con + && con != openbsd_con + && con != sun_con + && con != screen + && con != tmux ) + { + int n = (buffer[i + 4] - '0') * 10 + + (buffer[i + 5] - '0'); + write (fd_master, "\033]4;", 4); + write (fd_master, &buffer[i + 4], 1); + write (fd_master, &buffer[i + 5], 1); + write (fd_master, ";rgb:", 5); + write (fd_master, colorname[n], 14); + write (fd_master, "\a", 1); + } + + i += 9; + } + else if ( i < length - 9 // Get xterm color name 0-9 + && buffer[i] == '\033' + && buffer[i + 1] == ']' + && buffer[i + 2] == '4' + && buffer[i + 3] == ';' + && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' + && buffer[i + 5] >= '0' && buffer[i + 5] <= '9' + && buffer[i + 6] >= '0' && buffer[i + 6] <= '9' + && buffer[i + 7] == ';' + && buffer[i + 8] == '?' + && buffer[i + 9] == '\a' ) + { + if ( con != ansi + && con != rxvt + && con != kde_konsole + && con != kterm + && con != cygwin + && con != mintty + && con != linux_con + && con != freebsd_con + && con != netbsd_con + && con != openbsd_con + && con != sun_con + && con != screen + && con != tmux ) + { + int n = (buffer[i + 4] - '0') * 100 + + (buffer[i + 5] - '0') * 10 + + (buffer[i + 6] - '0'); + + if ( n < 256 ) + { + write (fd_master, "\033]4;", 4); + write (fd_master, &buffer[i + 4], 1); + write (fd_master, &buffer[i + 5], 1); + write (fd_master, &buffer[i + 6], 1); + write (fd_master, ";rgb:", 5); + write (fd_master, colorname[n], 14); + write (fd_master, "\a", 1); + } + } + + i += 10; + } + else + { + write (fd_stdout, &buffer[i], 1); // Send data to stdout + } + } +} + +} // namespace test + +#endif // CONEMU_H diff --git a/test/fmouse-test.cpp b/test/fmouse-test.cpp index 6ac1d65b..b13f9231 100644 --- a/test/fmouse-test.cpp +++ b/test/fmouse-test.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 * @@ -30,6 +30,8 @@ #include +namespace test +{ //---------------------------------------------------------------------- // class FMouse_protected @@ -77,6 +79,8 @@ class FMouse_protected : public finalcut::FMouse }; #pragma pack(pop) +} // namespace test + //---------------------------------------------------------------------- // class finalcut::FMouseTest @@ -129,7 +133,7 @@ class FMouseTest : public CPPUNIT_NS::TestFixture //---------------------------------------------------------------------- void FMouseTest::classNameTest() { - FMouse_protected m; + test::FMouse_protected m; const char* const classname1 = m.getClassName(); CPPUNIT_ASSERT ( std::strcmp(classname1, "FMouse") == 0 ); @@ -159,7 +163,7 @@ void FMouseTest::classNameTest() //---------------------------------------------------------------------- void FMouseTest::noArgumentTest() { - FMouse_protected mouse; + test::FMouse_protected mouse; CPPUNIT_ASSERT ( mouse.getPos() == finalcut::FPoint(0, 0) ); CPPUNIT_ASSERT ( mouse.getNewMousePosition() == finalcut::FPoint(0, 0) ); CPPUNIT_ASSERT ( ! mouse.hasEvent() ); @@ -201,7 +205,7 @@ void FMouseTest::doubleClickTest() { using finalcut::operator -; - FMouse_protected mouse; + test::FMouse_protected mouse; CPPUNIT_ASSERT ( mouse.getDblclickInterval() == 500000 ); // 500 ms timeval tv = { 0, 0 }; CPPUNIT_ASSERT ( mouse.isDblclickTimeout(&tv) ); @@ -226,7 +230,7 @@ void FMouseTest::doubleClickTest() //---------------------------------------------------------------------- void FMouseTest::workspaceSizeTest() { - FMouse_protected mouse; + test::FMouse_protected mouse; CPPUNIT_ASSERT ( mouse.getMaxWidth() == 80 ); CPPUNIT_ASSERT ( mouse.getMaxHeight() == 25 ); diff --git a/test/fobject-test.cpp b/test/fobject-test.cpp index 71bebfb1..6dd61d9b 100644 --- a/test/fobject-test.cpp +++ b/test/fobject-test.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 * @@ -30,6 +30,8 @@ #include +namespace test +{ //---------------------------------------------------------------------- // class FObject_protected @@ -138,6 +140,8 @@ class FObject_userEvent : public finalcut::FObject }; #pragma pack(pop) +} // namespace test + //---------------------------------------------------------------------- // class FObjectTest @@ -219,7 +223,7 @@ void FObjectTest::noArgumentTest() CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") ); CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() ); - FObject_protected t; + test::FObject_protected t; auto ev = new finalcut::FEvent(finalcut::fc::None_Event); CPPUNIT_ASSERT ( ! t.event(ev) ); delete ev; @@ -294,7 +298,7 @@ void FObjectTest::childObjectTest() //---------------------------------------------------------------------- void FObjectTest::widgetObjectTest() { - FObject_protected o; + test::FObject_protected o; CPPUNIT_ASSERT ( ! o.isWidget() ); o.setWidgetProperty (true); CPPUNIT_ASSERT ( o.isWidget() ); @@ -451,8 +455,8 @@ void FObjectTest::timerTest() using finalcut::operator +=; using finalcut::operator <; - FObject_protected t1; - FObject_protected t2; + test::FObject_protected t1; + test::FObject_protected t2; int id1, id2; CPPUNIT_ASSERT ( t1.getTimerList()->empty() ); id1 = t1.addTimer(300); @@ -552,7 +556,7 @@ void FObjectTest::timerTest() //---------------------------------------------------------------------- void FObjectTest::performTimerActionTest() { - FObject_protected t1; + test::FObject_protected t1; uInt num_events = 0; uInt loop = 0; t1.addTimer(100); @@ -569,7 +573,7 @@ void FObjectTest::performTimerActionTest() CPPUNIT_ASSERT ( num_events == 9 ); CPPUNIT_ASSERT ( t1.count == 9 ); - FObject_timer t2; + test::FObject_timer t2; CPPUNIT_ASSERT ( t2.getValue() == 0 ); finalcut::FTimerEvent timer_ev (finalcut::fc::Timer_Event, 1); @@ -582,7 +586,7 @@ void FObjectTest::performTimerActionTest() //---------------------------------------------------------------------- void FObjectTest::userEventTest() { - FObject_userEvent user; + test::FObject_userEvent user; CPPUNIT_ASSERT ( user.getValue() == 0 ); int n = 9; diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index f3f664a6..7c6d52fc 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -31,272 +31,12 @@ #include #include +#include #include #define CPPUNIT_ASSERT_CSTRING(expected, actual) \ check_c_string (expected, actual, CPPUNIT_SOURCELINE()) -static char* colorname[] = -{ - C_STR("0000/0000/0000"), // 0 - C_STR("bbbb/0000/0000"), // 1 - C_STR("0000/bbbb/0000"), // 2 - C_STR("bbbb/bbbb/0000"), // 3 - C_STR("0000/0000/bbbb"), // 4 - C_STR("bbbb/0000/bbbb"), // 5 - C_STR("0000/bbbb/bbbb"), // 6 - C_STR("bbbb/bbbb/bbbb"), // 7 - C_STR("5555/5555/5555"), // 8 - C_STR("ffff/5555/5555"), // 9 - C_STR("5555/ffff/5555"), // 10 - C_STR("ffff/ffff/5555"), // 11 - C_STR("5555/5555/ffff"), // 12 - C_STR("ffff/5555/ffff"), // 13 - C_STR("5555/ffff/ffff"), // 14 - C_STR("ffff/ffff/ffff"), // 15 - C_STR("0000/0000/0000"), // 16 - C_STR("0000/0000/5f5f"), // 17 - C_STR("0000/0000/8787"), // 18 - C_STR("0000/0000/afaf"), // 19 - C_STR("0000/0000/d7d7"), // 20 - C_STR("0000/0000/ffff"), // 21 - C_STR("0000/5f5f/0000"), // 22 - C_STR("0000/5f5f/5f5f"), // 23 - C_STR("0000/5f5f/8787"), // 24 - C_STR("0000/5f5f/afaf"), // 25 - C_STR("0000/5f5f/d7d7"), // 26 - C_STR("0000/5f5f/ffff"), // 27 - C_STR("0000/8787/0000"), // 28 - C_STR("0000/8787/5f5f"), // 29 - C_STR("0000/8787/8787"), // 30 - C_STR("0000/8787/afaf"), // 31 - C_STR("0000/8787/d7d7"), // 32 - C_STR("0000/8787/ffff"), // 33 - C_STR("0000/afaf/0000"), // 34 - C_STR("0000/afaf/5f5f"), // 35 - C_STR("0000/afaf/8787"), // 36 - C_STR("0000/afaf/afaf"), // 37 - C_STR("0000/afaf/d7d7"), // 38 - C_STR("0000/afaf/ffff"), // 39 - C_STR("0000/d7d7/0000"), // 40 - C_STR("0000/d7d7/5f5f"), // 41 - C_STR("0000/d7d7/8787"), // 42 - C_STR("0000/d7d7/afaf"), // 43 - C_STR("0000/d7d7/d7d7"), // 44 - C_STR("0000/d7d7/ffff"), // 45 - C_STR("0000/ffff/0000"), // 46 - C_STR("0000/ffff/5f5f"), // 47 - C_STR("0000/ffff/8787"), // 48 - C_STR("0000/ffff/afaf"), // 49 - C_STR("0000/ffff/d7d7"), // 50 - C_STR("0000/ffff/ffff"), // 51 - C_STR("5f5f/0000/0000"), // 52 - C_STR("5f5f/0000/5f5f"), // 53 - C_STR("5f5f/0000/8787"), // 54 - C_STR("5f5f/0000/afaf"), // 55 - C_STR("5f5f/0000/d7d7"), // 56 - C_STR("5f5f/0000/ffff"), // 57 - C_STR("5f5f/5f5f/0000"), // 58 - C_STR("5f5f/5f5f/5f5f"), // 59 - C_STR("5f5f/5f5f/8787"), // 60 - C_STR("5f5f/5f5f/afaf"), // 61 - C_STR("5f5f/5f5f/d7d7"), // 62 - C_STR("5f5f/5f5f/ffff"), // 63 - C_STR("5f5f/8787/0000"), // 64 - C_STR("5f5f/8787/5f5f"), // 65 - C_STR("5f5f/8787/8787"), // 66 - C_STR("5f5f/8787/afaf"), // 67 - C_STR("5f5f/8787/d7d7"), // 68 - C_STR("5f5f/8787/ffff"), // 69 - C_STR("5f5f/afaf/0000"), // 70 - C_STR("5f5f/afaf/5f5f"), // 71 - C_STR("5f5f/afaf/8787"), // 72 - C_STR("5f5f/afaf/afaf"), // 73 - C_STR("5f5f/afaf/d7d7"), // 74 - C_STR("5f5f/afaf/ffff"), // 75 - C_STR("5f5f/d7d7/0000"), // 76 - C_STR("5f5f/d7d7/5f5f"), // 77 - C_STR("5f5f/d7d7/8787"), // 78 - C_STR("5f5f/d7d7/afaf"), // 79 - C_STR("5f5f/d7d7/d7d7"), // 80 - C_STR("5f5f/d7d7/ffff"), // 81 - C_STR("5f5f/ffff/0000"), // 82 - C_STR("5f5f/ffff/5f5f"), // 83 - C_STR("5f5f/ffff/8787"), // 84 - C_STR("5f5f/ffff/afaf"), // 85 - C_STR("5f5f/ffff/d7d7"), // 86 - C_STR("5f5f/ffff/ffff"), // 87 - C_STR("8787/0000/0000"), // 88 - C_STR("8787/0000/5f5f"), // 89 - C_STR("8787/0000/8787"), // 90 - C_STR("8787/0000/afaf"), // 91 - C_STR("8787/0000/d7d7"), // 92 - C_STR("8787/0000/ffff"), // 93 - C_STR("8787/5f5f/0000"), // 94 - C_STR("8787/5f5f/5f5f"), // 95 - C_STR("8787/5f5f/8787"), // 96 - C_STR("8787/5f5f/afaf"), // 97 - C_STR("8787/5f5f/d7d7"), // 98 - C_STR("8787/5f5f/ffff"), // 99 - C_STR("8787/8787/0000"), // 100 - C_STR("8787/8787/5f5f"), // 101 - C_STR("8787/8787/8787"), // 102 - C_STR("8787/8787/afaf"), // 103 - C_STR("8787/8787/d7d7"), // 104 - C_STR("8787/8787/ffff"), // 105 - C_STR("8787/afaf/0000"), // 106 - C_STR("8787/afaf/5f5f"), // 107 - C_STR("8787/afaf/8787"), // 108 - C_STR("8787/afaf/afaf"), // 109 - C_STR("8787/afaf/d7d7"), // 110 - C_STR("8787/afaf/ffff"), // 111 - C_STR("8787/d7d7/0000"), // 112 - C_STR("8787/d7d7/5f5f"), // 113 - C_STR("8787/d7d7/8787"), // 114 - C_STR("8787/d7d7/afaf"), // 115 - C_STR("8787/d7d7/d7d7"), // 116 - C_STR("8787/d7d7/ffff"), // 117 - C_STR("8787/ffff/0000"), // 118 - C_STR("8787/ffff/5f5f"), // 119 - C_STR("8787/ffff/8787"), // 120 - C_STR("8787/ffff/afaf"), // 121 - C_STR("8787/ffff/d7d7"), // 122 - C_STR("8787/ffff/ffff"), // 123 - C_STR("afaf/0000/0000"), // 124 - C_STR("afaf/0000/5f5f"), // 125 - C_STR("afaf/0000/8787"), // 126 - C_STR("afaf/0000/afaf"), // 127 - C_STR("afaf/0000/d7d7"), // 128 - C_STR("afaf/0000/ffff"), // 129 - C_STR("afaf/5f5f/0000"), // 130 - C_STR("afaf/5f5f/5f5f"), // 131 - C_STR("afaf/5f5f/8787"), // 132 - C_STR("afaf/5f5f/afaf"), // 133 - C_STR("afaf/5f5f/d7d7"), // 134 - C_STR("afaf/5f5f/ffff"), // 135 - C_STR("afaf/8787/0000"), // 136 - C_STR("afaf/8787/5f5f"), // 137 - C_STR("afaf/8787/8787"), // 138 - C_STR("afaf/8787/afaf"), // 139 - C_STR("afaf/8787/d7d7"), // 140 - C_STR("afaf/8787/ffff"), // 141 - C_STR("afaf/afaf/0000"), // 142 - C_STR("afaf/afaf/5f5f"), // 143 - C_STR("afaf/afaf/8787"), // 144 - C_STR("afaf/afaf/afaf"), // 145 - C_STR("afaf/afaf/d7d7"), // 146 - C_STR("afaf/afaf/ffff"), // 147 - C_STR("afaf/d7d7/0000"), // 148 - C_STR("afaf/d7d7/5f5f"), // 149 - C_STR("afaf/d7d7/8787"), // 150 - C_STR("afaf/d7d7/afaf"), // 151 - C_STR("afaf/d7d7/d7d7"), // 152 - C_STR("afaf/d7d7/ffff"), // 153 - C_STR("afaf/ffff/0000"), // 154 - C_STR("afaf/ffff/5f5f"), // 155 - C_STR("afaf/ffff/8787"), // 156 - C_STR("afaf/ffff/afaf"), // 157 - C_STR("afaf/ffff/d7d7"), // 158 - C_STR("afaf/ffff/ffff"), // 159 - C_STR("d7d7/0000/0000"), // 160 - C_STR("d7d7/0000/5f5f"), // 161 - C_STR("d7d7/0000/8787"), // 162 - C_STR("d7d7/0000/afaf"), // 163 - C_STR("d7d7/0000/d7d7"), // 164 - C_STR("d7d7/0000/ffff"), // 165 - C_STR("d7d7/5f5f/0000"), // 166 - C_STR("d7d7/5f5f/5f5f"), // 167 - C_STR("d7d7/5f5f/8787"), // 168 - C_STR("d7d7/5f5f/afaf"), // 169 - C_STR("d7d7/5f5f/d7d7"), // 170 - C_STR("d7d7/5f5f/ffff"), // 171 - C_STR("d7d7/8787/0000"), // 172 - C_STR("d7d7/8787/5f5f"), // 173 - C_STR("d7d7/8787/8787"), // 174 - C_STR("d7d7/8787/afaf"), // 175 - C_STR("d7d7/8787/d7d7"), // 176 - C_STR("d7d7/8787/ffff"), // 177 - C_STR("d7d7/afaf/0000"), // 178 - C_STR("d7d7/afaf/5f5f"), // 179 - C_STR("d7d7/afaf/8787"), // 180 - C_STR("d7d7/afaf/afaf"), // 181 - C_STR("d7d7/afaf/d7d7"), // 182 - C_STR("d7d7/afaf/ffff"), // 183 - C_STR("d7d7/d7d7/0000"), // 184 - C_STR("d7d7/d7d7/5f5f"), // 185 - C_STR("d7d7/d7d7/8787"), // 186 - C_STR("d7d7/d7d7/afaf"), // 187 - C_STR("d7d7/d7d7/d7d7"), // 188 - C_STR("d7d7/d7d7/ffff"), // 189 - C_STR("d7d7/ffff/0000"), // 190 - C_STR("d7d7/ffff/5f5f"), // 191 - C_STR("d7d7/ffff/8787"), // 192 - C_STR("d7d7/ffff/afaf"), // 193 - C_STR("d7d7/ffff/d7d7"), // 194 - C_STR("d7d7/ffff/ffff"), // 195 - C_STR("ffff/0000/0000"), // 196 - C_STR("ffff/0000/5f5f"), // 197 - C_STR("ffff/0000/8787"), // 198 - C_STR("ffff/0000/afaf"), // 199 - C_STR("ffff/0000/d7d7"), // 200 - C_STR("ffff/0000/ffff"), // 201 - C_STR("ffff/5f5f/0000"), // 202 - C_STR("ffff/5f5f/5f5f"), // 203 - C_STR("ffff/5f5f/8787"), // 204 - C_STR("ffff/5f5f/afaf"), // 205 - C_STR("ffff/5f5f/d7d7"), // 206 - C_STR("ffff/5f5f/ffff"), // 207 - C_STR("ffff/8787/0000"), // 208 - C_STR("ffff/8787/5f5f"), // 209 - C_STR("ffff/8787/8787"), // 210 - C_STR("ffff/8787/afaf"), // 211 - C_STR("ffff/8787/d7d7"), // 212 - C_STR("ffff/8787/ffff"), // 213 - C_STR("ffff/afaf/0000"), // 214 - C_STR("ffff/afaf/5f5f"), // 215 - C_STR("ffff/afaf/8787"), // 216 - C_STR("ffff/afaf/afaf"), // 217 - C_STR("ffff/afaf/d7d7"), // 218 - C_STR("ffff/afaf/ffff"), // 219 - C_STR("ffff/d7d7/0000"), // 220 - C_STR("ffff/d7d7/5f5f"), // 221 - C_STR("ffff/d7d7/8787"), // 222 - C_STR("ffff/d7d7/afaf"), // 223 - C_STR("ffff/d7d7/d7d7"), // 224 - C_STR("ffff/d7d7/ffff"), // 225 - C_STR("ffff/ffff/0000"), // 226 - C_STR("ffff/ffff/5f5f"), // 227 - C_STR("ffff/ffff/8787"), // 228 - C_STR("ffff/ffff/afaf"), // 229 - C_STR("ffff/ffff/d7d7"), // 230 - C_STR("ffff/ffff/ffff"), // 231 - C_STR("0808/0808/0808"), // 232 - C_STR("1212/1212/1212"), // 233 - C_STR("1c1c/1c1c/1c1c"), // 234 - C_STR("2626/2626/2626"), // 235 - C_STR("3030/3030/3030"), // 236 - C_STR("3a3a/3a3a/3a3a"), // 237 - C_STR("4444/4444/4444"), // 238 - C_STR("4e4e/4e4e/4e4e"), // 239 - C_STR("5858/5858/5858"), // 240 - C_STR("6262/6262/6262"), // 241 - C_STR("6c6c/6c6c/6c6c"), // 242 - C_STR("7676/7676/7676"), // 243 - C_STR("8080/8080/8080"), // 244 - C_STR("8a8a/8a8a/8a8a"), // 245 - C_STR("9494/9494/9494"), // 246 - C_STR("9e9e/9e9e/9e9e"), // 247 - C_STR("a8a8/a8a8/a8a8"), // 248 - C_STR("b2b2/b2b2/b2b2"), // 249 - C_STR("bcbc/bcbc/bcbc"), // 250 - C_STR("c6c6/c6c6/c6c6"), // 251 - C_STR("d0d0/d0d0/d0d0"), // 252 - C_STR("dada/dada/dada"), // 253 - C_STR("e4e4/e4e4/e4e4"), // 254 - C_STR("eeee/eeee/eeee"), // 255 - 0 -}; - //---------------------------------------------------------------------- void check_c_string ( const char* s1 , const char* s2 @@ -319,34 +59,9 @@ void check_c_string ( const char* s1 #pragma pack(push) #pragma pack(1) -class FTermDetectionTest : public CPPUNIT_NS::TestFixture +class FTermDetectionTest : public CPPUNIT_NS::TestFixture, test::ConEmu { public: - // Enumeration - enum console - { - ansi, - xterm, - rxvt, - urxvt, - mlterm, - putty, - kde_konsole, - gnome_terminal, - newer_vte_terminal, - kterm, - tera_term, - cygwin, - mintty, - linux_con, - freebsd_con, - netbsd_con, - openbsd_con, - sun_con, - screen, - tmux - }; - FTermDetectionTest(); ~FTermDetectionTest(); @@ -375,23 +90,6 @@ class FTermDetectionTest : public CPPUNIT_NS::TestFixture void ttytypeTest(); private: - char* getAnswerback (console); - char* getDSR (console); - char* getDECID (console); - char* getDA (console); - char* getDA1 (console); - char* getSEC_DA (console); - void debugOutput(); - bool openMasterPTY(); - bool openSlavePTY(); - void closeMasterPTY(); - void closeSlavePTY(); - void closeStandardStreams(); - pid_t forkProcess(); - bool isChildProcess (pid_t); - void terminalSimulation (console); - void parseTerminalBuffer (std::size_t, console); - // Adds code needed to register the test suite CPPUNIT_TEST_SUITE (FTermDetectionTest); @@ -421,44 +119,16 @@ class FTermDetectionTest : public CPPUNIT_NS::TestFixture // End of test suite definition CPPUNIT_TEST_SUITE_END(); - - // Data Members - int fd_stdin{fileno(stdin)}; - int fd_stdout{fileno(stdout)}; - int fd_stderr{fileno(stderr)}; - int fd_master{-1}; - int fd_slave{-1}; - bool debug{false}; - char buffer[2048]{}; - static bool* shared_state; - }; #pragma pack(pop) -// static class attributes -bool* FTermDetectionTest::shared_state = nullptr; - //---------------------------------------------------------------------- FTermDetectionTest::FTermDetectionTest() -{ - // Map shared memory - void* ptr = mmap ( NULL - , sizeof(*shared_state) - , PROT_READ | PROT_WRITE - , MAP_SHARED | MAP_ANONYMOUS, -1 - , 0 ); - shared_state = static_cast(ptr); - *shared_state = false; -} +{ } //---------------------------------------------------------------------- FTermDetectionTest::~FTermDetectionTest() -{ - closeMasterPTY(); - closeSlavePTY(); - // Unmap shared memory - munmap (shared_state, sizeof(*shared_state)); -} +{ } //---------------------------------------------------------------------- void FTermDetectionTest::classNameTest() @@ -476,9 +146,9 @@ void FTermDetectionTest::ansiTest() setenv ("TERM", "ansi", 1); data.setTermFileName(C_STR("ansi")); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "ansi", 1); unsetenv("TERMCAP"); @@ -523,14 +193,14 @@ void FTermDetectionTest::ansiTest() CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (ansi); + // Start the terminal emulation + startConEmuTerminal (ConEmu::ansi); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -545,9 +215,9 @@ void FTermDetectionTest::xtermTest() data.setTermFileName(C_STR("xterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm", 1); setenv ("XTERM_VERSION", "XTerm(312)", 1); @@ -584,14 +254,14 @@ void FTermDetectionTest::xtermTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (xterm); + // Start the terminal emulation + startConEmuTerminal (ConEmu::xterm); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -606,9 +276,9 @@ void FTermDetectionTest::rxvtTest() data.setTermFileName(C_STR("rxvt-cygwin-native")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "rxvt-cygwin-native", 1); setenv ("COLORTERM", "rxvt-xpm", 1); @@ -646,14 +316,14 @@ void FTermDetectionTest::rxvtTest() CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("rxvt-cygwin-native") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (rxvt); + // Start the terminal emulation + startConEmuTerminal (ConEmu::rxvt); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -668,9 +338,9 @@ void FTermDetectionTest::urxvtTest() data.setTermFileName(C_STR("rxvt-unicode-256color")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "rxvt-unicode-256color", 1); setenv ("COLORTERM", "rxvt-xpm", 1); @@ -707,14 +377,14 @@ void FTermDetectionTest::urxvtTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (urxvt); + // Start the terminal emulation + startConEmuTerminal (ConEmu::urxvt); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -729,9 +399,9 @@ void FTermDetectionTest::mltermTest() data.setTermFileName(C_STR("mlterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "mlterm", 1); setenv ("MLTERM", "3.8.4", 1); @@ -776,14 +446,14 @@ void FTermDetectionTest::mltermTest() CPPUNIT_ASSERT ( detect.canDisplay256Colors() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("xterm-256color") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (mlterm); + // Start the terminal emulation + startConEmuTerminal (ConEmu::mlterm); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -798,9 +468,9 @@ void FTermDetectionTest::puttyTest() data.setTermFileName(C_STR("xterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm", 1); unsetenv("TERMCAP"); @@ -837,15 +507,15 @@ void FTermDetectionTest::puttyTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - debug = true; - debugOutput(); - closeStandardStreams(); + enableConEmuDebug(true); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (putty); + // Start the terminal emulation + startConEmuTerminal (ConEmu::putty); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -860,9 +530,9 @@ void FTermDetectionTest::kdeKonsoleTest() data.setTermFileName(C_STR("xterm-256color")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm-256color", 1); setenv ("COLORTERM", "truecolor", 1); @@ -899,14 +569,14 @@ void FTermDetectionTest::kdeKonsoleTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (kde_konsole); + // Start the terminal emulation + startConEmuTerminal (ConEmu::kde_konsole); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -921,9 +591,9 @@ void FTermDetectionTest::gnomeTerminalTest() data.setTermFileName(C_STR("xterm-256color")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm-256color", 1); setenv ("COLORTERM", "truecolor", 1); @@ -961,14 +631,14 @@ void FTermDetectionTest::gnomeTerminalTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (gnome_terminal); + // Start the terminal emulation + startConEmuTerminal (ConEmu::gnome_terminal); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -983,9 +653,9 @@ void FTermDetectionTest::newerVteTerminalTest() data.setTermFileName(C_STR("xterm-256color")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm-256color", 1); setenv ("COLORTERM", "truecolor", 1); @@ -1023,14 +693,14 @@ void FTermDetectionTest::newerVteTerminalTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (newer_vte_terminal); + // Start the terminal emulation + startConEmuTerminal (ConEmu::newer_vte_terminal); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1045,9 +715,9 @@ void FTermDetectionTest::ktermTest() data.setTermFileName(C_STR("kterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "kterm", 1); unsetenv("TERMCAP"); @@ -1092,14 +762,14 @@ void FTermDetectionTest::ktermTest() CPPUNIT_ASSERT ( ! detect.isKtermTerminal() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (kterm); + // Start the terminal emulation + startConEmuTerminal (ConEmu::kterm); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1114,9 +784,9 @@ void FTermDetectionTest::teraTermTest() data.setTermFileName(C_STR("xterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm", 1); unsetenv("TERMCAP"); @@ -1154,14 +824,14 @@ void FTermDetectionTest::teraTermTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (tera_term); + // Start the terminal emulation + startConEmuTerminal (ConEmu::tera_term); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1176,9 +846,9 @@ void FTermDetectionTest::cygwinTest() data.setTermFileName(C_STR("cygwin")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "cygwin", 1); unsetenv("TERMCAP"); @@ -1216,14 +886,14 @@ void FTermDetectionTest::cygwinTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (cygwin); + // Start the terminal emulation + startConEmuTerminal (ConEmu::cygwin); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1238,9 +908,9 @@ void FTermDetectionTest::minttyTest() data.setTermFileName(C_STR("xterm-256color")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm-256color", 1); unsetenv("TERMCAP"); @@ -1278,14 +948,14 @@ void FTermDetectionTest::minttyTest() CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (mintty); + // Start the terminal emulation + startConEmuTerminal (ConEmu::mintty); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1300,9 +970,9 @@ void FTermDetectionTest::linuxTest() data.setTermFileName(C_STR("linux")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "linux", 1); unsetenv("TERMCAP"); @@ -1347,14 +1017,14 @@ void FTermDetectionTest::linuxTest() CPPUNIT_ASSERT ( ! detect.isLinuxTerm() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (linux_con); + // Start the terminal emulation + startConEmuTerminal (ConEmu::linux_con); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1369,9 +1039,9 @@ void FTermDetectionTest::freebsdTest() data.setTermFileName(C_STR("xterm")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "xterm", 1); unsetenv("TERMCAP"); @@ -1419,14 +1089,14 @@ void FTermDetectionTest::freebsdTest() CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (freebsd_con); + // Start the terminal emulation + startConEmuTerminal (ConEmu::freebsd_con); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1441,9 +1111,9 @@ void FTermDetectionTest::netbsdTest() data.setTermFileName(C_STR("wsvt25")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "wsvt25", 1); unsetenv("TERMCAP"); @@ -1489,14 +1159,14 @@ void FTermDetectionTest::netbsdTest() CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (netbsd_con); + // Start the terminal emulation + startConEmuTerminal (ConEmu::netbsd_con); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1511,9 +1181,9 @@ void FTermDetectionTest::openbsdTest() data.setTermFileName(C_STR("vt220")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "vt220", 1); unsetenv("TERMCAP"); @@ -1559,14 +1229,14 @@ void FTermDetectionTest::openbsdTest() CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (openbsd_con); + // Start the terminal emulation + startConEmuTerminal (ConEmu::openbsd_con); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1580,9 +1250,9 @@ void FTermDetectionTest::sunTest() finalcut::FTermDetection detect; data.setTermFileName(C_STR("sun-color")); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "sun-color", 1); unsetenv("TERMCAP"); @@ -1627,14 +1297,14 @@ void FTermDetectionTest::sunTest() CPPUNIT_ASSERT ( ! detect.isSunTerminal() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (sun_con); + // Start the terminal emulation + startConEmuTerminal (ConEmu::sun_con); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1649,9 +1319,9 @@ void FTermDetectionTest::screenTest() data.setTermFileName(C_STR("screen")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "screen", 1); setenv ("TERMCAP", "SC|screen|VT 100/ANSI X3.64 virtual terminal:...", 1); @@ -1695,14 +1365,14 @@ void FTermDetectionTest::screenTest() CPPUNIT_ASSERT ( detect.canDisplay256Colors() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("screen-256color") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (screen); + // Start the terminal emulation + startConEmuTerminal (ConEmu::screen); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1717,9 +1387,9 @@ void FTermDetectionTest::tmuxTest() data.setTermFileName(C_STR("screen")); detect.setTerminalDetection(true); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { setenv ("TERM", "screen", 1); setenv ("TMUX", "/tmp/tmux-1000/default,7844,0", 1); @@ -1764,14 +1434,14 @@ void FTermDetectionTest::tmuxTest() CPPUNIT_ASSERT ( detect.canDisplay256Colors() ); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("screen-256color") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { // Start the terminal simulation - terminalSimulation (tmux); + startConEmuTerminal (ConEmu::tmux); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1821,9 +1491,9 @@ void FTermDetectionTest::ttytypeTest() detect.setTerminalDetection(true); detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype")); - pid_t pid = forkProcess(); + pid_t pid = forkConEmu(); - if ( isChildProcess(pid) ) + if ( isConEmuChildProcess(pid) ) { unsetenv("TERM"); unsetenv("TERMCAP"); @@ -1851,14 +1521,14 @@ void FTermDetectionTest::ttytypeTest() detect.detect(); CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), C_STR("vt100") ); - debugOutput(); - closeStandardStreams(); + printConEmuDebug(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } else // Parent { - // Start the terminal simulation - terminalSimulation (ansi); + // Start the terminal emulation + startConEmuTerminal (ConEmu::ansi); if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; @@ -1870,679 +1540,6 @@ void FTermDetectionTest::ttytypeTest() } -// private methods of FOptiMoveTest -//---------------------------------------------------------------------- -char* FTermDetectionTest::getAnswerback (console con) -{ - static char* Answerback[] = - { - 0, // Ansi, - 0, // XTerm - 0, // Rxvt - 0, // Urxvt - 0, // mlterm - Multi Lingual TERMinal - C_STR("PuTTY"), // PuTTY - 0, // KDE Konsole - 0, // GNOME Terminal - 0, // VTE Terminal >= 0.53.0 - 0, // kterm, - 0, // Tera Term - 0, // Cygwin - 0, // Mintty - 0, // Linux console - 0, // FreeBSD console - 0, // NetBSD console - 0, // OpenBSD console - 0, // Sun console - 0, // screen - 0 // tmux - }; - - return Answerback[con]; -} - -//---------------------------------------------------------------------- -char* FTermDetectionTest::getDSR (console con) -{ - static char* DSR[] = - { - 0, // Ansi, - C_STR("\033[0n"), // XTerm - C_STR("\033[0n"), // Rxvt - C_STR("\033[0n"), // Urxvt - C_STR("\033[0n"), // mlterm - Multi Lingual TERMinal - C_STR("\033[0n"), // PuTTY - C_STR("\033[0n"), // KDE Konsole - C_STR("\033[0n"), // GNOME Terminal - C_STR("\033[0n"), // VTE Terminal >= 0.53.0 - C_STR("\033[0n"), // kterm, - C_STR("\033[0n"), // Tera Term - 0, // Cygwin - C_STR("\033[0n"), // Mintty - C_STR("\033[0n"), // Linux console - C_STR("\033[0n"), // FreeBSD console - C_STR("\033[0n"), // NetBSD console - C_STR("\033[0n"), // OpenBSD console - 0, // Sun console - C_STR("\033[0n"), // screen - C_STR("\033[0n") // tmux - }; - - return DSR[con]; -} - -//---------------------------------------------------------------------- -char* FTermDetectionTest::getDECID (console con) -{ - static char* DECID[] = - { - 0, // Ansi, - C_STR("\033[?63;1;2;6;4;6;9;15;22c"), // XTerm - C_STR("\033[?1;2c"), // Rxvt - C_STR("\033[?1;2c"), // Urxvt - C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal - C_STR("\033[?6c"), // PuTTY - C_STR("\033[?1;2c"), // KDE Konsole - C_STR("\033[?62;c"), // GNOME Terminal - C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 - C_STR("\033[?1;2c"), // kterm, - C_STR("\033[?1;2c"), // Tera Term - 0, // Cygwin - C_STR("\033[?1;2;6;22c"), // Mintty - C_STR("\033[?6c"), // Linux console - 0, // FreeBSD console - 0, // NetBSD console - 0, // OpenBSD console - 0, // Sun console - C_STR("\033[?1;2c"), // screen - 0 // tmux - }; - - return DECID[con]; -} - -//---------------------------------------------------------------------- -char* FTermDetectionTest::getDA (console con) -{ - static char* DA[] = - { - 0, // Ansi, - C_STR("\033[?63;1;2;6;4;6;9;15;22c"), // XTerm - C_STR("\033[?1;2c"), // Rxvt - C_STR("\033[?1;2c"), // Urxvt - C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal - C_STR("\033[?6c"), // PuTTY - C_STR("\033[?1;2c"), // KDE Konsole - C_STR("\033[?62;c"), // GNOME Terminal - C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 - C_STR("\033[?1;2c"), // kterm, - C_STR("\033[?1;2c"), // Tera Term - C_STR("\033[?6c"), // Cygwin - C_STR("\033[?1;2;6;22c"), // Mintty - C_STR("\033[?6c"), // Linux console - C_STR("\033[?1;2c"), // FreeBSD console - C_STR("\033[?62;6c"), // NetBSD console - C_STR("\033[?62;6c"), // OpenBSD console - 0, // Sun console - C_STR("\033[?1;2c"), // screen - C_STR("\033[?1;2c") // tmux - }; - - return DA[con]; -} - -//---------------------------------------------------------------------- -char* FTermDetectionTest::getDA1 (console con) -{ - static char* DA1[] = - { - 0, // Ansi, - 0, // XTerm - C_STR("\033[?1;2c"), // Rxvt - C_STR("\033[?1;2c"), // Urxvt - C_STR("\033[?63;1;2;3;4;7;29c"), // mlterm - Multi Lingual TERMinal - C_STR("\033[?6c"), // PuTTY - C_STR("\033[?1;2c"), // KDE Konsole - C_STR("\033[?62;c"), // GNOME Terminal - C_STR("\033[?65;1;9c"), // VTE Terminal >= 0.53.0 - 0, // kterm, - C_STR("\033[?1;2c"), // Tera Term - C_STR("\033[?6c"), // Cygwin - C_STR("\033[?1;2;6;22c"), // Mintty - 0, // Linux console - 0, // FreeBSD console - 0, // NetBSD console - 0, // OpenBSD console - 0, // Sun console - 0, // screen - 0 // tmux - }; - - return DA1[con]; -} - -//---------------------------------------------------------------------- -char* FTermDetectionTest::getSEC_DA (console con) -{ - static char* SEC_DA[] = - { - 0, // Ansi, - C_STR("\033[>19;312;0c"), // XTerm - C_STR("\033[>82;20710;0c"), // Rxvt - C_STR("\033[>85;95;0c"), // Urxvt - C_STR("\033[>24;279;0c"), // mlterm - Multi Lingual TERMinal - C_STR("\033[>0;136;0c"), // PuTTY - C_STR("\033[>0;115;0c"), // KDE Konsole - C_STR("\033[>1;5202;0c"), // GNOME Terminal - C_STR("\033[>65;5300;1c"), // VTE Terminal >= 0.53.0 - C_STR("\033[?1;2c"), // kterm, - C_STR("\033[>32;278;0c"), // Tera Term - C_STR("\033[>67;200502;0c"), // Cygwin - C_STR("\033[>77;20402;0c"), // Mintty - 0, // Linux console - 0, // FreeBSD console - 0, // NetBSD console - 0, // OpenBSD console - 0, // Sun console - C_STR("\033[>83;40201;0c"), // screen - C_STR("\033[>84;0;0c") // tmux - }; - - return SEC_DA[con]; -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::debugOutput() -{ - if ( ! debug ) - return; - - setenv ("DSR", "\\033[5n", 1); - setenv ("CURSOR_POS", "\\033[6n", 1); - setenv ("DECID", "\\033Z", 1); - setenv ("DA", "\\033[c", 1); - setenv ("DA1", "\\033[1c", 1); - setenv ("SEC_DA", "\\033[>c", 1); - setenv ("ANSWERBACK", "\\005", 1); - setenv ("TITLE", "\\033[21t", 1); - setenv ("COLOR16", "\\033]4;15;?\\a", 1); - setenv ("COLOR88", "\\033]4;87;?\\a", 1); - setenv ("COLOR256", "\\033]4;254;?\\a", 1); - - setenv ("GO_MIDDLE", "\\033[80D\\033[15C", 1); - setenv ("GO_RIGHT", "\\033[79D\\033[40C", 1); - - finalcut::FString line (69, '-'); - std::cout << std::endl << line << std::endl; - std::cout << "Probe Escape sequence Reply"; - std::cout << std::endl << line << std::endl; - - // Command line - constexpr char debug_command[] = "/bin/bash -c ' \ - for i in DSR CURSOR_POS DECID DA DA1 SEC_DA ANSWERBACK \ - TITLE COLOR16 COLOR88 COLOR256; \ - do \ - eval \"echo -en \\\"$i${GO_MIDDLE}\\\"; \ - echo -n \\\"\\${$i}\\\"; \ - echo -en \\\"${GO_RIGHT}\\${$i}\\\"\"; \ - sleep 0.5; \ - echo -e \"\\r\"; \ - done'"; - system(debug_command); -} - -//---------------------------------------------------------------------- -bool FTermDetectionTest::openMasterPTY() -{ - int result; - - // Open a pseudoterminal device - fd_master = posix_openpt(O_RDWR); - - if ( fd_master < 0 ) - return false; - - // Change the slave pseudoterminal access rights - result = grantpt(fd_master); - - if ( result != 0 ) - return false; - - // Unlock the pseudoterminal master/slave pair - result = unlockpt(fd_master); - - if ( result != 0 ) - return false; - - return true; -} - -//---------------------------------------------------------------------- -bool FTermDetectionTest::openSlavePTY() -{ - closeSlavePTY(); - - // Get PTY filename - const char* pty_name = ptsname(fd_master); - - if ( pty_name == 0 ) - return false; - - // Open the slave PTY - fd_slave = open(pty_name, O_RDWR); - - if ( fd_slave < 0 ) - return false; - - return true; -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::closeMasterPTY() -{ - if ( fd_master <= 0 ) - return; - - close (fd_master); - fd_master = -1; -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::closeSlavePTY() -{ - if ( fd_slave <= 0 ) - return; - - close (fd_slave); - fd_slave = -1; -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::closeStandardStreams() -{ - close(fd_stdin); // stdin - close(fd_stdout); // stdout - close(fd_stderr); // stderr -} - -//---------------------------------------------------------------------- -pid_t FTermDetectionTest::forkProcess() -{ - // Initialize buffer with '\0' - std::fill_n (buffer, sizeof(buffer), '\0'); - - if ( ! openMasterPTY() ) - return -1; - - if ( ! openSlavePTY() ) - return -1; - - pid_t pid = fork(); // Create a child process - - if ( pid < 0) // Fork failed - return -1; - - if ( isChildProcess(pid) ) // Child process - { - struct termios term_settings; - closeMasterPTY(); - - // Creates a session and makes the current process to the leader - setsid(); - -#ifdef TIOCSCTTY - // Set controlling tty - if ( ioctl(fd_slave, TIOCSCTTY, 0) == -1 ) - { - *shared_state = true; - return -1; - } -#endif - - // Get current terminal settings - if ( tcgetattr(fd_slave, &term_settings) == -1 ) - { - *shared_state = true; - return -1; - } - - // Set raw mode on the slave side of the PTY - cfmakeraw (&term_settings); - tcsetattr (fd_slave, TCSANOW, &term_settings); - -#ifdef TIOCSWINSZ - // Set slave tty window size - struct winsize size; - size.ws_row = 25; - size.ws_col = 80; - - if ( ioctl(fd_slave, TIOCSWINSZ, &size) == -1) - { - *shared_state = true; - return -1; - } -#endif - - closeStandardStreams(); - - fd_stdin = dup(fd_slave); // PTY becomes stdin (0) - fd_stdout = dup(fd_slave); // PTY becomes stdout (1) - fd_stderr = dup(fd_slave); // PTY becomes stderr (2) - - closeSlavePTY(); - - // The child process is now ready for input - *shared_state = true; - } - else - { - constexpr int timeout = 150; // 1.5 seconds - int i = 0; - - // Wait until the child process is ready for input - while ( ! *shared_state && i < timeout ) - { - // Wait 10 ms (= 10,000,000 ns) - nanosleep ((const struct timespec[]){{0, 10000000L}}, NULL); - i++; - } - - *shared_state = false; - } - - return pid; -} - -//---------------------------------------------------------------------- -inline bool FTermDetectionTest::isChildProcess (pid_t pid) -{ - return bool( pid == 0 ); -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::terminalSimulation (console con) -{ - closeSlavePTY(); - - while ( 1 ) - { - fd_set ifds; - struct timeval tv; - ssize_t len; - - FD_ZERO(&ifds); - FD_SET(fd_stdin, &ifds); - FD_SET(fd_master, &ifds); - tv.tv_sec = 0; - tv.tv_usec = 750000; // 750 ms - - // Wait for data from stdin or the master side of PTY - if ( select(fd_master + 1, &ifds, 0, 0, &tv) < 0 ) - break; - - // Data on standard input - if ( FD_ISSET(fd_stdin, &ifds) ) - { - len = read (fd_stdin, buffer, sizeof(buffer)); - - if ( len > 0 && std::size_t(len) < sizeof(buffer) ) - { - buffer[len] = '\0'; - write (fd_master, buffer, len); // Send data to the master side - } - } - - // Data on the master side of PTY - if ( FD_ISSET(fd_master, &ifds) ) - { - len = read (fd_master, buffer, sizeof(buffer)); - - if ( len == -1 || std::size_t(len) >= sizeof(buffer) ) - break; - else if ( len > 0 ) - { - buffer[len] = '\0'; - parseTerminalBuffer (len, con); - } - } - } -} - -//---------------------------------------------------------------------- -void FTermDetectionTest::parseTerminalBuffer (std::size_t length, console con) -{ - for (std::size_t i = 0; i < length; i++) - { - if ( buffer[i] == ENQ[0] ) // Enquiry character - { - char* answer = getAnswerback(con); - - if ( answer ) - write(fd_master, answer, std::strlen(answer)); - } - else if ( i < length - 1 // Terminal ID (DECID) - && buffer[i] == '\033' - && buffer[i + 1] == 'Z' ) - { - char* DECID = getDECID(con); - - if ( DECID ) - write (fd_master, DECID, std::strlen(DECID)); - - i += 2; - } - else if ( i < length - 3 // Device status report (DSR) - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == '5' - && buffer[i + 3] == 'n' ) - { - char* DSR = getDSR(con); - - if ( DSR ) - write (fd_master, DSR, std::strlen(DSR)); - - i += 4; - } - else if ( i < length - 3 // Report cursor position (CPR) - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == '6' - && buffer[i + 3] == 'n' ) - { - write (fd_master, "\033[25;80R", 8); // row 25 ; column 80 - i += 4; - } - else if ( i < length - 2 // Device attributes (DA) - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == 'c' ) - { - char* DA = getDA(con); - - if ( DA ) - write (fd_master, DA, std::strlen(DA)); - - i += 3; - } - else if ( i < length - 3 // Device attributes (DA1) - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == '1' - && buffer[i + 3] == 'c' ) - { - char* DA1 = getDA1(con); - - if ( DA1 ) - write (fd_master, DA1, std::strlen(DA1)); - i += 4; - } - else if ( i < length - 3 // Secondary device attributes (SEC_DA) - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == '>' - && buffer[i + 3] == 'c' ) - { - char* SEC_DA = getSEC_DA(con); - - if ( SEC_DA ) - write (fd_master, SEC_DA, std::strlen(SEC_DA)); - - i += 4; - } - else if ( i < length - 4 // Report xterm window's title - && buffer[i] == '\033' - && buffer[i + 1] == '[' - && buffer[i + 2] == '2' - && buffer[i + 3] == '1' - && buffer[i + 4] == 't' ) - { - if ( con == urxvt ) - write (fd_master, "\033]l", 3); - else if ( con == tera_term ) - write (fd_master, "\033]l\033\\", 5); - else if ( con == screen ) - write (fd_master, "\033]lbash\033\\", 9); - else if ( con != ansi - && con != rxvt - && con != mlterm - && con != kde_konsole - && con != kterm - && con != cygwin - && con != mintty - && con != linux_con - && con != freebsd_con - && con != netbsd_con - && con != openbsd_con - && con != sun_con - && con != tmux ) - write (fd_master, "\033]lTITLE\033\\", 10); - - i += 5; - } - else if ( i < length - 7 // Get xterm color name 0-9 - && buffer[i] == '\033' - && buffer[i + 1] == ']' - && buffer[i + 2] == '4' - && buffer[i + 3] == ';' - && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' - && buffer[i + 5] == ';' - && buffer[i + 6] == '?' - && buffer[i + 7] == '\a' ) - { - if ( con != ansi - && con != rxvt - && con != kde_konsole - && con != kterm - && con != cygwin - && con != mintty - && con != linux_con - && con != freebsd_con - && con != netbsd_con - && con != openbsd_con - && con != sun_con - && con != screen - && con != tmux ) - { - int n = buffer[i + 4] - '0'; - write (fd_master, "\033]4;", 4); - write (fd_master, &buffer[i + 4], 1); - write (fd_master, ";rgb:", 5); - write (fd_master, colorname[n], 14); - write (fd_master, "\a", 1); - } - - i += 8; - } - else if ( i < length - 8 // Get xterm color name 0-9 - && buffer[i] == '\033' - && buffer[i + 1] == ']' - && buffer[i + 2] == '4' - && buffer[i + 3] == ';' - && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' - && buffer[i + 5] >= '0' && buffer[i + 5] <= '9' - && buffer[i + 6] == ';' - && buffer[i + 7] == '?' - && buffer[i + 8] == '\a' ) - { - if ( con != ansi - && con != rxvt - && con != kde_konsole - && con != kterm - && con != cygwin - && con != mintty - && con != linux_con - && con != freebsd_con - && con != netbsd_con - && con != openbsd_con - && con != sun_con - && con != screen - && con != tmux ) - { - int n = (buffer[i + 4] - '0') * 10 - + (buffer[i + 5] - '0'); - write (fd_master, "\033]4;", 4); - write (fd_master, &buffer[i + 4], 1); - write (fd_master, &buffer[i + 5], 1); - write (fd_master, ";rgb:", 5); - write (fd_master, colorname[n], 14); - write (fd_master, "\a", 1); - } - - i += 9; - } - else if ( i < length - 9 // Get xterm color name 0-9 - && buffer[i] == '\033' - && buffer[i + 1] == ']' - && buffer[i + 2] == '4' - && buffer[i + 3] == ';' - && buffer[i + 4] >= '0' && buffer[i + 4] <= '9' - && buffer[i + 5] >= '0' && buffer[i + 5] <= '9' - && buffer[i + 6] >= '0' && buffer[i + 6] <= '9' - && buffer[i + 7] == ';' - && buffer[i + 8] == '?' - && buffer[i + 9] == '\a' ) - { - if ( con != ansi - && con != rxvt - && con != kde_konsole - && con != kterm - && con != cygwin - && con != mintty - && con != linux_con - && con != freebsd_con - && con != netbsd_con - && con != openbsd_con - && con != sun_con - && con != screen - && con != tmux ) - { - int n = (buffer[i + 4] - '0') * 100 - + (buffer[i + 5] - '0') * 10 - + (buffer[i + 6] - '0'); - - if ( n < 256 ) - { - write (fd_master, "\033]4;", 4); - write (fd_master, &buffer[i + 4], 1); - write (fd_master, &buffer[i + 5], 1); - write (fd_master, &buffer[i + 6], 1); - write (fd_master, ";rgb:", 5); - write (fd_master, colorname[n], 14); - write (fd_master, "\a", 1); - } - } - - i += 10; - } - else - { - write (fd_stdout, &buffer[i], 1); // Send data to stdout - } - } -} - - // Put the test suite in the registry CPPUNIT_TEST_SUITE_REGISTRATION (FTermDetectionTest); diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp new file mode 100644 index 00000000..b45461f6 --- /dev/null +++ b/test/ftermlinux-test.cpp @@ -0,0 +1,1525 @@ +/*********************************************************************** +* ftermlinux-test.cpp - FTermLinux unit tests * +* * +* 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__linux__) + #include +#endif + +#include +#include + +namespace test +{ + +//---------------------------------------------------------------------- +// class FSystemTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FSystemTest : public finalcut::FSystem +{ + // Typedefs and Enumerations + typedef struct + { + unsigned char shift : 1; + unsigned char alt_gr : 1; + unsigned char ctrl : 1; + unsigned char alt : 1; + unsigned char : 4; // padding bits + } shiftstate; + + typedef struct + { + unsigned char red; + unsigned char green; + unsigned char blue; + } rgb; + + typedef struct + { + rgb color[16]; + } ColorMap; + + enum ac_mode + { + index_mode, + data_mode + }; + + public: + // Constructor + FSystemTest(); + + // Destructor + virtual ~FSystemTest(); + + // Methods + virtual uChar inPortByte (uShort); + virtual void outPortByte (uChar, uShort); + virtual int isTTY (int); + virtual int ioctl (int, uLong, ...); + virtual int open (const char*, int, ...); + virtual int close (int); + virtual FILE* fopen (const char*, const char*); + virtual int fclose (FILE*); + + private: + // Methods + static void initVScreenInfo(); + static void initFScreenInfo(); + + // Data Members + static shiftstate shift_state; + static rgb terminal_color[16]; + static rgb defaultColor[16]; + static unimapdesc terminal_unicode_map; + static struct fb_var_screeninfo fb_terminal_info; + static struct fb_fix_screeninfo fb_terminal_fix_info; + static bool vga_port_access; + + ac_mode attribute_controller_mode = index_mode; + unsigned char ac_address_register[21] = \ + { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, + 0x0e, 0x0f, 0x0c, 0x00, 0x0f, 0x08, 0x00 + }; + unsigned char ac_index = 0; + bool palette_addr_source_field = true; + unsigned char port_3cc = 0x67; // Miscellaneous output + unsigned char port_3da = 0; // Input status 1 + static uChar vga8x16[]; + static struct unipair unicode_cp437_pairs[]; +}; +#pragma pack(pop) + + +// private Data Member of FSystemTest +//---------------------------------------------------------------------- +uChar FSystemTest::vga8x16[] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, // 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, // 2 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, // 3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 4 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 5 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 6 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, // 9 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, // 10 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, // 11 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 12 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, // 13 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, // 14 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 15 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, // 16 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, // 17 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 18 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, // 19 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, // 20 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, // 21 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, // 22 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, // 23 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 24 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, // 25 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 26 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 27 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 28 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 29 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, // 30 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 31 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 32 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 33 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 34 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, // 35 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, // 36 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, // 37 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 38 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 39 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, // 40 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, // 41 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, // 44 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 45 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 46 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, // 47 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, // 48 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, // 49 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, // 50 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 51 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, // 52 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 53 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 54 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, // 55 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 56 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, // 57 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 58 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, // 59 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, // 60 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, // 62 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 63 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, // 64 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 65 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, // 66 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, // 67 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, // 68 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, // 69 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, // 70 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, // 71 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 72 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 73 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, // 74 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, // 75 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, // 76 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 77 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 78 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 79 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, // 80 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, // 81 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, // 82 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 83 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 84 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 85 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, // 86 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00, // 87 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 88 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 89 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, // 90 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, // 91 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, // 92 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, // 93 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, // 95 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 96 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 97 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, // 98 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 99 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 100 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 101 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, // 102 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, // 103 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, // 104 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 105 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, // 106 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, // 107 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 108 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 109 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, // 110 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 111 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, // 112 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, // 113 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, // 114 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 115 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, // 116 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 117 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, // 118 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, // 119 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, // 120 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, // 121 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, // 122 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, // 123 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 124 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, // 125 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, // 127 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, // 128 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 129 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 130 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 131 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 132 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 133 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 134 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00, // 135 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 136 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 137 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 138 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 139 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 140 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 141 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 142 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 143 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, // 144 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, 0x00, 0x00, 0x00, 0x00, // 145 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, // 146 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 147 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 148 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 149 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 150 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 151 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, // 152 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 153 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 154 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 155 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, // 156 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 157 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00, 0x00, // 158 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00, // 159 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 160 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, // 161 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 162 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, // 163 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, // 164 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 165 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 166 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 167 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, // 168 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, // 169 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // 170 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xdc, 0x86, 0x0c, 0x18, 0x3e, 0x00, 0x00, // 171 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x9e, 0x3e, 0x06, 0x06, 0x00, 0x00, // 172 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, // 173 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 174 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 175 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, // 176 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, // 177 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, // 178 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 179 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 180 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 181 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 182 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 183 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 184 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 185 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 186 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 187 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 188 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 189 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 190 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 191 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 192 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 193 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 194 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 195 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 196 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 197 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 198 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 199 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 200 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 201 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 202 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 203 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 204 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 205 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 206 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 207 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 208 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 209 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 210 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 211 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 212 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 213 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 214 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, // 215 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 216 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 217 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 218 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 219 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 220 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 221 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, // 222 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 223 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, // 224 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00, // 225 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, // 226 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, // 227 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, // 228 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, // 229 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, // 230 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 231 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, // 232 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, // 233 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00, // 234 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, // 235 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 236 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, // 237 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, // 238 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, // 239 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, // 240 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, // 241 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, // 242 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, // 243 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // 244 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, // 245 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 246 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 247 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 248 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 249 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 250 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, // 251 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 252 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 253 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, // 254 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 255 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +struct unipair FSystemTest::unicode_cp437_pairs[] = +{ + // .----------- unicode + // | .---- fontpos + // | | + {0x0000, 0x00}, + {0x0020, 0x20}, + {0x0021, 0x21}, + {0x0022, 0x22}, + {0x0023, 0x23}, + {0x0024, 0x24}, + {0x0025, 0x25}, + {0x0026, 0x26}, + {0x0027, 0x27}, + {0x0028, 0x28}, + {0x0029, 0x29}, + {0x002a, 0x2a}, + {0x002b, 0x2b}, + {0x002c, 0x2c}, + {0x002d, 0x2d}, + {0x002e, 0x2e}, + {0x002f, 0x2f}, + {0x0030, 0x30}, + {0x0031, 0x31}, + {0x0032, 0x32}, + {0x0033, 0x33}, + {0x0034, 0x34}, + {0x0035, 0x35}, + {0x0036, 0x36}, + {0x0037, 0x37}, + {0x0038, 0x38}, + {0x0039, 0x39}, + {0x003a, 0x3a}, + {0x003b, 0x3b}, + {0x003c, 0x3c}, + {0x003d, 0x3d}, + {0x003e, 0x3e}, + {0x003f, 0x3f}, + {0x0040, 0x40}, + {0x0041, 0x41}, + {0x0042, 0x42}, + {0x0043, 0x43}, + {0x0044, 0x44}, + {0x0045, 0x45}, + {0x0046, 0x46}, + {0x0047, 0x47}, + {0x0048, 0x48}, + {0x0049, 0x49}, + {0x004a, 0x4a}, + {0x004b, 0x4b}, + {0x004c, 0x4c}, + {0x004d, 0x4d}, + {0x004e, 0x4e}, + {0x004f, 0x4f}, + {0x0050, 0x50}, + {0x0051, 0x51}, + {0x0052, 0x52}, + {0x0053, 0x53}, + {0x0054, 0x54}, + {0x0055, 0x55}, + {0x0056, 0x56}, + {0x0057, 0x57}, + {0x0058, 0x58}, + {0x0059, 0x59}, + {0x005a, 0x5a}, + {0x005b, 0x5b}, + {0x005c, 0x5c}, + {0x005d, 0x5d}, + {0x005e, 0x5e}, + {0x005f, 0x5f}, + {0x0060, 0x60}, + {0x0061, 0x61}, + {0x0062, 0x62}, + {0x0063, 0x63}, + {0x0064, 0x64}, + {0x0065, 0x65}, + {0x0066, 0x66}, + {0x0067, 0x67}, + {0x0068, 0x68}, + {0x0069, 0x69}, + {0x006a, 0x6a}, + {0x006b, 0x6b}, + {0x006c, 0x6c}, + {0x006d, 0x6d}, + {0x006e, 0x6e}, + {0x006f, 0x6f}, + {0x0070, 0x70}, + {0x0071, 0x71}, + {0x0072, 0x72}, + {0x0073, 0x73}, + {0x0074, 0x74}, + {0x0075, 0x75}, + {0x0076, 0x76}, + {0x0077, 0x77}, + {0x0078, 0x78}, + {0x0079, 0x79}, + {0x007a, 0x7a}, + {0x007b, 0x7b}, + {0x007c, 0x7c}, + {0x007d, 0x7d}, + {0x007e, 0x7e}, + {0x00a0, 0xff}, + {0x00a1, 0xad}, + {0x00a2, 0x9b}, + {0x00a3, 0x9c}, + {0x00a4, 0x0f}, + {0x00a5, 0x9d}, + {0x00a6, 0x7c}, + {0x00a7, 0x15}, + {0x00a8, 0x22}, + {0x00a9, 0x43}, + {0x00aa, 0xa6}, + {0x00ab, 0xae}, + {0x00ac, 0xaa}, + {0x00ad, 0x2d}, + {0x00ae, 0x52}, + {0x00b0, 0xf8}, + {0x00b1, 0xf1}, + {0x00b2, 0xfd}, + {0x00b4, 0x27}, + {0x00b5, 0xe6}, + {0x00b6, 0x14}, + {0x00b7, 0xfa}, + {0x00b8, 0x2c}, + {0x00ba, 0xa7}, + {0x00bb, 0xaf}, + {0x00bc, 0xac}, + {0x00bd, 0xab}, + {0x00bf, 0xa8}, + {0x00c0, 0x41}, + {0x00c1, 0x41}, + {0x00c2, 0x41}, + {0x00c3, 0x41}, + {0x00c4, 0x8e}, + {0x00c5, 0x8f}, + {0x00c6, 0x92}, + {0x00c7, 0x80}, + {0x00c8, 0x45}, + {0x00c9, 0x90}, + {0x00ca, 0x45}, + {0x00cb, 0x45}, + {0x00cc, 0x49}, + {0x00cd, 0x49}, + {0x00ce, 0x49}, + {0x00cf, 0x49}, + {0x00d0, 0x44}, + {0x00d1, 0xa5}, + {0x00d2, 0x4f}, + {0x00d3, 0x4f}, + {0x00d4, 0x4f}, + {0x00d5, 0x4f}, + {0x00d6, 0x99}, + {0x00d7, 0x78}, + {0x00d8, 0xe8}, + {0x00d9, 0x55}, + {0x00da, 0x55}, + {0x00db, 0x55}, + {0x00dc, 0x9a}, + {0x00dd, 0x59}, + {0x00df, 0xe1}, + {0x00e0, 0x85}, + {0x00e1, 0xa0}, + {0x00e2, 0x83}, + {0x00e3, 0x61}, + {0x00e4, 0x84}, + {0x00e5, 0x86}, + {0x00e6, 0x91}, + {0x00e7, 0x87}, + {0x00e8, 0x8a}, + {0x00e9, 0x82}, + {0x00ea, 0x88}, + {0x00eb, 0x89}, + {0x00ec, 0x8d}, + {0x00ed, 0xa1}, + {0x00ee, 0x8c}, + {0x00ef, 0x8b}, + {0x00f0, 0xeb}, + {0x00f1, 0xa4}, + {0x00f2, 0x95}, + {0x00f3, 0xa2}, + {0x00f4, 0x93}, + {0x00f5, 0x6f}, + {0x00f6, 0x94}, + {0x00f7, 0xf6}, + {0x00f8, 0xed}, + {0x00f9, 0x97}, + {0x00fa, 0xa3}, + {0x00fb, 0x96}, + {0x00fc, 0x81}, + {0x00fd, 0x79}, + {0x00ff, 0x98}, + {0x0192, 0x9f}, + {0x0393, 0xe2}, + {0x0398, 0xe9}, + {0x03a3, 0xe4}, + {0x03a6, 0xe8}, + {0x03a9, 0xea}, + {0x03b1, 0xe0}, + {0x03b2, 0xe1}, + {0x03b4, 0xeb}, + {0x03b5, 0xee}, + {0x03bc, 0xe6}, + {0x03c0, 0xe3}, + {0x03c3, 0xe5}, + {0x03c4, 0xe7}, + {0x03c6, 0xed}, + {0x2022, 0x07}, + {0x203c, 0x13}, + {0x207f, 0xfc}, + {0x20a7, 0x9e}, + {0x2126, 0xea}, + {0x212a, 0x4b}, + {0x212b, 0x8f}, + {0x2190, 0x1b}, + {0x2191, 0x18}, + {0x2192, 0x1a}, + {0x2193, 0x19}, + {0x2194, 0x1d}, + {0x2195, 0x12}, + {0x21a8, 0x17}, + {0x2208, 0xee}, + {0x2219, 0xf9}, + {0x221a, 0xfb}, + {0x221e, 0xec}, + {0x221f, 0x1c}, + {0x2229, 0xef}, + {0x2248, 0xf7}, + {0x2261, 0xf0}, + {0x2264, 0xf3}, + {0x2265, 0xf2}, + {0x2302, 0x7f}, + {0x2310, 0xa9}, + {0x2320, 0xf4}, + {0x2321, 0xf5}, + {0x23bd, 0x5f}, + {0x2500, 0xc4}, + {0x2502, 0xb3}, + {0x250c, 0xda}, + {0x2510, 0xbf}, + {0x2514, 0xc0}, + {0x2518, 0xd9}, + {0x251c, 0xc3}, + {0x2524, 0xb4}, + {0x252c, 0xc2}, + {0x2534, 0xc1}, + {0x253c, 0xc5}, + {0x2550, 0xcd}, + {0x2551, 0xba}, + {0x2552, 0xd5}, + {0x2553, 0xd6}, + {0x2554, 0xc9}, + {0x2555, 0xb8}, + {0x2556, 0xb7}, + {0x2557, 0xbb}, + {0x2558, 0xd4}, + {0x2559, 0xd3}, + {0x255a, 0xc8}, + {0x255b, 0xbe}, + {0x255c, 0xbd}, + {0x255d, 0xbc}, + {0x255e, 0xc6}, + {0x255f, 0xc7}, + {0x2560, 0xcc}, + {0x2561, 0xb5}, + {0x2562, 0xb6}, + {0x2563, 0xb9}, + {0x2564, 0xd1}, + {0x2565, 0xd2}, + {0x2566, 0xcb}, + {0x2567, 0xcf}, + {0x2568, 0xd0}, + {0x2569, 0xca}, + {0x256a, 0xd8}, + {0x256b, 0xd7}, + {0x256c, 0xce}, + {0x2580, 0xdf}, + {0x2584, 0xdc}, + {0x2588, 0xdb}, + {0x258c, 0xdd}, + {0x2590, 0xde}, + {0x2591, 0xb0}, + {0x2592, 0xb1}, + {0x2593, 0xb2}, + {0x25a0, 0xfe}, + {0x25ac, 0x16}, + {0x25b2, 0x1e}, + {0x25b6, 0x10}, + {0x25ba, 0x10}, + {0x25bc, 0x1f}, + {0x25c0, 0x11}, + {0x25c4, 0x11}, + {0x25c6, 0x04}, + {0x25cb, 0x09}, + {0x25d8, 0x08}, + {0x25d9, 0x0a}, + {0x263a, 0x01}, + {0x263b, 0x02}, + {0x263c, 0x0f}, + {0x2640, 0x0c}, + {0x2642, 0x0b}, + {0x2660, 0x06}, + {0x2663, 0x05}, + {0x2665, 0x03}, + {0x2666, 0x04}, + {0x266a, 0x0d}, + {0x266b, 0x0e}, + {0xf804, 0x5f}, + {0xfffd, 0xfe} +}; + +FSystemTest::rgb FSystemTest::terminal_color[16] { }; + +FSystemTest::rgb FSystemTest::defaultColor[16] +{ + {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, + {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, + {0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa}, + {0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa}, + {0x55, 0x55, 0x55}, {0xff, 0x55, 0x55}, + {0x55, 0xff, 0x55}, {0xff, 0xff, 0x55}, + {0x55, 0x55, 0xff}, {0xff, 0x55, 0xff}, + {0x55, 0xff, 0xff}, {0xff, 0xff, 0xff} +}; + + +// static class attributes +//---------------------------------------------------------------------- +FSystemTest::shiftstate FSystemTest::shift_state; +unimapdesc FSystemTest::terminal_unicode_map; +struct fb_var_screeninfo FSystemTest::fb_terminal_info; +struct fb_fix_screeninfo FSystemTest::fb_terminal_fix_info; +bool FSystemTest::vga_port_access = false; + + +// constructors and destructor +//---------------------------------------------------------------------- +FSystemTest::FSystemTest() // constructor +{ + // fill bit field with 0 + memset (&shift_state, 0x00, sizeof(shift_state)); + memset (&terminal_unicode_map, 0x00, sizeof(terminal_unicode_map)); + + // init framebuffer + initVScreenInfo(); + initFScreenInfo(); +} + +//---------------------------------------------------------------------- +FSystemTest::~FSystemTest() // destructor +{ + if ( terminal_unicode_map.entries ) + delete[] terminal_unicode_map.entries; +} + + +// public methods of FSystemTest +//---------------------------------------------------------------------- +uChar FSystemTest::inPortByte (uShort port) +{ + std::cerr << "Call: im (port=" << port << ")\n"; + + switch ( port ) + { + case 0x3c1: + if ( attribute_controller_mode == data_mode ) + return ac_address_register[ac_index]; + break; + + case 0x3cc: + return port_3cc; + + case 0x3da: + attribute_controller_mode = index_mode; + return port_3da; + } + + return 0; +} + +//---------------------------------------------------------------------- +void FSystemTest::outPortByte (uChar value, uShort port) +{ + std::cerr << "Call: outb (value=" << value + << ", port=" << port << ")\n"; + + switch ( port ) + { + case 0x3c0: + if ( attribute_controller_mode == index_mode ) + { + ac_index = value & 0x1f; + palette_addr_source_field = bool(value & 0x20); + attribute_controller_mode = data_mode; + } + else + { + ac_address_register[ac_index] = value; + attribute_controller_mode = index_mode; + } + break; + + default: + return; + } +} + +//---------------------------------------------------------------------- +int FSystemTest::isTTY (int fd) +{ + std::cerr << "Call: isatty (fd=" << fd << ")\n"; + return 1; +} + +//---------------------------------------------------------------------- +int FSystemTest::ioctl (int fd, uLong request, ...) +{ + va_list args; + void* argp; + std::string req_string; + int ret_val = -1; + + va_start (args, request); + argp = va_arg (args, void*); + + switch ( request ) + { + case TIOCLINUX: + { + req_string = "TIOCLINUX"; + char* subcode = static_cast(argp); + unsigned char* state = reinterpret_cast(&shift_state); + + if ( *subcode == 6 ) + *subcode = static_cast(*state); + + ret_val = 0; + break; + } + + case KDFONTOP: + { + req_string = "KDFONTOP"; + struct console_font_op* fn = static_cast(argp); + fn->width = 8; + fn->height = 16; + fn->charcount = 256; + + if ( fn->data ) + memcpy (fn->data, &vga8x16, sizeof(vga8x16)); + + ret_val = 0; + break; + } + + case KDGKBTYPE: + { + req_string = "KDGKBTYPE"; + char* keyboard_type = static_cast(argp); + *keyboard_type = KB_101; + ret_val = 0; + break; + } + + case GIO_CMAP: + { + req_string = "GIO_CMAP"; + ColorMap* cmap = static_cast(argp); + // Set Default + if ( terminal_color[15].red == 0 + && terminal_color[15].green == 0 + && terminal_color[15].blue == 0 ) + { + for (size_t index = 0; index < 16; index++) + { + terminal_color[index].red = defaultColor[index].red; + terminal_color[index].green = defaultColor[index].green; + terminal_color[index].blue = defaultColor[index].blue; + } + } + + for (size_t index = 0; index < 16; index++) + { + cmap->color[index].red = terminal_color[index].red; + cmap->color[index].green = terminal_color[index].green; + cmap->color[index].blue = terminal_color[index].blue; + } + + ret_val = 0; + break; + } + + case PIO_CMAP: + { + req_string = "PIO_CMAP"; + ColorMap* cmap = static_cast(argp); + + for (size_t index = 0; index < 16; index++) + { + terminal_color[index].red = cmap->color[index].red; + terminal_color[index].green = cmap->color[index].green; + terminal_color[index].blue = cmap->color[index].blue; + } + + ret_val = 0; + break; + } + + case GIO_UNIMAP: + { + req_string = "GIO_UNIMAP"; + unimapdesc* umap = static_cast(argp); + size_t pairs = sizeof(unicode_cp437_pairs) / sizeof(unipair); + size_t pairs_size = pairs * sizeof(unipair); + + // Sets the default unicode map of the terminal on the first call + if ( terminal_unicode_map.entries == 0 ) + { + terminal_unicode_map.entry_ct = pairs; + terminal_unicode_map.entries = new unipair[pairs](); + memcpy (terminal_unicode_map.entries, &unicode_cp437_pairs, pairs_size); + } + + umap->entry_ct = terminal_unicode_map.entry_ct; + + if ( umap->entries && terminal_unicode_map.entries ) + { + memcpy (umap->entries, &terminal_unicode_map.entries, pairs_size); + ret_val = 0; + } + else + ret_val = -1; + + break; + } + + case PIO_UNIMAP: + { + req_string = "PIO_UNIMAP"; + unimapdesc* umap = static_cast(argp); + memcpy (&terminal_unicode_map, umap, sizeof(*umap)); + ret_val = 0; + break; + } + + case PIO_UNIMAPCLR: + req_string = "PIO_UNIMAPCLR"; + ret_val = 0; + break; + + case FBIOGET_VSCREENINFO: + { + req_string = "FBIOGET_VSCREENINFO"; + struct fb_var_screeninfo* fb_var \ + = static_cast(argp); + memcpy (fb_var, &fb_terminal_info, sizeof(fb_terminal_info)); + ret_val = 0; + break; + } + + case FBIOGET_FSCREENINFO: + { + req_string = "FBIOGET_FSCREENINFO"; + struct fb_fix_screeninfo* fb_fix + = static_cast(argp); + memcpy (fb_fix, &fb_terminal_fix_info, sizeof(fb_terminal_fix_info)); + ret_val = 0; + break; + } + + case KDENABIO: + { + req_string = "KDENABIO"; + vga_port_access = true; + ret_val = 0; + break; + } + + case KDDISABIO: + { + req_string = "KDDISABIO"; + vga_port_access = false; + ret_val = 0; + break; + } + + case TIOCGWINSZ: + { + req_string = "TIOCGWINSZ"; + struct winsize* win_size = static_cast(argp); + win_size->ws_col = 96; + win_size->ws_row = 36; + ret_val = 0; + break; + } + } + + va_end (args); + + std::cerr << "Call: ioctl (fd=" << fd + << ", request=" << req_string + << "(0x" << std::hex << request << ")" + << ", argp=" << argp << ")\n"; + return ret_val; +} + +//---------------------------------------------------------------------- +int FSystemTest::open (const char* pathname, int flags, ...) +{ + va_list args; + va_start (args, flags); + mode_t mode = static_cast(va_arg (args, int)); + va_end (args); + + std::cerr << "Call: open (pathname=\"" << pathname + << "\", flags=" << flags + << ", mode=" << mode << ")\n"; + + if ( std::strncmp(pathname, "/dev/fb0", 9) == 0 + || std::strncmp(pathname, "/dev/fb/0", 9) == 0 ) + return 99; // File descriptor + + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::close (int fildes) +{ + std::cerr << "Call: close (fildes=" << fildes << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +FILE* FSystemTest::fopen (const char* path, const char* mode) +{ + std::cerr << "Call: fopen (path=" << path + << ", mode=" << mode << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::fclose (FILE* fp) +{ + std::cerr << "Call: fclose (fp=" << fp << ")\n"; + return 0; +} + +// private methods of FSystemTest +//---------------------------------------------------------------------- +void FSystemTest::initVScreenInfo() +{ + fb_terminal_info.xres = 800; + fb_terminal_info.yres = 600; + fb_terminal_info.xres_virtual = 1176; + fb_terminal_info.yres_virtual = 885; + fb_terminal_info.xoffset = 0; + fb_terminal_info.yoffset = 0; + fb_terminal_info.bits_per_pixel = 32; + fb_terminal_info.grayscale = 0; + fb_terminal_info.red.offset = 16; + fb_terminal_info.red.length = 8; + fb_terminal_info.red.msb_right = 0; + fb_terminal_info.green.offset = 8; + fb_terminal_info.green.length = 8, + fb_terminal_info.green.msb_right = 0; + fb_terminal_info.blue.offset = 0; + fb_terminal_info.blue.length = 8; + fb_terminal_info.blue.msb_right = 0; + fb_terminal_info.transp.offset = 0; + fb_terminal_info.blue.length = 0; + fb_terminal_info.blue.msb_right = 0; + fb_terminal_info.nonstd = 0; + fb_terminal_info.activate = 0; + fb_terminal_info.height = 0xffffffff; + fb_terminal_info.width = 0xffffffff; + fb_terminal_info.accel_flags = 0; + fb_terminal_info.pixclock = 0; + fb_terminal_info.left_margin = 0; + fb_terminal_info.right_margin = 0; + fb_terminal_info.upper_margin = 0; + fb_terminal_info.lower_margin = 0; + fb_terminal_info.hsync_len = 0; + fb_terminal_info.vsync_len = 0; + fb_terminal_info.sync = 0; + fb_terminal_info.vmode = 0; + fb_terminal_info.rotate = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) + fb_terminal_info.colorspace = 0; +#endif + fb_terminal_info.reserved[0] = 0; + fb_terminal_info.reserved[1] = 0; + fb_terminal_info.reserved[2] = 0; + fb_terminal_info.reserved[3] = 0; +} + +//---------------------------------------------------------------------- +void FSystemTest::initFScreenInfo() +{ + char id[16] { "VESA VGA" }; + std::strncpy (fb_terminal_fix_info.id, id, sizeof(id)); + fb_terminal_fix_info.smem_start = 0xf9000000; + fb_terminal_fix_info.smem_len = 0x00500000; + fb_terminal_fix_info.type = 0; + fb_terminal_fix_info.type_aux = 0; + fb_terminal_fix_info.visual = 2; + fb_terminal_fix_info.xpanstep = 0; + fb_terminal_fix_info.ypanstep = 0; + fb_terminal_fix_info.ywrapstep = 0; + fb_terminal_fix_info.line_length = 5120; + fb_terminal_fix_info.mmio_start = 0; + fb_terminal_fix_info.mmio_len = 0; + fb_terminal_fix_info.accel = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) + fb_terminal_fix_info.capabilities = 0; +#endif + fb_terminal_fix_info.reserved[0] = 0; + fb_terminal_fix_info.reserved[1] = 0; +} + +} // namespace test + + +//---------------------------------------------------------------------- +// class FTermLinuxTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu +{ + public: + FTermLinuxTest(); + + protected: + void classNameTest(); + void linuxConsoleTest(); + + private: + // Adds code needed to register the test suite + CPPUNIT_TEST_SUITE (FTermLinuxTest); + + // Add a methods to the test suite + CPPUNIT_TEST (classNameTest); + CPPUNIT_TEST (linuxConsoleTest); + + // End of test suite definition + CPPUNIT_TEST_SUITE_END(); +}; +#pragma pack(pop) + +//---------------------------------------------------------------------- +FTermLinuxTest::FTermLinuxTest() +{ + +} + +//---------------------------------------------------------------------- +void FTermLinuxTest::classNameTest() +{ + const finalcut::FTermLinux p; + const char* const classname = p.getClassName(); + CPPUNIT_ASSERT ( std::strcmp(classname, "FTermLinux") == 0 ); +} + +//---------------------------------------------------------------------- +void FTermLinuxTest::linuxConsoleTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::PC); + + auto& character_map = data->getCharSubstitutionMap(); + character_map[finalcut::fc::BlackCircle] = L'*'; + character_map[finalcut::fc::Times] = L'x'; + character_map[L'ˣ'] = finalcut::fc::SuperscriptLatinSmallLetterN; + + data->setBaudrate(38400); + data->setTermType("linux"); + data->setTermFileName("/dev/tty2"); + +#if DEBUG + data->setFramebufferBpp(32); +#endif + + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + finalcut::FTermLinux linux; + + term_detection->setLinuxTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "linux", 1); + setenv ("COLUMNS", "90", 1); + setenv ("LINES", "30", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + term_detection->detect(); + linux.init(); + + CPPUNIT_ASSERT ( isatty(3) == 0 ); + CPPUNIT_ASSERT ( term_detection->isLinuxTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 96 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 36 ); + CPPUNIT_ASSERT ( data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); + CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); + + + // linux->setUTF8 (enable); + // linux->loadVGAFont() + // linux->loadNewFont() + // linux->loadOldFont(fc::character); + // linux->initCharMap (fc::character); + // linux->restoreCursorStyle(); + // linux->saveColorMap(); + // linux->resetColorMap(); + // linux->setPalette(index, r, g, b); + // linux->setBeep (Hz, ms); + // linux->resetBeep(); + // const char* cstyle = linux->setCursorStyle ( fc::underscore_cursor + // , data->isCursorHidden() ); + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::linux_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + linux.finish(); +} + + +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION (FTermLinuxTest); + +// The general unit test main part +#include From 1b35fd06238b0d77e204193cddae4a20533bd298 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 19 Jun 2019 21:57:45 +0200 Subject: [PATCH 27/70] pkg-config in .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ad616d2a..18c6b666 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ addons: - autoconf - autoconf-archive - libtool + - pkg-config - libglib2.0-dev - libncurses5-dev - gpm From 73293da481b71242a5b91e0378573dcbfafc4b1c Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 19 Jun 2019 23:12:44 +0200 Subject: [PATCH 28/70] Homebrew update --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 18c6b666..038d9c92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ addons: homebrew: packages: - autoconf-archive + update: true env: global: From 340d78e4331d5b856431e0a3b27e86892e46d2db Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 1 Jul 2019 01:07:54 +0200 Subject: [PATCH 29/70] Expanding the Unit Test for FTermLinux --- ChangeLog | 5 + fonts/unicodemap.h | 59 +- src/fterm.cpp | 49 +- src/ftermlinux.cpp | 5 +- src/ftermxterminal.cpp | 6 + src/fvterm.cpp | 29 +- src/include/final/fsystem.h | 2 + src/include/final/fsystemimpl.h | 79 ++- src/include/final/fterm.h | 5 - src/include/final/ftermxterminal.h | 1 + src/include/final/fvterm.h | 13 +- test/ftermlinux-test.cpp | 831 +++++++++++++++++++++++++---- 12 files changed, 860 insertions(+), 224 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4272404b..7b4467b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-06-30 Markus Gans + * Expanding the Unit Test for FTermLinux + * Update the cp437 unicode map + * Reducing the special cases for Solaris + 2019-06-19 Markus Gans * Add a unit test for FTermLinux with a Linux console emulation and a dedicated FSystem test instance diff --git a/fonts/unicodemap.h b/fonts/unicodemap.h index 92a13901..2dc98abc 100644 --- a/fonts/unicodemap.h +++ b/fonts/unicodemap.h @@ -14,7 +14,6 @@ static struct unipair unicode_cp437_pairs[] = // .----------- unicode // | .---- fontpos // | | - {0x0000, 0x00}, {0x0020, 0x20}, {0x0021, 0x21}, {0x0022, 0x22}, @@ -114,65 +113,34 @@ static struct unipair unicode_cp437_pairs[] = {0x00a1, 0xad}, {0x00a2, 0x9b}, {0x00a3, 0x9c}, - {0x00a4, 0x0f}, {0x00a5, 0x9d}, - {0x00a6, 0x7c}, {0x00a7, 0x15}, - {0x00a8, 0x22}, - {0x00a9, 0x43}, {0x00aa, 0xa6}, {0x00ab, 0xae}, {0x00ac, 0xaa}, - {0x00ad, 0x2d}, - {0x00ae, 0x52}, {0x00b0, 0xf8}, {0x00b1, 0xf1}, {0x00b2, 0xfd}, - {0x00b4, 0x27}, {0x00b5, 0xe6}, {0x00b6, 0x14}, {0x00b7, 0xfa}, - {0x00b8, 0x2c}, {0x00ba, 0xa7}, {0x00bb, 0xaf}, {0x00bc, 0xac}, {0x00bd, 0xab}, {0x00bf, 0xa8}, - {0x00c0, 0x41}, - {0x00c1, 0x41}, - {0x00c2, 0x41}, - {0x00c3, 0x41}, {0x00c4, 0x8e}, {0x00c5, 0x8f}, {0x00c6, 0x92}, {0x00c7, 0x80}, - {0x00c8, 0x45}, {0x00c9, 0x90}, - {0x00ca, 0x45}, - {0x00cb, 0x45}, - {0x00cc, 0x49}, - {0x00cd, 0x49}, - {0x00ce, 0x49}, - {0x00cf, 0x49}, - {0x00d0, 0x44}, {0x00d1, 0xa5}, - {0x00d2, 0x4f}, - {0x00d3, 0x4f}, - {0x00d4, 0x4f}, - {0x00d5, 0x4f}, {0x00d6, 0x99}, - {0x00d7, 0x78}, - {0x00d8, 0xe8}, - {0x00d9, 0x55}, - {0x00da, 0x55}, - {0x00db, 0x55}, {0x00dc, 0x9a}, - {0x00dd, 0x59}, {0x00df, 0xe1}, {0x00e0, 0x85}, {0x00e1, 0xa0}, {0x00e2, 0x83}, - {0x00e3, 0x61}, {0x00e4, 0x84}, {0x00e5, 0x86}, {0x00e6, 0x91}, @@ -185,20 +153,16 @@ static struct unipair unicode_cp437_pairs[] = {0x00ed, 0xa1}, {0x00ee, 0x8c}, {0x00ef, 0x8b}, - {0x00f0, 0xeb}, {0x00f1, 0xa4}, {0x00f2, 0x95}, {0x00f3, 0xa2}, {0x00f4, 0x93}, - {0x00f5, 0x6f}, {0x00f6, 0x94}, {0x00f7, 0xf6}, - {0x00f8, 0xed}, {0x00f9, 0x97}, {0x00fa, 0xa3}, {0x00fb, 0x96}, {0x00fc, 0x81}, - {0x00fd, 0x79}, {0x00ff, 0x98}, {0x0192, 0x9f}, {0x0393, 0xe2}, @@ -215,12 +179,23 @@ static struct unipair unicode_cp437_pairs[] = {0x03c3, 0xe5}, {0x03c4, 0xe7}, {0x03c6, 0xed}, + {0x2000, 0x20}, + {0x2001, 0x20}, + {0x2002, 0x20}, + {0x2003, 0x20}, + {0x2004, 0x20}, + {0x2005, 0x20}, + {0x2006, 0x20}, + {0x2007, 0x20}, + {0x2008, 0x20}, + {0x2009, 0x20}, + {0x200a, 0x20}, {0x2022, 0x07}, + {0x202f, 0x20}, {0x203c, 0x13}, {0x207f, 0xfc}, {0x20a7, 0x9e}, {0x2126, 0xea}, - {0x212a, 0x4b}, {0x212b, 0x8f}, {0x2190, 0x1b}, {0x2191, 0x18}, @@ -229,7 +204,9 @@ static struct unipair unicode_cp437_pairs[] = {0x2194, 0x1d}, {0x2195, 0x12}, {0x21a8, 0x17}, + {0x2205, 0xed}, {0x2208, 0xee}, + {0x220e, 0xfe}, {0x2219, 0xf9}, {0x221a, 0xfb}, {0x221e, 0xec}, @@ -239,11 +216,13 @@ static struct unipair unicode_cp437_pairs[] = {0x2261, 0xf0}, {0x2264, 0xf3}, {0x2265, 0xf2}, + {0x22c5, 0xf9}, + {0x2300, 0xed}, {0x2302, 0x7f}, {0x2310, 0xa9}, + {0x2319, 0x1c}, {0x2320, 0xf4}, {0x2321, 0xf5}, - {0x23bd, 0x5f}, {0x2500, 0xc4}, {0x2502, 0xb3}, {0x250c, 0xda}, @@ -300,7 +279,6 @@ static struct unipair unicode_cp437_pairs[] = {0x25bc, 0x1f}, {0x25c0, 0x11}, {0x25c4, 0x11}, - {0x25c6, 0x04}, {0x25cb, 0x09}, {0x25d8, 0x08}, {0x25d9, 0x0a}, @@ -315,8 +293,7 @@ static struct unipair unicode_cp437_pairs[] = {0x2666, 0x04}, {0x266a, 0x0d}, {0x266b, 0x0e}, - {0xf804, 0x5f}, - {0xfffd, 0xfe} + {0x266c, 0x0e} }; } // namespace fc diff --git a/src/fterm.cpp b/src/fterm.cpp index 5db43829..88afd3e7 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -823,42 +823,27 @@ void FTerm::putstringf (const char format[], ...) { assert ( format != 0 ); char buf[512]; - char* buffer; + char* str; va_list args; - buffer = buf; + str = buf; va_start (args, format); - vsnprintf (buffer, sizeof(buf), format, args); + vsnprintf (str, sizeof(buf), format, args); va_end (args); - tputs (buffer, 1, FTerm::putchar_ASCII); + fsys->tputs (str, 1, FTerm::putchar_ASCII); } //---------------------------------------------------------------------- -void FTerm::putstring (const char s[], int affcnt) +void FTerm::putstring (const char str[], int affcnt) { -#if defined(__sun) && defined(__SVR4) - tputs (C_STR(s), affcnt, FTerm::putchar_ASCII); -#else - tputs (s, affcnt, FTerm::putchar_ASCII); -#endif + fsys->tputs (str, affcnt, FTerm::putchar_ASCII); } -#if defined(__sun) && defined(__SVR4) -//---------------------------------------------------------------------- -int FTerm::putchar_ASCII (char c) -{ - if ( std::putchar(c) == EOF ) - return 0; - else - return 1; -} -#endif // defined(__sun) && defined(__SVR4) - //---------------------------------------------------------------------- int FTerm::putchar_ASCII (int c) { - if ( std::putchar(char(c)) == EOF ) + if ( fsys->putchar(char(c)) == EOF ) return 0; else return 1; @@ -870,31 +855,31 @@ int FTerm::putchar_UTF8 (int c) if ( c < 0x80 ) { // 1 Byte (7-bit): 0xxxxxxx - std::putchar (c); + fsys->putchar (c); return 1; } else if ( c < 0x800 ) { // 2 byte (11-bit): 110xxxxx 10xxxxxx - std::putchar (0xc0 | (c >> 6) ); - std::putchar (0x80 | (c & 0x3f) ); + fsys->putchar (0xc0 | (c >> 6) ); + fsys->putchar (0x80 | (c & 0x3f) ); return 2; } else if ( c < 0x10000 ) { // 3 byte (16-bit): 1110xxxx 10xxxxxx 10xxxxxx - std::putchar (0xe0 | (c >> 12) ); - std::putchar (0x80 | ((c >> 6) & 0x3f) ); - std::putchar (0x80 | (c & 0x3f) ); + fsys->putchar (0xe0 | (c >> 12) ); + fsys->putchar (0x80 | ((c >> 6) & 0x3f) ); + fsys->putchar (0x80 | (c & 0x3f) ); return 3; } else if ( c < 0x200000 ) { // 4 byte (21-bit): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - std::putchar (0xf0 | (c >> 18) ); - std::putchar (0x80 | ((c >> 12) & 0x3f) ); - std::putchar (0x80 | ((c >> 6) & 0x3f) ); - std::putchar (0x80 | (c & 0x3f)); + fsys->putchar (0xf0 | (c >> 18) ); + fsys->putchar (0x80 | ((c >> 12) & 0x3f) ); + fsys->putchar (0x80 | ((c >> 6) & 0x3f) ); + fsys->putchar (0x80 | (c & 0x3f)); return 4; } else diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index bc2062c0..d80b67cf 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -86,6 +86,7 @@ char* FTermLinux::setCursorStyle ( fc::linuxConsoleCursorStyle style // Set cursor style in linux console static char buf[16] = { }; + std::fill (std::begin(buf), std::end(buf), '\0'); if ( ! FTerm::isLinuxTerm() ) return buf; @@ -204,7 +205,7 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) if ( new_font || vga_font ) return; - if ( screen_unicode_map.entry_ct != 0 ) + if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries ) { for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) { @@ -318,7 +319,7 @@ bool FTermLinux::loadNewFont() else new_font = false; - if ( vga_font ) + if ( new_font ) { fterm_data->supportShadowCharacter (true); fterm_data->supportHalfBlockCharacter (true); diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index d3789c22..7ecdcaa8 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -41,6 +41,7 @@ const FString* FTermXTerminal::cursor_color = nullptr; const FString* FTermXTerminal::mouse_foreground_color = nullptr; const FString* FTermXTerminal::mouse_background_color = nullptr; const FString* FTermXTerminal::highlight_background_color = nullptr; +FSystem* FTermXTerminal::fsystem = nullptr; FTermDetection* FTermXTerminal::term_detection = nullptr; fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style; @@ -57,6 +58,8 @@ FTermXTerminal::FTermXTerminal() mouse_support = \ meta_sends_esc = \ xterm_default_colors = false; + // Get FSystem object + fsystem = FTerm::getFSystem(); } //---------------------------------------------------------------------- @@ -867,6 +870,9 @@ void FTermXTerminal::enableXTermMouse() if ( mouse_support ) return; + if ( ! fsystem ) + fsystem = FTerm::getFSystem(); + FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking CSI "?1000h" // enable x11 mouse tracking CSI "?1002h" // enable cell motion mouse tracking diff --git a/src/fvterm.cpp b/src/fvterm.cpp index ce2e51bb..1f9e3ed7 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -50,6 +50,7 @@ uInt FVTerm::clr_eol_length; uInt FVTerm::cursor_address_length; 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; @@ -1843,6 +1844,7 @@ void FVTerm::init (bool disable_alt_screen) init_object = this; vterm = nullptr; vdesktop = nullptr; + fsystem = FTerm::getFSystem(); try { @@ -2804,39 +2806,16 @@ inline void FVTerm::characterFilter (charData*& next_char) //---------------------------------------------------------------------- inline void FVTerm::appendOutputBuffer (const std::string& s) { -#if defined(__sun) && defined(__SVR4) - char* c_string = C_STR(s.c_str()); -#else const char* const& c_string = s.c_str(); -#endif - - tputs (c_string, 1, appendOutputBuffer); + fsystem->tputs (c_string, 1, appendOutputBuffer); } //---------------------------------------------------------------------- inline void FVTerm::appendOutputBuffer (const char s[]) { -#if defined(__sun) && defined(__SVR4) - tputs (C_STR(s), 1, appendOutputBuffer); -#else - tputs (s, 1, appendOutputBuffer); -#endif + fsystem->tputs (s, 1, appendOutputBuffer); } -#if defined(__sun) && defined(__SVR4) -//---------------------------------------------------------------------- -int FVTerm::appendOutputBuffer (char ch) -{ - // This method is required by tputs under Solaris - output_buffer->push(ch); - - if ( output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_SIZE ) - flush_out(); - - return ch; -} -#endif // defined(__sun) && defined(__SVR4) - //---------------------------------------------------------------------- int FVTerm::appendOutputBuffer (int ch) { diff --git a/src/include/final/fsystem.h b/src/include/final/fsystem.h index 2e2e80df..8d3ea699 100644 --- a/src/include/final/fsystem.h +++ b/src/include/final/fsystem.h @@ -65,6 +65,8 @@ class FSystem virtual int close (int) = 0; virtual FILE* fopen (const char*, const char*) = 0; virtual int fclose (FILE*) = 0; + virtual int putchar (int) = 0; + virtual int tputs (const char*, int, int (*)(int)) = 0; }; #pragma pack(pop) diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index cadab4b6..acc43659 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -41,6 +41,26 @@ #endif // defined(__x86_64__) || defined(__i386) || defined(__arm__) #endif // defined(__linux__) +#if defined(__sun) && defined(__SVR4) + #include + typedef struct termio SGTTY; + typedef struct termios SGTTYS; + + #ifdef _LP64 + typedef unsigned int chtype; + #else + typedef unsigned long chtype; + #endif // _LP64 + + #include // termcap +#else + #include // termcap +#endif // defined(__sun) && defined(__SVR4) + +#ifdef F_HAVE_LIBGPM + #undef buttons // from term.h +#endif + #include #include #include @@ -72,27 +92,41 @@ class FSystemImpl : public FSystem virtual ~FSystemImpl(); // Methods +#if defined(__linux__) +#if defined(__x86_64__) || defined(__i386) || defined(__arm__) virtual uChar inPortByte (uShort port) { + return ::inb (port); + } +#else + virtual uChar inPortByte (uShort) + { + return 0; + } +#endif +#else + virtual uChar inPortByte (uShort) + { + return 0; + } +#endif + + #if defined(__linux__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__) - return ::inb (port); -#else - return 0; -#endif -#else - return 0; -#endif - } - virtual void outPortByte (uChar value, uShort port) { -#if defined(__linux__) -#if defined(__x86_64__) || defined(__i386) || defined(__arm__) ::outb (value, port); -#endif -#endif } +#else + virtual void outPortByte (uChar, uShort) + { } +#endif +#else + virtual void outPortByte (uChar, uShort) + { } +#endif + virtual int isTTY (int fd) { @@ -133,6 +167,25 @@ class FSystemImpl : public FSystem { return std::fclose (fp); } + + virtual int putchar (int c) + { +#if defined(__sun) && defined(__SVR4) + return std::putchar(char(c)); +#else + return std::putchar(c); +#endif + } + + virtual int tputs (const char* str, int affcnt, int (*putc)(int)) + { +#if defined(__sun) && defined(__SVR4) + return ::tputs (C_STR(str), affcnt, reinterpret_cast(putc)); +#else + return ::tputs (str, affcnt, putc); +#endif + } + }; #pragma pack(pop) diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 75f81d70..a0a07c17 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -297,11 +297,6 @@ class FTerm final #endif ; static void putstring (const char[], int = 1); - -#if defined(__sun) && defined(__SVR4) - static int putchar_ASCII (char); -#endif - static int putchar_ASCII (int); static int putchar_UTF8 (int); diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index 54ededbe..b902cf72 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -150,6 +150,7 @@ class FTermXTerminal final static const FString* mouse_foreground_color; static const FString* mouse_background_color; static const FString* highlight_background_color; + static FSystem* fsystem; static FTermDetection* term_detection; static fc::xtermCursorStyle cursor_style; }; diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index a74adddb..d66364af 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -134,6 +134,7 @@ class FVTerm // Overloaded operators template FVTerm& operator << (const typeT&); + FVTerm& operator << (fc::SpecialCharacter); FVTerm& operator << (const std::string&); FVTerm& operator << (const FTermBuffer&); FVTerm& operator << (const std::vector&); @@ -468,13 +469,10 @@ class FVTerm static void characterFilter (charData*&); static void appendOutputBuffer (const std::string&); static void appendOutputBuffer (const char[]); - -#if defined(__sun) && defined(__SVR4) - static int appendOutputBuffer (char); -#endif static int appendOutputBuffer (int); // Data Members + static FSystem* fsystem; static FTerm* fterm; static std::queue* output_buffer; static charData term_attribute; @@ -552,6 +550,13 @@ inline FVTerm& FVTerm::operator << (const typeT& s) return *this; } +//---------------------------------------------------------------------- +inline FVTerm& FVTerm::operator << (fc::SpecialCharacter c) +{ + print (static_cast(c)); // Required under Solaris + return *this; +} + //---------------------------------------------------------------------- inline FVTerm& FVTerm::operator << (const std::string& string) { diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index b45461f6..e9a234a3 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -38,6 +38,24 @@ #include #include +#define CPPUNIT_ASSERT_CSTRING(expected, actual) \ + check_c_string (expected, actual, CPPUNIT_SOURCELINE()) + +//---------------------------------------------------------------------- +void check_c_string ( const char* s1 + , const char* s2 + , CppUnit::SourceLine sourceLine ) +{ + if ( s1 == 0 && s2 == 0 ) // Strings are equal + return; + + if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal + return; + + ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); +} + + namespace test { @@ -50,21 +68,22 @@ namespace test class FSystemTest : public finalcut::FSystem { + public: // Typedefs and Enumerations typedef struct { - unsigned char shift : 1; - unsigned char alt_gr : 1; - unsigned char ctrl : 1; - unsigned char alt : 1; - unsigned char : 4; // padding bits + uChar shift : 1; + uChar alt_gr : 1; + uChar ctrl : 1; + uChar alt : 1; + uChar : 4; // padding bits } shiftstate; typedef struct { - unsigned char red; - unsigned char green; - unsigned char blue; + uChar red; + uChar green; + uChar blue; } rgb; typedef struct @@ -78,7 +97,6 @@ class FSystemTest : public finalcut::FSystem data_mode }; - public: // Constructor FSystemTest(); @@ -86,14 +104,21 @@ class FSystemTest : public finalcut::FSystem virtual ~FSystemTest(); // Methods - virtual uChar inPortByte (uShort); - virtual void outPortByte (uChar, uShort); - virtual int isTTY (int); - virtual int ioctl (int, uLong, ...); - virtual int open (const char*, int, ...); - virtual int close (int); - virtual FILE* fopen (const char*, const char*); - virtual int fclose (FILE*); + virtual uChar inPortByte (uShort); + virtual void outPortByte (uChar, uShort); + virtual int isTTY (int); + virtual int ioctl (int, uLong, ...); + virtual int open (const char*, int, ...); + virtual int close (int); + virtual FILE* fopen (const char*, const char*); + virtual int fclose (FILE*); + virtual int putchar (int); + virtual int tputs (const char*, int, int (*)(int)); + rgb& getRGB (std::size_t); + console_font_op& getConsoleFont(); + + // Data Members + std::string characters; private: // Methods @@ -104,24 +129,26 @@ class FSystemTest : public finalcut::FSystem static shiftstate shift_state; static rgb terminal_color[16]; static rgb defaultColor[16]; + static struct console_font_op terminal_font; static unimapdesc terminal_unicode_map; static struct fb_var_screeninfo fb_terminal_info; static struct fb_fix_screeninfo fb_terminal_fix_info; static bool vga_port_access; ac_mode attribute_controller_mode = index_mode; - unsigned char ac_address_register[21] = \ + uChar ac_address_register[21] = \ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0c, 0x00, 0x0f, 0x08, 0x00 }; - unsigned char ac_index = 0; + uChar ac_index = 0; bool palette_addr_source_field = true; - unsigned char port_3cc = 0x67; // Miscellaneous output - unsigned char port_3da = 0; // Input status 1 + uChar port_3cc = 0x67; // Miscellaneous output + uChar port_3da = 0; // Input status 1 static uChar vga8x16[]; static struct unipair unicode_cp437_pairs[]; + }; #pragma pack(pop) @@ -649,7 +676,6 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = // .----------- unicode // | .---- fontpos // | | - {0x0000, 0x00}, {0x0020, 0x20}, {0x0021, 0x21}, {0x0022, 0x22}, @@ -749,65 +775,34 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x00a1, 0xad}, {0x00a2, 0x9b}, {0x00a3, 0x9c}, - {0x00a4, 0x0f}, {0x00a5, 0x9d}, - {0x00a6, 0x7c}, {0x00a7, 0x15}, - {0x00a8, 0x22}, - {0x00a9, 0x43}, {0x00aa, 0xa6}, {0x00ab, 0xae}, {0x00ac, 0xaa}, - {0x00ad, 0x2d}, - {0x00ae, 0x52}, {0x00b0, 0xf8}, {0x00b1, 0xf1}, {0x00b2, 0xfd}, - {0x00b4, 0x27}, {0x00b5, 0xe6}, {0x00b6, 0x14}, {0x00b7, 0xfa}, - {0x00b8, 0x2c}, {0x00ba, 0xa7}, {0x00bb, 0xaf}, {0x00bc, 0xac}, {0x00bd, 0xab}, {0x00bf, 0xa8}, - {0x00c0, 0x41}, - {0x00c1, 0x41}, - {0x00c2, 0x41}, - {0x00c3, 0x41}, {0x00c4, 0x8e}, {0x00c5, 0x8f}, {0x00c6, 0x92}, {0x00c7, 0x80}, - {0x00c8, 0x45}, {0x00c9, 0x90}, - {0x00ca, 0x45}, - {0x00cb, 0x45}, - {0x00cc, 0x49}, - {0x00cd, 0x49}, - {0x00ce, 0x49}, - {0x00cf, 0x49}, - {0x00d0, 0x44}, {0x00d1, 0xa5}, - {0x00d2, 0x4f}, - {0x00d3, 0x4f}, - {0x00d4, 0x4f}, - {0x00d5, 0x4f}, {0x00d6, 0x99}, - {0x00d7, 0x78}, - {0x00d8, 0xe8}, - {0x00d9, 0x55}, - {0x00da, 0x55}, - {0x00db, 0x55}, {0x00dc, 0x9a}, - {0x00dd, 0x59}, {0x00df, 0xe1}, {0x00e0, 0x85}, {0x00e1, 0xa0}, {0x00e2, 0x83}, - {0x00e3, 0x61}, {0x00e4, 0x84}, {0x00e5, 0x86}, {0x00e6, 0x91}, @@ -820,20 +815,16 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x00ed, 0xa1}, {0x00ee, 0x8c}, {0x00ef, 0x8b}, - {0x00f0, 0xeb}, {0x00f1, 0xa4}, {0x00f2, 0x95}, {0x00f3, 0xa2}, {0x00f4, 0x93}, - {0x00f5, 0x6f}, {0x00f6, 0x94}, {0x00f7, 0xf6}, - {0x00f8, 0xed}, {0x00f9, 0x97}, {0x00fa, 0xa3}, {0x00fb, 0x96}, {0x00fc, 0x81}, - {0x00fd, 0x79}, {0x00ff, 0x98}, {0x0192, 0x9f}, {0x0393, 0xe2}, @@ -850,12 +841,12 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x03c3, 0xe5}, {0x03c4, 0xe7}, {0x03c6, 0xed}, + {0x2008, 0x00}, {0x2022, 0x07}, {0x203c, 0x13}, {0x207f, 0xfc}, {0x20a7, 0x9e}, {0x2126, 0xea}, - {0x212a, 0x4b}, {0x212b, 0x8f}, {0x2190, 0x1b}, {0x2191, 0x18}, @@ -864,7 +855,9 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x2194, 0x1d}, {0x2195, 0x12}, {0x21a8, 0x17}, + {0x2205, 0xed}, {0x2208, 0xee}, + {0x220e, 0xfe}, {0x2219, 0xf9}, {0x221a, 0xfb}, {0x221e, 0xec}, @@ -874,11 +867,13 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x2261, 0xf0}, {0x2264, 0xf3}, {0x2265, 0xf2}, + {0x22c5, 0xf9}, + {0x2300, 0xed}, {0x2302, 0x7f}, {0x2310, 0xa9}, + {0x2319, 0x1c}, {0x2320, 0xf4}, {0x2321, 0xf5}, - {0x23bd, 0x5f}, {0x2500, 0xc4}, {0x2502, 0xb3}, {0x250c, 0xda}, @@ -935,7 +930,6 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x25bc, 0x1f}, {0x25c0, 0x11}, {0x25c4, 0x11}, - {0x25c6, 0x04}, {0x25cb, 0x09}, {0x25d8, 0x08}, {0x25d9, 0x0a}, @@ -950,8 +944,7 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x2666, 0x04}, {0x266a, 0x0d}, {0x266b, 0x0e}, - {0xf804, 0x5f}, - {0xfffd, 0xfe} + {0x266c, 0x0e} }; FSystemTest::rgb FSystemTest::terminal_color[16] { }; @@ -971,11 +964,12 @@ FSystemTest::rgb FSystemTest::defaultColor[16] // static class attributes //---------------------------------------------------------------------- -FSystemTest::shiftstate FSystemTest::shift_state; -unimapdesc FSystemTest::terminal_unicode_map; -struct fb_var_screeninfo FSystemTest::fb_terminal_info; -struct fb_fix_screeninfo FSystemTest::fb_terminal_fix_info; -bool FSystemTest::vga_port_access = false; +FSystemTest::shiftstate FSystemTest::shift_state; +struct console_font_op FSystemTest::terminal_font; +unimapdesc FSystemTest::terminal_unicode_map; +struct fb_var_screeninfo FSystemTest::fb_terminal_info; +struct fb_fix_screeninfo FSystemTest::fb_terminal_fix_info; +bool FSystemTest::vga_port_access = false; // constructors and destructor @@ -984,8 +978,12 @@ FSystemTest::FSystemTest() // constructor { // fill bit field with 0 memset (&shift_state, 0x00, sizeof(shift_state)); + memset (&terminal_font, 0x00, sizeof(terminal_font)); memset (&terminal_unicode_map, 0x00, sizeof(terminal_unicode_map)); + constexpr std::size_t font_data_size = 4 * 32 * 512; + terminal_font.data = new uChar[font_data_size]{ }; + // init framebuffer initVScreenInfo(); initFScreenInfo(); @@ -994,6 +992,9 @@ FSystemTest::FSystemTest() // constructor //---------------------------------------------------------------------- FSystemTest::~FSystemTest() // destructor { + if ( terminal_font.data ) + delete[] terminal_font.data; + if ( terminal_unicode_map.entries ) delete[] terminal_unicode_map.entries; } @@ -1074,7 +1075,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) { req_string = "TIOCLINUX"; char* subcode = static_cast(argp); - unsigned char* state = reinterpret_cast(&shift_state); + uChar* state = reinterpret_cast(&shift_state); if ( *subcode == 6 ) *subcode = static_cast(*state); @@ -1086,13 +1087,45 @@ int FSystemTest::ioctl (int fd, uLong request, ...) case KDFONTOP: { req_string = "KDFONTOP"; + constexpr std::size_t font_data_size = 4 * 32 * 512; struct console_font_op* fn = static_cast(argp); - fn->width = 8; - fn->height = 16; - fn->charcount = 256; - if ( fn->data ) - memcpy (fn->data, &vga8x16, sizeof(vga8x16)); + // Set Default + if ( terminal_font.data && terminal_font.data[219 * 32] == 0 ) + { + terminal_font.width = 8; + terminal_font.height = 16; + terminal_font.charcount = 256; + + if ( fn->data ) + std::memcpy (terminal_font.data, &vga8x16, sizeof(vga8x16)); + } + + if ( fn->op == KD_FONT_OP_GET ) + { + fn->flags = terminal_font.flags; + fn->width = terminal_font.width; + fn->height = terminal_font.height; + fn->charcount = terminal_font.charcount; + + if ( fn->data ) + std::memcpy (fn->data, terminal_font.data, font_data_size); + + terminal_font.op = KD_FONT_OP_GET; + } + + if ( fn->op == KD_FONT_OP_SET ) + { + terminal_font.flags = fn->flags; + terminal_font.width = fn->width; + terminal_font.height = fn->height; + terminal_font.charcount = fn->charcount; + + if ( fn->data ) + std::memcpy (terminal_font.data, fn->data, font_data_size); + + terminal_font.op = KD_FONT_OP_SET; + } ret_val = 0; break; @@ -1116,7 +1149,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) && terminal_color[15].green == 0 && terminal_color[15].blue == 0 ) { - for (size_t index = 0; index < 16; index++) + for (std::size_t index = 0; index < 16; index++) { terminal_color[index].red = defaultColor[index].red; terminal_color[index].green = defaultColor[index].green; @@ -1124,7 +1157,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) } } - for (size_t index = 0; index < 16; index++) + for (std::size_t index = 0; index < 16; index++) { cmap->color[index].red = terminal_color[index].red; cmap->color[index].green = terminal_color[index].green; @@ -1140,7 +1173,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) req_string = "PIO_CMAP"; ColorMap* cmap = static_cast(argp); - for (size_t index = 0; index < 16; index++) + for (std::size_t index = 0; index < 16; index++) { terminal_color[index].red = cmap->color[index].red; terminal_color[index].green = cmap->color[index].green; @@ -1155,26 +1188,30 @@ int FSystemTest::ioctl (int fd, uLong request, ...) { req_string = "GIO_UNIMAP"; unimapdesc* umap = static_cast(argp); - size_t pairs = sizeof(unicode_cp437_pairs) / sizeof(unipair); - size_t pairs_size = pairs * sizeof(unipair); + std::size_t pairs = sizeof(unicode_cp437_pairs) / sizeof(unipair); + std::size_t pairs_size = pairs * sizeof(unipair); // Sets the default unicode map of the terminal on the first call if ( terminal_unicode_map.entries == 0 ) { terminal_unicode_map.entry_ct = pairs; terminal_unicode_map.entries = new unipair[pairs](); - memcpy (terminal_unicode_map.entries, &unicode_cp437_pairs, pairs_size); + std::memcpy (terminal_unicode_map.entries, &unicode_cp437_pairs, pairs_size); } umap->entry_ct = terminal_unicode_map.entry_ct; if ( umap->entries && terminal_unicode_map.entries ) { - memcpy (umap->entries, &terminal_unicode_map.entries, pairs_size); + std::memcpy (umap->entries, terminal_unicode_map.entries, pairs_size); + errno = 0; ret_val = 0; } else + { + errno = ENOMEM; ret_val = -1; + } break; } @@ -1183,7 +1220,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) { req_string = "PIO_UNIMAP"; unimapdesc* umap = static_cast(argp); - memcpy (&terminal_unicode_map, umap, sizeof(*umap)); + std::memcpy (&terminal_unicode_map, umap, sizeof(*umap)); ret_val = 0; break; } @@ -1198,7 +1235,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) req_string = "FBIOGET_VSCREENINFO"; struct fb_var_screeninfo* fb_var \ = static_cast(argp); - memcpy (fb_var, &fb_terminal_info, sizeof(fb_terminal_info)); + std::memcpy (fb_var, &fb_terminal_info, sizeof(fb_terminal_info)); ret_val = 0; break; } @@ -1208,7 +1245,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) req_string = "FBIOGET_FSCREENINFO"; struct fb_fix_screeninfo* fb_fix = static_cast(argp); - memcpy (fb_fix, &fb_terminal_fix_info, sizeof(fb_terminal_fix_info)); + std::memcpy (fb_fix, &fb_terminal_fix_info, sizeof(fb_terminal_fix_info)); ret_val = 0; break; } @@ -1290,6 +1327,36 @@ int FSystemTest::fclose (FILE* fp) return 0; } +//---------------------------------------------------------------------- +int FSystemTest::putchar (int c) +{ + std::cerr << "Call: putchar (" << c << ")\n"; + characters.push_back(c); + return 1; +} + +//---------------------------------------------------------------------- +int FSystemTest::tputs (const char* str, int affcnt, int (*putc)(int)) +{ + return ::tputs (str, affcnt, putc); +} + +//---------------------------------------------------------------------- +FSystemTest::rgb& FSystemTest::getRGB (std::size_t i) +{ + if ( i < 16 ) + return terminal_color[i]; + else + return terminal_color[0]; +} + +//---------------------------------------------------------------------- +console_font_op& FSystemTest::getConsoleFont() +{ + return terminal_font; +} + + // private methods of FSystemTest //---------------------------------------------------------------------- void FSystemTest::initVScreenInfo() @@ -1380,6 +1447,9 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu protected: void classNameTest(); void linuxConsoleTest(); + void linuxCursorStyleTest(); + void linuxColorPaletteTest(); + void linuxFontTest(); private: // Adds code needed to register the test suite @@ -1388,6 +1458,9 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu // Add a methods to the test suite CPPUNIT_TEST (classNameTest); CPPUNIT_TEST (linuxConsoleTest); + CPPUNIT_TEST (linuxCursorStyleTest); + CPPUNIT_TEST (linuxColorPaletteTest); + CPPUNIT_TEST (linuxFontTest); // End of test suite definition CPPUNIT_TEST_SUITE_END(); @@ -1427,12 +1500,6 @@ void FTermLinuxTest::linuxConsoleTest() encoding_list["ASCII"] = finalcut::fc::ASCII; data->setTermEncoding(finalcut::fc::PC); - - auto& character_map = data->getCharSubstitutionMap(); - character_map[finalcut::fc::BlackCircle] = L'*'; - character_map[finalcut::fc::Times] = L'x'; - character_map[L'ˣ'] = finalcut::fc::SuperscriptLatinSmallLetterN; - data->setBaudrate(38400); data->setTermType("linux"); data->setTermFileName("/dev/tty2"); @@ -1488,20 +1555,34 @@ void FTermLinuxTest::linuxConsoleTest() CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); + test::FSystemTest* fsystest = static_cast(fsys); + linux.setUTF8 (false); + CPPUNIT_ASSERT ( fsystest->characters == ESC "%@" ); + fsystest->characters.clear(); + + linux.setUTF8 (true); + CPPUNIT_ASSERT ( fsystest->characters == ESC "%G" ); + fsystest->characters.clear(); + + + linux.setBeep (200, 100); + CPPUNIT_ASSERT ( fsystest->characters == CSI "10;200]" CSI "11;100]" ); + fsystest->characters.clear(); + linux.resetBeep(); + CPPUNIT_ASSERT ( fsystest->characters == CSI "10;750]" CSI "11;125]" ); + fsystest->characters.clear(); + + linux.initCharMap (finalcut::fc::character); + auto& character_map = data->getCharSubstitutionMap(); + CPPUNIT_ASSERT ( character_map.size() == 3 ); + CPPUNIT_ASSERT ( character_map[finalcut::fc::BlackCircle] == L'*' ); + CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' ); + CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'ⁿ' ); + + // linux.loadVGAFont() + // linux.loadNewFont() + // linux.loadOldFont(finalcut::fc::character); - // linux->setUTF8 (enable); - // linux->loadVGAFont() - // linux->loadNewFont() - // linux->loadOldFont(fc::character); - // linux->initCharMap (fc::character); - // linux->restoreCursorStyle(); - // linux->saveColorMap(); - // linux->resetColorMap(); - // linux->setPalette(index, r, g, b); - // linux->setBeep (Hz, ms); - // linux->resetBeep(); - // const char* cstyle = linux->setCursorStyle ( fc::underscore_cursor - // , data->isCursorHidden() ); closeConEmuStdStreams(); exit(EXIT_SUCCESS); } @@ -1517,6 +1598,552 @@ void FTermLinuxTest::linuxConsoleTest() linux.finish(); } +//---------------------------------------------------------------------- +void FTermLinuxTest::linuxCursorStyleTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::PC); + data->setBaudrate(38400); + data->setTermType("linux"); + data->setTermFileName("/dev/tty2"); + +#if DEBUG + data->setFramebufferBpp(32); +#endif + + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + finalcut::FTermLinux linux; + + term_detection->setLinuxTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "linux", 1); + setenv ("COLUMNS", "90", 1); + setenv ("LINES", "30", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + term_detection->detect(); + linux.init(); + + char* cursorstyle; + cursorstyle = linux.setCursorStyle (finalcut::fc::default_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?0c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::invisible_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?1c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::underscore_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?2c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::lower_third_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?3c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::lower_half_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?4c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::two_thirds_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?5c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::full_block_cursor, false); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?6c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor ); + + cursorstyle = linux.setCursorStyle (finalcut::fc::default_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?0c" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); + cursorstyle = linux.setCursorStyle (finalcut::fc::invisible_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?1c" ); + cursorstyle = linux.setCursorStyle (finalcut::fc::underscore_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?2c" ); + cursorstyle = linux.setCursorStyle (finalcut::fc::lower_third_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?3c" ); + cursorstyle = linux.setCursorStyle (finalcut::fc::lower_half_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?4c" ); + cursorstyle = linux.setCursorStyle (finalcut::fc::two_thirds_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?5c" ); + cursorstyle = linux.setCursorStyle (finalcut::fc::full_block_cursor, true); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); + CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor ); + cursorstyle = linux.restoreCursorStyle(); + CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?6c" ); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::linux_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + linux.finish(); +} + +//---------------------------------------------------------------------- +void FTermLinuxTest::linuxColorPaletteTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::PC); + data->setBaudrate(38400); + data->setTermType("linux"); + data->setTermFileName("/dev/tty2"); + +#if DEBUG + data->setFramebufferBpp(32); +#endif + + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + finalcut::FTermLinux linux; + + term_detection->setLinuxTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "linux", 1); + setenv ("COLUMNS", "90", 1); + setenv ("LINES", "30", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + term_detection->detect(); + linux.init(); + test::FSystemTest* fsystest = static_cast(fsys); + + CPPUNIT_ASSERT ( linux.resetColorMap() == true ); + CPPUNIT_ASSERT ( linux.saveColorMap() == true ); + FColor index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Black); + test::FSystemTest::rgb& RGB0 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB0.red == 0x00 ); + CPPUNIT_ASSERT ( RGB0.green == 0x00 ); + CPPUNIT_ASSERT ( RGB0.blue == 0x00 ); + linux.setPalette (index, 0x01, 0x02, 0x03); + CPPUNIT_ASSERT ( RGB0.red == 0x01 ); + CPPUNIT_ASSERT ( RGB0.green == 0x02 ); + CPPUNIT_ASSERT ( RGB0.blue == 0x03 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Blue); + test::FSystemTest::rgb& RGB1 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB1.red == 0x00 ); + CPPUNIT_ASSERT ( RGB1.green == 0x00 ); + CPPUNIT_ASSERT ( RGB1.blue == 0xaa ); + linux.setPalette (index, 0x04, 0x05, 0x06); + CPPUNIT_ASSERT ( RGB1.red == 0x04 ); + CPPUNIT_ASSERT ( RGB1.green == 0x05 ); + CPPUNIT_ASSERT ( RGB1.blue == 0x06 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Green); + test::FSystemTest::rgb& RGB2 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB2.red == 0x00 ); + CPPUNIT_ASSERT ( RGB2.green == 0xaa ); + CPPUNIT_ASSERT ( RGB2.blue == 0x00 ); + linux.setPalette (index, 0x07, 0x08, 0x09); + CPPUNIT_ASSERT ( RGB2.red == 0x07 ); + CPPUNIT_ASSERT ( RGB2.green == 0x08 ); + CPPUNIT_ASSERT ( RGB2.blue == 0x09 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Cyan); + test::FSystemTest::rgb& RGB3 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB3.red == 0x00 ); + CPPUNIT_ASSERT ( RGB3.green == 0xaa ); + CPPUNIT_ASSERT ( RGB3.blue == 0xaa ); + linux.setPalette (index, 0x0a, 0x0b, 0x0c); + CPPUNIT_ASSERT ( RGB3.red == 0x0a ); + CPPUNIT_ASSERT ( RGB3.green == 0x0b ); + CPPUNIT_ASSERT ( RGB3.blue == 0x0c ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Red); + test::FSystemTest::rgb& RGB4 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB4.red == 0xaa ); + CPPUNIT_ASSERT ( RGB4.green == 0x00 ); + CPPUNIT_ASSERT ( RGB4.blue == 0x00 ); + linux.setPalette (index, 0x0d, 0x0e, 0x0f); + CPPUNIT_ASSERT ( RGB4.red == 0x0d ); + CPPUNIT_ASSERT ( RGB4.green == 0x0e ); + CPPUNIT_ASSERT ( RGB4.blue == 0x0f ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Magenta); + test::FSystemTest::rgb& RGB5 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB5.red == 0xaa ); + CPPUNIT_ASSERT ( RGB5.green == 0x00 ); + CPPUNIT_ASSERT ( RGB5.blue == 0xaa ); + linux.setPalette (index, 0x10, 0x11, 0x12); + CPPUNIT_ASSERT ( RGB5.red == 0x10 ); + CPPUNIT_ASSERT ( RGB5.green == 0x11 ); + CPPUNIT_ASSERT ( RGB5.blue == 0x12 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Brown); + test::FSystemTest::rgb& RGB6 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB6.red == 0xaa ); + CPPUNIT_ASSERT ( RGB6.green == 0x55 ); + CPPUNIT_ASSERT ( RGB6.blue == 0x00 ); + linux.setPalette (index, 0x13, 0x14, 0x15); + CPPUNIT_ASSERT ( RGB6.red == 0x13 ); + CPPUNIT_ASSERT ( RGB6.green == 0x14 ); + CPPUNIT_ASSERT ( RGB6.blue == 0x15 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightGray); + test::FSystemTest::rgb& RGB7 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB7.red == 0xaa ); + CPPUNIT_ASSERT ( RGB7.green == 0xaa ); + CPPUNIT_ASSERT ( RGB7.blue == 0xaa ); + linux.setPalette (index, 0x16, 0x17, 0x18); + CPPUNIT_ASSERT ( RGB7.red == 0x16 ); + CPPUNIT_ASSERT ( RGB7.green == 0x17 ); + CPPUNIT_ASSERT ( RGB7.blue == 0x18 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::DarkGray); + test::FSystemTest::rgb& RGB8 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB8.red == 0x55 ); + CPPUNIT_ASSERT ( RGB8.green == 0x55 ); + CPPUNIT_ASSERT ( RGB8.blue == 0x55 ); + linux.setPalette (index, 0x19, 0x20, 0x21); + CPPUNIT_ASSERT ( RGB8.red == 0x19 ); + CPPUNIT_ASSERT ( RGB8.green == 0x20 ); + CPPUNIT_ASSERT ( RGB8.blue == 0x21 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightBlue); + test::FSystemTest::rgb& RGB9 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB9.red == 0x55 ); + CPPUNIT_ASSERT ( RGB9.green == 0x55 ); + CPPUNIT_ASSERT ( RGB9.blue == 0xff ); + linux.setPalette (index, 0x22, 0x23, 0x24); + CPPUNIT_ASSERT ( RGB9.red == 0x22 ); + CPPUNIT_ASSERT ( RGB9.green == 0x23 ); + CPPUNIT_ASSERT ( RGB9.blue == 0x24 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightGreen); + test::FSystemTest::rgb& RGB10 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB10.red == 0x55 ); + CPPUNIT_ASSERT ( RGB10.green == 0xff ); + CPPUNIT_ASSERT ( RGB10.blue == 0x55 ); + linux.setPalette (index, 0x25, 0x26, 0x27); + CPPUNIT_ASSERT ( RGB10.red == 0x25 ); + CPPUNIT_ASSERT ( RGB10.green == 0x26 ); + CPPUNIT_ASSERT ( RGB10.blue == 0x27 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightCyan); + test::FSystemTest::rgb& RGB11 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB11.red == 0x55 ); + CPPUNIT_ASSERT ( RGB11.green == 0xff ); + CPPUNIT_ASSERT ( RGB11.blue == 0xff ); + linux.setPalette (index, 0x28, 0x29, 0x30); + CPPUNIT_ASSERT ( RGB11.red == 0x28 ); + CPPUNIT_ASSERT ( RGB11.green == 0x29 ); + CPPUNIT_ASSERT ( RGB11.blue == 0x30 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightRed); + test::FSystemTest::rgb& RGB12 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB12.red == 0xff ); + CPPUNIT_ASSERT ( RGB12.green == 0x55 ); + CPPUNIT_ASSERT ( RGB12.blue == 0x55 ); + linux.setPalette (index, 0x31, 0x32, 0x33); + CPPUNIT_ASSERT ( RGB12.red == 0x31 ); + CPPUNIT_ASSERT ( RGB12.green == 0x32 ); + CPPUNIT_ASSERT ( RGB12.blue == 0x33 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightMagenta); + test::FSystemTest::rgb& RGB13 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB13.red == 0xff ); + CPPUNIT_ASSERT ( RGB13.green == 0x55 ); + CPPUNIT_ASSERT ( RGB13.blue == 0xff ); + linux.setPalette (index, 0x34, 0x35, 0x36); + CPPUNIT_ASSERT ( RGB13.red == 0x34 ); + CPPUNIT_ASSERT ( RGB13.green == 0x35 ); + CPPUNIT_ASSERT ( RGB13.blue == 0x36 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Yellow); + test::FSystemTest::rgb& RGB14 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB14.red == 0xff ); + CPPUNIT_ASSERT ( RGB14.green == 0xff ); + CPPUNIT_ASSERT ( RGB14.blue == 0x55 ); + linux.setPalette (index, 0x37, 0x38, 0x39); + CPPUNIT_ASSERT ( RGB14.red == 0x37 ); + CPPUNIT_ASSERT ( RGB14.green == 0x38 ); + CPPUNIT_ASSERT ( RGB14.blue == 0x39 ); + + index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::White); + test::FSystemTest::rgb& RGB15 = fsystest->getRGB(index); + CPPUNIT_ASSERT ( RGB15.red == 0xff ); + CPPUNIT_ASSERT ( RGB15.green == 0xff ); + CPPUNIT_ASSERT ( RGB15.blue == 0xff ); + linux.setPalette (index, 0x40, 0x41, 0x42); + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, -1, 0, 0); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, 0, -1, 0); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, 0, 0, -1); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, 256, 0, 0); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, 0, 256, 0); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + linux.setPalette (index, 0, 0, 256); // Out of range -> no change + CPPUNIT_ASSERT ( RGB15.red == 0x40 ); + CPPUNIT_ASSERT ( RGB15.green == 0x41 ); + CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::linux_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + linux.finish(); +} + +//---------------------------------------------------------------------- +void FTermLinuxTest::linuxFontTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::PC); + data->setBaudrate(38400); + data->setTermType("linux"); + data->setTermFileName("/dev/tty2"); + +#if DEBUG + data->setFramebufferBpp(32); +#endif + + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + finalcut::FTermLinux linux; + + term_detection->setLinuxTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "linux", 1); + setenv ("COLUMNS", "90", 1); + setenv ("LINES", "30", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + term_detection->detect(); + linux.init(); + test::FSystemTest* fsystest = static_cast(fsys); + console_font_op& font = fsystest->getConsoleFont(); + CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET ); + + linux.loadVGAFont(); + CPPUNIT_ASSERT ( data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); + CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET ); + + // Full block character test + for (std::size_t i = 0; i < 16 ; i++) + CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); + + linux.loadNewFont(); + + // Full block character test + for (std::size_t i = 0; i < 16 ; i++) + CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); + + + // New font bullet + CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 1] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 2] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 3] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 4] == 0x38 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 5] == 0x7c ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 6] == 0xfe ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 7] == 0xfe ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 8] == 0xfe ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 9] == 0x7c ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 10] == 0x38 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 11] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 12] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 13] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); + + linux.loadOldFont(finalcut::fc::character); + + // cp437 bullet operator + CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 1] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 2] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 3] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 4] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 5] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 6] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 7] == 0x18 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 8] == 0x18 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 9] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 10] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 11] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 12] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 13] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 ); + CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::linux_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + linux.finish(); +} // Put the test suite in the registry CPPUNIT_TEST_SUITE_REGISTRATION (FTermLinuxTest); From 38df0392356d4ac9effecdd2581c20fdc9444ef4 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 4 Jul 2019 15:26:26 +0200 Subject: [PATCH 30/70] Expanding the unit test for FTermLinux --- ChangeLog | 2 +- README.md | 66 +++-- build.sh | 1 + doc/class-diagram.txt | 67 +++-- src/ftermlinux.cpp | 8 +- src/include/final/fsystem.h | 17 +- src/include/final/fsystemimpl.h | 4 + test/ftermlinux-test.cpp | 486 ++++++++++++++++++++++++++++++-- 8 files changed, 561 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b4467b5..4c196acc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2019-06-30 Markus Gans - * Expanding the Unit Test for FTermLinux + * Expanding the unit test for FTermLinux * Update the cp437 unicode map * Reducing the special cases for Solaris diff --git a/README.md b/README.md index 7d707369..88bd0194 100644 --- a/README.md +++ b/README.md @@ -152,47 +152,53 @@ Class digramm 1┌──────────────┐ ┌-----------┤ FTermFreeBSD │ : └──────────────┘ - : 1┌──────────────┐ ┌───────────┐ - ┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ - : └──────────────┘ │ └───────────┘ + : 1┌──────────────┐ + ┌-----------┤ FTermOpenBSD │ + : └──────────────┘ + : 1┌────────────────┐ ┌───────────┐ + ┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │ + : └────────────────┘ │ └───────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ + ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │ : └────────────────┘ │ └─────────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ - : └────────────────┘ │ └─────────────┘ - : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │ + ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │ : └────────────────┘ │ └─────────────┘ : 1┌──────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ + ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │ : └──────────┘ │ └─────────────┘ - : 1┌──────────┐ │ ┌──────────────┐ - ┌-----------┤ FTermios │ ├────┤ FResizeEvent │ - : └──────────┘ │ └──────────────┘ - : 1┌───────────────┐ │ ┌────────────┐ - ┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ - : └───────────────┘ │ └────────────┘ + : 1┌──────────┐ │ ┌─────────────┐ + ┌-----------┤ FTermios │ ├────┤ FAccelEvent │ + : └──────────┘ │ └─────────────┘ + : 1┌───────────────┐ │ ┌──────────────┐ + ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │ + : └───────────────┘ │ └──────────────┘ : 1┌───────────┐ │ ┌────────────┐ - ┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ + ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │ + : └───────────┘ │ └────────────┘ + : 1┌───────────┐ │ ┌────────────┐ + ┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │ : └───────────┘ │ └────────────┘ : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ + ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │ : └───────────┘ │ └─────────────┘ - : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ - : └───────────┘ │ └─────────────┘ - : 1┌───────────────┐ │ - ┌-----------┤ FMouseControl │ │ ┌──────────────┐ - : └───────────────┘ │ ┌────┤ FApplication │ - : *┌─────────┐ │ │ └──────────────┘ - : ┌--------┤ FString │ │ │ ┌─────────┐ - : : └─────────┘ │ ├────┤ FButton │ - : : *┌────────┐ │ │ └─────────┘ - : ┌--------┤ FPoint │ │ │ ┌────────┐ - : : └────────┘ │ ├────┤ FLabel │ + : 1┌───────────────┐ │ ┌─────────────┐ + ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ + : └───────────────┘ │ └─────────────┘ + : 1┌─────────┐ │ + ┌-----------┤ FSystem │ │ + : └─────────┘ │ + : *┌─────────┐ │ + : ┌--------┤ FString │ │ ┌──────────────┐ + : : └─────────┘ │ ┌────┤ FApplication │ + : : *┌────────┐ │ │ └──────────────┘ + : ┌--------┤ FPoint │ │ │ ┌─────────┐ + : : └────────┘ │ ├────┤ FButton │ + : : *┌───────┐ │ │ └─────────┘ + : ┌--------┤ FRect │ │ │ ┌────────┐ + : : └───────┘ │ ├────┤ FLabel │ : : *┌───────┐ │ │ └────────┘ - : ┌--------┤ FRect │ │ │ ┌───────────┐ + : ┌--------┤ FSize │ │ │ ┌───────────┐ : : └───────┘ │ ├────┤ FLineEdit │ :1 :1 │ │ └───────────┘ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ diff --git a/build.sh b/build.sh index deeaebeb..22f260b4 100755 --- a/build.sh +++ b/build.sh @@ -139,6 +139,7 @@ if [ "$1" = "--unit-test" ] \ || [ "$1" = "--coverage" ] \ || [ "$1" = "coverage" ] then + rm test/*.log 2>/dev/null cd test && make check-TESTS cat ./*.log 2>/dev/null cd .. || exit diff --git a/doc/class-diagram.txt b/doc/class-diagram.txt index 200f4ace..5157f210 100644 --- a/doc/class-diagram.txt +++ b/doc/class-diagram.txt @@ -4,47 +4,53 @@ 1┌──────────────┐ ┌-----------┤ FTermFreeBSD │ : └──────────────┘ - : 1┌──────────────┐ ┌───────────┐ - ┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ - : └──────────────┘ │ └───────────┘ + : 1┌──────────────┐ + ┌-----------┤ FTermOpenBSD │ + : └──────────────┘ + : 1┌────────────────┐ ┌───────────┐ + ┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │ + : └────────────────┘ │ └───────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ + ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │ : └────────────────┘ │ └─────────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ - : └────────────────┘ │ └─────────────┘ - : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │ + ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │ : └────────────────┘ │ └─────────────┘ : 1┌──────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ + ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │ : └──────────┘ │ └─────────────┘ - : 1┌──────────┐ │ ┌──────────────┐ - ┌-----------┤ FTermios │ ├────┤ FResizeEvent │ - : └──────────┘ │ └──────────────┘ - : 1┌───────────────┐ │ ┌────────────┐ - ┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ - : └───────────────┘ │ └────────────┘ + : 1┌──────────┐ │ ┌─────────────┐ + ┌-----------┤ FTermios │ ├────┤ FAccelEvent │ + : └──────────┘ │ └─────────────┘ + : 1┌───────────────┐ │ ┌──────────────┐ + ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │ + : └───────────────┘ │ └──────────────┘ : 1┌───────────┐ │ ┌────────────┐ - ┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ + ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │ + : └───────────┘ │ └────────────┘ + : 1┌───────────┐ │ ┌────────────┐ + ┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │ : └───────────┘ │ └────────────┘ : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ + ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │ : └───────────┘ │ └─────────────┘ - : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ - : └───────────┘ │ └─────────────┘ - : 1┌───────────────┐ │ - ┌-----------┤ FMouseControl │ │ ┌──────────────┐ - : └───────────────┘ │ ┌────┤ FApplication │ - : *┌─────────┐ │ │ └──────────────┘ - : ┌--------┤ FString │ │ │ ┌─────────┐ - : : └─────────┘ │ ├────┤ FButton │ - : : *┌────────┐ │ │ └─────────┘ - : ┌--------┤ FPoint │ │ │ ┌────────┐ - : : └────────┘ │ ├────┤ FLabel │ + : 1┌───────────────┐ │ ┌─────────────┐ + ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ + : └───────────────┘ │ └─────────────┘ + : 1┌─────────┐ │ + ┌-----------┤ FSystem │ │ + : └─────────┘ │ + : *┌─────────┐ │ + : ┌--------┤ FString │ │ ┌──────────────┐ + : : └─────────┘ │ ┌────┤ FApplication │ + : : *┌────────┐ │ │ └──────────────┘ + : ┌--------┤ FPoint │ │ │ ┌─────────┐ + : : └────────┘ │ ├────┤ FButton │ + : : *┌───────┐ │ │ └─────────┘ + : ┌--------┤ FRect │ │ │ ┌────────┐ + : : └───────┘ │ ├────┤ FLabel │ : : *┌───────┐ │ │ └────────┘ - : ┌--------┤ FRect │ │ │ ┌───────────┐ + : ┌--------┤ FSize │ │ │ ┌───────────┐ : : └───────┘ │ ├────┤ FLineEdit │ :1 :1 │ │ └───────────┘ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ @@ -100,4 +106,3 @@ └──────────┘ │ ┌────────────────┐* : └──┤ FRadioMenuItem ├---┘ └────────────────┘ - diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index d80b67cf..b575820e 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -252,6 +252,7 @@ void FTermLinux::finish() bool FTermLinux::loadVGAFont() { vga_font = true; + new_font = false; if ( FTerm::openConsole() == 0 ) { @@ -292,6 +293,7 @@ bool FTermLinux::loadVGAFont() bool FTermLinux::loadNewFont() { new_font = true; + vga_font = false; if ( FTerm::openConsole() == 0 ) { @@ -840,7 +842,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) if ( screen_font.charcount > 256 ) return -1; - if ( getuid() != 0 ) // Direct hardware access requires root privileges + if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges return -2; if ( fd_tty < 0 ) @@ -1109,10 +1111,10 @@ FKey FTermLinux::shiftAltKeyCorrection (const FKey& key_id) return fc::Fmkey_sdown; // Shift+Meta+Down case fc::Fkey_left: - return fc::Fmkey_sright; // Shift+Meta+Left + return fc::Fmkey_sleft; // Shift+Meta+Left case fc::Fkey_right: - return fc::Fmkey_sleft; // Shift+Meta+Right + return fc::Fmkey_sright; // Shift+Meta+Right case fc::Fkey_ic: return fc::Fmkey_sic; // Shift+Meta+Ins diff --git a/src/include/final/fsystem.h b/src/include/final/fsystem.h index 8d3ea699..7d1ed7e6 100644 --- a/src/include/final/fsystem.h +++ b/src/include/final/fsystem.h @@ -58,15 +58,16 @@ class FSystem // Methods virtual uChar inPortByte (uShort) = 0; - virtual void outPortByte (uChar, uShort) = 0; - virtual int isTTY (int) = 0; - virtual int ioctl (int, uLong, ...) = 0; - virtual int open (const char*, int, ...) = 0; - virtual int close (int) = 0; + virtual void outPortByte (uChar, uShort) = 0; + virtual int isTTY (int) = 0; + virtual int ioctl (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; - virtual int putchar (int) = 0; - virtual int tputs (const char*, int, int (*)(int)) = 0; + virtual int fclose (FILE*) = 0; + virtual int putchar (int) = 0; + virtual int tputs (const char*, int, int (*)(int)) = 0; + virtual uid_t getuid() = 0; }; #pragma pack(pop) diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index acc43659..69a337a7 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -186,6 +186,10 @@ class FSystemImpl : public FSystem #endif } + virtual uid_t getuid() + { + return ::getuid(); + } }; #pragma pack(pop) diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index e9a234a3..ac96c7e9 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -114,11 +114,11 @@ class FSystemTest : public finalcut::FSystem virtual int fclose (FILE*); virtual int putchar (int); virtual int tputs (const char*, int, int (*)(int)); + virtual uid_t getuid(); rgb& getRGB (std::size_t); console_font_op& getConsoleFont(); - - // Data Members - std::string characters; + shiftstate& getShiftState(); + std::string& getCharacters(); private: // Methods @@ -126,6 +126,7 @@ class FSystemTest : public finalcut::FSystem static void initFScreenInfo(); // Data Members + std::string characters; static shiftstate shift_state; static rgb terminal_color[16]; static rgb defaultColor[16]; @@ -148,7 +149,6 @@ class FSystemTest : public finalcut::FSystem uChar port_3da = 0; // Input status 1 static uChar vga8x16[]; static struct unipair unicode_cp437_pairs[]; - }; #pragma pack(pop) @@ -1341,6 +1341,12 @@ int FSystemTest::tputs (const char* str, int affcnt, int (*putc)(int)) return ::tputs (str, affcnt, putc); } +//---------------------------------------------------------------------- +uid_t FSystemTest::getuid() +{ + return 0; +} + //---------------------------------------------------------------------- FSystemTest::rgb& FSystemTest::getRGB (std::size_t i) { @@ -1356,6 +1362,17 @@ console_font_op& FSystemTest::getConsoleFont() return terminal_font; } +//---------------------------------------------------------------------- +FSystemTest::shiftstate& FSystemTest::getShiftState() +{ + return shift_state; +} + +//---------------------------------------------------------------------- +std::string& FSystemTest::getCharacters() +{ + return characters; +} // private methods of FSystemTest //---------------------------------------------------------------------- @@ -1450,6 +1467,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu void linuxCursorStyleTest(); void linuxColorPaletteTest(); void linuxFontTest(); + void modifierKeyTest(); private: // Adds code needed to register the test suite @@ -1461,6 +1479,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu CPPUNIT_TEST (linuxCursorStyleTest); CPPUNIT_TEST (linuxColorPaletteTest); CPPUNIT_TEST (linuxFontTest); + CPPUNIT_TEST (modifierKeyTest); // End of test suite definition CPPUNIT_TEST_SUITE_END(); @@ -1556,21 +1575,22 @@ void FTermLinuxTest::linuxConsoleTest() CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); test::FSystemTest* fsystest = static_cast(fsys); + std::string& characters = fsystest->getCharacters(); linux.setUTF8 (false); - CPPUNIT_ASSERT ( fsystest->characters == ESC "%@" ); - fsystest->characters.clear(); + CPPUNIT_ASSERT ( characters == ESC "%@" ); + characters.clear(); linux.setUTF8 (true); - CPPUNIT_ASSERT ( fsystest->characters == ESC "%G" ); - fsystest->characters.clear(); + CPPUNIT_ASSERT ( characters == ESC "%G" ); + characters.clear(); linux.setBeep (200, 100); - CPPUNIT_ASSERT ( fsystest->characters == CSI "10;200]" CSI "11;100]" ); - fsystest->characters.clear(); + CPPUNIT_ASSERT ( characters == CSI "10;200]" CSI "11;100]" ); + characters.clear(); linux.resetBeep(); - CPPUNIT_ASSERT ( fsystest->characters == CSI "10;750]" CSI "11;125]" ); - fsystest->characters.clear(); + CPPUNIT_ASSERT ( characters == CSI "10;750]" CSI "11;125]" ); + characters.clear(); linux.initCharMap (finalcut::fc::character); auto& character_map = data->getCharSubstitutionMap(); @@ -1579,10 +1599,6 @@ void FTermLinuxTest::linuxConsoleTest() CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' ); CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'ⁿ' ); - // linux.loadVGAFont() - // linux.loadNewFont() - // linux.loadOldFont(finalcut::fc::character); - closeConEmuStdStreams(); exit(EXIT_SUCCESS); } @@ -2075,23 +2091,28 @@ void FTermLinuxTest::linuxFontTest() test::FSystemTest* fsystest = static_cast(fsys); console_font_op& font = fsystest->getConsoleFont(); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET ); + CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() ); + CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); linux.loadVGAFont(); CPPUNIT_ASSERT ( data->hasShadowCharacter() ); CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET ); + CPPUNIT_ASSERT ( linux.isVGAFontUsed() ); + CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); // Full block character test for (std::size_t i = 0; i < 16 ; i++) CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); linux.loadNewFont(); + CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() ); + CPPUNIT_ASSERT ( linux.isNewFontUsed() ); // Full block character test for (std::size_t i = 0; i < 16 ; i++) CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); - // New font bullet CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 1] == 0x00 ); @@ -2111,6 +2132,8 @@ void FTermLinuxTest::linuxFontTest() CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); linux.loadOldFont(finalcut::fc::character); + CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() ); + CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); // cp437 bullet operator CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); @@ -2145,6 +2168,435 @@ void FTermLinuxTest::linuxFontTest() linux.finish(); } +//---------------------------------------------------------------------- +void FTermLinuxTest::modifierKeyTest() +{ + FKey keycode; + FKey mod_keycode; + const finalcut::FTermLinux linux; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + test::FSystemTest* fsystest = static_cast(fsys); + test::FSystemTest::shiftstate& mod_key = fsystest->getShiftState(); + + // Up key + keycode = finalcut::fc::Fkey_up; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_up ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sr ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_up ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_up ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sup ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sup ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_up ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sup ); + + // Down key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_down; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_down ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sf ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_down ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_down ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sdown ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sdown ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_down ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sdown ); + + // Left key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_left; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_left ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sleft ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_left ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_left ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sleft ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sleft ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_left ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sleft ); + + // Right key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_right; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_right ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sright ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_right ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_right ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sright ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sright ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_right ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sright ); + + // Insert key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_ic; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_ic ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sic ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_ic ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_ic ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sic ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sic ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_ic ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sic ); + + // Delete key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_dc; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_dc ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sdc ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_dc ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_dc ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sdc ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sdc ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_dc ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sdc ); + + // Home key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_home; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_home ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_shome ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_home ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_home ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_shome ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_shome ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_home ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_shome ); + + // End key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_end; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_end ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_send ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_end ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_end ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_send ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_send ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_end ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_send ); + + // Page Up key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_ppage; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_ppage ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sprevious ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_ppage ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_ppage ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sppage ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sppage ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_ppage ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sppage ); + + // Page Down key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_npage; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_npage ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_snext ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_npage ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_npage ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_snpage ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_snpage ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_npage ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_snpage ); +} + // Put the test suite in the registry CPPUNIT_TEST_SUITE_REGISTRATION (FTermLinuxTest); From 7cd169758c9656e9ebb9cbd921a2b43b7c7aec9b Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 6 Jul 2019 02:57:03 +0200 Subject: [PATCH 31/70] Expanding the unit test for FTermLinux --- test/ftermlinux-test.cpp | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index ac96c7e9..b7021b9c 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -1585,7 +1585,15 @@ void FTermLinuxTest::linuxConsoleTest() characters.clear(); - linux.setBeep (200, 100); + linux.setBeep (20, 100); // Hz < 21 + CPPUNIT_ASSERT ( characters.empty() ); + linux.setBeep (32767, 100); // Hz > 32766 + CPPUNIT_ASSERT ( characters.empty() ); + linux.setBeep (200, -1); // ms < 0 + CPPUNIT_ASSERT ( characters.empty() ); + linux.setBeep (200, 2000); // ms > 1999 + CPPUNIT_ASSERT ( characters.empty() ); + linux.setBeep (200, 100); // 200 Hz - 100 ms CPPUNIT_ASSERT ( characters == CSI "10;200]" CSI "11;100]" ); characters.clear(); linux.resetBeep(); @@ -2595,6 +2603,48 @@ void FTermLinuxTest::modifierKeyTest() mod_key.shift = 1; mod_keycode = linux.modifierKeyCorrection(keycode); CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_snpage ); + + // Space key + mod_key.shift = 0; + mod_key.ctrl = 0; + mod_key.alt = 0; + keycode = finalcut::fc::Fkey_space; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.shift = 1; + mod_key.ctrl = 1; + mod_key.alt = 0; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.ctrl = 0; + mod_key.alt = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.shift = 0; + mod_key.ctrl = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); + + mod_key.shift = 1; + mod_keycode = linux.modifierKeyCorrection(keycode); + CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); } // Put the test suite in the registry From ff9673d262ea5d2f66c1d8c5de2623be64a0b956 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 14 Jul 2019 18:30:35 +0200 Subject: [PATCH 32/70] Reduces the use of raw loops --- ChangeLog | 3 ++ examples/mouse.cpp | 2 +- src/fdialog.cpp | 2 +- src/ffiledialog.cpp | 43 +++++++++--------- src/fmouse.cpp | 41 +++++++++++------ src/foptiattr.cpp | 7 +-- src/fterm.cpp | 14 +++--- src/ftermdetection.cpp | 4 +- src/ftermfreebsd.cpp | 13 +++--- src/ftermlinux.cpp | 80 +++++++++++++++++++-------------- src/fwidget.cpp | 2 +- src/include/final/flistview.h | 24 +++++++--- src/include/final/fmouse.h | 11 +++-- src/include/final/fsystemimpl.h | 30 ++++++------- src/include/final/fterm.h | 27 ++++++++--- src/include/final/ftermlinux.h | 2 + test/ftermlinux-test.cpp | 76 +++++++++++++++++-------------- 17 files changed, 231 insertions(+), 150 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c196acc..82faf720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-07-14 Markus Gans + * Reduces the use of raw loops + 2019-06-30 Markus Gans * Expanding the unit test for FTermLinux * Update the cp437 unicode map diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 4d8d3294..b94c143f 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -144,7 +144,7 @@ void ColorChooser::draw() if ( c == bg_color ) { - print() << ' ' << fc::Times << ' '; + print() << L' ' << fc::Times << L' '; } else print (" "); diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 97d271ab..df78fb83 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -679,7 +679,7 @@ void FDialog::onWindowInactive (FEvent*) //---------------------------------------------------------------------- void FDialog::onWindowRaised (FEvent*) { - if ( ! (isShown() && isShown()) ) + if ( ! isShown() ) return; putArea (getTermPos(), vwin); diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 9ad221bf..ab0a5aeb 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -453,12 +453,14 @@ int FFileDialog::numOfDirs() if ( dir_entries.empty() ) return 0; - int n = 0; - - for (auto&& entry : dir_entries) - if ( entry.directory && std::strcmp(entry.name, ".") != 0 ) - n++; - + int n = std::count_if ( std::begin(dir_entries) + , std::end(dir_entries) + , [] (dir_entry& entry) + { + return entry.directory + && std::strcmp(entry.name, ".") != 0; + } + ); return n; } @@ -761,25 +763,26 @@ void FFileDialog::cb_processActivate (FWidget*, FDataPtr) else { bool found = false; + const auto& input = filename.getText().trim(); if ( ! dir_entries.empty() ) { - const auto& input = filename.getText().trim(); - - for (auto&& entry : dir_entries) - { - if ( entry.name && input && ! input.isNull() - && std::strcmp(entry.name, input) == 0 - && entry.directory ) - { - found = true; - changeDir(input); - break; - } - } + found = std::any_of ( std::begin(dir_entries) + , std::end(dir_entries) + , [&input] (dir_entry& entry) + { + return entry.name + && input + && ! input.isNull() + && std::strcmp(entry.name, input) == 0 + && entry.directory; + } + ); } - if ( ! found ) + if ( found ) + changeDir(input); + else done (FDialog::Accept); } } diff --git a/src/fmouse.cpp b/src/fmouse.cpp index f05be3e8..373cff92 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -1426,11 +1426,14 @@ bool FMouseControl::isMoved() //---------------------------------------------------------------------- bool FMouseControl::isInputDataPending() { - for (auto&& m : mouse_protocol) - if ( m.second && m.second->isInputDataPending() ) - return true; - - return false; + return std::any_of ( std::begin(mouse_protocol) + , std::end(mouse_protocol) + , [] (FMouseProtocol::const_reference m) + { + return m.second + && m.second->isInputDataPending(); + } + ); } //---------------------------------------------------------------------- @@ -1557,21 +1560,33 @@ void FMouseControl::drawGpmPointer() //---------------------------------------------------------------------- FMouse* FMouseControl::getMouseWithData() { - for (auto&& m : mouse_protocol) - if ( m.second && m.second->hasData() ) - return m.second; + const auto& iter = \ + std::find_if ( std::begin(mouse_protocol) + , std::end(mouse_protocol) + , [] (FMouseProtocol::const_reference m) + { + return m.second + && m.second->hasData(); + } + ); - return 0; + return ( iter != mouse_protocol.end() ) ? iter->second : 0; } //---------------------------------------------------------------------- FMouse* FMouseControl::getMouseWithEvent() { - for (auto&& m : mouse_protocol) - if ( m.second && m.second->hasEvent() ) - return m.second; + const auto& iter = \ + std::find_if ( std::begin(mouse_protocol) + , std::end(mouse_protocol) + , [] (FMouseProtocol::const_reference m) + { + return m.second + && m.second->hasEvent(); + } + ); - return 0; + return ( iter != mouse_protocol.end() ) ? iter->second : 0; } //---------------------------------------------------------------------- diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 68c9a7c4..d7cf0b57 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -1546,12 +1546,13 @@ inline void FOptiAttr::reset (charData*& attr) bool FOptiAttr::caused_reset_attributes (char cap[], uChar test) { // test if "cap" reset all attributes - auto& ue = F_exit_underline_mode.cap; - auto& se = F_exit_standout_mode.cap; - auto& me = F_exit_attribute_mode.cap; if ( cap ) { + auto& ue = F_exit_underline_mode.cap; + auto& se = F_exit_standout_mode.cap; + auto& me = F_exit_attribute_mode.cap; + if ( (test & test_ansi_reset) && std::strncmp (cap, CSI "m", 3) == 0 ) return true; diff --git a/src/fterm.cpp b/src/fterm.cpp index 88afd3e7..56d7b941 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -51,7 +51,11 @@ FTermXTerminal* FTerm::xterm = nullptr; FKeyboard* FTerm::keyboard = nullptr; FMouseControl* FTerm::mouse = nullptr; -#if defined(__linux__) +#if defined(UNIT_TEST) + FTermLinux* FTerm::linux = nullptr; + FTermFreeBSD* FTerm::freebsd = nullptr; + FTermOpenBSD* FTerm::openbsd = nullptr; +#elif defined(__linux__) FTermLinux* FTerm::linux = nullptr; #elif defined(__FreeBSD__) || defined(__DragonFly__) FTermFreeBSD* FTerm::freebsd = nullptr; @@ -1731,7 +1735,7 @@ inline void FTerm::allocationValues() linux = new FTermLinux(); #elif defined(__FreeBSD__) || defined(__DragonFly__) freebsd = new FTermFreeBSD(); -#elif defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) openbsd = new FTermOpenBSD(); #endif @@ -1754,7 +1758,7 @@ inline void FTerm::deallocationValues() delete debug_data; #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) if ( openbsd ) delete openbsd; #elif defined(__FreeBSD__) || defined(__DragonFly__) @@ -1924,7 +1928,7 @@ void FTerm::initOSspecifics() freebsd->disableChangeCursorStyle(); freebsd->init(); // Initialize BSD console -#elif defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) if ( init_values.meta_sends_escape ) openbsd->enableMetaSendsEscape(); else @@ -2035,7 +2039,7 @@ void FTerm::finishOSspecifics1() linux->finish(); #elif defined(__FreeBSD__) || defined(__DragonFly__) freebsd->finish(); -#elif defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) openbsd->finish(); #endif } diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 76852a4e..19689ac8 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -846,7 +846,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[]) char* new_termtype = current_termtype; -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) if ( secondary_da.terminal_id_version == 20 && FTermOpenBSD::isBSDConsole() ) @@ -861,7 +861,7 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[]) } } -#endif // defined(__NetBSD__) || defined(__OpenBSD__) +#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) return new_termtype; } diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 50123e3c..231a13ed 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -21,6 +21,7 @@ ***********************************************************************/ #include "final/fcharmap.h" +#include "final/fterm.h" #include "final/ftermfreebsd.h" namespace finalcut @@ -53,7 +54,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) { // Set cursor style in a BSD console - if ( ! fsysten || ! isFreeBSDConsole() || ! change_cursorstyle ) + if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle ) return; cursor_style = style; @@ -61,7 +62,7 @@ void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) if ( hidden ) return; - fsysten->ioctl (0, CONS_CURSORTYPE, &style); + fsystem->ioctl (0, CONS_CURSORTYPE, &style); } //---------------------------------------------------------------------- @@ -71,7 +72,7 @@ bool FTermFreeBSD::isFreeBSDConsole() keymap_t keymap; - if ( fsysten && fsysten->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) + if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) return true; else return false; @@ -149,7 +150,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey() keymap_t keymap; if ( fsystem ) - ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); + ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -169,7 +170,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) keymap_t keymap; if ( fsystem ) - ret = fsysten->ioctl (0, GIO_KEYMAP, &keymap); + ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); if ( ret < 0 ) return false; @@ -178,7 +179,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) keymap.key[left_alt].map[0] = key; if ( (keymap.n_keys > 0) - && fsystem && (fsysten->ioctl(0, PIO_KEYMAP, &keymap) < 0) ) + && fsystem && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) ) return false; else return true; diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index b575820e..91b97a10 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -46,8 +46,8 @@ namespace finalcut FSystem* FTermLinux::fsystem = nullptr; FTermDetection* FTermLinux::term_detection = nullptr; fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style; - FTermLinux::ColorMap FTermLinux::saved_color_map; - FTermLinux::ColorMap FTermLinux::cmap; + FTermLinux::ColorMap FTermLinux::saved_color_map{}; + FTermLinux::ColorMap FTermLinux::cmap{}; int FTermLinux::framebuffer_bpp = -1; #endif // defined(__linux__) @@ -152,6 +152,9 @@ void FTermLinux::init() { // initialize Linux console + if ( ! fsystem ) + fsystem = FTerm::getFSystem(); + fterm_data = FTerm::getFTermData(); fsystem = FTerm::getFSystem(); term_detection = FTerm::getFTermDetection(); @@ -159,6 +162,7 @@ void FTermLinux::init() screen_font.data = nullptr; fterm_data->supportShadowCharacter (true); fterm_data->supportHalfBlockCharacter (true); + getVGAPalette(); if ( FTerm::openConsole() == 0 ) { @@ -505,8 +509,8 @@ int FTermLinux::getFramebuffer_bpp() return -1; } - if ( ! fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) - && ! fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) ) + if ( fsystem->ioctl(fd, FBIOGET_VSCREENINFO, &fb_var) == 0 + && fsystem->ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix) == 0 ) { fsystem->close(fd); return int(fb_var.bits_per_pixel); @@ -864,6 +868,36 @@ int FTermLinux::setBlinkAsIntensity (bool enable) return 0; } +//---------------------------------------------------------------------- +void FTermLinux::getVGAPalette() +{ + if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &cmap) != 0 ) + setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work +} + +//---------------------------------------------------------------------- +void FTermLinux::setVGADefaultPalette() +{ + constexpr rgb defaultColor[16] = + { + {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, + {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, + {0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa}, + {0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa}, + {0x55, 0x55, 0x55}, {0xff, 0x55, 0x55}, + {0x55, 0xff, 0x55}, {0xff, 0xff, 0x55}, + {0x55, 0x55, 0xff}, {0xff, 0x55, 0xff}, + {0x55, 0xff, 0xff}, {0xff, 0xff, 0xff} + }; + + for (std::size_t index = 0; index < 16; index++) + { + cmap.color[index].red = defaultColor[index].red; + cmap.color[index].green = defaultColor[index].green; + cmap.color[index].blue = defaultColor[index].blue; + } +} + //---------------------------------------------------------------------- bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b) { @@ -878,10 +912,10 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b) cmap.color[index].blue = uChar(b); } - if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &cmap) ) - return false; - else + if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) == 0 ) return true; + else + return false; } //---------------------------------------------------------------------- @@ -889,10 +923,10 @@ bool FTermLinux::saveVGAPalette() { // Save the current vga color map - if ( fsystem && fsystem->ioctl (0, GIO_CMAP, &saved_color_map) ) - has_saved_palette = false; - else + if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &saved_color_map) == 0 ) has_saved_palette = true; + else + has_saved_palette = false; return has_saved_palette; } @@ -902,36 +936,16 @@ bool FTermLinux::resetVGAPalette() { // Reset the vga color map - if ( ! fsystem ) - fsystem = FTerm::getFSystem(); - if ( has_saved_palette ) { - if ( fsystem->ioctl (0, PIO_CMAP, &saved_color_map) ) + if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &saved_color_map) ) return false; } else { - constexpr rgb defaultColor[16] = - { - {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, - {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, - {0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa}, - {0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa}, - {0x55, 0x55, 0x55}, {0xff, 0x55, 0x55}, - {0x55, 0xff, 0x55}, {0xff, 0xff, 0x55}, - {0x55, 0x55, 0xff}, {0xff, 0x55, 0xff}, - {0x55, 0xff, 0xff}, {0xff, 0xff, 0xff} - }; + setVGADefaultPalette(); - for (std::size_t index = 0; index < 16; index++) - { - cmap.color[index].red = defaultColor[index].red; - cmap.color[index].green = defaultColor[index].green; - cmap.color[index].blue = defaultColor[index].blue; - } - - if ( fsystem->ioctl (0, PIO_CMAP, &cmap) ) + if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) != 0 ) return false; } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index b4c17efc..aa8c5864 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -2063,7 +2063,7 @@ inline void FWidget::insufficientSpaceAdjust() if ( getHeight() < size_hints.min_height ) adjust_wsize.setWidth(size_hints.min_height); - if ( getHeight() <= 0 ) + if ( getHeight() == 0 ) adjust_wsize.setHeight(1); } diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 83c0da83..f9de75fb 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -92,7 +92,7 @@ class FListViewItem : public FObject FListViewItem& operator = (const FListViewItem&); // Accessors - virtual const char* getClassName() const; + virtual const char* getClassName() const override; uInt getColumnCount() const; int getSortColumn() const; FString getText (int) const; @@ -580,8 +580,15 @@ FObject::FObjectIterator { FStringList str_cols; - for (auto& col : list) - str_cols.push_back (FString() << col); + std::transform ( std::begin(list) + , std::end(list) + , std::back_inserter(str_cols) + , [] (const T& col) -> const FString + { + const FString s = FString() << col; + return std::move(s); + } + ); auto item_iter = insert (str_cols, d, parent_iter); return item_iter; @@ -609,8 +616,15 @@ FObject::FObjectIterator { FStringList str_cols; - for (auto& col : cols) - str_cols.push_back (FString() << col); + std::transform ( std::begin(cols) + , std::end(cols) + , std::back_inserter(str_cols) + , [] (const ColT& col) -> const FString + { + const FString s = FString() << col; + return std::move(s); + } + ); auto item_iter = insert (str_cols, d, parent_iter); return item_iter; diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index d3d2ddf6..221d5154 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -502,6 +502,9 @@ class FMouseControl void drawGpmPointer(); private: + // Typedef + typedef std::map FMouseProtocol; + // Accessor FMouse* getMouseWithData(); FMouse* getMouseWithEvent(); @@ -510,10 +513,10 @@ class FMouseControl void disableXTermMouse(); // Data Member - std::map mouse_protocol{}; - FPoint zero_point{0, 0}; - bool use_gpm_mouse{false}; - bool use_xterm_mouse{false}; + FMouseProtocol mouse_protocol{}; + FPoint zero_point{0, 0}; + bool use_gpm_mouse{false}; + bool use_xterm_mouse{false}; }; #pragma pack(pop) diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index 69a337a7..d00083d4 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -94,18 +94,18 @@ class FSystemImpl : public FSystem // Methods #if defined(__linux__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__) - virtual uChar inPortByte (uShort port) + virtual uChar inPortByte (uShort port) override { return ::inb (port); } #else - virtual uChar inPortByte (uShort) + virtual uChar inPortByte (uShort) override { return 0; } #endif #else - virtual uChar inPortByte (uShort) + virtual uChar inPortByte (uShort) override { return 0; } @@ -114,26 +114,26 @@ class FSystemImpl : public FSystem #if defined(__linux__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__) - virtual void outPortByte (uChar value, uShort port) + virtual void outPortByte (uChar value, uShort port) override { ::outb (value, port); } #else - virtual void outPortByte (uChar, uShort) + virtual void outPortByte (uChar, uShort) override { } #endif #else - virtual void outPortByte (uChar, uShort) + virtual void outPortByte (uChar, uShort) override { } #endif - virtual int isTTY (int fd) + virtual int isTTY (int fd) override { return ::isatty(fd); } - virtual int ioctl (int fd, uLong request, ...) + virtual int ioctl (int fd, uLong request, ...) override { va_list args; va_start (args, request); @@ -143,7 +143,7 @@ class FSystemImpl : public FSystem return ret; } - virtual int open (const char* pathname, int flags, ...) + virtual int open (const char* pathname, int flags, ...) override { va_list args; va_start (args, flags); @@ -153,22 +153,22 @@ class FSystemImpl : public FSystem return ret; } - virtual int close (int fildes) + virtual int close (int fildes) override { return ::close(fildes); } - virtual FILE* fopen (const char* path, const char* mode) + virtual FILE* fopen (const char* path, const char* mode) override { return std::fopen (path, mode); } - virtual int fclose (FILE* fp) + virtual int fclose (FILE* fp) override { return std::fclose (fp); } - virtual int putchar (int c) + virtual int putchar (int c) override { #if defined(__sun) && defined(__SVR4) return std::putchar(char(c)); @@ -177,7 +177,7 @@ class FSystemImpl : public FSystem #endif } - virtual int tputs (const char* str, int affcnt, int (*putc)(int)) + virtual int tputs (const char* str, int affcnt, int (*putc)(int)) override { #if defined(__sun) && defined(__SVR4) return ::tputs (C_STR(str), affcnt, reinterpret_cast(putc)); @@ -186,7 +186,7 @@ class FSystemImpl : public FSystem #endif } - virtual uid_t getuid() + virtual uid_t getuid() override { return ::getuid(); } diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index a0a07c17..5b0715ee 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -132,7 +132,11 @@ #include "final/ftermdebugdata.h" #include "final/ftermdetection.h" -#if defined(__linux__) +#if defined(UNIT_TEST) + #include "final/ftermlinux.h" + #include "final/ftermfreebsd.h" + #include "final/ftermopenbsd.h" +#elif defined(__linux__) #include "final/ftermlinux.h" #elif defined(__FreeBSD__) || defined(__DragonFly__) #include "final/ftermfreebsd.h" @@ -196,7 +200,11 @@ class FTerm final static FKeyboard* getFKeyboard(); static FMouseControl* getFMouseControl(); -#if defined(__linux__) +#if defined(UNIT_TEST) + static FTermLinux* getFTermLinux(); + static FTermFreeBSD* getFTermFreeBSD(); + static FTermOpenBSD* getFTermOpenBSD(); +#elif defined(__linux__) static FTermLinux* getFTermLinux(); #elif defined(__FreeBSD__) || defined(__DragonFly__) static FTermFreeBSD* getFTermFreeBSD(); @@ -323,7 +331,7 @@ class FTerm final newfont = false; encoding = fc::UNKNOWN; - #if defined(__FreeBSD__) || defined(__DragonFly__) + #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) meta_sends_escape = true; change_cursorstyle = true; #elif defined(__NetBSD__) || defined(__OpenBSD__) @@ -340,7 +348,7 @@ class FTerm final uInt8 : 2; // padding bits fc::encoding encoding; - #if defined(__FreeBSD__) || defined(__DragonFly__) + #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) uInt8 meta_sends_escape : 1; uInt8 change_cursorstyle : 1; uInt8 : 6; // padding bits @@ -413,7 +421,12 @@ class FTerm final static FKeyboard* keyboard; static FMouseControl* mouse; -#if defined(__linux__) +#if defined(UNIT_TEST) + #undef linux + static FTermLinux* linux; + static FTermFreeBSD* freebsd; + static FTermOpenBSD* openbsd; +#elif defined(__linux__) #undef linux static FTermLinux* linux; #elif defined(__FreeBSD__) || defined(__DragonFly__) @@ -631,7 +644,7 @@ inline FTermLinux* FTerm::getFTermLinux() return linux; } -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) //---------------------------------------------------------------------- inline FTermFreeBSD* FTerm::getFTermFreeBSD() { @@ -651,7 +664,7 @@ inline FTermFreeBSD* FTerm::getFTermFreeBSD() return freebsd; } -#elif defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) //---------------------------------------------------------------------- inline FTermOpenBSD* FTerm::getFTermOpenBSD() { diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 4b444074..f34b0fef 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -155,6 +155,8 @@ class FTermLinux final static uChar getAttributeMode(); static void setAttributeMode (uChar); static int setBlinkAsIntensity (bool); + static void getVGAPalette(); + static void setVGADefaultPalette(); static bool setVGAPalette (FColor, int, int, int); static bool saveVGAPalette(); static bool resetVGAPalette(); diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index b7021b9c..26a221ec 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -104,17 +104,17 @@ class FSystemTest : public finalcut::FSystem virtual ~FSystemTest(); // Methods - virtual uChar inPortByte (uShort); - virtual void outPortByte (uChar, uShort); - virtual int isTTY (int); - virtual int ioctl (int, uLong, ...); - virtual int open (const char*, int, ...); - virtual int close (int); - virtual FILE* fopen (const char*, const char*); - virtual int fclose (FILE*); - virtual int putchar (int); - virtual int tputs (const char*, int, int (*)(int)); - virtual uid_t getuid(); + virtual uChar inPortByte (uShort) override; + virtual void outPortByte (uChar, uShort) override; + virtual int isTTY (int) override; + virtual int ioctl (int, uLong, ...) override; + virtual int open (const char*, int, ...) override; + virtual int close (int) override; + virtual FILE* fopen (const char*, const char*) override; + virtual int fclose (FILE*) override; + virtual int putchar (int) override; + virtual int tputs (const char*, int, int (*)(int)) override; + virtual uid_t getuid() override; rgb& getRGB (std::size_t); console_font_op& getConsoleFont(); shiftstate& getShiftState(); @@ -1282,7 +1282,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...) std::cerr << "Call: ioctl (fd=" << fd << ", request=" << req_string << "(0x" << std::hex << request << ")" - << ", argp=" << argp << ")\n"; + << ", argp=" << argp << std::dec << ")\n"; return ret_val; } @@ -1837,7 +1837,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB0.red == 0x00 ); CPPUNIT_ASSERT ( RGB0.green == 0x00 ); CPPUNIT_ASSERT ( RGB0.blue == 0x00 ); - linux.setPalette (index, 0x01, 0x02, 0x03); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x01, 0x02, 0x03) ); CPPUNIT_ASSERT ( RGB0.red == 0x01 ); CPPUNIT_ASSERT ( RGB0.green == 0x02 ); CPPUNIT_ASSERT ( RGB0.blue == 0x03 ); @@ -1847,7 +1847,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB1.red == 0x00 ); CPPUNIT_ASSERT ( RGB1.green == 0x00 ); CPPUNIT_ASSERT ( RGB1.blue == 0xaa ); - linux.setPalette (index, 0x04, 0x05, 0x06); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x04, 0x05, 0x06) ); CPPUNIT_ASSERT ( RGB1.red == 0x04 ); CPPUNIT_ASSERT ( RGB1.green == 0x05 ); CPPUNIT_ASSERT ( RGB1.blue == 0x06 ); @@ -1857,7 +1857,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB2.red == 0x00 ); CPPUNIT_ASSERT ( RGB2.green == 0xaa ); CPPUNIT_ASSERT ( RGB2.blue == 0x00 ); - linux.setPalette (index, 0x07, 0x08, 0x09); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x07, 0x08, 0x09) ); CPPUNIT_ASSERT ( RGB2.red == 0x07 ); CPPUNIT_ASSERT ( RGB2.green == 0x08 ); CPPUNIT_ASSERT ( RGB2.blue == 0x09 ); @@ -1867,7 +1867,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB3.red == 0x00 ); CPPUNIT_ASSERT ( RGB3.green == 0xaa ); CPPUNIT_ASSERT ( RGB3.blue == 0xaa ); - linux.setPalette (index, 0x0a, 0x0b, 0x0c); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x0a, 0x0b, 0x0c) ); CPPUNIT_ASSERT ( RGB3.red == 0x0a ); CPPUNIT_ASSERT ( RGB3.green == 0x0b ); CPPUNIT_ASSERT ( RGB3.blue == 0x0c ); @@ -1877,7 +1877,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB4.red == 0xaa ); CPPUNIT_ASSERT ( RGB4.green == 0x00 ); CPPUNIT_ASSERT ( RGB4.blue == 0x00 ); - linux.setPalette (index, 0x0d, 0x0e, 0x0f); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x0d, 0x0e, 0x0f) ); CPPUNIT_ASSERT ( RGB4.red == 0x0d ); CPPUNIT_ASSERT ( RGB4.green == 0x0e ); CPPUNIT_ASSERT ( RGB4.blue == 0x0f ); @@ -1887,7 +1887,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB5.red == 0xaa ); CPPUNIT_ASSERT ( RGB5.green == 0x00 ); CPPUNIT_ASSERT ( RGB5.blue == 0xaa ); - linux.setPalette (index, 0x10, 0x11, 0x12); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x10, 0x11, 0x12) ); CPPUNIT_ASSERT ( RGB5.red == 0x10 ); CPPUNIT_ASSERT ( RGB5.green == 0x11 ); CPPUNIT_ASSERT ( RGB5.blue == 0x12 ); @@ -1897,7 +1897,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB6.red == 0xaa ); CPPUNIT_ASSERT ( RGB6.green == 0x55 ); CPPUNIT_ASSERT ( RGB6.blue == 0x00 ); - linux.setPalette (index, 0x13, 0x14, 0x15); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x13, 0x14, 0x15) ); CPPUNIT_ASSERT ( RGB6.red == 0x13 ); CPPUNIT_ASSERT ( RGB6.green == 0x14 ); CPPUNIT_ASSERT ( RGB6.blue == 0x15 ); @@ -1907,7 +1907,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB7.red == 0xaa ); CPPUNIT_ASSERT ( RGB7.green == 0xaa ); CPPUNIT_ASSERT ( RGB7.blue == 0xaa ); - linux.setPalette (index, 0x16, 0x17, 0x18); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x16, 0x17, 0x18) ); CPPUNIT_ASSERT ( RGB7.red == 0x16 ); CPPUNIT_ASSERT ( RGB7.green == 0x17 ); CPPUNIT_ASSERT ( RGB7.blue == 0x18 ); @@ -1917,7 +1917,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB8.red == 0x55 ); CPPUNIT_ASSERT ( RGB8.green == 0x55 ); CPPUNIT_ASSERT ( RGB8.blue == 0x55 ); - linux.setPalette (index, 0x19, 0x20, 0x21); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x19, 0x20, 0x21) ); CPPUNIT_ASSERT ( RGB8.red == 0x19 ); CPPUNIT_ASSERT ( RGB8.green == 0x20 ); CPPUNIT_ASSERT ( RGB8.blue == 0x21 ); @@ -1927,7 +1927,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB9.red == 0x55 ); CPPUNIT_ASSERT ( RGB9.green == 0x55 ); CPPUNIT_ASSERT ( RGB9.blue == 0xff ); - linux.setPalette (index, 0x22, 0x23, 0x24); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x22, 0x23, 0x24) ); CPPUNIT_ASSERT ( RGB9.red == 0x22 ); CPPUNIT_ASSERT ( RGB9.green == 0x23 ); CPPUNIT_ASSERT ( RGB9.blue == 0x24 ); @@ -1937,7 +1937,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB10.red == 0x55 ); CPPUNIT_ASSERT ( RGB10.green == 0xff ); CPPUNIT_ASSERT ( RGB10.blue == 0x55 ); - linux.setPalette (index, 0x25, 0x26, 0x27); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x25, 0x26, 0x27) ); CPPUNIT_ASSERT ( RGB10.red == 0x25 ); CPPUNIT_ASSERT ( RGB10.green == 0x26 ); CPPUNIT_ASSERT ( RGB10.blue == 0x27 ); @@ -1947,7 +1947,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB11.red == 0x55 ); CPPUNIT_ASSERT ( RGB11.green == 0xff ); CPPUNIT_ASSERT ( RGB11.blue == 0xff ); - linux.setPalette (index, 0x28, 0x29, 0x30); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x28, 0x29, 0x30) ); CPPUNIT_ASSERT ( RGB11.red == 0x28 ); CPPUNIT_ASSERT ( RGB11.green == 0x29 ); CPPUNIT_ASSERT ( RGB11.blue == 0x30 ); @@ -1957,7 +1957,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB12.red == 0xff ); CPPUNIT_ASSERT ( RGB12.green == 0x55 ); CPPUNIT_ASSERT ( RGB12.blue == 0x55 ); - linux.setPalette (index, 0x31, 0x32, 0x33); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x31, 0x32, 0x33) ); CPPUNIT_ASSERT ( RGB12.red == 0x31 ); CPPUNIT_ASSERT ( RGB12.green == 0x32 ); CPPUNIT_ASSERT ( RGB12.blue == 0x33 ); @@ -1967,7 +1967,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB13.red == 0xff ); CPPUNIT_ASSERT ( RGB13.green == 0x55 ); CPPUNIT_ASSERT ( RGB13.blue == 0xff ); - linux.setPalette (index, 0x34, 0x35, 0x36); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x34, 0x35, 0x36) ); CPPUNIT_ASSERT ( RGB13.red == 0x34 ); CPPUNIT_ASSERT ( RGB13.green == 0x35 ); CPPUNIT_ASSERT ( RGB13.blue == 0x36 ); @@ -1977,7 +1977,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB14.red == 0xff ); CPPUNIT_ASSERT ( RGB14.green == 0xff ); CPPUNIT_ASSERT ( RGB14.blue == 0x55 ); - linux.setPalette (index, 0x37, 0x38, 0x39); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x37, 0x38, 0x39) ); CPPUNIT_ASSERT ( RGB14.red == 0x37 ); CPPUNIT_ASSERT ( RGB14.green == 0x38 ); CPPUNIT_ASSERT ( RGB14.blue == 0x39 ); @@ -1987,35 +1987,43 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB15.red == 0xff ); CPPUNIT_ASSERT ( RGB15.green == 0xff ); CPPUNIT_ASSERT ( RGB15.blue == 0xff ); - linux.setPalette (index, 0x40, 0x41, 0x42); + CPPUNIT_ASSERT ( linux.setPalette (index, 0x40, 0x41, 0x42) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, -1, 0, 0); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, -1, 0, 0) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, 0, -1, 0); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, 0, -1, 0) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, 0, 0, -1); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, 0, 0, -1) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, 256, 0, 0); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, 256, 0, 0) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, 0, 256, 0); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, 0, 256, 0) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); - linux.setPalette (index, 0, 0, 256); // Out of range -> no change + // Out of range -> no change + CPPUNIT_ASSERT ( linux.setPalette (index, 0, 0, 256) ); CPPUNIT_ASSERT ( RGB15.red == 0x40 ); CPPUNIT_ASSERT ( RGB15.green == 0x41 ); CPPUNIT_ASSERT ( RGB15.blue == 0x42 ); + CPPUNIT_ASSERT ( linux.resetColorMap() == true ); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } From c49252ab452e0af0b4d0f9ed3d36c552b38209b1 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 14 Jul 2019 23:05:54 +0200 Subject: [PATCH 33/70] Add a unit test for FTermOpenBSD to test the OpenBSD and NetBSD console --- ChangeLog | 2 + build.sh | 2 +- doc/build_openbsd.txt | 20 ++ scripts/cppcheck.sh | 4 +- src/fbutton.cpp | 2 +- src/fbuttongroup.cpp | 2 +- src/flistbox.cpp | 2 +- src/fmenubar.cpp | 2 +- src/fstatusbar.cpp | 2 +- src/ftermopenbsd.cpp | 19 +- src/ftextview.cpp | 2 +- src/fwidget.cpp | 2 +- src/include/final/ftermopenbsd.h | 14 +- test/Makefile.am | 3 + test/conemu.h | 4 +- test/ftermdetection-test.cpp | 40 +-- test/ftermopenbsd-test.cpp | 458 +++++++++++++++++++++++++++++++ 17 files changed, 534 insertions(+), 46 deletions(-) create mode 100644 doc/build_openbsd.txt create mode 100644 test/ftermopenbsd-test.cpp diff --git a/ChangeLog b/ChangeLog index 82faf720..f0ec253c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2019-07-14 Markus Gans * Reduces the use of raw loops + * Add a unit test for FTermOpenBSD to test the OpenBSD + and NetBSD console 2019-06-30 Markus Gans * Expanding the unit test for FTermLinux diff --git a/build.sh b/build.sh index 22f260b4..49ccb530 100755 --- a/build.sh +++ b/build.sh @@ -83,7 +83,7 @@ case "$1" in ;; "--unit-test"|"unit-test") - if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test + if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test then echo "${RED}Configure failed!${NORMAL}" 1>&2 exit 255 diff --git a/doc/build_openbsd.txt b/doc/build_openbsd.txt new file mode 100644 index 00000000..29de3c4d --- /dev/null +++ b/doc/build_openbsd.txt @@ -0,0 +1,20 @@ +Install egcc on OpenBSD +----------------------- +openbsd# pkg_add g++ +quirks-3.124 signed on 2019-04-15T12:10:16Z +Ambiguous: choose package for g++ +a 0: + 1: g++-4.9.4p18 + 2: g++-8.3.0 +Your choice: 2 +g++-8.3.0:gcc-libs-8.3.0: ok +g++-8.3.0:gmp-6.1.2p3: ok +g++-8.3.0:mpfr-3.1.5.2p0: ok +g++-8.3.0:libmpc-0.9p2: ok +g++-8.3.0:gcc-8.3.0: ok +g++-8.3.0: ok + +Build FINAL CUT with eg++ +------------------------- +openbsd# CXX=eg++ ./build.sh + diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index a3ddc952..e98a26b7 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -2,8 +2,8 @@ if [ $# -gt 0 ] then - eval cppcheck --force --enable=all -I../src/include/ "$@" + eval cppcheck --force --std=c++11 --enable=all -I../src/include/ "$@" else - eval cppcheck --force --enable=all -I../src/include/ ../src/ ../examples/ + eval cppcheck --force --std=c++11 --enable=all -I../src/include/ ../src/ ../examples/ fi diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 18aba978..4cf8779d 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -249,7 +249,7 @@ void FButton::hide() if ( size == 0 ) return; - auto blank = createBlankArray(size + 1); + char* blank = createBlankArray(size + 1); for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++) { diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index ab892929..0d460d0c 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -216,7 +216,7 @@ void FButtonGroup::hide() if ( size == 0 ) return; - auto blank = createBlankArray(size + 1); + char* blank = createBlankArray(size + 1); for (int y = 0; y < int(getHeight()); y++) { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 7343d05f..975d54de 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -309,7 +309,7 @@ void FListBox::clear() if ( size == 0 ) return; - auto blank = createBlankArray(size + 1); + char* blank = createBlankArray(size + 1); std::memset (blank, ' ', size); blank[size] = '\0'; diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 148b6a49..a4ac2beb 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -65,7 +65,7 @@ void FMenuBar::hide() FColor bg = wc.term_bg; setColor (fg, bg); screenWidth = getDesktopWidth(); - auto blank = createBlankArray (screenWidth + 1); + char* blank = createBlankArray (screenWidth + 1); print() << FPoint(1, 1) << blank; destroyBlankArray (blank); } diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index f62a704a..5a0c9dd5 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -177,7 +177,7 @@ void FStatusBar::hide() FColor bg = wc.term_bg; setColor (fg, bg); screenWidth = getDesktopWidth(); - auto blank = createBlankArray(screenWidth + 1); + char* blank = createBlankArray(screenWidth + 1); print() << FPoint(1, 1) << blank; destroyBlankArray (blank); } diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index 792680c1..1106e1ab 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -20,13 +20,14 @@ * . * ***********************************************************************/ +#include "final/fterm.h" #include "final/ftermopenbsd.h" namespace finalcut { // static class attributes -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) kbd_t FTermOpenBSD::bsd_keyboard_encoding = 0; bool FTermOpenBSD::meta_sends_escape = true; FSystem* FTermOpenBSD::fsystem = nullptr; @@ -39,7 +40,7 @@ namespace finalcut // public methods of FTermOpenBSD //---------------------------------------------------------------------- -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) bool FTermOpenBSD::isBSDConsole() { // Check if it's a NetBSD/OpenBSD workstation console @@ -47,7 +48,7 @@ bool FTermOpenBSD::isBSDConsole() static kbd_t kbdencoding; if ( fsystem - && fsysten->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) + && fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) return true; else return false; @@ -58,11 +59,11 @@ void FTermOpenBSD::init() { // initialize BSD workstation console + fsystem = FTerm::getFSystem(); + if ( ! isBSDConsole() ) return; - fsystem = FTerm::getFSystem(); - if ( meta_sends_escape ) { // save current left alt key mapping @@ -92,7 +93,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding() int ret = -1; if ( fsystem ) - ret = fsysten->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); + ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); if ( ret < 0 ) return false; @@ -105,8 +106,8 @@ bool FTermOpenBSD::saveBSDConsoleEncoding() //---------------------------------------------------------------------- bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) { - if ( fsysten - && fsysten->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) + if ( fsystem + && fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) return false; else return true; @@ -125,6 +126,6 @@ bool FTermOpenBSD::resetBSDConsoleEncoding() { return setBSDConsoleEncoding (bsd_keyboard_encoding); } -#endif // defined(__NetBSD__) || defined(__OpenBSD__) +#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) } // namespace finalcut diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 017b52dd..3488a52f 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -294,7 +294,7 @@ void FTextView::clear() if ( size == 0 ) return; - auto blank = createBlankArray(size + 1); + char* blank = createBlankArray(size + 1); for (int y = 0; y < int(getTextHeight()); y++) { diff --git a/src/fwidget.cpp b/src/fwidget.cpp index aa8c5864..0aaea38d 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1638,7 +1638,7 @@ void FWidget::hideSize (const FSize& size) } setColor (fg, bg); - auto blank = createBlankArray(size.getWidth()); + char* blank = createBlankArray(size.getWidth()); if ( blank == 0 ) return; diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 966a471d..0be3b2e1 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -38,7 +38,11 @@ #include #include "final/fsystem.h" -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(UNIT_TEST) + #define WSKBDIO_GETENCODING uInt32(0x4004570F) + #define WSKBDIO_SETENCODING uInt32(0x80045710) + typedef uInt32 kbd_t; +#elif defined(__NetBSD__) || defined(__OpenBSD__) #include #include #endif @@ -83,7 +87,7 @@ class FTermOpenBSD final static void finish(); private: -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) // Methods static bool saveBSDConsoleEncoding(); static bool setBSDConsoleEncoding (kbd_t); @@ -94,7 +98,7 @@ class FTermOpenBSD final static kbd_t bsd_keyboard_encoding; static bool meta_sends_escape; static FSystem* fsystem; -#endif // defined(__NetBSD__) || defined(__OpenBSD__) +#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) }; #pragma pack(pop) @@ -104,14 +108,14 @@ inline const char* FTermOpenBSD::getClassName() const { return "FTermOpenBSD"; } //---------------------------------------------------------------------- -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) inline void FTermOpenBSD::enableMetaSendsEscape() { meta_sends_escape = true; } //---------------------------------------------------------------------- inline void FTermOpenBSD::disableMetaSendsEscape() { meta_sends_escape = false; } -#endif // defined(__NetBSD__) || defined(__OpenBSD__) +#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) } // namespace finalcut diff --git a/test/Makefile.am b/test/Makefile.am index da1e79e9..0cfee202 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -14,6 +14,7 @@ noinst_PROGRAMS = \ ftermdetection_test \ ftermcapquirks_test \ ftermlinux_test \ + ftermopenbsd_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ @@ -29,6 +30,7 @@ ftermdata_test_SOURCES = ftermdata-test.cpp ftermdetection_test_SOURCES = ftermdetection-test.cpp ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp ftermlinux_test_SOURCES = ftermlinux-test.cpp +ftermopenbsd_test_SOURCES = ftermopenbsd-test.cpp foptimove_test_SOURCES = foptimove-test.cpp foptiattr_test_SOURCES = foptiattr-test.cpp fcolorpair_test_SOURCES = fcolorpair-test.cpp @@ -44,6 +46,7 @@ TESTS = fobject_test \ ftermdetection_test \ ftermcapquirks_test \ ftermlinux_test \ + ftermopenbsd_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ diff --git a/test/conemu.h b/test/conemu.h index b106631e..36c200ca 100644 --- a/test/conemu.h +++ b/test/conemu.h @@ -788,8 +788,8 @@ inline char* ConEmu::getSEC_DA (console con) C_STR("\033[>77;20402;0c"), // Mintty 0, // Linux console 0, // FreeBSD console - 0, // NetBSD console - 0, // OpenBSD console + C_STR("\033[>24;20;0c"), // NetBSD console + C_STR("\033[>24;20;0c"), // OpenBSD console 0, // Sun console C_STR("\033[>83;40201;0c"), // screen C_STR("\033[>84;0;0c") // tmux diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index 7c6d52fc..126c08ce 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -144,7 +144,7 @@ void FTermDetectionTest::ansiTest() finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; setenv ("TERM", "ansi", 1); - data.setTermFileName(C_STR("ansi")); + data.setTermType(C_STR("ansi")); pid_t pid = forkConEmu(); @@ -212,7 +212,7 @@ void FTermDetectionTest::xtermTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm")); + data.setTermType(C_STR("xterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -273,7 +273,7 @@ void FTermDetectionTest::rxvtTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("rxvt-cygwin-native")); + data.setTermType(C_STR("rxvt-cygwin-native")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -335,7 +335,7 @@ void FTermDetectionTest::urxvtTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("rxvt-unicode-256color")); + data.setTermType(C_STR("rxvt-unicode-256color")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -396,7 +396,7 @@ void FTermDetectionTest::mltermTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("mlterm")); + data.setTermType(C_STR("mlterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -465,7 +465,7 @@ void FTermDetectionTest::puttyTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm")); + data.setTermType(C_STR("xterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -527,7 +527,7 @@ void FTermDetectionTest::kdeKonsoleTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm-256color")); + data.setTermType(C_STR("xterm-256color")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -588,7 +588,7 @@ void FTermDetectionTest::gnomeTerminalTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm-256color")); + data.setTermType(C_STR("xterm-256color")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -650,7 +650,7 @@ void FTermDetectionTest::newerVteTerminalTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm-256color")); + data.setTermType(C_STR("xterm-256color")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -712,7 +712,7 @@ void FTermDetectionTest::ktermTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("kterm")); + data.setTermType(C_STR("kterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -781,7 +781,7 @@ void FTermDetectionTest::teraTermTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm")); + data.setTermType(C_STR("xterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -843,7 +843,7 @@ void FTermDetectionTest::cygwinTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("cygwin")); + data.setTermType(C_STR("cygwin")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -905,7 +905,7 @@ void FTermDetectionTest::minttyTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm-256color")); + data.setTermType(C_STR("xterm-256color")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -967,7 +967,7 @@ void FTermDetectionTest::linuxTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("linux")); + data.setTermType(C_STR("linux")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -1036,7 +1036,7 @@ void FTermDetectionTest::freebsdTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("xterm")); + data.setTermType(C_STR("xterm")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -1108,7 +1108,7 @@ void FTermDetectionTest::netbsdTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("wsvt25")); + data.setTermType(C_STR("wsvt25")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -1178,7 +1178,7 @@ void FTermDetectionTest::openbsdTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("vt220")); + data.setTermType(C_STR("vt220")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -1248,7 +1248,7 @@ void FTermDetectionTest::sunTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("sun-color")); + data.setTermType(C_STR("sun-color")); pid_t pid = forkConEmu(); @@ -1316,7 +1316,7 @@ void FTermDetectionTest::screenTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("screen")); + data.setTermType(C_STR("screen")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); @@ -1384,7 +1384,7 @@ void FTermDetectionTest::tmuxTest() { finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; - data.setTermFileName(C_STR("screen")); + data.setTermType(C_STR("screen")); detect.setTerminalDetection(true); pid_t pid = forkConEmu(); diff --git a/test/ftermopenbsd-test.cpp b/test/ftermopenbsd-test.cpp new file mode 100644 index 00000000..e45d4eef --- /dev/null +++ b/test/ftermopenbsd-test.cpp @@ -0,0 +1,458 @@ +/*********************************************************************** +* ftermopenbsd-test.cpp - FTermOpenBSD unit tests * +* * +* 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define CPPUNIT_ASSERT_CSTRING(expected, actual) \ + check_c_string (expected, actual, CPPUNIT_SOURCELINE()) + +//---------------------------------------------------------------------- +void check_c_string ( const char* s1 + , const char* s2 + , CppUnit::SourceLine sourceLine ) +{ + if ( s1 == 0 && s2 == 0 ) // Strings are equal + return; + + if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal + return; + + ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); +} + + +namespace test +{ + +//---------------------------------------------------------------------- +// class FSystemTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FSystemTest : public finalcut::FSystem +{ + public: + // Constructor + FSystemTest(); + + // Destructor + virtual ~FSystemTest(); + + // Methods + virtual uChar inPortByte (uShort) override; + virtual void outPortByte (uChar, uShort) override; + virtual int isTTY (int) override; + virtual int ioctl (int, uLong, ...) override; + virtual int open (const char*, int, ...) override; + virtual int close (int) override; + virtual FILE* fopen (const char*, const char*) override; + virtual int fclose (FILE*) override; + virtual int putchar (int) override; + virtual int tputs (const char*, int, int (*)(int)) override; + virtual uid_t getuid() override; + + private: + kbd_t kbdencoding = 512; +}; +#pragma pack(pop) + + +// constructors and destructor +//---------------------------------------------------------------------- +FSystemTest::FSystemTest() // constructor +{ +} + +//---------------------------------------------------------------------- +FSystemTest::~FSystemTest() // destructor +{ +} + + +// public methods of FSystemTest +//---------------------------------------------------------------------- +uChar FSystemTest::inPortByte (uShort) +{ + return 0; +} + +//---------------------------------------------------------------------- +void FSystemTest::outPortByte (uChar, uShort) +{ +} + +//---------------------------------------------------------------------- +int FSystemTest::isTTY (int fd) +{ + std::cerr << "Call: isatty (fd=" << fd << ")\n"; + return 1; +} + +//---------------------------------------------------------------------- +int FSystemTest::ioctl (int fd, uLong request, ...) +{ + va_list args; + void* argp; + std::string req_string; + int ret_val = -1; + + va_start (args, request); + argp = va_arg (args, void*); + + switch ( request ) + { + case WSKBDIO_GETENCODING: + { + req_string = "WSKBDIO_GETENCODING"; + kbd_t* kbd_enc = static_cast(argp); + *kbd_enc = kbdencoding; + ret_val = 0; + break; + } + + case WSKBDIO_SETENCODING: + { + req_string = "WSKBDIO_SETENCODING"; + kbd_t* kbd_enc = static_cast(argp); + kbdencoding = *kbd_enc; + ret_val = 0; + break; + } + + case TIOCGWINSZ: + { + req_string = "TIOCGWINSZ"; + struct winsize* win_size = static_cast(argp); + win_size->ws_col = 80; + win_size->ws_row = 25; + ret_val = 0; + break; + } + } + + va_end (args); + + std::cerr << "Call: ioctl (fd=" << fd + << ", request=" << req_string + << "(0x" << std::hex << request << ")" + << ", argp=" << argp << std::dec << ")\n"; + return ret_val; +} + +//---------------------------------------------------------------------- +int FSystemTest::open (const char* pathname, int flags, ...) +{ + va_list args; + va_start (args, flags); + mode_t mode = static_cast(va_arg (args, int)); + va_end (args); + + std::cerr << "Call: open (pathname=\"" << pathname + << "\", flags=" << flags + << ", mode=" << mode << ")\n"; + + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::close (int fildes) +{ + std::cerr << "Call: close (fildes=" << fildes << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +FILE* FSystemTest::fopen (const char* path, const char* mode) +{ + std::cerr << "Call: fopen (path=" << path + << ", mode=" << mode << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::fclose (FILE* fp) +{ + std::cerr << "Call: fclose (fp=" << fp << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::putchar (int c) +{ +#if defined(__sun) && defined(__SVR4) + return std::putchar(char(c)); +#else + return std::putchar(c); +#endif +} + +//---------------------------------------------------------------------- +int FSystemTest::tputs (const char* str, int affcnt, int (*putc)(int)) +{ + return ::tputs (str, affcnt, putc); +} + +//---------------------------------------------------------------------- +uid_t FSystemTest::getuid() +{ + return 0; +} + +} // namespace test + + +//---------------------------------------------------------------------- +// class ftermopenbsdTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class ftermopenbsdTest : public CPPUNIT_NS::TestFixture, test::ConEmu +{ + public: + ftermopenbsdTest(); + + protected: + void classNameTest(); + void netbsdConsoleTest(); + void openbsdConsoleTest(); + + private: + // Adds code needed to register the test suite + CPPUNIT_TEST_SUITE (ftermopenbsdTest); + + // Add a methods to the test suite + CPPUNIT_TEST (classNameTest); + CPPUNIT_TEST (netbsdConsoleTest); + CPPUNIT_TEST (openbsdConsoleTest); + + // End of test suite definition + CPPUNIT_TEST_SUITE_END(); +}; +#pragma pack(pop) + +//---------------------------------------------------------------------- +ftermopenbsdTest::ftermopenbsdTest() +{ + +} + +//---------------------------------------------------------------------- +void ftermopenbsdTest::classNameTest() +{ + const finalcut::FTermOpenBSD p; + const char* const classname = p.getClassName(); + CPPUNIT_ASSERT ( std::strcmp(classname, "FTermOpenBSD") == 0 ); +} + +//---------------------------------------------------------------------- +void ftermopenbsdTest::netbsdConsoleTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::VT100); + data->setBaudrate(9600); + data->setTermType("wsvt25"); + data->setTermFileName("/dev/ttyE1"); + data->setTTYFileDescriptor(0); + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + term_detection->setTerminalDetection(true); + finalcut::FTermOpenBSD netbsd; + + //term_detection->setNetBSDTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "wsvt25", 1); + setenv ("COLUMNS", "80", 1); + setenv ("LINES", "25", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + netbsd.init(); + term_detection->detect(); + finalcut::FTerm::detectTermSize(); + + CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( term_detection->isNetBSDTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::netbsd_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + netbsd.finish(); +} + +//---------------------------------------------------------------------- +void ftermopenbsdTest::openbsdConsoleTest() +{ + finalcut::FTermData* data; + finalcut::FSystem* fsys; + fsys = new test::FSystemTest(); + finalcut::FTerm::setFSystem(fsys); + finalcut::FTermDetection* term_detection; + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::VT100); + data->setBaudrate(9600); + data->setTermType("vt220"); + data->setTermFileName("/dev/ttyC0"); + data->setTTYFileDescriptor(0); + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + term_detection->setTerminalDetection(true); + finalcut::FTermOpenBSD openbsd; + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "vt220", 1); + setenv ("COLUMNS", "80", 1); + setenv ("LINES", "25", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + openbsd.init(); + term_detection->detect(); + finalcut::FTerm::detectTermSize(); + + CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( term_detection->isOpenBSDTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + CPPUNIT_ASSERT_CSTRING ( term_detection->getTermType(), C_STR("pccon") ); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::openbsd_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } + + openbsd.finish(); +} + + +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION (ftermopenbsdTest); + +// The general unit test main part +#include From 8d9e92023ae1cf927f7c9d78c2dbfee5574ed244 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 14 Jul 2019 23:21:49 +0200 Subject: [PATCH 34/70] minor fixes --- build.sh | 2 +- src/include/final/flistview.h | 4 ++-- test/ftermopenbsd-test.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 49ccb530..0e19f63d 100755 --- a/build.sh +++ b/build.sh @@ -91,7 +91,7 @@ case "$1" in ;; "--coverage"|"coverage") - if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test --with-gcov + if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test --with-gcov then echo "${RED}Configure failed!${NORMAL}" 1>&2 exit 255 diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index f9de75fb..de69c091 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -586,7 +586,7 @@ FObject::FObjectIterator , [] (const T& col) -> const FString { const FString s = FString() << col; - return std::move(s); + return s; } ); @@ -622,7 +622,7 @@ FObject::FObjectIterator , [] (const ColT& col) -> const FString { const FString s = FString() << col; - return std::move(s); + return s; } ); diff --git a/test/ftermopenbsd-test.cpp b/test/ftermopenbsd-test.cpp index e45d4eef..00cd090b 100644 --- a/test/ftermopenbsd-test.cpp +++ b/test/ftermopenbsd-test.cpp @@ -434,7 +434,7 @@ void ftermopenbsdTest::openbsdConsoleTest() CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT_CSTRING ( term_detection->getTermType(), C_STR("pccon") ); - + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } From 3c52e77448a7e567291c6c6ce3a096dcac392e3a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 17 Jul 2019 01:37:44 +0200 Subject: [PATCH 35/70] FTermOpenBSD unit test completed --- test/ftermopenbsd-test.cpp | 48 ++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/test/ftermopenbsd-test.cpp b/test/ftermopenbsd-test.cpp index 00cd090b..f51b4fe2 100644 --- a/test/ftermopenbsd-test.cpp +++ b/test/ftermopenbsd-test.cpp @@ -318,14 +318,12 @@ void ftermopenbsdTest::netbsdConsoleTest() term_detection = finalcut::FTerm::getFTermDetection(); term_detection->setTerminalDetection(true); - finalcut::FTermOpenBSD netbsd; - - //term_detection->setNetBSDTerm(true); - pid_t pid = forkConEmu(); if ( isConEmuChildProcess(pid) ) { + finalcut::FTermOpenBSD netbsd; + setenv ("TERM", "wsvt25", 1); setenv ("COLUMNS", "80", 1); setenv ("LINES", "25", 1); @@ -339,17 +337,34 @@ void ftermopenbsdTest::netbsdConsoleTest() unsetenv("KONSOLE_DCOP"); unsetenv("TMUX"); + netbsd.disableMetaSendsEscape(); netbsd.init(); term_detection->detect(); finalcut::FTerm::detectTermSize(); CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( ! term_detection->isOpenBSDTerm() ); CPPUNIT_ASSERT ( term_detection->isNetBSDTerm() ); CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + netbsd.finish(); + + netbsd.enableMetaSendsEscape(); + netbsd.init(); + + CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( ! term_detection->isOpenBSDTerm() ); + CPPUNIT_ASSERT ( term_detection->isNetBSDTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + + netbsd.finish(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } @@ -361,8 +376,6 @@ void ftermopenbsdTest::netbsdConsoleTest() if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; } - - netbsd.finish(); } //---------------------------------------------------------------------- @@ -404,12 +417,12 @@ void ftermopenbsdTest::openbsdConsoleTest() term_detection = finalcut::FTerm::getFTermDetection(); term_detection->setTerminalDetection(true); - finalcut::FTermOpenBSD openbsd; - pid_t pid = forkConEmu(); if ( isConEmuChildProcess(pid) ) { + finalcut::FTermOpenBSD openbsd; + setenv ("TERM", "vt220", 1); setenv ("COLUMNS", "80", 1); setenv ("LINES", "25", 1); @@ -423,18 +436,35 @@ void ftermopenbsdTest::openbsdConsoleTest() unsetenv("KONSOLE_DCOP"); unsetenv("TMUX"); + openbsd.disableMetaSendsEscape(); openbsd.init(); term_detection->detect(); finalcut::FTerm::detectTermSize(); CPPUNIT_ASSERT ( isatty(0) == 1 ); CPPUNIT_ASSERT ( term_detection->isOpenBSDTerm() ); + CPPUNIT_ASSERT ( ! term_detection->isNetBSDTerm() ); CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT_CSTRING ( term_detection->getTermType(), C_STR("pccon") ); + openbsd.finish(); + + openbsd.enableMetaSendsEscape(); + openbsd.init(); + + CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( term_detection->isOpenBSDTerm() ); + CPPUNIT_ASSERT ( ! term_detection->isNetBSDTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + + openbsd.finish(); + closeConEmuStdStreams(); exit(EXIT_SUCCESS); } @@ -446,8 +476,6 @@ void ftermopenbsdTest::openbsdConsoleTest() if ( waitpid(pid, 0, WUNTRACED) != pid ) std::cerr << "waitpid error" << std::endl; } - - openbsd.finish(); } From 2b9c64a445b5cd213256d0802a7d0dbc4dd4058a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 21 Jul 2019 23:31:21 +0200 Subject: [PATCH 36/70] Reduce include entries in the header files --- ChangeLog | 3 + examples/mouse.cpp | 8 +- src/fapplication.cpp | 5 + src/fbutton.cpp | 2 + src/fbuttongroup.cpp | 2 + src/fcheckbox.cpp | 1 + src/fcheckmenuitem.cpp | 3 +- src/fcolorpalette.cpp | 3 +- src/fdialog.cpp | 4 + src/fdialoglistmenu.cpp | 3 +- src/ffiledialog.cpp | 1 + src/fkey_map.cpp | 6 +- src/fkeyboard.cpp | 5 + src/flabel.cpp | 2 + src/flineedit.cpp | 5 + src/flistbox.cpp | 4 + src/flistview.cpp | 5 + src/fmenu.cpp | 5 + src/fmenubar.cpp | 4 + src/fmenuitem.cpp | 1 + src/fmenulist.cpp | 4 +- src/fmessagebox.cpp | 1 + src/fmouse.cpp | 4 + src/fobject.cpp | 5 +- src/foptiattr.cpp | 1 + src/fprogressbar.cpp | 4 + src/fradiomenuitem.cpp | 3 +- src/frect.cpp | 36 +++ src/fscrollbar.cpp | 3 + src/fscrollview.cpp | 2 + src/fstatusbar.cpp | 2 + src/fswitch.cpp | 3 + src/fterm.cpp | 496 +++++++++++++++++++++++++++-- src/ftermbuffer.cpp | 5 + src/ftermcap.cpp | 31 +- src/ftermcapquirks.cpp | 10 +- src/ftermdebugdata.cpp | 40 +++ src/ftermdetection.cpp | 25 ++ src/ftermfreebsd.cpp | 2 + src/ftermlinux.cpp | 9 +- src/ftermopenbsd.cpp | 1 + src/ftermxterminal.cpp | 6 + src/ftextview.cpp | 6 + src/ftogglebutton.cpp | 3 + src/ftooltip.cpp | 1 + src/fvterm.cpp | 32 +- src/fwidget.cpp | 6 +- src/fwidgetcolors.cpp | 1 + src/fwindow.cpp | 1 + src/include/final/fapplication.h | 19 +- src/include/final/fbutton.h | 1 + src/include/final/fbuttongroup.h | 1 + src/include/final/fcolorpair.h | 3 +- src/include/final/fcolorpalette.h | 2 - src/include/final/fconfig.h | 4 +- src/include/final/fdialog.h | 5 +- src/include/final/fevent.h | 9 +- src/include/final/ffiledialog.h | 2 + src/include/final/final.h | 31 +- src/include/final/fkeyboard.h | 8 +- src/include/final/flabel.h | 1 + src/include/final/flineedit.h | 4 +- src/include/final/flistbox.h | 6 +- src/include/final/flistview.h | 4 +- src/include/final/fmenu.h | 8 +- src/include/final/fmenubar.h | 6 +- src/include/final/fmessagebox.h | 8 +- src/include/final/fmouse.h | 2 - src/include/final/fobject.h | 20 +- src/include/final/foptiattr.h | 52 +-- src/include/final/foptimove.h | 2 - src/include/final/fpoint.h | 1 - src/include/final/frect.h | 30 +- src/include/final/fsize.h | 1 + src/include/final/fstatusbar.h | 3 +- src/include/final/fterm.h | 424 ++---------------------- src/include/final/ftermbuffer.h | 7 +- src/include/final/ftermcap.h | 9 +- src/include/final/ftermcapquirks.h | 10 +- src/include/final/ftermdata.h | 144 +++++---- src/include/final/ftermdebugdata.h | 29 +- src/include/final/ftermdetection.h | 15 - src/include/final/ftermfreebsd.h | 5 +- src/include/final/ftermlinux.h | 13 +- src/include/final/ftermopenbsd.h | 4 +- src/include/final/ftermxterminal.h | 10 +- src/include/final/ftextview.h | 7 +- src/include/final/ftypes.h | 46 +++ src/include/final/fvterm.h | 25 +- src/include/final/fwidget.h | 13 +- test/foptiattr-test.cpp | 48 ++- 91 files changed, 1094 insertions(+), 763 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0ec253c..4958c213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-07-21 Markus Gans + * Reduce include entries in the header files + 2019-07-14 Markus Gans * Reduces the use of raw loops * Add a unit test for FTermOpenBSD to test the OpenBSD diff --git a/examples/mouse.cpp b/examples/mouse.cpp index b94c143f..48279768 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -491,11 +491,13 @@ void MouseDraw::drawCanvas() for (int y = 0; y < y_end; y++) // line loop { - charData* canvaschar; // canvas character - charData* winchar; // window character + finalcut::charData* canvaschar; // canvas character + finalcut::charData* winchar; // window character canvaschar = &canvas->text[y * x_end]; winchar = &print_area->text[(ay + y) * w_line_len + ax]; - std::memcpy (winchar, canvaschar, sizeof(charData) * unsigned(x_end)); + std::memcpy ( winchar + , canvaschar + , sizeof(finalcut::charData) * unsigned(x_end) ); if ( int(print_area->changes[ay + y].xmin) > ax ) print_area->changes[ay + y].xmin = uInt(ax); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 5eaee5b9..e301b38b 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -24,9 +24,14 @@ #include #include "final/fapplication.h" +#include "final/fevent.h" #include "final/fmenu.h" +#include "final/fmenubar.h" #include "final/fmessagebox.h" +#include "final/fmouse.h" #include "final/fstatusbar.h" +#include "final/ftermios.h" +#include "final/fwidgetcolors.h" #include "final/fwindow.h" namespace finalcut diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 4cf8779d..62a81d72 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -21,6 +21,8 @@ ***********************************************************************/ #include "final/fapplication.h" +#include "final/fcolorpair.h" +#include "final/fevent.h" #include "final/fbutton.h" #include "final/fstatusbar.h" diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 0d460d0c..9a017676 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -23,6 +23,8 @@ #include "final/fapplication.h" #include "final/fbuttongroup.h" +#include "final/fevent.h" +#include "final/fsize.h" #include "final/fstatusbar.h" #include "final/ftogglebutton.h" diff --git a/src/fcheckbox.cpp b/src/fcheckbox.cpp index 469a1601..6d4e8630 100644 --- a/src/fcheckbox.cpp +++ b/src/fcheckbox.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fcheckbox.h" namespace finalcut diff --git a/src/fcheckmenuitem.cpp b/src/fcheckmenuitem.cpp index de5f0276..0fa0c23c 100644 --- a/src/fcheckmenuitem.cpp +++ b/src/fcheckmenuitem.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fcheckmenuitem.h" #include "final/fmenu.h" diff --git a/src/fcolorpalette.cpp b/src/fcolorpalette.cpp index 99a9289c..249d25c1 100644 --- a/src/fcolorpalette.cpp +++ b/src/fcolorpalette.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 * @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fcolorpalette.h" namespace finalcut diff --git a/src/fdialog.cpp b/src/fdialog.cpp index df78fb83..10ac314a 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -24,7 +24,11 @@ #include "final/fapplication.h" #include "final/fdialog.h" +#include "final/fevent.h" +#include "final/fmenuitem.h" #include "final/fstatusbar.h" +#include "final/ftooltip.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fdialoglistmenu.cpp b/src/fdialoglistmenu.cpp index 7c322e40..627cbbe0 100644 --- a/src/fdialoglistmenu.cpp +++ b/src/fdialoglistmenu.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2016-2018 Markus Gans * +* Copyright 2016-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 * @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fdialoglistmenu.h" namespace finalcut diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index ab0a5aeb..4c41fa2d 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -27,6 +27,7 @@ #include +#include "final/fevent.h" #include "final/ffiledialog.h" namespace finalcut diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index 85f79a19..523d34ea 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.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 * @@ -20,8 +20,8 @@ * . * ***********************************************************************/ -#include -#include +#include "final/fc.h" +#include "final/fkey_map.h" namespace finalcut { diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 0e4c0251..ed70a105 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -30,9 +30,14 @@ #include "final/fkeyboard.h" #include "final/fkey_map.h" +#include "final/fobject.h" #include "final/fterm.h" #include "final/ftermios.h" +#if defined(__linux__) + #include "final/ftermlinux.h" +#endif + namespace finalcut { diff --git a/src/flabel.cpp b/src/flabel.cpp index c9b5221c..11891115 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -23,6 +23,8 @@ #include #include "final/fapplication.h" +#include "final/fcolorpair.h" +#include "final/fevent.h" #include "final/flabel.h" #include "final/fstatusbar.h" diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 184e92e3..ec71ec77 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -23,8 +23,13 @@ #include #include "final/fapplication.h" +#include "final/fevent.h" +#include "final/flabel.h" #include "final/flineedit.h" +#include "final/fpoint.h" +#include "final/fsize.h" #include "final/fstatusbar.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 975d54de..c42e9f32 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -24,9 +24,13 @@ #include #include "final/fapplication.h" +#include "final/fcolorpair.h" +#include "final/fevent.h" #include "final/flistbox.h" #include "final/fscrollbar.h" +#include "final/fstring.h" #include "final/fstatusbar.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/flistview.cpp b/src/flistview.cpp index cc09e0a8..928055f7 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -27,11 +27,16 @@ #include #include +#include "final/emptyfstring.h" #include "final/fapplication.h" +#include "final/fcolorpair.h" +#include "final/fevent.h" #include "final/flistview.h" #include "final/fscrollbar.h" #include "final/fstatusbar.h" +#include "final/fstring.h" #include "final/ftermbuffer.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fmenu.cpp b/src/fmenu.cpp index ebe78901..8602f52a 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -24,9 +24,14 @@ #include #include "final/fapplication.h" +#include "final/fcolorpair.h" #include "final/fdialog.h" +#include "final/fevent.h" #include "final/fmenu.h" +#include "final/fmenubar.h" +#include "final/fmenuitem.h" #include "final/fstatusbar.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index a4ac2beb..008e2237 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -24,8 +24,12 @@ #include #include "final/fapplication.h" +#include "final/fevent.h" +#include "final/fmenu.h" #include "final/fmenubar.h" +#include "final/fmenuitem.h" #include "final/fstatusbar.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index b488f726..098632ee 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -24,6 +24,7 @@ #include "final/fapplication.h" #include "final/fdialog.h" +#include "final/fevent.h" #include "final/fmenu.h" #include "final/fmenubar.h" #include "final/fmenulist.h" diff --git a/src/fmenulist.cpp b/src/fmenulist.cpp index 6836272b..dbe47e81 100644 --- a/src/fmenulist.cpp +++ b/src/fmenulist.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -22,7 +22,9 @@ #include +#include "final/fc.h" #include "final/fmenulist.h" +#include "final/fmenuitem.h" namespace finalcut { diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index ca00bad4..c4e80031 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -23,6 +23,7 @@ #include #include "final/fapplication.h" +#include "final/fbutton.h" #include "final/fmessagebox.h" namespace finalcut diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 373cff92..8084cc4c 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -27,9 +27,13 @@ #include #include +#include "final/fconfig.h" +#include "final/fkeyboard.h" #include "final/fmouse.h" +#include "final/fobject.h" #include "final/fterm.h" #include "final/ftermxterminal.h" +#include "final/ftypes.h" namespace finalcut { diff --git a/src/fobject.cpp b/src/fobject.cpp index ed969f20..205a5020 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -22,6 +22,9 @@ #include +#include "final/emptyfstring.h" +#include "final/fevent.h" +#include "final/fc.h" #include "final/fobject.h" namespace finalcut diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index d7cf0b57..84329b4a 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -22,6 +22,7 @@ #include +#include "final/fc.h" #include "final/foptiattr.h" namespace finalcut diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index c0dc7be7..3be23971 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -20,7 +20,11 @@ * . * ***********************************************************************/ +#include "final/fevent.h" +#include "final/fcolorpair.h" #include "final/fprogressbar.h" +#include "final/fstring.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fradiomenuitem.cpp b/src/fradiomenuitem.cpp index 0b53e1dc..0e84ab7d 100644 --- a/src/fradiomenuitem.cpp +++ b/src/fradiomenuitem.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fradiomenuitem.h" #include "final/fmenu.h" diff --git a/src/frect.cpp b/src/frect.cpp index fa5d52a3..51d20ae3 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -22,7 +22,9 @@ #include +#include "final/fpoint.h" #include "final/frect.h" +#include "final/fsize.h" namespace finalcut { @@ -60,6 +62,40 @@ bool FRect::isEmpty() const return X2 == X1 - 1 && Y2 == Y1 - 1; } +//---------------------------------------------------------------------- +FPoint FRect::getPos() const +{ + return FPoint(X1, Y1); +} + +//---------------------------------------------------------------------- +FPoint FRect::getUpperLeftPos() const +{ + return FPoint(X1, Y1); +} + +//---------------------------------------------------------------------- +FPoint FRect::getUpperRightPos() const +{ + return FPoint(X2, Y1); +} + +//---------------------------------------------------------------------- +FPoint FRect::getLowerLeftPos() const +{ return FPoint(X1, Y2); } + +//---------------------------------------------------------------------- +FPoint FRect::getLowerRightPos() const +{ + return FPoint(X2, Y2); +} + +//---------------------------------------------------------------------- +FSize FRect::getSize() const +{ + return FSize(getWidth(), getHeight()); +} + //---------------------------------------------------------------------- void FRect::setX1 (int n) { diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index dd7149a3..f635fcb7 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -22,7 +22,10 @@ #include +#include "final/fevent.h" #include "final/fscrollbar.h" +#include "final/fsize.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 66c65ede..f460976e 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -23,8 +23,10 @@ #include +#include "final/fevent.h" #include "final/fscrollview.h" #include "final/fwindow.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 5a0c9dd5..d4f9b45f 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -22,7 +22,9 @@ #include +#include "final/fevent.h" #include "final/fstatusbar.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fswitch.cpp b/src/fswitch.cpp index bb156d33..334f9b8b 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -20,7 +20,10 @@ * . * ***********************************************************************/ +#include "final/fcolorpair.h" +#include "final/fevent.h" #include "final/fswitch.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fterm.cpp b/src/fterm.cpp index 56d7b941..45fa6c2a 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -25,8 +25,37 @@ #include #include -#include "final/fterm.h" +#include "final/fc.h" #include "final/fcharmap.h" +#include "final/fcolorpalette.h" +#include "final/fkey_map.h" +#include "final/fkeyboard.h" +#include "final/fmouse.h" +#include "final/foptiattr.h" +#include "final/foptimove.h" +#include "final/fstring.h" +#include "final/fsystem.h" +#include "final/fsystemimpl.h" +#include "final/fterm.h" +#include "final/ftermcap.h" +#include "final/ftermcapquirks.h" +#include "final/ftermdata.h" +#include "final/ftermdebugdata.h" +#include "final/ftermdetection.h" +#include "final/ftermios.h" +#include "final/ftermxterminal.h" + +#if defined(UNIT_TEST) + #include "final/ftermlinux.h" + #include "final/ftermfreebsd.h" + #include "final/ftermopenbsd.h" +#elif defined(__linux__) + #include "final/ftermlinux.h" +#elif defined(__FreeBSD__) || defined(__DragonFly__) + #include "final/ftermfreebsd.h" +#elif defined(__NetBSD__) || defined(__OpenBSD__) + #include "final/ftermopenbsd.h" +#endif namespace finalcut { @@ -42,35 +71,34 @@ int (*FTerm::Fputchar)(int); // static class attributes FTerm::initializationValues FTerm::init_values; -FTermData* FTerm::data = nullptr; -FSystem* FTerm::fsys = nullptr; -FOptiMove* FTerm::opti_move = nullptr; -FOptiAttr* FTerm::opti_attr = nullptr; -FTermDetection* FTerm::term_detection = nullptr; -FTermXTerminal* FTerm::xterm = nullptr; -FKeyboard* FTerm::keyboard = nullptr; -FMouseControl* FTerm::mouse = nullptr; +FTermData* FTerm::data = nullptr; +FSystem* FTerm::fsys = nullptr; +FOptiMove* FTerm::opti_move = nullptr; +FOptiAttr* FTerm::opti_attr = nullptr; +FTermDetection* FTerm::term_detection = nullptr; +FTermXTerminal* FTerm::xterm = nullptr; +FKeyboard* FTerm::keyboard = nullptr; +FMouseControl* FTerm::mouse = nullptr; #if defined(UNIT_TEST) - FTermLinux* FTerm::linux = nullptr; - FTermFreeBSD* FTerm::freebsd = nullptr; - FTermOpenBSD* FTerm::openbsd = nullptr; + FTermLinux* FTerm::linux = nullptr; + FTermFreeBSD* FTerm::freebsd = nullptr; + FTermOpenBSD* FTerm::openbsd = nullptr; #elif defined(__linux__) - FTermLinux* FTerm::linux = nullptr; + FTermLinux* FTerm::linux = nullptr; #elif defined(__FreeBSD__) || defined(__DragonFly__) - FTermFreeBSD* FTerm::freebsd = nullptr; + FTermFreeBSD* FTerm::freebsd = nullptr; #elif defined(__NetBSD__) || defined(__OpenBSD__) - FTermOpenBSD* FTerm::openbsd = nullptr; + FTermOpenBSD* FTerm::openbsd = nullptr; #endif #if DEBUG - FTermDebugData* FTerm::debug_data = nullptr; + FTermDebugData* FTerm::debug_data = nullptr; #endif // function prototypes uInt env2uint (const char*); - //---------------------------------------------------------------------- // class FTerm //---------------------------------------------------------------------- @@ -120,12 +148,414 @@ const FString FTerm::getKeyName (FKey keynum) return keyboard->getKeyName (keynum); } +//---------------------------------------------------------------------- +charSubstitution& FTerm::getCharSubstitutionMap() +{ + return data->getCharSubstitutionMap(); +} + +//---------------------------------------------------------------------- +int FTerm::getTTYFileDescriptor() +{ + return ( data ) ? data->getTTYFileDescriptor() : 0; +} + +//---------------------------------------------------------------------- +char* FTerm::getTermType() +{ + return data->getTermType(); +} + +//---------------------------------------------------------------------- +char* FTerm::getTermFileName() +{ + return data->getTermFileName(); +} + +//---------------------------------------------------------------------- +int FTerm::getTabstop() +{ + return FTermcap::tabstop; +} + +//---------------------------------------------------------------------- +int FTerm::getMaxColor() +{ + return FTermcap::max_color; +} + +//---------------------------------------------------------------------- +FTermData* FTerm::getFTermData() +{ + if ( data == 0 ) + { + try + { + data = new FTermData; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return data; +} + +//---------------------------------------------------------------------- +FSystem* FTerm::getFSystem() +{ + if ( fsys == 0 ) + { + try + { + fsys = new FSystemImpl; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return fsys; +} + +//---------------------------------------------------------------------- +FOptiMove* FTerm::getFOptiMove() +{ + if ( opti_move == 0 ) + { + try + { + opti_move = new FOptiMove; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return opti_move; +} + +//---------------------------------------------------------------------- +FOptiAttr* FTerm::getFOptiAttr() +{ + if ( opti_attr == 0 ) + { + try + { + opti_attr = new FOptiAttr; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return opti_attr; +} + +//---------------------------------------------------------------------- +FTermDetection* FTerm::getFTermDetection() +{ + if ( term_detection == 0 ) + { + try + { + term_detection = new FTermDetection; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return term_detection; +} + +//---------------------------------------------------------------------- +FTermXTerminal* FTerm::getFTermXTerminal() +{ + if ( xterm == 0 ) + { + try + { + xterm = new FTermXTerminal; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return xterm; +} + +//---------------------------------------------------------------------- +FKeyboard* FTerm::getFKeyboard() +{ + if ( keyboard == 0 ) + { + try + { + keyboard = new FKeyboard; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return keyboard; +} + +//---------------------------------------------------------------------- +FMouseControl* FTerm::getFMouseControl() +{ + if ( mouse == 0 ) + { + try + { + mouse = new FMouseControl; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return mouse; +} + +#if defined(__linux__) +//---------------------------------------------------------------------- +FTermLinux* FTerm::getFTermLinux() +{ + if ( linux == 0 ) + { + try + { + linux = new FTermLinux; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return linux; +} + +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) +//---------------------------------------------------------------------- +FTermFreeBSD* FTerm::getFTermFreeBSD() +{ + if ( freebsd == 0 ) + { + try + { + freebsd = new FTermFreeBSD; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return freebsd; +} + +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) +//---------------------------------------------------------------------- +FTermOpenBSD* FTerm::getFTermOpenBSD() +{ + if ( openbsd == 0 ) + { + try + { + openbsd = new FTermOpenBSD; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return openbsd; +} +#endif + +#if DEBUG +//---------------------------------------------------------------------- +FTermDebugData& FTerm::getFTermDebugData() +{ + if ( debug_data == 0 ) + { + try + { + debug_data = new FTermDebugData; + } + catch (const std::bad_alloc& ex) + { + std::cerr << bad_alloc_str << ex.what() << std::endl; + std::abort(); + } + } + + return *debug_data; +} +#endif // DEBUG + //---------------------------------------------------------------------- bool FTerm::isNormal (charData*& ch) { return opti_attr->isNormal(ch); } +//---------------------------------------------------------------------- +bool FTerm::hasUTF8() +{ + return data->hasUTF8Console(); +} + +//---------------------------------------------------------------------- +bool FTerm::isMonochron() +{ + return data->isMonochron(); +} + +//---------------------------------------------------------------------- +bool FTerm::isXTerminal() +{ + return term_detection->isXTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isAnsiTerminal() +{ + return term_detection->isAnsiTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isRxvtTerminal() +{ + return term_detection->isRxvtTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isUrxvtTerminal() +{ + return term_detection->isUrxvtTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isMltermTerminal() +{ + return term_detection->isMltermTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isPuttyTerminal() +{ + return term_detection->isPuttyTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isKdeTerminal() +{ + return term_detection->isKdeTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isGnomeTerminal() +{ + return term_detection->isGnomeTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isKtermTerminal() +{ + return term_detection->isKtermTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isTeraTerm() +{ + return term_detection->isTeraTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isSunTerminal() +{ + return term_detection->isSunTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isCygwinTerminal() +{ + return term_detection->isCygwinTerminal(); +} + +//---------------------------------------------------------------------- +bool FTerm::isMinttyTerm() +{ + return term_detection->isMinttyTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isLinuxTerm() +{ + return term_detection->isLinuxTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isFreeBSDTerm() +{ + return term_detection->isFreeBSDTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isNetBSDTerm() +{ + return term_detection->isNetBSDTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isOpenBSDTerm() +{ + return term_detection->isOpenBSDTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isScreenTerm() +{ + return term_detection->isScreenTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isTmuxTerm() +{ + return term_detection->isTmuxTerm(); +} + +//---------------------------------------------------------------------- +bool FTerm::isNewFont() +{ + return data->isNewFont(); +} + //---------------------------------------------------------------------- bool FTerm::isCursorHideable() { @@ -137,6 +567,30 @@ bool FTerm::isCursorHideable() return false; } +//---------------------------------------------------------------------- +bool FTerm::hasChangedTermSize() +{ + return data->hasTermResized(); +} + +//---------------------------------------------------------------------- +bool FTerm::hasShadowCharacter() +{ + return data->hasShadowCharacter(); +} + +//---------------------------------------------------------------------- +bool FTerm::hasHalfBlockCharacter() +{ + return data->hasHalfBlockCharacter(); +} + +//---------------------------------------------------------------------- +bool FTerm::hasAlternateScreen() +{ + return data->hasAlternateScreen(); +} + //---------------------------------------------------------------------- bool FTerm::canChangeColorPalette() { @@ -917,6 +1371,12 @@ char* FTerm::changeAttribute ( charData*& term_attr return opti_attr->changeAttribute (term_attr, next_attr); } +//---------------------------------------------------------------------- +void FTerm::changeTermSizeFinished() +{ + data->setTermResized(false); +} + //---------------------------------------------------------------------- void FTerm::exitWithMessage (const FString& message) { @@ -1129,7 +1589,7 @@ void FTerm::init_cygwin_charmap() } // General encoding changes - characterSub& sub_map = data->getCharSubstitutionMap(); + charSubstitution& sub_map = data->getCharSubstitutionMap(); sub_map[L'•'] = L'*'; sub_map[L'●'] = L'*'; sub_map[L'◘'] = L'*'; diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index b65b8fd4..71c27619 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -23,7 +23,12 @@ #include #include +#include "final/fc.h" +#include "final/fcolorpair.h" +#include "final/fstring.h" #include "final/ftermbuffer.h" +#include "final/fvterm.h" +#include "final/ftypes.h" namespace finalcut { diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index b6966bcd..5f955151 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -24,26 +24,31 @@ #include #include +#include "final/emptyfstring.h" +#include "final/fc.h" +#include "final/fkey_map.h" #include "final/fterm.h" +#include "final/ftermdata.h" #include "final/ftermcap.h" +#include "final/ftermdetection.h" namespace finalcut { // static class attributes -bool FTermcap::background_color_erase = false; -bool FTermcap::can_change_color_palette = false; -bool FTermcap::automatic_left_margin = false; -bool FTermcap::automatic_right_margin = false; -bool FTermcap::eat_nl_glitch = false; -bool FTermcap::ansi_default_color = false; -bool FTermcap::osc_support = false; -bool FTermcap::no_utf8_acs_chars = false; -int FTermcap::max_color = 1; -int FTermcap::tabstop = 8; -int FTermcap::attr_without_color = 0; -FTermData* FTermcap::fterm_data = nullptr; -FTermDetection* FTermcap::term_detection = nullptr; +bool FTermcap::background_color_erase = false; +bool FTermcap::can_change_color_palette = false; +bool FTermcap::automatic_left_margin = false; +bool FTermcap::automatic_right_margin = false; +bool FTermcap::eat_nl_glitch = false; +bool FTermcap::ansi_default_color = false; +bool FTermcap::osc_support = false; +bool FTermcap::no_utf8_acs_chars = false; +int FTermcap::max_color = 1; +int FTermcap::tabstop = 8; +int FTermcap::attr_without_color = 0; +FTermData* FTermcap::fterm_data = nullptr; +FTermDetection* FTermcap::term_detection = nullptr; //---------------------------------------------------------------------- diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index ce6e7afb..3e7548cb 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -22,14 +22,20 @@ #include +#include "final/fc.h" +#include "final/fkey_map.h" +#include "final/fterm.h" +#include "final/ftermcap.h" #include "final/ftermcapquirks.h" +#include "final/ftermdata.h" +#include "final/ftermdetection.h" namespace finalcut { // static class attributes -FTermData* FTermcapQuirks::fterm_data = nullptr; -FTermDetection* FTermcapQuirks::term_detection = nullptr; +FTermData* FTermcapQuirks::fterm_data = nullptr; +FTermDetection* FTermcapQuirks::term_detection = nullptr; //---------------------------------------------------------------------- diff --git a/src/ftermdebugdata.cpp b/src/ftermdebugdata.cpp index 44014157..9183c26b 100644 --- a/src/ftermdebugdata.cpp +++ b/src/ftermdebugdata.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fterm.h" #include "final/ftermdata.h" #include "final/ftermdetection.h" @@ -44,6 +45,45 @@ void FTermDebugData::init() data = FTerm::getFTermData(); term_detection = FTerm::getFTermDetection(); } + +//---------------------------------------------------------------------- +const FString& FTermDebugData::getAnswerbackString() +{ + return term_detection->getAnswerbackString(); +} + +//---------------------------------------------------------------------- +const FString& FTermDebugData::getSecDAString() +{ + return term_detection->getSecDAString(); +} + +//---------------------------------------------------------------------- +const char* FTermDebugData::getTermType_256color() +{ + return term_detection->getTermType_256color(); +} + +//---------------------------------------------------------------------- +const char* FTermDebugData::getTermType_Answerback() +{ + return term_detection->getTermType_Answerback(); +} + +//---------------------------------------------------------------------- +const char* FTermDebugData::getTermType_SecDA() +{ + return term_detection->getTermType_SecDA(); +} + +//---------------------------------------------------------------------- +#if defined(__linux__) +int FTermDebugData::getFramebufferBpp() +{ + return data->getFramebufferBpp(); +} +#endif // defined(__linux__) + #endif // DEBUG } // namespace finalcut diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 19689ac8..c7056c7f 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -20,8 +20,19 @@ * . * ***********************************************************************/ +#include "final/emptyfstring.h" +#include "final/fc.h" +#include "final/fconfig.h" +#include "final/fsystem.h" #include "final/fterm.h" +#include "final/ftermdata.h" #include "final/ftermdetection.h" +#include "final/ftermios.h" +#include "final/ftypes.h" + +#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) + #include "final/ftermopenbsd.h" +#endif namespace finalcut { @@ -85,6 +96,20 @@ FTermDetection::~FTermDetection() // destructor // public methods of FTermDetection +//---------------------------------------------------------------------- +#if DEBUG +const FString& FTermDetection::getAnswerbackString() +{ + return ( answer_back ) ? *answer_back : fc::emptyFString::get(); +} + +//---------------------------------------------------------------------- +const FString& FTermDetection::getSecDAString() +{ + return ( sec_da ) ? *sec_da : fc::emptyFString::get(); +} +#endif + //---------------------------------------------------------------------- void FTermDetection::setTtyTypeFileName (char ttytype_filename[]) { diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 231a13ed..c9edcee5 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -21,8 +21,10 @@ ***********************************************************************/ #include "final/fcharmap.h" +#include "final/fsystem.h" #include "final/fterm.h" #include "final/ftermfreebsd.h" +#include "final/ftypes.h" namespace finalcut { diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 91b97a10..91e97581 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -20,10 +20,17 @@ * . * ***********************************************************************/ +#include "final/fc.h" +#include "final/fcharmap.h" +#include "final/fsystem.h" #include "final/fterm.h" +#include "final/ftermcap.h" +#include "final/ftermdetection.h" #include "final/ftermlinux.h" +#include "final/ftypes.h" #if defined(__linux__) + #include // need keyboard modifiers #include "../fonts/newfont.h" #include "../fonts/unicodemap.h" #include "../fonts/vgafont.h" @@ -1276,7 +1283,7 @@ void FTermLinux::characterFallback ( wchar_t ucs , std::vector fallback ) { constexpr sInt16 NOT_FOUND = -1; - characterSub& sub_map = fterm_data->getCharSubstitutionMap(); + charSubstitution& sub_map = fterm_data->getCharSubstitutionMap(); if ( fallback.size() < 2 || ucs != fallback[0] ) return; diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index 1106e1ab..d7e68d43 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fsystem.h" #include "final/fterm.h" #include "final/ftermopenbsd.h" diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index 7ecdcaa8..a10a2eea 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -20,9 +20,15 @@ * . * ***********************************************************************/ +#include "final/fc.h" +#include "final/fstring.h" #include "final/fterm.h" +#include "final/ftermcap.h" +#include "final/ftermdetection.h" #include "final/ftermfreebsd.h" +#include "final/ftermios.h" #include "final/ftermxterminal.h" +#include "final/fsize.h" namespace finalcut { diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 3488a52f..a15c91a5 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -22,9 +22,15 @@ #include +#include "final/fapplication.h" +#include "final/fc.h" #include "final/fdialog.h" +#include "final/fevent.h" +#include "final/fstring.h" +#include "final/fscrollbar.h" #include "final/fstatusbar.h" #include "final/ftextview.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 5b5f1069..0e98cbb8 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -22,8 +22,11 @@ #include "final/fapplication.h" #include "final/fbuttongroup.h" +#include "final/fevent.h" +#include "final/fpoint.h" #include "final/fstatusbar.h" #include "final/ftogglebutton.h" +#include "final/fwidget.h" namespace finalcut { diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index 7ef2469c..ec2d078f 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -22,6 +22,7 @@ #include "final/fapplication.h" #include "final/ftooltip.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 1f9e3ed7..c1bed783 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -25,8 +25,16 @@ #include #include "final/fapplication.h" +#include "final/fcolorpair.h" +#include "final/fkeyboard.h" +#include "final/foptiattr.h" +#include "final/foptimove.h" +#include "final/fsystem.h" #include "final/fterm.h" +#include "final/ftermdata.h" #include "final/ftermbuffer.h" +#include "final/ftermcap.h" +#include "final/ftypes.h" #include "final/fvterm.h" #include "final/fwidget.h" #include "final/fwindow.h" @@ -56,10 +64,10 @@ FVTerm::term_area* FVTerm::vterm = nullptr; FVTerm::term_area* FVTerm::vdesktop = nullptr; FVTerm::term_area* FVTerm::active_area = nullptr; FKeyboard* FVTerm::keyboard = nullptr; -FVTerm::charData FVTerm::term_attribute; -FVTerm::charData FVTerm::next_attribute; -FVTerm::charData FVTerm::s_ch; -FVTerm::charData FVTerm::i_ch; +charData FVTerm::term_attribute; +charData FVTerm::next_attribute; +charData FVTerm::s_ch; +charData FVTerm::i_ch; //---------------------------------------------------------------------- @@ -1632,7 +1640,7 @@ void FVTerm::clearArea (term_area* area, int fillchar) } //---------------------------------------------------------------------- -FVTerm::charData FVTerm::generateCharacter (const FPoint& pos) +charData FVTerm::generateCharacter (const FPoint& pos) { // Generates characters for a given position considering all areas @@ -1701,9 +1709,9 @@ FVTerm::charData FVTerm::generateCharacter (const FPoint& pos) } //---------------------------------------------------------------------- -FVTerm::charData FVTerm::getCharacter ( character_type char_type - , const FPoint& pos - , FVTerm* obj ) +charData FVTerm::getCharacter ( character_type char_type + , const FPoint& pos + , FVTerm* obj ) { // Gets the overlapped or the covered character for a given position @@ -1768,16 +1776,14 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type } //---------------------------------------------------------------------- -FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos - , FVTerm* obj ) +charData FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) { // Gets the covered character for a given position return getCharacter (covered_character, pos, obj); } //---------------------------------------------------------------------- -FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos - , FVTerm* obj ) +charData FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) { // Gets the overlapped character for a given position return getCharacter (overlapped_character, pos, obj); @@ -2797,7 +2803,7 @@ int FVTerm::appendLowerRight (charData*& screen_char) //---------------------------------------------------------------------- inline void FVTerm::characterFilter (charData*& next_char) { - FTerm::characterSub& sub_map = fterm->getCharSubstitutionMap(); + 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]; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 0aaea38d..f6898777 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -23,9 +23,12 @@ #include #include "final/fapplication.h" +#include "final/fevent.h" #include "final/fmenubar.h" #include "final/fstatusbar.h" +#include "final/fstring.h" #include "final/fwidget.h" +#include "final/fwidgetcolors.h" namespace finalcut { @@ -47,7 +50,6 @@ bool FWidget::init_desktop; bool FWidget::hideable; uInt FWidget::modal_dialogs; - //---------------------------------------------------------------------- // class FWidget //---------------------------------------------------------------------- @@ -2171,7 +2173,7 @@ void FWidget::draw() void FWidget::drawWindows() { // redraw windows - FOptiAttr::charData default_char; + charData default_char; default_char.code = ' '; default_char.fg_color = fc::Black; default_char.bg_color = fc::Black; diff --git a/src/fwidgetcolors.cpp b/src/fwidgetcolors.cpp index 8a98bbc4..c5213af5 100644 --- a/src/fwidgetcolors.cpp +++ b/src/fwidgetcolors.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include "final/fc.h" #include "final/fterm.h" #include "final/fwidgetcolors.h" diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 95ce6b13..f7cd50f4 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -21,6 +21,7 @@ ***********************************************************************/ #include "final/fapplication.h" +#include "final/fevent.h" #include "final/fmenubar.h" #include "final/fstatusbar.h" #include "final/fwindow.h" diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 028b50ba..e13a8e32 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2013-2018 Markus Gans * +* Copyright 2013-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 * @@ -66,13 +66,26 @@ #include #include -#include "final/fevent.h" +#include "final/ftypes.h" #include "final/fwidget.h" -#include "final/fwindow.h" namespace finalcut { +// class forward declaration +class FEvent; +class FAccelEvent; +class FCloseEvent; +class FFocusEvent; +class FKeyEvent; +class FMouseEvent; +class FTimerEvent; +class FWheelEvent; +class FMouseControl; +class FKeyboard; +class FPoint; +class FObject; + //---------------------------------------------------------------------- // class FApplication //---------------------------------------------------------------------- diff --git a/src/include/final/fbutton.h b/src/include/final/fbutton.h index 5ec9abad..12bf069b 100644 --- a/src/include/final/fbutton.h +++ b/src/include/final/fbutton.h @@ -53,6 +53,7 @@ #endif #include "final/fwidget.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index 7d50c92b..a6370505 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -54,6 +54,7 @@ #endif #include "final/fscrollview.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/include/final/fcolorpair.h b/src/include/final/fcolorpair.h index c109b9e1..1be32b10 100644 --- a/src/include/final/fcolorpair.h +++ b/src/include/final/fcolorpair.h @@ -35,7 +35,8 @@ #error "Only can be included directly." #endif -//#include ... +#include "final/fc.h" +#include "final/ftypes.h" namespace finalcut { diff --git a/src/include/final/fcolorpalette.h b/src/include/final/fcolorpalette.h index c14e8569..e588d824 100644 --- a/src/include/final/fcolorpalette.h +++ b/src/include/final/fcolorpalette.h @@ -35,8 +35,6 @@ #error "Only can be included directly." #endif -#include "final/fc.h" - namespace finalcut { 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/fdialog.h b/src/include/final/fdialog.h index e912c467..c30a60f8 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -57,13 +57,14 @@ #endif #include "final/fmenu.h" -#include "final/fmenuitem.h" -#include "final/ftooltip.h" #include "final/fwindow.h" namespace finalcut { +// class forward declaration +class FToolTip; + //---------------------------------------------------------------------- // class FDialog //---------------------------------------------------------------------- diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h index 5d186224..87fe0b6e 100644 --- a/src/include/final/fevent.h +++ b/src/include/final/fevent.h @@ -65,7 +65,11 @@ * │ ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏ * │ * │ ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏ - * └─────▏FTimerEvent ▏ + * ├─────▏FTimerEvent ▏ + * │ ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * │ + * │ ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * └─────▏FUserEvent ▏ * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏ */ @@ -83,6 +87,9 @@ namespace finalcut { +// class forward declaration +class FPoint; + //---------------------------------------------------------------------- // class FEvent //---------------------------------------------------------------------- diff --git a/src/include/final/ffiledialog.h b/src/include/final/ffiledialog.h index 27b53b9e..6b40f57b 100644 --- a/src/include/final/ffiledialog.h +++ b/src/include/final/ffiledialog.h @@ -63,11 +63,13 @@ #endif #include +#include #include #include #include #include +#include #include #include diff --git a/src/include/final/final.h b/src/include/final/final.h index 21bdd84e..c90cddde 100644 --- a/src/include/final/final.h +++ b/src/include/final/final.h @@ -4,7 +4,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -26,15 +26,21 @@ #define USE_FINAL_H +#include #include #include #include #include +#include "final/fc.h" +#include "final/fcolorpair.h" +#include "final/fcharmap.h" #include #include #include #include +#include #include +#include #include #include #include @@ -43,6 +49,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -52,11 +61,31 @@ #include #include #include +#include #include +#include +#include +#include +#include +#include +#include #include #include +#include #include +#if defined(UNIT_TEST) + #include "final/ftermlinux.h" + #include "final/ftermfreebsd.h" + #include "final/ftermopenbsd.h" +#elif defined(__linux__) + #include "final/ftermlinux.h" +#elif defined(__FreeBSD__) || defined(__DragonFly__) + #include "final/ftermfreebsd.h" +#elif defined(__NetBSD__) || defined(__OpenBSD__) + #include "final/ftermopenbsd.h" +#endif + #undef USE_FINAL_H #endif // FINAL_H diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index efdea002..274a59d7 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -35,19 +35,15 @@ #error "Only can be included directly." #endif -#include "final/fobject.h" #include "final/ftypes.h" -#if defined(__linux__) - #include "final/ftermlinux.h" -#endif - namespace finalcut { // class forward declaration class FApplication; - +class FString; +class FTermLinux; //---------------------------------------------------------------------- // class FKeyboardCommand diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index 285d3e18..fcf52545 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -55,6 +55,7 @@ #include #include "final/fwidget.h" +#include "final/fwidgetcolors.h" namespace finalcut { diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index b108d673..f1144184 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -53,11 +53,13 @@ #endif #include "final/fwidget.h" -#include "final/flabel.h" namespace finalcut { +// class forward declaration +class FLabel; + //---------------------------------------------------------------------- // class FLineEdit //---------------------------------------------------------------------- diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index bd3c57ff..aa0cd6c7 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -56,13 +56,15 @@ e Copyright 2014-2019 Markus Gans * #include #include -#include "final/fscrollbar.h" -#include "final/fstring.h" #include "final/fwidget.h" namespace finalcut { +// class forward declaration +class FScrollbar; +class FString; + //---------------------------------------------------------------------- // class FListBoxItem //---------------------------------------------------------------------- diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index de69c091..6f6709be 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -57,8 +57,6 @@ #include #include -#include "final/fscrollbar.h" -#include "final/fstring.h" #include "final/ftermbuffer.h" #include "final/fwidget.h" @@ -67,6 +65,8 @@ namespace finalcut // class forward declaration class FListView; +class FScrollbar; +class FString; //---------------------------------------------------------------------- // class FListViewItem diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index 5f5f8da7..33566411 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -60,13 +60,15 @@ #endif #include "final/fwindow.h" -#include "final/fmenubar.h" #include "final/fmenulist.h" -#include "final/fmenuitem.h" namespace finalcut { +// class forward declaration +class FMenuBar; +class FMenuItem; + //---------------------------------------------------------------------- // class FMenu //---------------------------------------------------------------------- diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index 144bf90c..b78be7fb 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -59,13 +59,15 @@ #error "Only can be included directly." #endif -#include "final/fmenu.h" #include "final/fmenulist.h" #include "final/fwindow.h" namespace finalcut { +// class forward declaration +class FMenu; + //---------------------------------------------------------------------- // class FMenuBar //---------------------------------------------------------------------- diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index 829ae318..f938b586 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -64,13 +64,15 @@ #include -#include "final/fbutton.h" #include "final/fdialog.h" -#include "final/fterm.h" +#include "final/fwidgetcolors.h" namespace finalcut { +// class forward declaration +class FButton; + //---------------------------------------------------------------------- // class FMessageBox //---------------------------------------------------------------------- diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 221d5154..14368b65 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -63,10 +63,8 @@ #include #include -#include "final/fconfig.h" #include "final/fkeyboard.h" #include "final/fpoint.h" -#include "final/ftypes.h" #if defined(__linux__) #include // need for gpm keyboard modifiers diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h index ca93937c..e0bbd1e5 100644 --- a/src/include/final/fobject.h +++ b/src/include/final/fobject.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-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 * @@ -48,14 +48,22 @@ #include #include -#include "final/emptyfstring.h" -#include "final/fc.h" -#include "final/fevent.h" -#include "final/ftypes.h" - namespace finalcut { +// class forward declaration +class FEvent; +class FKeyEvent; +class FMouseEvent; +class FWheelEvent; +class FFocusEvent; +class FAccelEvent; +class FShowEvent; +class FHideEvent; +class FCloseEvent; +class FTimerEvent; +class FUserEvent; + //---------------------------------------------------------------------- // class FObject //---------------------------------------------------------------------- diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index 299c872d..23f670ce 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -58,9 +58,6 @@ #include // need for std::swap -#include "final/fc.h" -#include "final/ftypes.h" - namespace finalcut { @@ -74,46 +71,7 @@ namespace finalcut class FOptiAttr final { public: - // Typedefs - typedef struct - { - wchar_t code; // character code - wchar_t encoded_code; // encoded output character - FColor fg_color; // foreground color - FColor bg_color; // background color - - union attribute - { - struct - { - // Attribute byte #0 - uInt8 bold : 1; // bold - uInt8 dim : 1; // dim - uInt8 italic : 1; // italic - uInt8 underline : 1; // underline - uInt8 blink : 1; // blink - uInt8 reverse : 1; // reverse - uInt8 standout : 1; // standout - uInt8 invisible : 1; // invisible - // Attribute byte #1 - uInt8 protect : 1; // protect mode - uInt8 crossed_out : 1; // crossed out - uInt8 dbl_underline : 1; // double underline - uInt8 alt_charset : 1; // alternate character set (vt100) - uInt8 pc_charset : 1; // pc character set (CP437) - uInt8 transparent : 1; // transparent - uInt8 trans_shadow : 1; // transparent shadow - uInt8 inherit_bg : 1; // inherit background - // Attribute byte #2 - uInt8 no_changes : 1; // no changes required - uInt8 printed : 1; // is printed to VTerm - uInt8 : 6; // padding bits - } bit; - - uInt8 byte[3]; - } attr; - } charData; - + // Typedef typedef struct { bool ansi_default_color; @@ -381,8 +339,8 @@ class FOptiAttr final // FOptiAttr inline functions //---------------------------------------------------------------------- -inline bool operator == ( const FOptiAttr::charData& lhs, - const FOptiAttr::charData& rhs ) +inline bool operator == ( const charData& lhs, + const charData& rhs ) { return lhs.code == rhs.code && lhs.fg_color == rhs.fg_color @@ -392,8 +350,8 @@ inline bool operator == ( const FOptiAttr::charData& lhs, } //---------------------------------------------------------------------- -inline bool operator != ( const FOptiAttr::charData& lhs, - const FOptiAttr::charData& rhs ) +inline bool operator != ( const charData& lhs, + const charData& rhs ) { return ! ( lhs == rhs ); } //---------------------------------------------------------------------- diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index 772a91d0..dbd1d1f8 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -63,8 +63,6 @@ #include #include -#include "final/ftypes.h" - namespace finalcut { diff --git a/src/include/final/fpoint.h b/src/include/final/fpoint.h index e775e94d..ef86c8ee 100644 --- a/src/include/final/fpoint.h +++ b/src/include/final/fpoint.h @@ -36,7 +36,6 @@ #endif #include -#include "final/ftypes.h" namespace finalcut { diff --git a/src/include/final/frect.h b/src/include/final/frect.h index a9f7a0e2..5e1ae4dd 100644 --- a/src/include/final/frect.h +++ b/src/include/final/frect.h @@ -40,12 +40,14 @@ #endif #include -#include "final/fpoint.h" -#include "final/fsize.h" namespace finalcut { +// class forward declaration +class FPoint; +class FSize; + //---------------------------------------------------------------------- // class FRect //---------------------------------------------------------------------- @@ -186,26 +188,6 @@ inline int FRect::getX() const inline int FRect::getY() const { return Y1; } -//---------------------------------------------------------------------- -inline FPoint FRect::getPos() const -{ return FPoint(X1, Y1); } - -//---------------------------------------------------------------------- -inline FPoint FRect::getUpperLeftPos() const -{ return FPoint(X1, Y1); } - -//---------------------------------------------------------------------- -inline FPoint FRect::getUpperRightPos() const -{ return FPoint(X2, Y1); } - -//---------------------------------------------------------------------- -inline FPoint FRect::getLowerLeftPos() const -{ return FPoint(X1, Y2); } - -//---------------------------------------------------------------------- -inline FPoint FRect::getLowerRightPos() const -{ return FPoint(X2, Y2); } - //---------------------------------------------------------------------- inline std::size_t FRect::getWidth() const { @@ -220,10 +202,6 @@ inline std::size_t FRect::getHeight() const return ( h < 0 ) ? 0 : std::size_t(h); } -//---------------------------------------------------------------------- -inline FSize FRect::getSize() const -{ return FSize(getWidth(), getHeight()); } - //---------------------------------------------------------------------- inline int& FRect::x1_ref() { return X1; } diff --git a/src/include/final/fsize.h b/src/include/final/fsize.h index 1efd77e1..f424e78d 100644 --- a/src/include/final/fsize.h +++ b/src/include/final/fsize.h @@ -36,6 +36,7 @@ #endif #include + #include "final/ftypes.h" namespace finalcut diff --git a/src/include/final/fstatusbar.h b/src/include/final/fstatusbar.h index c5e6c7c8..925018a4 100644 --- a/src/include/final/fstatusbar.h +++ b/src/include/final/fstatusbar.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -61,6 +61,7 @@ #include +#include "final/fwidget.h" #include "final/fwindow.h" namespace finalcut diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 5b0715ee..86706eda 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -115,41 +115,36 @@ #include #include "final/fc.h" -#include "final/fcolorpalette.h" -#include "final/fkey_map.h" -#include "final/fkeyboard.h" -#include "final/fmouse.h" -#include "final/foptiattr.h" -#include "final/foptimove.h" -#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" -#include "final/ftermdebugdata.h" -#include "final/ftermdetection.h" - -#if defined(UNIT_TEST) - #include "final/ftermlinux.h" - #include "final/ftermfreebsd.h" - #include "final/ftermopenbsd.h" -#elif defined(__linux__) - #include "final/ftermlinux.h" -#elif defined(__FreeBSD__) || defined(__DragonFly__) - #include "final/ftermfreebsd.h" -#elif defined(__NetBSD__) || defined(__OpenBSD__) - #include "final/ftermopenbsd.h" -#endif - -#include "final/ftermios.h" -#include "final/ftermxterminal.h" namespace finalcut { +// class forward declaration +class FKeyboard; +class FMouseControl; +class FOptiAttr; +class FOptiMove; +class FSize; +class FString; +class FSystem; +class FTermData; +class FTermDebugData; +class FTermDetection; +class FTermXTerminal; + +#if defined(UNIT_TEST) + class FTermLinux; + class FTermFreeBSD; + class FTermOpenBSD; +#elif defined(__linux__) + class FTermLinux; +#elif defined(__FreeBSD__) || defined(__DragonFly__) + class FTermFreeBSD; +#elif defined(__NetBSD__) || defined(__OpenBSD__) + class FTermOpenBSD; +#endif + //---------------------------------------------------------------------- // class FTerm //---------------------------------------------------------------------- @@ -160,10 +155,6 @@ namespace finalcut class FTerm final { public: - // Typedefs - typedef FOptiAttr::charData charData; - typedef FTermData::characterSub characterSub; - struct initializationValues; // forward declaration // Constructor @@ -189,7 +180,7 @@ class FTerm final static int getTabstop(); static int getMaxColor(); initializationValues& getInitValues(); - characterSub& getCharSubstitutionMap(); + charSubstitution& getCharSubstitutionMap(); static FTermData* getFTermData(); static FSystem* getFSystem(); @@ -447,369 +438,10 @@ class FTerm final inline const char* FTerm::getClassName() const { return "FTerm"; } -//---------------------------------------------------------------------- -inline int FTerm::getTTYFileDescriptor() -{ return ( data ) ? data->getTTYFileDescriptor() : 0; } - -//---------------------------------------------------------------------- -inline char* FTerm::getTermType() -{ return data->getTermType(); } - -//---------------------------------------------------------------------- -inline char* FTerm::getTermFileName() -{ return data->getTermFileName(); } - -//---------------------------------------------------------------------- -inline int FTerm::getTabstop() -{ return FTermcap::tabstop; } - -//---------------------------------------------------------------------- -inline int FTerm::getMaxColor() -{ return FTermcap::max_color; } - //---------------------------------------------------------------------- inline FTerm::initializationValues& FTerm::getInitValues() { return init_values; } -//---------------------------------------------------------------------- -inline FTerm::characterSub& FTerm::getCharSubstitutionMap() -{ return data->getCharSubstitutionMap(); } - -//---------------------------------------------------------------------- -inline FTermData* FTerm::getFTermData() -{ - if ( data == 0 ) - { - try - { - data = new FTermData; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return data; -} - -//---------------------------------------------------------------------- -inline FSystem* FTerm::getFSystem() -{ - if ( fsys == 0 ) - { - try - { - fsys = new FSystemImpl; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return fsys; -} - -//---------------------------------------------------------------------- -inline FOptiMove* FTerm::getFOptiMove() -{ - if ( opti_move == 0 ) - { - try - { - opti_move = new FOptiMove; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return opti_move; -} - -//---------------------------------------------------------------------- -inline FOptiAttr* FTerm::getFOptiAttr() -{ - if ( opti_attr == 0 ) - { - try - { - opti_attr = new FOptiAttr; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return opti_attr; -} - -//---------------------------------------------------------------------- -inline FTermDetection* FTerm::getFTermDetection() -{ - if ( term_detection == 0 ) - { - try - { - term_detection = new FTermDetection; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return term_detection; -} -//---------------------------------------------------------------------- -inline FTermXTerminal* FTerm::getFTermXTerminal() -{ - if ( xterm == 0 ) - { - try - { - xterm = new FTermXTerminal; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return xterm; -} -//---------------------------------------------------------------------- -inline FKeyboard* FTerm::getFKeyboard() -{ - if ( keyboard == 0 ) - { - try - { - keyboard = new FKeyboard; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return keyboard; -} -//---------------------------------------------------------------------- -inline FMouseControl* FTerm::getFMouseControl() -{ - if ( mouse == 0 ) - { - try - { - mouse = new FMouseControl; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return mouse; -} - -#if defined(__linux__) -//---------------------------------------------------------------------- -inline FTermLinux* FTerm::getFTermLinux() -{ - if ( linux == 0 ) - { - try - { - linux = new FTermLinux; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return linux; -} - -#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) -//---------------------------------------------------------------------- -inline FTermFreeBSD* FTerm::getFTermFreeBSD() -{ - if ( freebsd == 0 ) - { - try - { - freebsd = new FTermFreeBSD; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return freebsd; -} - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) -//---------------------------------------------------------------------- -inline FTermOpenBSD* FTerm::getFTermOpenBSD() -{ - if ( openbsd == 0 ) - { - try - { - openbsd = new FTermOpenBSD; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return openbsd; -} -#endif - -#if DEBUG -//---------------------------------------------------------------------- -inline FTermDebugData& FTerm::getFTermDebugData() -{ - if ( debug_data == 0 ) - { - try - { - debug_data = new FTermDebugData; - } - catch (const std::bad_alloc& ex) - { - std::cerr << bad_alloc_str << ex.what() << std::endl; - std::abort(); - } - } - - return *debug_data; -} -#endif // DEBUG - -//---------------------------------------------------------------------- -inline bool FTerm::hasUTF8() -{ return data->hasUTF8Console(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isMonochron() -{ return data->isMonochron(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isXTerminal() -{ return term_detection->isXTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isAnsiTerminal() -{ return term_detection->isAnsiTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isRxvtTerminal() -{ return term_detection->isRxvtTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isUrxvtTerminal() -{ return term_detection->isUrxvtTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isMltermTerminal() -{ return term_detection->isMltermTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isPuttyTerminal() -{ return term_detection->isPuttyTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isKdeTerminal() -{ return term_detection->isKdeTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isGnomeTerminal() -{ return term_detection->isGnomeTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isKtermTerminal() -{ return term_detection->isKtermTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isTeraTerm() -{ return term_detection->isTeraTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isSunTerminal() -{ return term_detection->isSunTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isCygwinTerminal() -{ return term_detection->isCygwinTerminal(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isMinttyTerm() -{ return term_detection->isMinttyTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isLinuxTerm() -{ return term_detection->isLinuxTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isFreeBSDTerm() -{ return term_detection->isFreeBSDTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isNetBSDTerm() -{ return term_detection->isNetBSDTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isOpenBSDTerm() -{ return term_detection->isOpenBSDTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isScreenTerm() -{ return term_detection->isScreenTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isTmuxTerm() -{ return term_detection->isTmuxTerm(); } - -//---------------------------------------------------------------------- -inline bool FTerm::isNewFont() -{ return data->isNewFont(); } - -//---------------------------------------------------------------------- -inline bool FTerm::hasChangedTermSize() -{ return data->hasTermResized(); } - -//---------------------------------------------------------------------- -inline bool FTerm::hasShadowCharacter() -{ return data->hasShadowCharacter(); } - -//---------------------------------------------------------------------- -inline bool FTerm::hasHalfBlockCharacter() -{ return data->hasHalfBlockCharacter(); } - -//---------------------------------------------------------------------- -inline bool FTerm::hasAlternateScreen() -{ return data->hasAlternateScreen(); } - //---------------------------------------------------------------------- inline void FTerm::setFSystem (FSystem* fsystem) { fsys = fsystem; } @@ -822,10 +454,6 @@ inline bool FTerm::setUTF8() inline bool FTerm::unsetUTF8() { return setUTF8(false); } -//---------------------------------------------------------------------- -inline void FTerm::changeTermSizeFinished() -{ data->setTermResized(false); } - } // namespace finalcut diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index 9005e54a..b5c667e5 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -39,12 +39,12 @@ #include #include -#include "final/fvterm.h" -#include "final/fstring.h" - namespace finalcut { +// class forward declaration +class FColorPair; + //---------------------------------------------------------------------- // class FTermBuffer //---------------------------------------------------------------------- @@ -56,7 +56,6 @@ class FTermBuffer { public: // Typedef - typedef FOptiAttr::charData charData; typedef std::vector charDataVector; // Constructor diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index c632d702..63d0b6d3 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -58,17 +58,16 @@ #include #include -#include "final/emptyfstring.h" -#include "final/fkey_map.h" -#include "final/ftermdetection.h" - - // FTermcap string macro #define TCAP(...) FTermcap::strings[__VA_ARGS__].string namespace finalcut { +// class forward declaration +class FTermData; +class FTermDetection; + //---------------------------------------------------------------------- // class FTermcap //---------------------------------------------------------------------- diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index a22c72e6..dd258276 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -35,15 +35,13 @@ #error "Only can be included directly." #endif -#include "final/fc.h" -#include "final/fterm.h" -#include "final/ftermcap.h" -#include "final/ftermdata.h" -#include "final/ftermdetection.h" - namespace finalcut { +// class forward declaration +class FTermData; +class FTermDetection; + //---------------------------------------------------------------------- // class FTermcapsQuirks //---------------------------------------------------------------------- diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index bce63091..80e78382 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -58,7 +58,6 @@ class FTermData final public: // Typedefs typedef std::unordered_map encodingMap; - typedef std::unordered_map characterSub; // Constructors FTermData() {} @@ -73,89 +72,88 @@ class FTermData final FTermData& operator = (const FTermData&) = delete; // Accessors - const char* getClassName() const; - encodingMap& getEncodingList(); - characterSub& getCharSubstitutionMap(); - fc::encoding getTermEncoding() const; - FRect& getTermGeometry(); - int getTTYFileDescriptor() const; - uInt getBaudrate() const; - char* getTermType(); - char* getTermFileName(); - const FString& getXtermFont() const; - const FString& getXtermTitle() const; + const char* getClassName() const; + encodingMap& getEncodingList(); + charSubstitution& getCharSubstitutionMap(); + fc::encoding getTermEncoding() const; + FRect& getTermGeometry(); + int getTTYFileDescriptor() const; + uInt getBaudrate() const; + char* getTermType(); + char* getTermFileName(); + const FString& getXtermFont() const; + const FString& getXtermTitle() const; #if DEBUG - int getFramebufferBpp() const; + int getFramebufferBpp() const; #endif // Inquiries - bool hasShadowCharacter() const; - bool hasHalfBlockCharacter() const; - bool hasCursorOptimisation() const; - bool isCursorHidden() const; - bool hasAlternateScreen() const; - bool hasASCIIConsole() const; - bool hasVT100Console() const; - bool hasUTF8Console() const; - bool isUTF8() const; - bool isNewFont() const; - bool isVGAFont() const; - bool isMonochron() const; - bool hasTermResized() const; + bool hasShadowCharacter() const; + bool hasHalfBlockCharacter() const; + bool hasCursorOptimisation() const; + bool isCursorHidden() const; + bool hasAlternateScreen() const; + bool hasASCIIConsole() const; + bool hasVT100Console() const; + bool hasUTF8Console() const; + bool isUTF8() const; + bool isNewFont() const; + bool isVGAFont() const; + bool isMonochron() const; + bool hasTermResized() const; // Mutators - void setTermEncoding(fc::encoding); - void setTTYFileDescriptor (int); - void setBaudrate (uInt); - void supportShadowCharacter (bool); - void supportHalfBlockCharacter (bool); - void supportCursorOptimisation (bool); - void setCursorHidden (bool); - void useAlternateScreen (bool); - void setASCIIConsole (bool); - void setVT100Console (bool); - void setUTF8Console (bool); - void setUTF8 (bool); - void setNewFont (bool); - void setVGAFont (bool); - void setMonochron (bool); - void setTermResized (bool); - void setTermType (const char[]); - void setTermFileName (const char[]); - void setXtermFont (const FString&); - void setXtermTitle (const FString&); + void setTermEncoding(fc::encoding); + void setTTYFileDescriptor (int); + void setBaudrate (uInt); + void supportShadowCharacter (bool); + void supportHalfBlockCharacter (bool); + void supportCursorOptimisation (bool); + void setCursorHidden (bool); + void useAlternateScreen (bool); + void setASCIIConsole (bool); + void setVT100Console (bool); + void setUTF8Console (bool); + void setUTF8 (bool); + void setNewFont (bool); + void setVGAFont (bool); + void setMonochron (bool); + void setTermResized (bool); + void setTermType (const char[]); + void setTermFileName (const char[]); + void setXtermFont (const FString&); + void setXtermTitle (const FString&); #if DEBUG - void setFramebufferBpp (int); + void setFramebufferBpp (int); #endif private: // Data Members - encodingMap encoding_list{}; - characterSub char_substitution_map{}; - fc::encoding term_encoding{fc::UNKNOWN}; - FRect term_geometry{}; // current terminal geometry - int fd_tty{-1}; // Teletype (tty) file descriptor is still undefined - uInt baudrate{0}; - bool shadow_character{true}; - bool half_block_character{true}; - bool cursor_optimisation{true}; - bool hidden_cursor{false}; // Global cursor hidden state - bool use_alternate_screen{true}; - bool ascii_console{false}; - bool vt100_console{false}; - bool utf8_console{false}; - bool utf8_state{false}; - bool new_font{false}; - bool vga_font{false}; - bool monochron{false}; - bool resize_term{false}; - char termtype[256]{'\0'}; - char termfilename[256]{'\0'}; - FString xterm_font{}; - FString xterm_title{}; - + encodingMap encoding_list{}; + charSubstitution char_substitution_map{}; + fc::encoding term_encoding{fc::UNKNOWN}; + FRect term_geometry{}; // current terminal geometry + int fd_tty{-1}; // Teletype (tty) file descriptor is still undefined + uInt baudrate{0}; + bool shadow_character{true}; + bool half_block_character{true}; + bool cursor_optimisation{true}; + bool hidden_cursor{false}; // Global cursor hidden state + bool use_alternate_screen{true}; + bool ascii_console{false}; + bool vt100_console{false}; + bool utf8_console{false}; + bool utf8_state{false}; + bool new_font{false}; + bool vga_font{false}; + bool monochron{false}; + bool resize_term{false}; + char termtype[256]{'\0'}; + char termfilename[256]{'\0'}; + FString xterm_font{}; + FString xterm_title{}; #if DEBUG - int framebuffer_bpp{-1}; + int framebuffer_bpp{-1}; #endif }; #pragma pack(pop) @@ -170,7 +168,7 @@ inline FTermData::encodingMap& FTermData::getEncodingList() { return encoding_list; } //---------------------------------------------------------------------- -inline FTermData::characterSub& FTermData::getCharSubstitutionMap() +inline charSubstitution& FTermData::getCharSubstitutionMap() { return char_substitution_map; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermdebugdata.h b/src/include/final/ftermdebugdata.h index 91081897..f6f36eb8 100644 --- a/src/include/final/ftermdebugdata.h +++ b/src/include/final/ftermdebugdata.h @@ -40,6 +40,8 @@ namespace finalcut // class forward declaration class FTerm; +class FTermData; +class FTermDetection; #if DEBUG //---------------------------------------------------------------------- @@ -79,33 +81,6 @@ class FTermDebugData final static FTermData* data; static FTermDetection* term_detection; }; - -//---------------------------------------------------------------------- -inline const FString& FTermDebugData::getAnswerbackString() -{ return term_detection->getAnswerbackString(); } - -//---------------------------------------------------------------------- -inline const FString& FTermDebugData::getSecDAString() -{ return term_detection->getSecDAString(); } - -//---------------------------------------------------------------------- -inline const char* FTermDebugData::getTermType_256color() -{ return term_detection->getTermType_256color(); } - -//---------------------------------------------------------------------- -inline const char* FTermDebugData::getTermType_Answerback() -{ return term_detection->getTermType_Answerback(); } - -//---------------------------------------------------------------------- -inline const char* FTermDebugData::getTermType_SecDA() -{ return term_detection->getTermType_SecDA(); } - -//---------------------------------------------------------------------- -#if defined(__linux__) -inline int FTermDebugData::getFramebufferBpp() -{ return data->getFramebufferBpp(); } -#endif // defined(__linux__) - #endif // DEBUG } // namespace finalcut diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index d071ea30..94451fd1 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -41,13 +41,6 @@ #include #include -#include "final/fc.h" -#include "final/fconfig.h" -#include "final/fsystem.h" -#include "final/ftermdata.h" -#include "final/ftermios.h" -#include "final/ftypes.h" - namespace finalcut { @@ -267,14 +260,6 @@ inline FTermDetection::terminalType& FTermDetection::getTermTypeStruct() { return terminal_type; } #if DEBUG -//---------------------------------------------------------------------- -inline const FString& FTermDetection::getAnswerbackString() -{ return ( answer_back ) ? *answer_back : fc::emptyFString::get(); } - -//---------------------------------------------------------------------- -inline const FString& FTermDetection::getSecDAString() -{ return ( sec_da ) ? *sec_da : fc::emptyFString::get(); } - //---------------------------------------------------------------------- inline const char* FTermDetection::getTermType_256color() { return termtype_256color; } diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 331352b9..3fbac38e 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -36,8 +36,6 @@ #endif #include "final/fc.h" -#include "final/fsystem.h" -#include "final/ftypes.h" #if defined(__FreeBSD__) || defined(__DragonFly__) #undef mouse_info // consio.h @@ -50,6 +48,9 @@ namespace finalcut { +// class forward declaration +class FSystem; + //---------------------------------------------------------------------- // class FTermFreeBSD //---------------------------------------------------------------------- diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index f34b0fef..86812579 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -51,15 +51,16 @@ #include // need for sprintf #include -#include "final/fc.h" -#include "final/fcharmap.h" -#include "final/fsystem.h" -#include "final/ftermdetection.h" -#include "final/ftypes.h" +#include "final/ftermdata.h" namespace finalcut { +// class forward declaration +class FSystem; +class FTermData; +class FTermDetection; + //---------------------------------------------------------------------- // class FTermLinux //---------------------------------------------------------------------- @@ -134,8 +135,6 @@ class FTermLinux final rgb color[16]; } ColorMap; - typedef FTermData::characterSub characterSub; - // Accessors static int getFramebuffer_bpp(); static bool getScreenFont(); diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 0be3b2e1..c21a4be0 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -36,7 +36,6 @@ #endif #include -#include "final/fsystem.h" #if defined(UNIT_TEST) #define WSKBDIO_GETENCODING uInt32(0x4004570F) @@ -50,6 +49,9 @@ namespace finalcut { +// class forward declaration +class FSystem; + //---------------------------------------------------------------------- // class FTermOpenBSD //---------------------------------------------------------------------- diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index b902cf72..c1911efd 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -35,14 +35,14 @@ #error "Only can be included directly." #endif -#include "final/fc.h" -#include "final/fstring.h" -#include "final/ftermcap.h" -#include "final/ftermdetection.h" - namespace finalcut { +// class forward declaration +class FString; +class FSystem; +class FTermDetection; + //---------------------------------------------------------------------- // class FTermXTerminal //---------------------------------------------------------------------- diff --git a/src/include/final/ftextview.h b/src/include/final/ftextview.h index 6aa709a0..f54309e8 100644 --- a/src/include/final/ftextview.h +++ b/src/include/final/ftextview.h @@ -55,15 +55,14 @@ #include #include -#include "final/fapplication.h" -#include "final/fscrollbar.h" -#include "final/fstatusbar.h" -#include "final/fstring.h" #include "final/fwidget.h" namespace finalcut { +// class forward declaration +class FString; + //---------------------------------------------------------------------- // class FTextView //---------------------------------------------------------------------- diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index 12020637..bc8a5990 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -32,6 +32,7 @@ #include #include +#include #include #define null nullptr @@ -103,6 +104,51 @@ struct getPrecision } }; +typedef std::unordered_map charSubstitution; + +#pragma pack(push) +#pragma pack(1) + +typedef struct +{ + wchar_t code; // character code + wchar_t encoded_code; // encoded output character + FColor fg_color; // foreground color + FColor bg_color; // background color + + union attribute + { + struct + { + // Attribute byte #0 + uInt8 bold : 1; // bold + uInt8 dim : 1; // dim + uInt8 italic : 1; // italic + uInt8 underline : 1; // underline + uInt8 blink : 1; // blink + uInt8 reverse : 1; // reverse + uInt8 standout : 1; // standout + uInt8 invisible : 1; // invisible + // Attribute byte #1 + uInt8 protect : 1; // protect mode + uInt8 crossed_out : 1; // crossed out + uInt8 dbl_underline : 1; // double underline + uInt8 alt_charset : 1; // alternate character set (vt100) + uInt8 pc_charset : 1; // pc character set (CP437) + uInt8 transparent : 1; // transparent + uInt8 trans_shadow : 1; // transparent shadow + uInt8 inherit_bg : 1; // inherit background + // Attribute byte #2 + uInt8 no_changes : 1; // no changes required + uInt8 printed : 1; // is printed to VTerm + uInt8 : 6; // padding bits + } bit; + + uInt8 byte[3]; + } attr; +} charData; +#pragma pack(pop) + namespace fc { #pragma pack(push) diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index d66364af..cfb07ce8 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -57,9 +57,8 @@ #include #include +#include "final/fc.h" #include "final/fterm.h" -#include "final/fcolorpair.h" - // Preprocessing handler macro #define F_PREPROC_HANDLER(i,h) \ @@ -70,10 +69,19 @@ namespace finalcut { // class forward declaration +class FColorPair; +class FKeyboard; +class FMouseControl; +class FPoint; +class FRect; +class FSize; +class FString; +class FSystem; +class FTerm; class FTermBuffer; +class FTermDebugData; class FWidget; - //---------------------------------------------------------------------- // class FVTerm //---------------------------------------------------------------------- @@ -92,7 +100,6 @@ class FVTerm uInt trans_count; // Number of transparent characters } line_changes; - typedef FOptiAttr::charData charData; typedef void (FVTerm::*FPreprocessingHandler)(); struct term_area; // forward declaration @@ -420,9 +427,7 @@ class FVTerm term_area* vwin{nullptr}; // virtual window private: - // Typedef and Enumeration - typedef FTermcap::tcap_map termcap_map; - + // Enumeration enum exit_state { not_used, @@ -431,8 +436,8 @@ class FVTerm }; // Constants + // Buffer size for character output on the terminal static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; - // Buffer size for character output on the terminal // Methods void init (bool); @@ -566,7 +571,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; @@ -603,7 +608,7 @@ inline FVTerm::term_area* FVTerm::getVWin() const { return vwin; } //---------------------------------------------------------------------- -inline FVTerm::charData FVTerm::getAttribute() +inline charData FVTerm::getAttribute() { return next_attribute; } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 35652746..98951803 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -99,8 +99,11 @@ #include #include "final/fvterm.h" -#include "final/fwidgetcolors.h" - +#include "final/fobject.h" +#include "final/fpoint.h" +#include "final/frect.h" +#include "final/fsize.h" +#include "final/ftypes.h" // Callback macros #define F_FUNCTION_CALLBACK(h) \ @@ -114,8 +117,12 @@ namespace finalcut { // class forward declaration -class FStatusBar; class FMenuBar; +class FRect; +class FResizeEvent; +class FSize; +class FStatusBar; +class FWidgetColors; //---------------------------------------------------------------------- // class FWidget diff --git a/test/foptiattr-test.cpp b/test/foptiattr-test.cpp index 727ca059..fac9dd71 100644 --- a/test/foptiattr-test.cpp +++ b/test/foptiattr-test.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 * @@ -121,7 +121,7 @@ void FOptiAttrTest::classNameTest() //---------------------------------------------------------------------- void FOptiAttrTest::noArgumentTest() { - finalcut::FOptiAttr::charData* ch = new finalcut::FOptiAttr::charData(); + finalcut::charData* ch = new finalcut::charData(); finalcut::FOptiAttr oa; oa.initialize(); @@ -133,7 +133,7 @@ void FOptiAttrTest::noArgumentTest() CPPUNIT_ASSERT ( oa.isNormal(ch) ); // Null test - finalcut::FOptiAttr::charData* ch_null = nullptr; + finalcut::charData* 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("") ); @@ -207,10 +207,8 @@ void FOptiAttrTest::fakeReverseTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::FOptiAttr::charData* from = \ - new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = \ - new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Gray text on blue background @@ -304,8 +302,8 @@ void FOptiAttrTest::ansiTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -769,8 +767,8 @@ void FOptiAttrTest::vt100Test() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -1240,8 +1238,8 @@ void FOptiAttrTest::xtermTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -1711,8 +1709,8 @@ void FOptiAttrTest::rxvtTest() oa.set_orig_orig_colors (0); oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -2183,8 +2181,8 @@ void FOptiAttrTest::linuxTest() oa.set_orig_orig_colors (C_STR(OSC "R")); oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -2666,8 +2664,8 @@ void FOptiAttrTest::puttyTest() oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -3139,8 +3137,8 @@ void FOptiAttrTest::teratermTest() oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -3614,8 +3612,8 @@ void FOptiAttrTest::ibmColorTest() oa.initialize(); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold @@ -4055,8 +4053,8 @@ void FOptiAttrTest::wyse50Test() oa.setTermEnvironment(optiattr_env); - finalcut::FOptiAttr::charData* from = new finalcut::FOptiAttr::charData(); - finalcut::FOptiAttr::charData* to = new finalcut::FOptiAttr::charData(); + finalcut::charData* from = new finalcut::charData(); + finalcut::charData* to = new finalcut::charData(); CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 ); // Default color + bold From f78aba0395a59e893c2112ee766bf35b76766278 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 28 Jul 2019 23:12:01 +0200 Subject: [PATCH 37/70] Add unit test for the FTermFreeBSD class --- ChangeLog | 6 + src/fterm.cpp | 25 +- src/ftermcapquirks.cpp | 8 +- src/ftermdetection.cpp | 6 +- src/ftermfreebsd.cpp | 51 +- src/ftermopenbsd.cpp | 4 +- src/ftermxterminal.cpp | 2 +- src/include/final/fconfig.h | 4 +- src/include/final/fterm.h | 2 +- src/include/final/ftermcapquirks.h | 2 +- src/include/final/ftermfreebsd.h | 28 +- test/Makefile.am | 3 + test/conemu.h | 2 +- test/ftermfreebsd-test.cpp | 726 +++++++++++++++++++++++++++++ test/ftermlinux-test.cpp | 2 - test/ftermopenbsd-test.cpp | 14 +- 16 files changed, 848 insertions(+), 37 deletions(-) create mode 100644 test/ftermfreebsd-test.cpp diff --git a/ChangeLog b/ChangeLog index 4958c213..a409039b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-07-28 Markus Gans + * FreeBSD can now change the frequency and duration + of the pc speaker signal + * Added a unit test for the FTermFreeBSD class to test + the FreeBSD console + 2019-07-21 Markus Gans * Reduce include entries in the header files diff --git a/src/fterm.cpp b/src/fterm.cpp index 45fa6c2a..e26851ce 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -918,13 +918,13 @@ char* FTerm::enableCursor() enable_str[SIZE - 1] = '\0'; -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) if ( isFreeBSDTerm() ) { // Restore the last used FreeBSD console cursor style freebsd->restoreCursorStyle(); } -#endif // defined(__FreeBSD__) || defined(__DragonFly__) +#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) return enable_str; } @@ -1093,6 +1093,11 @@ void FTerm::setBeep (int Hz, int ms) { linux->setBeep (Hz, ms); } +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) +void FTerm::setBeep (int Hz, int ms) +{ + freebsd->setBeep (Hz, ms); +} #else void FTerm::setBeep (int, int) { } @@ -1103,6 +1108,8 @@ void FTerm::resetBeep() { #if defined(__linux__) linux->resetBeep(); +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) + freebsd->resetBeep(); #endif } @@ -1353,7 +1360,7 @@ void FTerm::initScreenSettings() // Important: Do not use setNewFont() or setVGAFont() after // the console character mapping has been initialized linux->initCharMap (fc::character); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) freebsd->initCharMap (fc::character); #endif @@ -2005,7 +2012,7 @@ void FTerm::setInsertCursorStyle() , data->isCursorHidden() ); putstring (cstyle); std::fflush(stdout); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) freebsd->setCursorStyle ( fc::destructive_cursor , data->isCursorHidden() ); #endif @@ -2025,7 +2032,7 @@ void FTerm::setOverwriteCursorStyle() , data->isCursorHidden() ); putstring (cstyle); std::fflush(stdout); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) freebsd->setCursorStyle ( fc::normal_cursor , data->isCursorHidden() ); #endif @@ -2193,7 +2200,7 @@ inline void FTerm::allocationValues() #if defined(__linux__) linux = new FTermLinux(); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) freebsd = new FTermFreeBSD(); #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) openbsd = new FTermOpenBSD(); @@ -2221,7 +2228,7 @@ inline void FTerm::deallocationValues() #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) if ( openbsd ) delete openbsd; -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) if ( freebsd ) delete freebsd; #elif defined(__linux__) @@ -2376,7 +2383,7 @@ void FTerm::initOSspecifics() #endif // defined(__linux__) -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) if ( init_values.meta_sends_escape ) freebsd->enableMetaSendsEscape(); else @@ -2497,7 +2504,7 @@ void FTerm::finishOSspecifics1() { #if defined(__linux__) linux->finish(); -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) freebsd->finish(); #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) openbsd->finish(); diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 3e7548cb..a125b5b4 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -92,12 +92,12 @@ void FTermcapQuirks::terminalFixup() { screen(); } -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) else if ( td->isFreeBSDTerm() ) { freebsd(); } -#endif // defined(__FreeBSD__) || defined(__DragonFly__) +#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) // xterm and compatible terminals if ( td->isXTerminal() && ! td->isPuttyTerminal() ) @@ -112,7 +112,7 @@ void FTermcapQuirks::terminalFixup() // private methods of FTermcapQuirks //---------------------------------------------------------------------- -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) void FTermcapQuirks::freebsd() { // FreeBSD console fixes @@ -136,7 +136,7 @@ void FTermcapQuirks::freebsd() FTermcap::attr_without_color = 18; } -#endif // defined(__FreeBSD__) || defined(__DragonFly__) +#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) //---------------------------------------------------------------------- void FTermcapQuirks::cygwin() diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index c7056c7f..5b307fb6 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -30,6 +30,10 @@ #include "final/ftermios.h" #include "final/ftypes.h" +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) + #include "final/ftermfreebsd.h" +#endif + #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #include "final/ftermopenbsd.h" #endif @@ -846,7 +850,7 @@ inline char* FTermDetection::secDA_Analysis_0 (char current_termtype[]) else if ( secondary_da.terminal_id_version == 136 ) terminal_type.putty = true; // PuTTY -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) if ( FTermFreeBSD::isFreeBSDConsole() ) terminal_type.freebsd_con = true; #endif diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index c9edcee5..32867929 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -30,7 +30,7 @@ namespace finalcut { // static class attributes -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) uInt FTermFreeBSD::bsd_alt_keymap = 0; FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style = fc::normal_cursor; bool FTermFreeBSD::change_cursorstyle = true; @@ -45,7 +45,7 @@ namespace finalcut // public methods of FTermFreeBSD //---------------------------------------------------------------------- -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle() { return cursor_style; @@ -72,7 +72,7 @@ bool FTermFreeBSD::isFreeBSDConsole() { // Check if it's a FreeBSD console - keymap_t keymap; + keymap_t keymap{}; if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) return true; @@ -80,16 +80,49 @@ bool FTermFreeBSD::isFreeBSDConsole() return false; } +//---------------------------------------------------------------------- +void FTermFreeBSD::setBeep (int Hz, int ms) +{ + if ( ! FTerm::isFreeBSDTerm() ) + return; + + // range for frequency: 21-32766 + if ( Hz < 21 || Hz > 32766 ) + return; + + // range for duration: 0-1999 + if ( ms < 0 || ms > 1999 ) + return; + + constexpr int timer_frequency = 1193182; + int period = timer_frequency / Hz; + ms /= 10; + FTerm::putstringf ( CSI "=%d;%dB", period, ms ); + std::fflush(stdout); +} + +//---------------------------------------------------------------------- +void FTermFreeBSD::resetBeep() +{ + if ( ! FTerm::isFreeBSDTerm() ) + return; + + // default frequency: 1491 Hz + // default duration: 50 ms + FTerm::putstring ( CSI "=800;5B" ); + std::fflush(stdout); +} + //---------------------------------------------------------------------- void FTermFreeBSD::init() { // initialize BSD console + fsystem = FTerm::getFSystem(); + if ( ! isFreeBSDConsole() ) return; - fsystem = FTerm::getFSystem(); - if ( meta_sends_escape ) { // save current left alt key mapping @@ -149,7 +182,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey() static constexpr int left_alt = 0x38; int ret = -1; - keymap_t keymap; + keymap_t keymap{}; if ( fsystem ) ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); @@ -169,7 +202,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) static constexpr int left_alt = 0x38; int ret = -1; - keymap_t keymap; + keymap_t keymap{}; if ( fsystem ) ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); @@ -177,7 +210,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) if ( ret < 0 ) return false; - // map to meta key + // Mapping "key" on the left alt key keymap.key[left_alt].map[0] = key; if ( (keymap.n_keys > 0) @@ -202,6 +235,6 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta() return setFreeBSDAltKey (bsd_alt_keymap); } -#endif // defined(__FreeBSD__) || defined(__DragonFly__) +#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) } // namespace finalcut diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index d7e68d43..d7c52e81 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -46,7 +46,7 @@ bool FTermOpenBSD::isBSDConsole() { // Check if it's a NetBSD/OpenBSD workstation console - static kbd_t kbdencoding; + static kbd_t kbdencoding{}; if ( fsystem && fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) @@ -90,7 +90,7 @@ void FTermOpenBSD::finish() //---------------------------------------------------------------------- bool FTermOpenBSD::saveBSDConsoleEncoding() { - static kbd_t k_encoding; + static kbd_t k_encoding{}; int ret = -1; if ( fsystem ) diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index a10a2eea..d42fc63e 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -384,7 +384,7 @@ void FTermXTerminal::setXTermCursorStyle() { // Set the xterm cursor style -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) if ( FTermFreeBSD::isFreeBSDConsole() ) return; #endif diff --git a/src/include/final/fconfig.h b/src/include/final/fconfig.h index 1c5275ff..a1ab15de 100644 --- a/src/include/final/fconfig.h +++ b/src/include/final/fconfig.h @@ -50,7 +50,9 @@ #endif /* Define to 1 if GPM mouse is enabled */ -/* #undef HAVE_LIBGPM */ +#ifndef F_HAVE_LIBGPM +#define F_HAVE_LIBGPM 1 +#endif /* Define to 1 if you have the header file. */ #ifndef F_HAVE_LINUX_FB_H diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 86706eda..818767cd 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -204,7 +204,7 @@ class FTerm final #endif #if DEBUG - FTermDebugData& getFTermDebugData(); + static FTermDebugData& getFTermDebugData(); #endif // Inquiries diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index dd258276..41411eaf 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -66,7 +66,7 @@ class FTermcapQuirks final private: // Methods -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) static void freebsd(); #endif static void cygwin(); diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 3fbac38e..1da5262d 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -37,7 +37,27 @@ #include "final/fc.h" -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(UNIT_TEST) + #define CONS_CURSORTYPE 0x80046307 + #define GIO_KEYMAP 0x20006b06 + #define PIO_KEYMAP 0x20006b07 + #define META 0x84 // Meta key + #define NUM_KEYS 256 // Number of keys in table + #define NUM_STATES 8 // States per key + + struct keyent_t + { + int map[NUM_STATES]; + int spcl; + int flgs; + }; + + struct keymap_t + { + int n_keys; + struct keyent_t key[NUM_KEYS]; + }; +#elif defined(__FreeBSD__) || defined(__DragonFly__) #undef mouse_info // consio.h #undef buttons // consio.h @@ -89,6 +109,8 @@ class FTermFreeBSD final static void disableChangeCursorStyle(); static void enableMetaSendsEscape(); static void disableMetaSendsEscape(); + static void setBeep (int, int); + static void resetBeep(); // Methods static void init(); @@ -118,7 +140,7 @@ inline const char* FTermFreeBSD::getClassName() const { return "FTermFreeBSD"; } //---------------------------------------------------------------------- -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) inline void FTermFreeBSD::enableChangeCursorStyle() { change_cursorstyle = true; } @@ -133,7 +155,7 @@ inline void FTermFreeBSD::enableMetaSendsEscape() //---------------------------------------------------------------------- inline void FTermFreeBSD::disableMetaSendsEscape() { meta_sends_escape = false; } -#endif // defined(__FreeBSD__) || defined(__DragonFly__) +#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) } // namespace finalcut diff --git a/test/Makefile.am b/test/Makefile.am index 0cfee202..f2218ba9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -15,6 +15,7 @@ noinst_PROGRAMS = \ ftermcapquirks_test \ ftermlinux_test \ ftermopenbsd_test \ + ftermfreebsd_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ @@ -31,6 +32,7 @@ ftermdetection_test_SOURCES = ftermdetection-test.cpp ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp ftermlinux_test_SOURCES = ftermlinux-test.cpp ftermopenbsd_test_SOURCES = ftermopenbsd-test.cpp +ftermfreebsd_test_SOURCES = ftermfreebsd-test.cpp foptimove_test_SOURCES = foptimove-test.cpp foptiattr_test_SOURCES = foptiattr-test.cpp fcolorpair_test_SOURCES = fcolorpair-test.cpp @@ -47,6 +49,7 @@ TESTS = fobject_test \ ftermcapquirks_test \ ftermlinux_test \ ftermopenbsd_test \ + ftermfreebsd_test \ foptimove_test \ foptiattr_test \ fcolorpair_test \ diff --git a/test/conemu.h b/test/conemu.h index 36c200ca..25941b1f 100644 --- a/test/conemu.h +++ b/test/conemu.h @@ -787,7 +787,7 @@ inline char* ConEmu::getSEC_DA (console con) C_STR("\033[>67;200502;0c"), // Cygwin C_STR("\033[>77;20402;0c"), // Mintty 0, // Linux console - 0, // FreeBSD console + C_STR("\033[>0;10;0c"), // FreeBSD console C_STR("\033[>24;20;0c"), // NetBSD console C_STR("\033[>24;20;0c"), // OpenBSD console 0, // Sun console diff --git a/test/ftermfreebsd-test.cpp b/test/ftermfreebsd-test.cpp new file mode 100644 index 00000000..34191676 --- /dev/null +++ b/test/ftermfreebsd-test.cpp @@ -0,0 +1,726 @@ +/*********************************************************************** +* ftermfreebsd-test.cpp - FTermFreeBSD unit tests * +* * +* 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace test +{ + +//---------------------------------------------------------------------- +// class FSystemTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FSystemTest : public finalcut::FSystem +{ + public: + // Constructor + FSystemTest(); + + // Destructor + virtual ~FSystemTest(); + + // Methods + virtual uChar inPortByte (uShort) override; + virtual void outPortByte (uChar, uShort) override; + virtual int isTTY (int) override; + virtual int ioctl (int, uLong, ...) override; + virtual int open (const char*, int, ...) override; + virtual int close (int) override; + virtual FILE* fopen (const char*, const char*) override; + virtual int fclose (FILE*) override; + virtual int putchar (int) override; + virtual int tputs (const char*, int, int (*)(int)) override; + virtual uid_t getuid() override; + std::string& getCharacters(); + int& getCursorType(); + + private: + // Data Members + std::string characters; + int cursor_type = 0; + static struct keymap_t keymap; + static struct keymap_t terminal_keymap; +}; +#pragma pack(pop) + +// private Data Member of FSystemTest +//---------------------------------------------------------------------- +struct keymap_t FSystemTest::keymap = +{ + 109, // Number of keys + { + // map spcl flag + //------------------------------------------------ ---- ---- + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0xff, 0x00 }, + { {0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x86, 0x1b}, 0x02, 0x00 }, + { {0x31, 0x21, 0x00, 0x00, 0x31, 0x21, 0x00, 0x00}, 0x33, 0x00 }, + { {0x32, 0x22, 0x00, 0x00, 0xb2, 0xb2, 0x00, 0x00}, 0x33, 0x00 }, + { {0x33, 0xa7, 0x00, 0x00, 0xb3, 0xb3, 0x00, 0x00}, 0x33, 0x00 }, + { {0x34, 0x24, 0x00, 0x00, 0x34, 0x24, 0x00, 0x00}, 0x33, 0x00 }, + { {0x35, 0x25, 0x00, 0x00, 0x35, 0x25, 0x00, 0x00}, 0x33, 0x00 }, + { {0x36, 0x26, 0x00, 0x00, 0x36, 0x26, 0x00, 0x00}, 0x33, 0x00 }, + { {0x37, 0x2f, 0x00, 0x00, 0x7b, 0x7b, 0x00, 0x00}, 0x33, 0x00 }, + { {0x38, 0x28, 0x1b, 0x1b, 0x5b, 0x5b, 0x1b, 0x1b}, 0x00, 0x00 }, + { {0x39, 0x29, 0x1d, 0x1d, 0x5d, 0x5d, 0x1d, 0x1d}, 0x00, 0x00 }, + { {0x30, 0x3d, 0x00, 0x00, 0x7d, 0x7d, 0x00, 0x00}, 0x33, 0x00 }, + { {0xdf, 0x3f, 0x1c, 0x1c, 0x5c, 0x5c, 0x1c, 0x1c}, 0x00, 0x00 }, + { {0x27, 0x60, 0x00, 0x00, 0xb3, 0xb4, 0x00, 0x00}, 0x33, 0x00 }, + { {0x08, 0x08, 0x7f, 0x7f, 0x08, 0x08, 0x7f, 0x7f}, 0x00, 0x00 }, + { {0x09, 0x08, 0x00, 0x00, 0x09, 0x08, 0x00, 0x00}, 0x77, 0x00 }, + { {0x71, 0x51, 0x11, 0x11, 0x40, 0x40, 0x00, 0x00}, 0x00, 0x01 }, + { {0x77, 0x57, 0x17, 0x17, 0x77, 0x57, 0x17, 0x17}, 0x00, 0x01 }, + { {0x65, 0x45, 0x05, 0x05, 0x20ac, 0x45, 0x05, 0x05}, 0x00, 0x01 }, + { {0x72, 0x52, 0x12, 0x12, 0x72, 0x52, 0x12, 0x12}, 0x00, 0x01 }, + { {0x74, 0x54, 0x14, 0x14, 0x74, 0x54, 0x14, 0x14}, 0x00, 0x01 }, + { {0x7a, 0x5a, 0x1a, 0x1a, 0x7a, 0x5a, 0x1a, 0x1a}, 0x00, 0x01 }, + { {0x75, 0x55, 0x15, 0x15, 0x75, 0x55, 0x15, 0x15}, 0x00, 0x01 }, + { {0x69, 0x49, 0x09, 0x09, 0x69, 0x49, 0x09, 0x09}, 0x00, 0x01 }, + { {0x6f, 0x4f, 0x0f, 0x0f, 0x6f, 0x4f, 0x0f, 0x0f}, 0x00, 0x01 }, + { {0x70, 0x50, 0x10, 0x10, 0x70, 0x50, 0x10, 0x10}, 0x00, 0x01 }, + { {0xfc, 0xdc, 0x00, 0x00, 0xfc, 0xdc, 0x1b, 0x00}, 0x31, 0x01 }, + { {0x2b, 0x2a, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00}, 0x33, 0x00 }, + { {0x0d, 0x0d, 0x0a, 0x0a, 0x0d, 0x0d, 0x0a, 0x0a}, 0x00, 0x00 }, + { {0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}, 0xff, 0x00 }, + { {0x61, 0x41, 0x01, 0x01, 0x61, 0x41, 0x01, 0x01}, 0x00, 0x01 }, + { {0x73, 0x53, 0x13, 0x13, 0x73, 0x53, 0x13, 0x13}, 0x00, 0x01 }, + { {0x64, 0x44, 0x04, 0x04, 0x64, 0x44, 0x04, 0x04}, 0x00, 0x01 }, + { {0x66, 0x46, 0x06, 0x06, 0x66, 0x46, 0x06, 0x06}, 0x00, 0x01 }, + { {0x67, 0x47, 0x07, 0x07, 0x67, 0x47, 0x07, 0x07}, 0x00, 0x01 }, + { {0x68, 0x48, 0x08, 0x08, 0x68, 0x48, 0x08, 0x08}, 0x00, 0x01 }, + { {0x6a, 0x4a, 0x0a, 0x0a, 0x6a, 0x4a, 0x0a, 0x0a}, 0x00, 0x01 }, + { {0x6b, 0x4b, 0x0b, 0x0b, 0x6b, 0x4b, 0x0b, 0x0b}, 0x00, 0x01 }, + { {0x6c, 0x4c, 0x0c, 0x0c, 0x6c, 0x4c, 0x0c, 0x0c}, 0x00, 0x01 }, + { {0xf6, 0xd6, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x00}, 0x33, 0x01 }, + { {0xe4, 0xc4, 0x00, 0x00, 0xe4, 0xc4, 0x00, 0x00}, 0x33, 0x01 }, + { {0x5e, 0xb0, 0x1e, 0x1e, 0x5e, 0xb0, 0x1e, 0x1e}, 0x00, 0x00 }, + { {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}, 0xff, 0x00 }, + { {0x23, 0x27, 0x00, 0x00, 0x23, 0x27, 0x00, 0x00}, 0x33, 0x00 }, + { {0x79, 0x59, 0x19, 0x19, 0x79, 0x59, 0x19, 0x19}, 0x00, 0x01 }, + { {0x78, 0x58, 0x18, 0x18, 0x78, 0x58, 0x18, 0x18}, 0x00, 0x01 }, + { {0x63, 0x43, 0x03, 0x03, 0xa2, 0x43, 0x03, 0x03}, 0x00, 0x01 }, + { {0x76, 0x56, 0x16, 0x16, 0x76, 0x56, 0x16, 0x16}, 0x00, 0x01 }, + { {0x62, 0x42, 0x02, 0x02, 0x62, 0x42, 0x02, 0x02}, 0x00, 0x01 }, + { {0x6e, 0x4e, 0x0e, 0x0e, 0x6e, 0x4e, 0x0e, 0x0e}, 0x00, 0x01 }, + { {0x6d, 0x4d, 0x0d, 0x0d, 0xb5, 0xb5, 0x0d, 0x0d}, 0x00, 0x01 }, + { {0x2c, 0x3b, 0x00, 0x00, 0x2c, 0x3b, 0x00, 0x00}, 0x33, 0x00 }, + { {0x2e, 0x3a, 0x00, 0x00, 0x2e, 0x3a, 0x00, 0x00}, 0x33, 0x00 }, + { {0x2d, 0x5f, 0x1f, 0x1f, 0x2d, 0x5f, 0x1f, 0x1f}, 0x00, 0x00 }, + { {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}, 0xff, 0x00 }, + { {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 0x00, 0x00 }, + { {0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}, 0xff, 0x00 }, + { {0x20, 0x20, 0x00, 0x20, 0x20, 0x20, 0x87, 0x20}, 0x02, 0x00 }, + { {0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, 0xff, 0x00 }, + { {0x1b, 0x27, 0x33, 0x3f, 0x0b, 0x15, 0x0b, 0x15}, 0xff, 0x00 }, + { {0x1c, 0x28, 0x34, 0x40, 0x0c, 0x16, 0x0c, 0x16}, 0xff, 0x00 }, + { {0x1d, 0x29, 0x35, 0x41, 0x0d, 0x17, 0x0d, 0x17}, 0xff, 0x00 }, + { {0x1e, 0x2a, 0x36, 0x42, 0x0e, 0x18, 0x0e, 0x18}, 0xff, 0x00 }, + { {0x1f, 0x2b, 0x37, 0x43, 0x0f, 0x19, 0x0f, 0x19}, 0xff, 0x00 }, + { {0x20, 0x2c, 0x38, 0x44, 0x10, 0x1a, 0x10, 0x1a}, 0xff, 0x00 }, + { {0x21, 0x2d, 0x39, 0x45, 0x11, 0x11, 0x11, 0x11}, 0xff, 0x00 }, + { {0x22, 0x2e, 0x3a, 0x46, 0x12, 0x12, 0x12, 0x12}, 0xff, 0x00 }, + { {0x23, 0x2f, 0x3b, 0x47, 0x13, 0x13, 0x13, 0x13}, 0xff, 0x00 }, + { {0x24, 0x30, 0x3c, 0x48, 0x14, 0x14, 0x14, 0x14}, 0xff, 0x00 }, + { {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05}, 0xff, 0x00 }, + { {0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, 0xff, 0x00 }, + { {0x4b, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37}, 0x80, 0x02 }, + { {0x4c, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38}, 0x80, 0x02 }, + { {0x4d, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, 0x80, 0x02 }, + { {0x4e, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d}, 0x80, 0x02 }, + { {0x4f, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34}, 0x80, 0x02 }, + { {0x50, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35}, 0x80, 0x02 }, + { {0x51, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}, 0x80, 0x02 }, + { {0x52, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b}, 0x80, 0x02 }, + { {0x53, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31}, 0x80, 0x02 }, + { {0x54, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32}, 0x80, 0x02 }, + { {0x55, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33}, 0x80, 0x02 }, + { {0x56, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}, 0x80, 0x02 }, + { {0x7f, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x85, 0x85}, 0x03, 0x02 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0xff, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0xff, 0x00 }, + { {0x3c, 0x3e, 0x00, 0x00, 0x7c, 0xa6, 0x00, 0x00}, 0x33, 0x00 }, + { {0x25, 0x31, 0x3d, 0x49, 0x15, 0x15, 0x15, 0x15}, 0xff, 0x00 }, + { {0x26, 0x32, 0x3e, 0x4a, 0x16, 0x16, 0x16, 0x16}, 0xff, 0x00 }, + { {0x0d, 0x0d, 0x0a, 0x0a, 0x0d, 0x0d, 0x0a, 0x0a}, 0x00, 0x00 }, + { {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}, 0xff, 0x00 }, + { {0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f}, 0x00, 0x02 }, + { {0x0a, 0x99, 0x86, 0x86, 0x00, 0x00, 0x00, 0x00}, 0xff, 0x00 }, + { {0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81}, 0xff, 0x00 }, + { {0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b}, 0xff, 0x00 }, + { {0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c}, 0xff, 0x00 }, + { {0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d}, 0xff, 0x00 }, + { {0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f}, 0xff, 0x00 }, + { {0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51}, 0xff, 0x00 }, + { {0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53}, 0xff, 0x00 }, + { {0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54}, 0xff, 0x00 }, + { {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55}, 0xff, 0x00 }, + { {0x56, 0xa3, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56}, 0xff, 0x00 }, + { {0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x85, 0x57}, 0xff, 0x00 }, + { {0x06, 0x88, 0x06, 0x88, 0x87, 0x00, 0x87, 0x00}, 0xff, 0x00 }, + { {0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58}, 0xff, 0x00 }, + { {0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59}, 0xff, 0x00 }, + { {0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a}, 0xff, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0xff, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 }, + { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x00, 0x00 } + // | | | | | | | | + // | | | | | | | `--- 0: Shift-Ctrl-Alt + // | | | | | | `--------- 1: Ctrl-Alt + // | | | | | `--------------- 2: Shift-Alt + // | | | | `--------------------- 3: Alt + // | | | `--------------------------- 4: Shift-Ctrl + // | | `--------------------------------- 5: Ctrl + // | `--------------------------------------- 6: Shift + // `--------------------------------------------- 7: Base + // | + // `- spcl bit + // + // spcl = A special treatment key (bits correspond to the map field) + // flag = 0 -> 'O' = Caps lock + num lock are ignored + // flag = 1 -> 'C' = Caps lock affects the key + // flag = 2 -> 'N' = Num lock affects the key + } +}; + +// static class attributes +//---------------------------------------------------------------------- +struct keymap_t FSystemTest::terminal_keymap{}; + +// constructors and destructor +//---------------------------------------------------------------------- +FSystemTest::FSystemTest() // constructor +{ +} + +//---------------------------------------------------------------------- +FSystemTest::~FSystemTest() // destructor +{ +} + + +// public methods of FSystemTest +//---------------------------------------------------------------------- +uChar FSystemTest::inPortByte (uShort) +{ + return 0; +} + +//---------------------------------------------------------------------- +void FSystemTest::outPortByte (uChar, uShort) +{ +} + +//---------------------------------------------------------------------- +int FSystemTest::isTTY (int fd) +{ + std::cerr << "Call: isatty (fd=" << fd << ")\n"; + return 1; +} + +//---------------------------------------------------------------------- +int FSystemTest::ioctl (int fd, uLong request, ...) +{ + va_list args; + void* argp; + std::string req_string; + int ret_val = -1; + + va_start (args, request); + argp = va_arg (args, void*); + + switch ( request ) + { + case CONS_CURSORTYPE: + { + req_string = "CONS_CURSORTYPE"; + constexpr int blink_cursor = int(1 << 0); + constexpr int char_cursor = int(1 << 1); + constexpr int hidden_cursor = int(1 << 2); + constexpr int reset_cursor = int(1 << 30); + constexpr int cursor_attrs = int( blink_cursor \ + | char_cursor \ + | hidden_cursor ); + int* cur_flags = static_cast(argp); + *cur_flags = *cur_flags & cursor_attrs; + + if ( *cur_flags & reset_cursor ) + cursor_type = 0; + else + cursor_type = *cur_flags; + + ret_val = 0; + break; + } + + case GIO_KEYMAP: + { + req_string = "GIO_KEYMAP"; + keymap_t* kmap = static_cast(argp); + + // Sets the default keymap of the terminal on the first call + if ( terminal_keymap.n_keys == 0 ) + { + terminal_keymap.n_keys = keymap.n_keys; + std::memcpy (terminal_keymap.key, &keymap.key, sizeof(keymap.key)); + } + + kmap->n_keys = terminal_keymap.n_keys; + std::memcpy (kmap->key, terminal_keymap.key, sizeof(keymap.key)); + ret_val = 0; + break; + } + + case PIO_KEYMAP: + { + req_string = "PIO_KEYMAP"; + keymap_t* kmap = static_cast(argp); + std::memcpy (terminal_keymap.key, kmap->key, sizeof(keymap.key)); + ret_val = 0; + break; + } + + case TIOCGWINSZ: + req_string = "TIOCGWINSZ"; + struct winsize* win_size = static_cast(argp); + win_size->ws_col = 80; + win_size->ws_row = 25; + ret_val = 0; + break; + } + + va_end (args); + + std::cerr << "Call: ioctl (fd=" << fd + << ", request=" << req_string + << "(0x" << std::hex << request << ")" + << ", argp=" << argp << std::dec << ")\n"; + return ret_val; +} + +//---------------------------------------------------------------------- +int FSystemTest::open (const char* pathname, int flags, ...) +{ + va_list args; + va_start (args, flags); + mode_t mode = static_cast(va_arg (args, int)); + va_end (args); + + std::cerr << "Call: open (pathname=\"" << pathname + << "\", flags=" << flags + << ", mode=" << mode << ")\n"; + + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::close (int fildes) +{ + std::cerr << "Call: close (fildes=" << fildes << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +FILE* FSystemTest::fopen (const char* path, const char* mode) +{ + std::cerr << "Call: fopen (path=" << path + << ", mode=" << mode << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::fclose (FILE* fp) +{ + std::cerr << "Call: fclose (fp=" << fp << ")\n"; + return 0; +} + +//---------------------------------------------------------------------- +int FSystemTest::putchar (int c) +{ + std::cerr << "Call: putchar (" << c << ")\n"; + characters.push_back(c); + return 1; +} + +//---------------------------------------------------------------------- +int FSystemTest::tputs (const char* str, int affcnt, int (*putc)(int)) +{ + return ::tputs (str, affcnt, putc); +} + +//---------------------------------------------------------------------- +uid_t FSystemTest::getuid() +{ + return 0; +} + +//---------------------------------------------------------------------- +std::string& FSystemTest::getCharacters() +{ + return characters; +} + +//---------------------------------------------------------------------- +int& FSystemTest::getCursorType() +{ + return cursor_type; +} + + + + +} // namespace test + + +//---------------------------------------------------------------------- +// class ftermfreebsdTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class ftermfreebsdTest : public CPPUNIT_NS::TestFixture, test::ConEmu +{ + public: + ftermfreebsdTest(); + + protected: + void classNameTest(); + void netbsdConsoleTest(); + void freebsdConsoleTest(); + + private: + // Adds code needed to register the test suite + CPPUNIT_TEST_SUITE (ftermfreebsdTest); + + // Add a methods to the test suite + CPPUNIT_TEST (classNameTest); + CPPUNIT_TEST (freebsdConsoleTest); + + // End of test suite definition + CPPUNIT_TEST_SUITE_END(); +}; +#pragma pack(pop) + +//---------------------------------------------------------------------- +ftermfreebsdTest::ftermfreebsdTest() +{ + +} + +//---------------------------------------------------------------------- +void ftermfreebsdTest::classNameTest() +{ + const finalcut::FTermFreeBSD p; + const char* const classname = p.getClassName(); + CPPUNIT_ASSERT ( std::strcmp(classname, "FTermFreeBSD") == 0 ); +} + + +//---------------------------------------------------------------------- +void ftermfreebsdTest::freebsdConsoleTest() +{ + setenv ("TERM", "xterm", 1); + setenv ("COLUMNS", "80", 1); + setenv ("LINES", "25", 1); + + finalcut::FTermData* data; + finalcut::FSystem* fsys = new test::FSystemTest(); + finalcut::FTermDetection* term_detection; + finalcut::FTerm::setFSystem(fsys); + std::cout << "\n"; + data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::fc::UTF8; + encoding_list["UTF8"] = finalcut::fc::UTF8; + encoding_list["VT100"] = finalcut::fc::VT100; + encoding_list["PC"] = finalcut::fc::PC; + encoding_list["ASCII"] = finalcut::fc::ASCII; + + data->setTermEncoding(finalcut::fc::VT100); + data->setBaudrate(9600); + data->setTermType("xterm"); + data->setTermFileName("/dev/ttyv0"); + data->setTTYFileDescriptor(0); + data->supportShadowCharacter (false); + data->supportHalfBlockCharacter (false); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + term_detection = finalcut::FTerm::getFTermDetection(); + term_detection->setTerminalDetection(true); + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + finalcut::FTermFreeBSD freebsd; + + setenv ("TERM", "xterm", 1); + setenv ("COLUMNS", "80", 1); + setenv ("LINES", "25", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + finalcut::FTerm::detectTermSize(); + freebsd.enableMetaSendsEscape(); + freebsd.enableChangeCursorStyle(); + freebsd.init(); + term_detection->detect(); + +#if DEBUG + const finalcut::FString& sec_da = \ + finalcut::FTerm::getFTermDebugData().getSecDAString(); + CPPUNIT_ASSERT ( sec_da == "\033[>0;10;0c" ); +#endif + + CPPUNIT_ASSERT ( isatty(0) == 1 ); + CPPUNIT_ASSERT ( term_detection->isFreeBSDTerm() ); + CPPUNIT_ASSERT ( data->getTermGeometry().getWidth() == 80 ); + CPPUNIT_ASSERT ( data->getTermGeometry().getHeight() == 25 ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + + test::FSystemTest* fsystest = static_cast(fsys); + freebsd.setCursorStyle (finalcut::fc::normal_cursor, false); + CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::normal_cursor ); + + freebsd.setCursorStyle (finalcut::fc::blink_cursor, false); + CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::blink_cursor ); + + freebsd.setCursorStyle (finalcut::fc::destructive_cursor, false); + CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::destructive_cursor ); + + std::string& characters = fsystest->getCharacters(); + characters.clear(); + freebsd.setBeep (20, 100); // Hz < 21 + CPPUNIT_ASSERT ( characters.empty() ); + freebsd.setBeep (32767, 100); // Hz > 32766 + CPPUNIT_ASSERT ( characters.empty() ); + freebsd.setBeep (200, -1); // ms < 0 + CPPUNIT_ASSERT ( characters.empty() ); + freebsd.setBeep (200, 2000); // ms > 1999 + CPPUNIT_ASSERT ( characters.empty() ); + freebsd.setBeep (200, 100); // 200 Hz - 100 ms + + CPPUNIT_ASSERT ( characters == CSI "=5965;10B" ); + characters.clear(); + freebsd.resetBeep(); + CPPUNIT_ASSERT ( characters == CSI "=800;5B" ); + characters.clear(); + + freebsd.finish(); + + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::freebsd_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } +} + + +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION (ftermfreebsdTest); + +// The general unit test main part +#include diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index 26a221ec..e7c801a0 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -2083,8 +2083,6 @@ void FTermLinuxTest::linuxFontTest() term_detection = finalcut::FTerm::getFTermDetection(); finalcut::FTermLinux linux; - term_detection->setLinuxTerm(true); - pid_t pid = forkConEmu(); if ( isConEmuChildProcess(pid) ) diff --git a/test/ftermopenbsd-test.cpp b/test/ftermopenbsd-test.cpp index f51b4fe2..88e2fdbb 100644 --- a/test/ftermopenbsd-test.cpp +++ b/test/ftermopenbsd-test.cpp @@ -153,14 +153,12 @@ int FSystemTest::ioctl (int fd, uLong request, ...) } case TIOCGWINSZ: - { req_string = "TIOCGWINSZ"; struct winsize* win_size = static_cast(argp); win_size->ws_col = 80; win_size->ws_row = 25; ret_val = 0; break; - } } va_end (args); @@ -342,6 +340,12 @@ void ftermopenbsdTest::netbsdConsoleTest() term_detection->detect(); finalcut::FTerm::detectTermSize(); +#if DEBUG + const finalcut::FString& sec_da = \ + finalcut::FTerm::getFTermDebugData().getSecDAString(); + CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); +#endif + CPPUNIT_ASSERT ( isatty(0) == 1 ); CPPUNIT_ASSERT ( ! term_detection->isOpenBSDTerm() ); CPPUNIT_ASSERT ( term_detection->isNetBSDTerm() ); @@ -441,6 +445,12 @@ void ftermopenbsdTest::openbsdConsoleTest() term_detection->detect(); finalcut::FTerm::detectTermSize(); +#if DEBUG + const finalcut::FString& sec_da = \ + finalcut::FTerm::getFTermDebugData().getSecDAString(); + CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); +#endif + CPPUNIT_ASSERT ( isatty(0) == 1 ); CPPUNIT_ASSERT ( term_detection->isOpenBSDTerm() ); CPPUNIT_ASSERT ( ! term_detection->isNetBSDTerm() ); From 8026f6475416c64d1ba778e12162aa1d3cf8bbc8 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 28 Jul 2019 23:48:14 +0200 Subject: [PATCH 38/70] Add compile flag for the coverity scan test --- .build.sh.swp | Bin 0 -> 16384 bytes .travis.yml | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .build.sh.swp diff --git a/.build.sh.swp b/.build.sh.swp new file mode 100644 index 0000000000000000000000000000000000000000..daf2ade7ab140bcb7a03219efef24e518982724e GIT binary patch literal 16384 zcmeI2UuYyr9mng|TNl(l8b9m?oP697C|}GMe#rnPw+uG@j)L1Q4j?2MM04R9|TWC!3V)7#p4$LfcmZK?&+Dh z-op8^E7jzauC9Omt8Z6V*RN_iv(K!o(x+x-368fBqP{Y{vo>`C8{1qE)VO8a_hSKx*td$x>;K9WI^c7B)vOVV{=#qtOBn~fsK$v3RnfK0#*U5fK|XMU=^?mSOxA)1=9E!`8Z5JR+uk~^Lo_m0h&w0|H)n zGa;V`+h7%(1s?>b!5G*)LC6Yt7@PnE{OygnC-@ymz!mUbFbT%MyTCiat>c9J5PT1O z0wf>=0(f8<{PKQ6eh$72Zh}vOLvS5@6#O2GEH8s^fG>gPz-PdxK>|2sVd!n?xM;xN_|VeA|_`RVZ~LbUm(PMMP*m=n}Kfc|q&K3QIx zhgQ43xwLqr6-ht9FK7hyIUa;JR=d8ozPY+^?uJ7frzhr2k+dhI2?RbJqce4PP>8Wu z2|qY!I<<|>rL!v+9opL1ID2kkx!rWw;^NYotz|@AyjVtcDO;bVMGDSaYb)n3pI>U9 zcPL}Jzp$z+6%k!G+QZ$^SOkPZAjLod0xGVIn%LqRZp~rM30g8T17`q0Exm`R>RnW;& zF;p&)ZkTz3dBI2t87YxwN+M^>-Cg0CfaetfB_zhW#8?nVfka~&NAt9~N_d&n{egMH z4YiGVRV=+0>pLgnY9^#Bm?@|udfbclbs*?Uj9vYhW0+-rlH$&~Go`{!@vT4x*zcwc z4dhyd|BPwQ>o^RLMz}n{gv|PgM%k|7aZg)>(PE&KZdxXHWwbAGGv4j=rR;X;r6VZ`yE*j}L0%=E!RH;L~) zx)|P6sm=7!Z5gx?5S0}jR@bLQq&#D^jKqN}V%%+vp3 z73^^rz1&Zg5a_j0jIO2culpT~(FKK)`YwIZPXy*dipwO9AS^mi*Gx7rf(<7(=S? zy*r8=86eF}2~Eq-cSWf1u}9#RTiM=UI8le0KE&jq@2}ATbKy6T`DK(z7X4rINIm<%Nkr z<@(UcN|+1`gJ50;-6&FSo@IDuRv1Uw-f+3obx-Wo^(#UsEwW=8cL@_Y=8w$fc8Ezf ziA?5g-yy`z>YZ9^W9xEjeQQlm)WlUfOD85U)hptfjZsCa1gADB@eaFmt}pvHhEX@bZ`rAqNhArr2reFaLWt|(A+$GJ ziz}N(F+GjXABTB7Ln(Q%IYWv7RL6&}awHr=@>zY;+1{R=pTE?1$nxgW(pq^vduo0T zaqtL+Vj76aXZ1}-|K{Eyecdya1jDUj$zOH^H-D1uTLS;GekHKfvF? zZ@`bhi{K`B76jmF&;VoL-QW?RZ9EC=VHL0nSOu&CRspMkRlq7>6|f3e1^#yh#%Z7L z3alI$kG*h6;m*y>Xdlz~ag@3|h5!Bd4E(=gFBGmYavHB2F1D%1?FpRpmHQdQri z-ln8+LUDsjx%1wn)iw#;AtMPxn<;dMZjUBbn+_(;tO%H;5Y))34I0O!=H9m1VrsxT ztdz;rr;k0_S<=hM6kB)jiS>5i*rT0o`4~(y8&8f7jBYiFeBq<2p`E$fBgRTuS%){M z!?>^5q#CMaur5$rU3hv4PtmLc=y209IzH2EIHb7CXf$P4Y9C%d({=`Rm;$Uv=RPpe zpja1BBBtyrh5yX(cO~jzO|M)VF(s>I5q*gj5p#kkJ~>#4sLxGd%aVwMyHIMdPgnGZ zYFAY6=IQkOX!o#+oc6HuX?FRDjxG03%WbecXDb&v-ytowIjP=`9ArDPiHi7Q&8gVO l9p1d5^jsi!^U9W^sEg%XB-2 Date: Mon, 29 Jul 2019 02:34:58 +0200 Subject: [PATCH 39/70] small fixes --- .build.sh.swp | Bin 16384 -> 0 bytes src/fpoint.cpp | 8 ++++++++ src/frect.cpp | 10 ++++++++++ src/fsize.cpp | 8 ++++++++ src/fstring.cpp | 16 +++++++++++++++- src/ftermfreebsd.cpp | 11 +++++++---- src/fvterm.cpp | 12 +++++++----- src/include/final/fpoint.h | 1 + src/include/final/frect.h | 1 + src/include/final/fsize.h | 1 + src/include/final/fstring.h | 4 +++- src/include/final/ftermfreebsd.h | 2 +- test/ftermfreebsd-test.cpp | 2 ++ test/ftermlinux-test.cpp | 9 +++++++-- test/ftermopenbsd-test.cpp | 4 ++++ 15 files changed, 75 insertions(+), 14 deletions(-) delete mode 100644 .build.sh.swp diff --git a/.build.sh.swp b/.build.sh.swp deleted file mode 100644 index daf2ade7ab140bcb7a03219efef24e518982724e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2UuYyr9mng|TNl(l8b9m?oP697C|}GMe#rnPw+uG@j)L1Q4j?2MM04R9|TWC!3V)7#p4$LfcmZK?&+Dh z-op8^E7jzauC9Omt8Z6V*RN_iv(K!o(x+x-368fBqP{Y{vo>`C8{1qE)VO8a_hSKx*td$x>;K9WI^c7B)vOVV{=#qtOBn~fsK$v3RnfK0#*U5fK|XMU=^?mSOxA)1=9E!`8Z5JR+uk~^Lo_m0h&w0|H)n zGa;V`+h7%(1s?>b!5G*)LC6Yt7@PnE{OygnC-@ymz!mUbFbT%MyTCiat>c9J5PT1O z0wf>=0(f8<{PKQ6eh$72Zh}vOLvS5@6#O2GEH8s^fG>gPz-PdxK>|2sVd!n?xM;xN_|VeA|_`RVZ~LbUm(PMMP*m=n}Kfc|q&K3QIx zhgQ43xwLqr6-ht9FK7hyIUa;JR=d8ozPY+^?uJ7frzhr2k+dhI2?RbJqce4PP>8Wu z2|qY!I<<|>rL!v+9opL1ID2kkx!rWw;^NYotz|@AyjVtcDO;bVMGDSaYb)n3pI>U9 zcPL}Jzp$z+6%k!G+QZ$^SOkPZAjLod0xGVIn%LqRZp~rM30g8T17`q0Exm`R>RnW;& zF;p&)ZkTz3dBI2t87YxwN+M^>-Cg0CfaetfB_zhW#8?nVfka~&NAt9~N_d&n{egMH z4YiGVRV=+0>pLgnY9^#Bm?@|udfbclbs*?Uj9vYhW0+-rlH$&~Go`{!@vT4x*zcwc z4dhyd|BPwQ>o^RLMz}n{gv|PgM%k|7aZg)>(PE&KZdxXHWwbAGGv4j=rR;X;r6VZ`yE*j}L0%=E!RH;L~) zx)|P6sm=7!Z5gx?5S0}jR@bLQq&#D^jKqN}V%%+vp3 z73^^rz1&Zg5a_j0jIO2culpT~(FKK)`YwIZPXy*dipwO9AS^mi*Gx7rf(<7(=S? zy*r8=86eF}2~Eq-cSWf1u}9#RTiM=UI8le0KE&jq@2}ATbKy6T`DK(z7X4rINIm<%Nkr z<@(UcN|+1`gJ50;-6&FSo@IDuRv1Uw-f+3obx-Wo^(#UsEwW=8cL@_Y=8w$fc8Ezf ziA?5g-yy`z>YZ9^W9xEjeQQlm)WlUfOD85U)hptfjZsCa1gADB@eaFmt}pvHhEX@bZ`rAqNhArr2reFaLWt|(A+$GJ ziz}N(F+GjXABTB7Ln(Q%IYWv7RL6&}awHr=@>zY;+1{R=pTE?1$nxgW(pq^vduo0T zaqtL+Vj76aXZ1}-|K{Eyecdya1jDUj$zOH^H-D1uTLS;GekHKfvF? zZ@`bhi{K`B76jmF&;VoL-QW?RZ9EC=VHL0nSOu&CRspMkRlq7>6|f3e1^#yh#%Z7L z3alI$kG*h6;m*y>Xdlz~ag@3|h5!Bd4E(=gFBGmYavHB2F1D%1?FpRpmHQdQri z-ln8+LUDsjx%1wn)iw#;AtMPxn<;dMZjUBbn+_(;tO%H;5Y))34I0O!=H9m1VrsxT ztdz;rr;k0_S<=hM6kB)jiS>5i*rT0o`4~(y8&8f7jBYiFeBq<2p`E$fBgRTuS%){M z!?>^5q#CMaur5$rU3hv4PtmLc=y209IzH2EIHb7CXf$P4Y9C%d({=`Rm;$Uv=RPpe zpja1BBBtyrh5yX(cO~jzO|M)VF(s>I5q*gj5p#kkJ~>#4sLxGd%aVwMyHIMdPgnGZ zYFAY6=IQkOX!o#+oc6HuX?FRDjxG03%WbecXDb&v-ytowIjP=`9ArDPiHi7Q&8gVO l9p1d5^jsi!^U9W^sEg%XB-2