From 97f1dea7b8f60a7847be04020b7b7bb04f78d47b Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 8 Oct 2020 16:28:29 +0200 Subject: [PATCH] Add some includes --- examples/windows.cpp | 4 ++-- src/fapplication.cpp | 2 +- src/fkeyboard.cpp | 1 + src/flineedit.cpp | 1 + src/flogger.cpp | 1 + src/fmessagebox.cpp | 4 ++-- src/foptiattr.cpp | 1 + src/foptimove.cpp | 1 + src/ftermdetection.cpp | 2 ++ src/ftermlinux.cpp | 1 + src/ftermxterminal.cpp | 2 ++ src/ftextview.cpp | 2 +- src/fwidget.cpp | 18 ++++++++++-------- src/include/final/frect.h | 4 ++-- src/include/final/fstring.h | 1 + test/fkeyboard-test.cpp | 22 ++++++++++++++++++++++ 16 files changed, 51 insertions(+), 16 deletions(-) diff --git a/examples/windows.cpp b/examples/windows.cpp index 5d750c66..b3ee3827 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -261,10 +261,10 @@ Window::Window (finalcut::FWidget* parent) Statusbar.setMessage("Status bar message"); // Generate data vector for the windows - for (int n{1}; n <= 6; n++) + for (uInt n{1}; n < 7; n++) { auto win_dat = new win_data; - win_dat->title.sprintf("Window %1d", n); + win_dat->title.sprintf("Window %1u", n); windows.push_back(win_dat); } } diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 1c68fd9d..b490a189 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -97,7 +97,7 @@ FApplication::FApplication (const int& _argc, char* _argv[]) if ( ! (_argc && _argv) ) { typedef char* CString; - static std::array empty{CString("")}; + static std::array empty{{CString("")}}; app_argc = 0; app_argv = empty.data(); } diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 79ea18ff..f0d9d2db 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include #include "final/fkeyboard.h" diff --git a/src/flineedit.cpp b/src/flineedit.cpp index b130c935..47ac36cf 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/flogger.cpp b/src/flogger.cpp index 4daaa0c8..d75341b3 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/flogger.h" diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index c8599240..d707e89f 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -207,8 +207,8 @@ void FMessageBox::init() { calculateDimensions(); - if ( (button_digit[2] && ! button_digit[1]) - || (button_digit[1] && ! button_digit[0]) ) + if ( (button_digit[2] != Reject && button_digit[1] == Reject) + || (button_digit[1] != Reject && button_digit[0] == Reject) ) { button_digit[0] = button_digit[1] \ = button_digit[2] \ diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index ea103bd4..4c03b929 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fc.h" diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 6ce2918e..38e05c20 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 083d95c9..8eed2bd6 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -24,6 +24,8 @@ #include "final/fconfig.h" // includes _GNU_SOURCE for fd_set #endif +#include + #include "final/emptyfstring.h" #include "final/fapplication.h" #include "final/fc.h" diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 45d47f49..fd8fade7 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index ce079766..a73717dd 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -24,6 +24,8 @@ #include "final/fconfig.h" // includes _GNU_SOURCE for fd_set #endif +#include + #include "final/fapplication.h" #include "final/fc.h" #include "final/flog.h" diff --git a/src/ftextview.cpp b/src/ftextview.cpp index c08a03b5..961ce175 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -535,7 +535,7 @@ void FTextView::adjustSize() if ( width < 3 ) return; - const int hmax = ( max_width > int(width) - nf_offset - 2 ) + const int hmax = ( max_width >= int(width) - nf_offset - 1 ) ? max_width - int(width) + nf_offset + 2 : 0; hbar->setMaximum (hmax); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index d44b85c7..5dfb4856 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1798,21 +1798,23 @@ inline void FWidget::insufficientSpaceAdjust() // move left if not enough space while ( getTermX() + int(getWidth()) - padding.right > woffset.getX2() + 2 ) { - adjust_wsize.x1_ref()--; - adjust_wsize.x2_ref()--; - - if ( adjust_wsize.x1_ref() < 1 ) + if ( adjust_wsize.x1_ref() < 2 ) adjust_wsize.x1_ref() = 1; + else + adjust_wsize.x1_ref()--; + + adjust_wsize.x2_ref()--; } // move up if not enough space while ( getTermY() + int(getHeight()) - padding.bottom > woffset.getY2() + 2 ) { - adjust_wsize.y1_ref()--; - adjust_wsize.y2_ref()--; - - if ( adjust_wsize.y1_ref() < 1 ) + if ( adjust_wsize.y1_ref() < 2 ) adjust_wsize.y1_ref() = 1; + else + adjust_wsize.y1_ref()--; + + adjust_wsize.y2_ref()--; } // reduce the width if not enough space diff --git a/src/include/final/frect.h b/src/include/final/frect.h index 0768f1ae..15c4a25e 100644 --- a/src/include/final/frect.h +++ b/src/include/final/frect.h @@ -202,14 +202,14 @@ inline int FRect::getY() const //---------------------------------------------------------------------- inline std::size_t FRect::getWidth() const { - const int w = X2 - X1 + 1; + const int w = X2 - (X1 - 1); // overflow save return ( w < 0 ) ? 0 : std::size_t(w); } //---------------------------------------------------------------------- inline std::size_t FRect::getHeight() const { - const int h = Y2 - Y1 + 1; + const int h = Y2 - (Y1 - 1); // overflow save return ( h < 0 ) ? 0 : std::size_t(h); } diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 7beec6aa..8102d4cd 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -49,6 +49,7 @@ #include #include +#include #include #include #include diff --git a/test/fkeyboard-test.cpp b/test/fkeyboard-test.cpp index a70ff8d0..3cff23c6 100644 --- a/test/fkeyboard-test.cpp +++ b/test/fkeyboard-test.cpp @@ -32,6 +32,23 @@ #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 { @@ -379,6 +396,11 @@ void FKeyboardTest::noArgumentTest() keyboard->setReadBlockingTime(100000); // 100 ms CPPUNIT_ASSERT ( keyboard->getReadBlockingTime() == 100 * 1000 ); + + // Check key map + CPPUNIT_ASSERT ( test::fkey[0].num == finalcut::fc::Fkey_backspace ); + CPPUNIT_ASSERT_CSTRING ( test::fkey[0].string, "\177" ); + CPPUNIT_ASSERT_CSTRING ( test::fkey[0].tname, "kb" ); } //----------------------------------------------------------------------