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;