diff --git a/ChangeLog b/ChangeLog index e22edc8e..ed7c4075 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2023-10-25 Markus Gans + * Reorganize the data structure of FVTerm::FTermArea + 2023-10-23 Markus Gans * Reorganize the data structure of FOptiAttr diff --git a/examples/mouse.cpp b/examples/mouse.cpp index eb54633f..8d650f38 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2017-2022 Markus Gans * +* Copyright 2017-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -385,11 +385,11 @@ void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust) return; const FSize no_shadow{0, 0}; - const int old_w = canvas->width; - const int old_h = canvas->height; + const int old_w = canvas->size.width; + const int old_h = canvas->size.height; resizeArea (scroll_geometry, no_shadow, canvas.get()); - if ( old_w != canvas->width || old_h != canvas->height ) + if ( old_w != canvas->size.width || old_h != canvas->size.height ) { setColor(getForegroundColor(), getBackgroundColor()); clearArea (canvas.get(), ' '); @@ -466,8 +466,8 @@ void MouseDraw::drawBrush (int x, int y, bool swap_color) setColor (c_chooser.getForeground(), c_chooser.getBackground()); // set canvas print cursor position - canvas->setCursorPos ( x - canvas->offset_left - 10 - , y - canvas->offset_top - 2 ); + canvas->setCursorPos ( x - canvas->position.x - 10 + , y - canvas->position.y - 2 ); // print on canvas canvas->print (brush.getBrush()); @@ -490,10 +490,10 @@ void MouseDraw::drawCanvas() return; auto printarea = getCurrentPrintArea(); - const int ax = 9 + getTermX() - printarea->offset_left; - const int ay = 1 + getTermY() - printarea->offset_top; - const int y_end = canvas->height; - const int x_end = canvas->width; + const int ax = 9 + getTermX() - printarea->position.x; + const int ay = 1 + getTermY() - printarea->position.y; + const int y_end = canvas->size.height; + const int x_end = canvas->size.width; for (auto y{0}; y < y_end; y++) // line loop { diff --git a/final/ftimer.cpp b/final/ftimer.cpp index 971ab01e..822109d2 100644 --- a/final/ftimer.cpp +++ b/final/ftimer.cpp @@ -44,6 +44,7 @@ std::shared_timed_mutex timer_var::mutex{}; // Static class attribute FTimer* FObjectTimer::timer{nullptr}; + //---------------------------------------------------------------------- // class FObjectTimer //---------------------------------------------------------------------- diff --git a/final/fwidget_functions.cpp b/final/fwidget_functions.cpp index a501eb98..19c30314 100644 --- a/final/fwidget_functions.cpp +++ b/final/fwidget_functions.cpp @@ -353,10 +353,10 @@ void drawTransparentShadow (FWidget* w) return; auto& area = *w->getPrintArea(); - const auto width = uInt(area.width); - const auto height = uInt(area.height); - const auto shadow_width = uInt(area.right_shadow); - const auto shadow_height = uInt(area.bottom_shadow); + const auto width = uInt(area.size.width); + const auto height = uInt(area.size.height); + const auto shadow_width = uInt(area.shadow.width); + const auto shadow_height = uInt(area.shadow.height); const auto& wc = FWidget::getColorTheme(); const FChar transparent_char @@ -517,12 +517,12 @@ void drawGenericBlockShadow ( FWidget* w auto& area = *w->getPrintArea(); const bool is_window = w->isWindowWidget(); - const auto width = is_window ? uInt(area.width) : uInt(w->getWidth()); - const auto height = is_window ? uInt(area.height) : uInt(w->getHeight()); - const auto shadow_width = uInt(area.right_shadow); - const auto shadow_height = uInt(area.bottom_shadow); - const auto x_offset = uInt(w->woffset.getX1() + w->getX() - area.offset_left - 1); - const auto y_offset = uInt(w->woffset.getY1() + w->getY() - area.offset_top - 1); + const auto width = is_window ? uInt(area.size.width) : uInt(w->getWidth()); + const auto height = is_window ? uInt(area.size.height) : uInt(w->getHeight()); + const auto shadow_width = uInt(area.shadow.width); + const auto shadow_height = uInt(area.shadow.height); + const auto x_offset = uInt(w->woffset.getX1() + w->getX() - area.position.x - 1); + const auto y_offset = uInt(w->woffset.getY1() + w->getY() - area.position.y - 1); if ( is_window && (shadow_width < 1 || shadow_height < 1) ) return; @@ -815,8 +815,8 @@ void drawGenericBox ( FWidget* w, const FRect& r // Adjust box position to match print area auto box = r; box.move (-1, -1); - const auto x_offset = uInt(w->woffset.getX1() + w->getX() - area.offset_left - 1); - const auto y_offset = uInt(w->woffset.getY1() + w->getY() - area.offset_top - 1); + const auto x_offset = uInt(w->woffset.getX1() + w->getX() - area.position.x - 1); + const auto y_offset = uInt(w->woffset.getY1() + w->getY() - area.position.y - 1); // Draw the top line of the box auto* area_pos = &area.getFChar(int(x_offset) + box.getX1(), int(y_offset) + box.getY1()); diff --git a/final/output/tty/ftermdetection.cpp b/final/output/tty/ftermdetection.cpp index 5340343a..89863bbe 100644 --- a/final/output/tty/ftermdetection.cpp +++ b/final/output/tty/ftermdetection.cpp @@ -238,84 +238,68 @@ auto FTermDetection::getTTYSFileEntry() -> bool void FTermDetection::termtypeAnalysis() { static auto& fterm_data = FTermData::getInstance(); - - // Cygwin console - if ( termtype.left(6) == "cygwin" ) - fterm_data.setTermType (FTermType::cygwin); - - // rxvt terminal emulator (native MS Window System port) on cygwin - if ( termtype == "rxvt-cygwin-native" ) - fterm_data.setTermType (FTermType::rxvt); - - // ANSI X3.64 terminal - if ( termtype.left(4) == "ansi" ) - { - terminal_detection = false; - fterm_data.setTermType (FTermType::ansi); - } - - // Sun Microsystems workstation console - if ( termtype.left(3) == "sun" ) + static const std::vector> termTypeMap = { - terminal_detection = false; - fterm_data.setTermType (FTermType::sun_con); - } - - // Kterm - if ( termtype.left(5) == "kterm" ) + // Cygwin console + { L"cygwin" , FTermType::cygwin }, + // rxvt terminal emulator (native MS Window System port) on cygwin + { L"rxvt-cygwin-native" , FTermType::rxvt }, + // ANSI X3.64 terminal + { L"ansi" , FTermType::ansi }, + // Sun Microsystems workstation console + { L"sun" , FTermType::sun_con }, + // Kterm + { L"kterm" , FTermType::kterm }, + // mlterm + { L"mlterm" , FTermType::mlterm }, + // st - simple terminal + { L"st-256color" , FTermType::stterm }, + // rxvt + { L"rxvt" , FTermType::rxvt }, + // urxvt + { L"rxvt-unicode" , FTermType::urxvt }, + // screen or tmux with termtype screen + { L"screen" , FTermType::screen }, + // tmux + { L"tmux" , FTermType::tmux }, + // Linux console + { L"linux" , FTermType::linux_con }, + { L"con" , FTermType::linux_con }, + // NetBSD workstation console + { L"wsvt25" , FTermType::netbsd_con }, + // kitty + { L"xterm-kitty" , FTermType::kitty }, + // alacritty + { L"alacritty" , FTermType::xterm } + }; + + auto search_predicate = [this] (const auto& pair) { - terminal_detection = false; - fterm_data.setTermType (FTermType::kterm); - } + return startsWithTermType(pair.first); + }; + auto iter = std::find_if ( termTypeMap.begin() + , termTypeMap.end() + , search_predicate ); - // mlterm - if ( termtype.left(6) == "mlterm" ) - fterm_data.setTermType (FTermType::mlterm); - - // st - simple terminal - if ( termtype.left(11) == "st-256color" ) - fterm_data.setTermType (FTermType::stterm); + if ( iter == termTypeMap.end() ) // not found + return; - // rxvt - if ( termtype.left(4) == "rxvt" ) - fterm_data.setTermType (FTermType::rxvt); + fterm_data.setTermType (iter->second); - // urxvt - if ( termtype.left(12) == "rxvt-unicode" ) - fterm_data.setTermType (FTermType::urxvt); + if ( fterm_data.isTermType(FTermType::ansi) + || fterm_data.isTermType(FTermType::sun_con) + || fterm_data.isTermType(FTermType::kterm) ) + terminal_detection = false; - // screen or tmux with termtype screen - if ( termtype.left(6) == "screen" ) + if ( fterm_data.isTermType(FTermType::screen) ) { - fterm_data.setTermType (FTermType::screen); auto tmux = std::getenv("TMUX"); if ( tmux && tmux[0] != '\0' ) fterm_data.setTermType (FTermType::tmux); } - - // tmux - if ( termtype.left(4) == "tmux" ) - { + else if ( fterm_data.isTermType(FTermType::tmux) ) fterm_data.setTermType (FTermType::screen); - fterm_data.setTermType (FTermType::tmux); - } - - // Linux console - if ( termtype.left(5) == "linux" || termtype.left(3) == "con" ) - fterm_data.setTermType (FTermType::linux_con); - - // NetBSD workstation console - if ( termtype.left(6) == "wsvt25" ) - fterm_data.setTermType (FTermType::netbsd_con); - - // kitty - if ( termtype.left(11) == "xterm-kitty" ) - fterm_data.setTermType (FTermType::kitty); - - // alacritty - if ( termtype.left(9) == "alacritty" ) - fterm_data.setTermType (FTermType::xterm); } //---------------------------------------------------------------------- @@ -353,7 +337,7 @@ void FTermDetection::detectTerminal() static auto& fterm_data = FTermData::getInstance(); // Test if the terminal is a xterm - if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" ) + if ( startsWithTermType(L"xterm") || startsWithTermType(L"Eterm") ) { fterm_data.setTermType (FTermType::xterm); @@ -361,7 +345,7 @@ void FTermDetection::detectTerminal() if ( ! new_termtype && termtype.getLength() == 5 ) new_termtype = "xterm-16color"; } - else if ( termtype.left(4) == "ansi" ) // ANSI detection + else if ( startsWithTermType(L"ansi") ) // ANSI detection fterm_data.setTermType (FTermType::ansi); // set the new environment variable TERM @@ -443,19 +427,19 @@ auto FTermDetection::termtype_256color_quirks() -> FString if ( ! color256 ) return new_termtype; - if ( termtype.left(5) == "xterm" ) + if ( startsWithTermType(L"xterm") ) new_termtype = "xterm-256color"; - if ( termtype.left(6) == "screen" ) + if ( startsWithTermType(L"screen") ) new_termtype = "screen-256color"; - if ( termtype.left(5) == "Eterm" ) + if ( startsWithTermType(L"Eterm") ) new_termtype = "Eterm-256color"; - if ( termtype.left(6) == "mlterm" ) + if ( startsWithTermType(L"mlterm") ) new_termtype = "mlterm-256color"; - if ( termtype.left(4) == "rxvt" + if ( startsWithTermType(L"rxvt") && color_env.string1.left(8) == "rxvt-xpm" ) { new_termtype = "rxvt-256color"; @@ -837,9 +821,9 @@ inline auto FTermDetection::secDA_Analysis_24 (const FString& current_termtype) // NetBSD/OpenBSD workstation console auto& fterm_data = FTermData::getInstance(); - if ( termtype.left(6) == "wsvt25" ) + if ( startsWithTermType(L"wsvt25") ) fterm_data.setTermType (FTermType::netbsd_con); - else if ( termtype.left(5) == "vt220" ) + else if ( startsWithTermType(L"vt220") ) { fterm_data.setTermType (FTermType::openbsd_con); new_termtype = "pccon"; @@ -941,7 +925,7 @@ inline auto FTermDetection::secDA_Analysis_85() const -> FString return [this] () { - if ( termtype.left(5) == "rxvt-" ) + if ( startsWithTermType(L"rxvt-") ) { if ( color256 ) return FString("rxvt-256color"); diff --git a/final/output/tty/ftermdetection.h b/final/output/tty/ftermdetection.h index e1e74e13..dbabffa7 100644 --- a/final/output/tty/ftermdetection.h +++ b/final/output/tty/ftermdetection.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2018-2022 Markus Gans * +* Copyright 2018-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -107,6 +107,8 @@ class FTermDetection final #if F_HAVE_GETTTYNAM auto getTTYSFileEntry() -> bool; #endif + template + bool startsWithTermType (StringT&&) const; void termtypeAnalysis(); void detectTerminal(); auto init_256colorTerminal() -> FString; @@ -191,6 +193,13 @@ inline auto FTermDetection::hasTerminalDetection() const noexcept -> bool inline void FTermDetection::setTerminalDetection (bool enable) noexcept { terminal_detection = enable; } +//---------------------------------------------------------------------- +template +inline bool FTermDetection::startsWithTermType (StringT&& prefix) const +{ + return termtype.toWString().find(std::forward(prefix)) == 0; +} + } // namespace finalcut #endif // FTERMDETECTION_H diff --git a/final/output/tty/ftermoutput.cpp b/final/output/tty/ftermoutput.cpp index 65efeee5..18db19ca 100644 --- a/final/output/tty/ftermoutput.cpp +++ b/final/output/tty/ftermoutput.cpp @@ -331,7 +331,7 @@ auto FTermOutput::updateTerminal() -> bool std::size_t changedlines = 0; - for (uInt y{0}; y < uInt(vterm->height); y++) + for (uInt y{0}; y < uInt(vterm->size.height); y++) { FVTerm::reduceTerminalLineUpdates(y); @@ -502,8 +502,8 @@ inline auto FTermOutput::isInputCursorInsideTerminal() const -> bool if ( ! vterm || ! vterm->input_cursor_visible ) return false; - const int x = vterm->input_cursor_x; - const int y = vterm->input_cursor_y; + const int x = vterm->input_cursor.x; + const int y = vterm->input_cursor.y; return ( x >= 0 && x < int(getColumnNumber()) && y >= 0 && y < int(getLineNumber()) ); } @@ -632,7 +632,7 @@ auto FTermOutput::canClearToEOL (uInt xmin, uInt y) const -> bool const auto& ut = FTermcap::background_color_erase; const auto* ch = min_char + 1; - for (int x{int(xmin) + 1}; x < vterm->width; x++) + for (int x{int(xmin) + 1}; x < vterm->size.width; x++) { if ( *min_char == *ch ) beginning_whitespace++; @@ -642,7 +642,7 @@ auto FTermOutput::canClearToEOL (uInt xmin, uInt y) const -> bool ++ch; } - return ( beginning_whitespace == uInt(vterm->width) - xmin + return ( beginning_whitespace == uInt(vterm->size.width) - xmin && (ut || normal) && clr_eol_length < beginning_whitespace ); } @@ -664,7 +664,7 @@ auto FTermOutput::canClearLeadingWS (uInt& xmin, uInt y) const -> bool const auto& ut = FTermcap::background_color_erase; const auto* ch = first_char + 1; - for (int x{1}; x < vterm->width; x++) + for (int x{1}; x < vterm->size.width; x++) { if ( *first_char == *ch ) leading_whitespace++; @@ -691,7 +691,7 @@ auto FTermOutput::canClearTrailingWS (uInt& xmax, uInt y) const -> bool // => clear from xmax to end of line const auto& ce = TCAP(t_clr_eol); - const auto* last_char = &vterm->getFChar(vterm->width - 1, int(y)); + const auto* last_char = &vterm->getFChar(vterm->size.width - 1, int(y)); if ( ! ce || last_char->ch[0] != L' ' ) return false; @@ -701,7 +701,7 @@ auto FTermOutput::canClearTrailingWS (uInt& xmax, uInt y) const -> bool const auto& ut = FTermcap::background_color_erase; const auto* ch = last_char; - for (int x{vterm->width - 1}; x > 0 ; x--) + for (int x{vterm->size.width - 1}; x > 0 ; x--) { if ( *last_char == *ch ) trailing_whitespace++; @@ -711,10 +711,10 @@ auto FTermOutput::canClearTrailingWS (uInt& xmax, uInt y) const -> bool --ch; } - if ( trailing_whitespace > uInt(vterm->width) - xmax && (ut || normal) + if ( trailing_whitespace > uInt(vterm->size.width) - xmax && (ut || normal) && clr_bol_length < trailing_whitespace ) { - xmax = uInt(vterm->width) - trailing_whitespace; + xmax = uInt(vterm->size.width) - trailing_whitespace; return true; } @@ -811,7 +811,7 @@ inline void FTermOutput::replaceNonPrintableFullwidth ( uInt x print_char.ch[1] = L'\0'; print_char.attr.bit.fullwidth_padding = false; } - else if ( x == uInt(vterm->width - 1) && isFullWidthChar(print_char) ) + else if ( x == uInt(vterm->size.width - 1) && isFullWidthChar(print_char) ) { print_char.ch[0] = wchar_t(UniChar::SingleRightAngleQuotationMark); // › print_char.ch[1] = L'\0'; @@ -825,11 +825,11 @@ void FTermOutput::printCharacter ( uInt& x, uInt y, bool min_and_not_max { // General character output on terminal - if ( x < uInt(vterm->width - 1) && isFullWidthChar(print_char) ) + if ( x < uInt(vterm->size.width - 1) && isFullWidthChar(print_char) ) { printFullWidthCharacter (x, y, print_char); } - else if ( x > 0 && x < uInt(vterm->width - 1) + else if ( x > 0 && x < uInt(vterm->size.width - 1) && isFullWidthPaddingChar(print_char) ) { printFullWidthPaddingCharacter (x, y, print_char); @@ -1121,10 +1121,10 @@ void FTermOutput::cursorWrap() const { // Wrap the cursor - if ( term_pos->getX() < vterm->width ) + if ( term_pos->getX() < vterm->size.width ) return; - if ( term_pos->getY() == vterm->height - 1 ) + if ( term_pos->getY() == vterm->size.height - 1 ) { term_pos->x_ref()--; } @@ -1163,7 +1163,7 @@ inline auto FTermOutput::updateTerminalLine (uInt y) -> bool auto& min_char = vterm->getFChar(int(xmin), int(y)); appendAttributes (min_char); appendOutputBuffer (FTermControl{TCAP(t_clr_eol)}); - markAsPrinted (xmin, uInt(vterm->width - 1), y); + markAsPrinted (xmin, uInt(vterm->size.width - 1), y); } else { @@ -1183,15 +1183,15 @@ inline auto FTermOutput::updateTerminalLine (uInt y) -> bool if ( draw_trailing_ws ) { - auto& last_char = vterm->getFChar(vterm->width - 1, int(y)); + auto& last_char = vterm->getFChar(vterm->size.width - 1, int(y)); appendAttributes (last_char); appendOutputBuffer (FTermControl{TCAP(t_clr_eol)}); - markAsPrinted (xmax + 1, uInt(vterm->width - 1), y); + markAsPrinted (xmax + 1, uInt(vterm->size.width - 1), y); } } // Reset line changes and wrap the cursor - xmin = uInt(vterm->width); + xmin = uInt(vterm->size.width); xmax = 0; cursorWrap(); return true; @@ -1204,7 +1204,7 @@ auto FTermOutput::updateTerminalCursor() -> bool if ( isInputCursorInsideTerminal() ) { - setCursor (FPoint{vterm->input_cursor_x, vterm->input_cursor_y}); + setCursor (FPoint{vterm->input_cursor.x, vterm->input_cursor.y}); showCursor(); return true; } @@ -1356,8 +1356,8 @@ inline void FTermOutput::charsetChanges (FChar& next_char) const //---------------------------------------------------------------------- inline void FTermOutput::appendCharacter (FChar& next_char) { - const int term_width = vterm->width - 1; - const int term_height = vterm->height - 1; + const int term_width = vterm->size.width - 1; + const int term_height = vterm->size.height - 1; if ( term_pos->getX() == term_width && term_pos->getY() == term_height ) diff --git a/final/vterm/fvterm.cpp b/final/vterm/fvterm.cpp index c11d8fa6..b4b43482 100644 --- a/final/vterm/fvterm.cpp +++ b/final/vterm/fvterm.cpp @@ -111,8 +111,8 @@ auto FVTerm::getPrintCursor() -> FPoint const auto& win = getPrintArea(); if ( win ) - return { win->offset_left + win->cursor_x - , win->offset_top + win->cursor_y }; + return { win->position.x + win->cursor.x + , win->position.y + win->cursor.y }; return {0, 0}; // Fallback coordinates } @@ -139,8 +139,8 @@ void FVTerm::setCursor (const FPoint& pos) noexcept { if ( auto win = getPrintArea() ) { - win->setCursorPos ( pos.getX() - win->offset_left - , pos.getY() - win->offset_top ); + win->setCursorPos ( pos.getX() - win->position.x + , pos.getY() - win->position.y ); } } @@ -190,11 +190,11 @@ void FVTerm::resizeVTerm (const FSize& size) const noexcept //---------------------------------------------------------------------- void FVTerm::putVTerm() const { - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { auto& vterm_changes = vterm->changes[unsigned(i)]; vterm_changes.xmin = 0; - vterm_changes.xmax = uInt(vterm->width - 1); + vterm_changes.xmax = uInt(vterm->size.width - 1); } updateTerminal(); @@ -300,18 +300,18 @@ inline auto FVTerm::interpretControlCodes ( FTermArea* area switch ( term_char.ch[0] ) { case L'\n': - area->cursor_y++; + area->cursor.y++; // fall through case L'\r': - area->cursor_x = 1; + area->cursor.x = 1; break; case L'\t': - area->cursor_x += tabstop - ((area->cursor_x - 1) % tabstop); + area->cursor.x += tabstop - ((area->cursor.x - 1) % tabstop); break; case L'\b': - area->cursor_x--; + area->cursor.x--; break; case L'\a': @@ -462,21 +462,21 @@ auto FVTerm::print (FTermArea* area, const FChar& term_char) const noexcept -> i if ( char_width == 0 && ! term_char.attr.bit.fullwidth_padding ) return 0; - area->cursor_x++; + area->cursor.x++; area->has_changes = true; // Line break at right margin - if ( area->cursor_x > getFullAreaWidth(area) ) + if ( area->cursor.x > getFullAreaWidth(area) ) { - area->cursor_x = 1; - area->cursor_y++; + area->cursor.x = 1; + area->cursor.y++; } else if ( char_width == 2 ) printPaddingCharacter (area, term_char); // Prevent up scrolling - if ( area->cursor_y > getFullAreaHeight(area) ) - area->cursor_y--; + if ( area->cursor.y > getFullAreaHeight(area) ) + area->cursor.y--; return 1; } @@ -540,26 +540,26 @@ void FVTerm::resizeArea ( const FRect& box { // Resize the virtual window to a new size - const auto offset_left = box.getX(); - const auto offset_top = box.getY(); + const auto position_x = box.getX(); + const auto position_y = box.getY(); const auto width = int(box.getWidth()); const auto height = int(box.getHeight()); const auto rsw = int(shadow.getWidth()); const auto bsh = int(shadow.getHeight()); - assert ( offset_top >= 0 && width > 0 && height > 0 + assert ( position_y >= 0 && width > 0 && height > 0 && rsw >= 0 && bsh >= 0 ); if ( ! area ) return; - if ( width == area->width - && height == area->height - && rsw == area->right_shadow - && bsh == area->bottom_shadow ) + if ( width == area->size.width + && height == area->size.height + && rsw == area->shadow.width + && bsh == area->shadow.height ) { - area->offset_left = offset_left; - area->offset_top = offset_top; + area->position.x = position_x; + area->position.y = position_y; return; // Move only } @@ -582,15 +582,15 @@ void FVTerm::resizeArea ( const FRect& box if ( ! realloc_success ) return; - area->offset_left = offset_left; - area->offset_top = offset_top; - area->width = width; - area->height = height; - area->min_width = width; - area->min_height = DEFAULT_MINIMIZED_HEIGHT; - area->right_shadow = rsw; - area->bottom_shadow = bsh; - area->has_changes = false; + area->position.x = position_x; + area->position.y = position_y; + area->size.width = width; + area->size.height = height; + area->min_size.width = width; + area->min_size.height = DEFAULT_MINIMIZED_HEIGHT; + area->shadow.width = rsw; + area->shadow.height = bsh; + area->has_changes = false; const FSize size{full_width, full_height}; resetTextAreaToDefault (area, size); // Set default FChar in area @@ -614,8 +614,8 @@ void FVTerm::restoreVTerm (const FRect& box) const noexcept || box.getWidth() == 0 || box.getHeight() == 0 ) return; - const auto vterm_size = FSize{ std::size_t(vterm->width) - , std::size_t(vterm->height) }; + const auto vterm_size = FSize{ std::size_t(vterm->size.width) + , std::size_t(vterm->size.height) }; if ( vdesktop && vdesktop->reprint(box, vterm_size) ) addLayer(vdesktop.get()); @@ -638,11 +638,11 @@ auto FVTerm::updateVTermCursor (const FTermArea* area) const noexcept -> bool if ( area->input_cursor_visible ) { // area cursor position - const int cx = area->input_cursor_x; - const int cy = area->input_cursor_y; - // terminal position = area offset + area cursor position - const int x = area->offset_left + cx; - const int y = area->offset_top + cy; + const int cx = area->input_cursor.x; + const int cy = area->input_cursor.y; + // terminal position = area position + area cursor position + const int x = area->position.x + cx; + const int y = area->position.y + cy; if ( isInsideArea (FPoint{cx, cy}, area) && isInsideTerminal (FPoint{x, y}) @@ -691,8 +691,8 @@ void FVTerm::getArea (const FPoint& pos, FTermArea* area) const noexcept if ( ax < 0 || ay < 0 ) return; - int y_end = std::min(vterm->height - ay, area->height); - int length = std::min(vterm->width - ax, area->width); + int y_end = std::min(vterm->size.height - ay, area->size.height); + int length = std::min(vterm->size.width - ax, area->size.width); for (auto y{0}; y < y_end; y++) // line loop { @@ -715,18 +715,18 @@ void FVTerm::getArea (const FRect& box, FTermArea* area) const noexcept int x = box.getX() - 1; int y = box.getY() - 1; - int dx = x - area->offset_left; - int dy = y - area->offset_top; - auto w = std::min(area->width - dx, int(box.getWidth())); - auto h = std::min(area->height - dy, int(box.getHeight())); + int dx = x - area->position.x; + int dy = y - area->position.y; + auto w = std::min(area->size.width - dx, int(box.getWidth())); + auto h = std::min(area->size.height - dy, int(box.getHeight())); if ( x < 0 || y < 0 ) return; if ( dx < 0 ) { w += dx; x -= dx; dx = 0; } if ( dy < 0 ) { h += dy; y -= dy; dy = 0; } - const int y_end = std::min(vterm->height - y, h); - const int length = std::min(vterm->width - x, w); + const int y_end = std::min(vterm->size.height - y, h); + const int length = std::min(vterm->size.width - x, w); if ( length < 1 ) return; @@ -750,12 +750,12 @@ void FVTerm::addLayer (FTermArea* area) const noexcept if ( ! area || ! area->visible ) return; - const int ax = std::max(area->offset_left, 0); - const int ol = std::max(0, -area->offset_left); // Outside left - const int ay = area->offset_top; + const int ax = std::max(area->position.x, 0); + const int ol = std::max(0, -area->position.x); // Outside left + const int ay = area->position.y; const int width = getFullAreaWidth(area); - const int height = area->minimized ? area->min_height : getFullAreaHeight(area); - const int y_end = std::min(vterm->height - ay, height); + const int height = area->minimized ? area->min_size.height : getFullAreaHeight(area); + const int y_end = std::min(vterm->size.height - ay, height); // Call the preprocessing handler methods (child area change handling) callPreprocessingHandler(area); @@ -766,7 +766,7 @@ void FVTerm::addLayer (FTermArea* area) const noexcept auto line_xmin = int(line_changes.xmin); auto line_xmax = int(line_changes.xmax); line_xmin = std::max(line_xmin, ol); - line_xmax = std::min(line_xmax, vterm->width + ol - ax - 1); + line_xmax = std::min(line_xmax, vterm->size.width + ol - ax - 1); if ( line_xmin > line_xmax ) continue; @@ -775,7 +775,7 @@ void FVTerm::addLayer (FTermArea* area) const noexcept const int tx = ax - ol; // Global terminal positions for x const int ty = ay + y; // Global terminal positions for y - if ( ax + line_xmin >= vterm->width || tx + line_xmin + ol < 0 || ty < 0 ) + if ( ax + line_xmin >= vterm->size.width || tx + line_xmin + ol < 0 || ty < 0 ) continue; // Area character @@ -799,7 +799,7 @@ void FVTerm::addLayer (FTermArea* area) const noexcept int new_xmax = ax + line_xmax; auto& vterm_changes = vterm->changes[unsigned(ty)]; vterm_changes.xmin = std::min(vterm_changes.xmin, uInt(new_xmin)); - new_xmax = std::min(new_xmax, vterm->width - 1); + new_xmax = std::min(new_xmax, vterm->size.width - 1); vterm_changes.xmax = std::max (vterm_changes.xmax, uInt(new_xmax)); line_changes.xmin = uInt(width); line_changes.xmax = 0; @@ -833,15 +833,15 @@ void FVTerm::copyArea (FTermArea* dst, const FPoint& pos, const FTermArea* const skip_one_vterm_update = true; const int src_width = getFullAreaWidth(src); - const int src_height = src->minimized ? src->min_height : getFullAreaHeight(src); + const int src_height = src->minimized ? src->min_size.height : getFullAreaHeight(src); int ax = pos.getX() - 1; int ay = pos.getY() - 1; int ol = std::max(0, -ax); // outside left int ot = std::max(0, -ay); // outside top ax = std::max(0, ax); ay = std::max(0, ay); - const int y_end = std::min(dst->height - ay, src_height - ot); - const int length = std::min(dst->width - ax, src_width - ol); + const int y_end = std::min(dst->size.height - ay, src_height - ot); + const int length = std::min(dst->size.width - ax, src_width - ol); if ( length < 1 ) return; @@ -897,31 +897,31 @@ void FVTerm::scrollAreaForward (FTermArea* area) { // Scrolls the entire area on line up - if ( ! area || area->height <= 1 ) + if ( ! area || area->size.height <= 1 ) return; - const int y_max = area->height - 1; - const int x_max = area->width - 1; + const int y_max = area->size.height - 1; + const int x_max = area->size.width - 1; for (auto y{0}; y < y_max; y++) { auto& dc = area->getFChar(0, y); // destination character const auto& sc = area->getFChar(0, y + 1); // source character - putAreaLine (sc, dc, unsigned(area->width)); + putAreaLine (sc, dc, unsigned(area->size.width)); auto& line_changes = area->changes[unsigned(y)]; line_changes.xmin = 0; line_changes.xmax = uInt(x_max); } // insert a new line below - const auto& lc = area->getFChar(x_max, area->height - 2); // last character + const auto& lc = area->getFChar(x_max, area->size.height - 2); // last character nc.fg_color = lc.fg_color; nc.bg_color = lc.bg_color; nc.attr = lc.attr; nc.ch[0] = L' '; nc.ch[1] = L'\0'; auto& dc = area->getFChar(0, y_max); // destination character - std::fill (&dc, &dc + area->width, nc); + std::fill (&dc, &dc + area->size.width, nc); auto& new_line_changes = area->changes[unsigned(y_max)]; new_line_changes.xmin = 0; new_line_changes.xmax = uInt(x_max); @@ -936,17 +936,17 @@ void FVTerm::scrollAreaReverse (FTermArea* area) { // Scrolls the entire area one line down - if ( ! area || area->height <= 1 ) + if ( ! area || area->size.height <= 1 ) return; - const int y_max = area->height - 1; - const int x_max = area->width - 1; + const int y_max = area->size.height - 1; + const int x_max = area->size.width - 1; for (auto y = y_max; y > 0; y--) { auto& dc = area->getFChar(0, y); // destination character const auto& sc = area->getFChar(0, y - 1); // source character - putAreaLine (sc, dc, unsigned(area->width)); + putAreaLine (sc, dc, unsigned(area->size.width)); auto& line_changes = area->changes[unsigned(y)]; line_changes.xmin = 0; line_changes.xmax = uInt(x_max); @@ -960,7 +960,7 @@ void FVTerm::scrollAreaReverse (FTermArea* area) nc.ch[0] = L' '; nc.ch[1] = L'\0'; auto& dc = area->getFChar(0, 0); // destination character - std::fill (&dc, &dc + area->width, nc); + std::fill (&dc, &dc + area->size.width, nc); auto& new_line_changes = area->changes[unsigned(y_max)]; new_line_changes.xmin = 0; new_line_changes.xmax = uInt(x_max); @@ -991,7 +991,7 @@ void FVTerm::clearArea (FTermArea* area, wchar_t fillchar) noexcept const auto width = uInt(getFullAreaWidth(area)); - if ( area->right_shadow == 0 ) + if ( area->shadow.width == 0 ) { if ( clearFullArea(area, nc) ) return; @@ -999,7 +999,7 @@ void FVTerm::clearArea (FTermArea* area, wchar_t fillchar) noexcept else clearAreaWithShadow(area, nc); - for (auto i{0}; i < area->height; i++) + for (auto i{0}; i < area->size.height; i++) { auto& line_changes = area->changes[unsigned(i)]; line_changes.xmin = 0; @@ -1009,15 +1009,15 @@ void FVTerm::clearArea (FTermArea* area, wchar_t fillchar) noexcept || nc.attr.bit.color_overlay || nc.attr.bit.inherit_background ) line_changes.trans_count = width; - else if ( area->right_shadow != 0 ) - line_changes.trans_count = uInt(area->right_shadow); + else if ( area->shadow.width != 0 ) + line_changes.trans_count = uInt(area->shadow.width); else line_changes.trans_count = 0; } - for (auto i{0}; i < area->bottom_shadow; i++) + for (auto i{0}; i < area->shadow.height; i++) { - const int y = area->height + i; + const int y = area->size.height + i; auto& line_changes = area->changes[unsigned(y)]; line_changes.xmin = 0; line_changes.xmax = width - 1; @@ -1183,8 +1183,8 @@ auto FVTerm::isCovered (const FPoint& pos, const FTermArea* area) const noexcept if ( found && win->contains(pos) ) // is covered { - const auto& tmp = win->getFChar( pos.getX() - win->offset_left - , pos.getY() - win->offset_top ); + const auto& tmp = win->getFChar( pos.getX() - win->position.x + , pos.getY() - win->position.y ); if ( tmp.attr.bit.color_overlay ) { @@ -1206,13 +1206,13 @@ auto FVTerm::isCovered (const FPoint& pos, const FTermArea* area) const noexcept //---------------------------------------------------------------------- constexpr auto FVTerm::getFullAreaWidth (const FTermArea* area) const noexcept -> int { - return area->width + area->right_shadow; + return area->size.width + area->shadow.width; } //---------------------------------------------------------------------- constexpr auto FVTerm::getFullAreaHeight (const FTermArea* area) const noexcept -> int { - return area->height + area->bottom_shadow; + return area->size.height + area->shadow.height; } //---------------------------------------------------------------------- @@ -1233,21 +1233,21 @@ void FVTerm::passChangesToOverlap (const FTermArea* area) const // Pass the changes to the overlapping window win->has_changes = true; - const int win_offset_top = win->offset_top; - const int y_start = std::max(0, std::max(area->offset_top, win_offset_top)) - win_offset_top; - const int area_height = area->minimized ? area->min_height : getFullAreaHeight(area); - const int win_height = win->minimized ? win->min_height : getFullAreaHeight(win); - const int area_y2 = area->offset_top + area_height - 1; - const int win_y2 = win_offset_top + win_height - 1; - const int y_end = std::min(vterm->height - 1, std::min(area_y2, win_y2)) - win_offset_top; + const int win_position_y = win->position.y; + const int y_start = std::max(0, std::max(area->position.y, win_position_y)) - win_position_y; + const int area_height = area->minimized ? area->min_size.height : getFullAreaHeight(area); + const int win_height = win->minimized ? win->min_size.height : getFullAreaHeight(win); + const int area_y2 = area->position.y + area_height - 1; + const int win_y2 = win_position_y + win_height - 1; + const int y_end = std::min(vterm->size.height - 1, std::min(area_y2, win_y2)) - win_position_y; for (auto y{y_start}; y <= y_end; y++) // Line loop { - const int win_offset_left = win->offset_left; - const int x_start = std::max(0, std::max(area->offset_left, win_offset_left)) - win_offset_left; - const int area_x2 = area->offset_left + area->width + area->right_shadow - 1; - const int win_x2 = win_offset_left + win->width + win->right_shadow - 1; - const int x_end = std::min(vterm->width - 1, std::min(area_x2, win_x2)) - win_offset_left; + const int win_position_x = win->position.x; + const int x_start = std::max(0, std::max(area->position.x, win_position_x)) - win_position_x; + const int area_x2 = area->position.x + area->size.width + area->shadow.width - 1; + const int win_x2 = win_position_x + win->size.width + win->shadow.width - 1; + const int x_end = std::min(vterm->size.width - 1, std::min(area_x2, win_x2)) - win_position_x; auto& line_changes = win->changes[unsigned(y)]; line_changes.xmin = uInt(std::min(int(line_changes.xmin), x_start)); line_changes.xmax = uInt(std::max(int(line_changes.xmax), x_end)); @@ -1276,7 +1276,7 @@ void FVTerm::restoreOverlaidWindows (const FTermArea* area) const noexcept const auto& win = win_obj->getVWin(); if ( overlaid && win && win->visible && win->isOverlapped(area) ) - copyArea (vterm.get(), FPoint{win->offset_left + 1, win->offset_top + 1}, win); + copyArea (vterm.get(), FPoint{win->position.x + 1, win->position.y + 1}, win); else if ( getVWin() == win ) overlaid = true; } @@ -1328,13 +1328,13 @@ inline void FVTerm::scrollTerminalForward() const if ( ! foutput->scrollTerminalForward() ) return; - const int y_max = vdesktop->height - 1; + const int y_max = vdesktop->size.height - 1; // avoid update lines from 0 to (y_max - 1) for (auto y{0}; y < y_max; y++) { auto& vdesktop_changes = vdesktop->changes[unsigned(y)]; - vdesktop_changes.xmin = uInt(vdesktop->width - 1); + vdesktop_changes.xmin = uInt(vdesktop->size.width - 1); vdesktop_changes.xmax = 0; } @@ -1353,13 +1353,13 @@ inline void FVTerm::scrollTerminalReverse() const if ( ! foutput->scrollTerminalReverse() ) return; - const int y_max = vdesktop->height - 1; + const int y_max = vdesktop->size.height - 1; // avoid update lines from 1 to y_max for (auto y{0}; y < y_max; y++) { auto& vdesktop_changes = vdesktop->changes[unsigned(y + 1)]; - vdesktop_changes.xmin = uInt(vdesktop->width - 1); + vdesktop_changes.xmin = uInt(vdesktop->size.width - 1); vdesktop_changes.xmax = 0; } @@ -1421,8 +1421,8 @@ auto FVTerm::isInsideArea (const FPoint& pos, const FTermArea* area) const -> bo const int x = pos.getX(); const int y = pos.getY(); - return x >= 0 && x < area->width - && y >= 0 && y < area->height; + return x >= 0 && x < area->size.width + && y >= 0 && y < area->size.height; } //---------------------------------------------------------------------- @@ -1693,11 +1693,11 @@ auto FVTerm::clearFullArea (FTermArea* area, FChar& fillchar) const -> bool } else { - for (auto i{0}; i < vdesktop->height; i++) + for (auto i{0}; i < vdesktop->size.height; i++) { auto& vdesktop_changes = vdesktop->changes[unsigned(i)]; vdesktop_changes.xmin = 0; - vdesktop_changes.xmax = uInt(vdesktop->width) - 1; + vdesktop_changes.xmax = uInt(vdesktop->size.width) - 1; vdesktop_changes.trans_count = 0; } @@ -1716,20 +1716,20 @@ void FVTerm::clearAreaWithShadow (FTermArea* area, const FChar& fillchar) const t_char.attr.bit.char_width = 0; const int total_width = getFullAreaWidth(area); - for (auto y{0}; y < area->height; y++) + for (auto y{0}; y < area->size.height; y++) { // Clear area const auto area_pos = &area->getFChar(0, y); - std::fill (area_pos, area_pos + area->width, fillchar); + std::fill (area_pos, area_pos + area->size.width, fillchar); // Make right shadow transparent - const auto shadow_begin = &area->getFChar(area->width, y); - std::fill (shadow_begin, shadow_begin + area->right_shadow, t_char); + const auto shadow_begin = &area->getFChar(area->size.width, y); + std::fill (shadow_begin, shadow_begin + area->shadow.width, t_char); } // Make bottom shadow transparent - for (auto y{0}; y < area->bottom_shadow; y++) + for (auto y{0}; y < area->shadow.height; y++) { - const auto area_pos = &area->getFChar(0, area->height + y); + const auto area_pos = &area->getFChar(0, area->size.height + y); std::fill (area_pos, area_pos + total_width, t_char); } } @@ -1738,22 +1738,22 @@ void FVTerm::clearAreaWithShadow (FTermArea* area, const FChar& fillchar) const inline auto FVTerm::printWrap (FTermArea* area) const -> bool { bool end_of_area{false}; - const int& width = area->width; - const int& height = area->height; - const int& rsh = area->right_shadow; - const int& bsh = area->bottom_shadow; + const int& width = area->size.width; + const int& height = area->size.height; + const int& rsh = area->shadow.width; + const int& bsh = area->shadow.height; // Line break at right margin - if ( area->cursor_x > width + rsh ) + if ( area->cursor.x > width + rsh ) { - area->cursor_x = 1; - area->cursor_y++; + area->cursor.x = 1; + area->cursor.y++; } // Prevent up scrolling - if ( area->cursor_y > height + bsh ) + if ( area->cursor.y > height + bsh ) { - area->cursor_y--; + area->cursor.y--; end_of_area = true; } @@ -1790,8 +1790,8 @@ inline auto FVTerm::changedFromTransparency (const FChar& from, const FChar& to) inline auto FVTerm::printCharacterOnCoordinate ( FTermArea* area , const FChar& ch ) const noexcept -> std::size_t { - const int ax = area->cursor_x - 1; - const int ay = area->cursor_y - 1; + const int ax = area->cursor.x - 1; + const int ay = area->cursor.y - 1; auto* ac = &area->getFChar(ax, ay); // area character if ( *ac == ch ) // compare with an overloaded operator diff --git a/final/vterm/fvterm.h b/final/vterm/fvterm.h index adce14dd..7e687ef2 100644 --- a/final/vterm/fvterm.h +++ b/final/vterm/fvterm.h @@ -398,12 +398,12 @@ struct FVTerm::FTermArea // Define virtual terminal character properties inline auto getFChar (int x, int y) const noexcept -> const FChar& { - return data[unsigned(y) * unsigned(width + right_shadow) + unsigned(x)]; + return data[unsigned(y) * unsigned(size.width + shadow.width) + unsigned(x)]; } inline auto getFChar (int x, int y) noexcept -> FChar& { - return data[unsigned(y) * unsigned(width + right_shadow) + unsigned(x)]; + return data[unsigned(y) * unsigned(size.width + shadow.width) + unsigned(x)]; } inline auto getFChar (const FPoint& pos) const noexcept -> const FChar& @@ -418,14 +418,14 @@ struct FVTerm::FTermArea // Define virtual terminal character properties inline void setCursorPos (int x, int y) noexcept { - cursor_x = x; - cursor_y = y; + cursor.x = x; + cursor.y = y; } inline void setInputCursorPos (int x, int y) noexcept { - input_cursor_x = x; - input_cursor_y = y; + input_cursor.x = x; + input_cursor.y = y; } template @@ -438,28 +438,34 @@ struct FVTerm::FTermArea // Define virtual terminal character properties } // Data members - int offset_left{0}; // Distance from left terminal side - int offset_top{0}; // Distance from top of the terminal - int width{-1}; // Window width - int height{-1}; // Window height - int min_width{-1}; // Minimized window width - int min_height{-1}; // Minimized window height - int right_shadow{0}; // Right window shadow - int bottom_shadow{0}; // Bottom window shadow - int cursor_x{0}; // X-position for the next write operation - int cursor_y{0}; // Y-position for the next write operation - int input_cursor_x{-1}; // X-position input cursor - int input_cursor_y{-1}; // Y-position input cursor + struct Coordinate + { + int x{}; + int y{}; + }; + + struct Dimension + { + int width{}; + int height{}; + }; + + Coordinate position{0, 0}; // Distance from left and top of terminal edge + Dimension size{-1, -1}; // Window width and height + Dimension shadow{0, 0}; // Right and bottom window shadow + Dimension min_size{-1, -1}; // Minimized window width and height + Coordinate cursor{0, 0}; // Position for the next write operation + Coordinate input_cursor{-1, -1}; // Position of visible input cursor int layer{-1}; Encoding encoding{Encoding::Unknown}; bool input_cursor_visible{false}; bool has_changes{false}; bool visible{false}; bool minimized{false}; - FDataAccessPtr owner{nullptr}; // Object that owns this FTermArea + FDataAccessPtr owner{nullptr}; // Object that owns this FTermArea FPreprocVector preproc_list{}; FLineChangesPtr changes{}; - FCharPtr data{}; // FChar data of the drawing area + FCharPtr data{}; // FChar data of the drawing area }; //---------------------------------------------------------------------- @@ -467,24 +473,24 @@ inline auto FVTerm::FTermArea::contains (const FPoint& pos) const noexcept -> bo { // Is the terminal position (pos) located on my area? - const int current_height = minimized ? min_height : height + bottom_shadow; + const int current_height = minimized ? min_size.height : size.height + shadow.height; const int x = pos.getX(); const int y = pos.getY(); - return x >= offset_left - && x < offset_left + width + right_shadow - && y >= offset_top - && y < offset_top + current_height; + return x >= position.x + && x < position.x + size.width + shadow.width + && y >= position.y + && y < position.y + current_height; } //---------------------------------------------------------------------- inline auto FVTerm::FTermArea::isOverlapped (const FRect& box) const noexcept -> bool { - const int current_height = minimized ? min_height - : height + bottom_shadow; - const int x1 = offset_left; - const int x2 = offset_left + width + right_shadow - 1; - const int y1 = offset_top; - const int y2 = offset_top + current_height - 1; + const int current_height = minimized ? min_size.height + : size.height + shadow.height; + const int x1 = position.x; + const int x2 = position.x + size.width + shadow.width - 1; + const int y1 = position.y; + const int y2 = position.y + current_height - 1; return ( std::max(x1, box.getX1() - 1) <= std::min(x2, box.getX2() - 1) && std::max(y1, box.getY1() - 1) <= std::min(y2, box.getY2() - 1) ); @@ -493,19 +499,19 @@ inline auto FVTerm::FTermArea::isOverlapped (const FRect& box) const noexcept -> //---------------------------------------------------------------------- inline auto FVTerm::FTermArea::isOverlapped (const FTermArea* area) const noexcept -> bool { - const int current_height = minimized ? min_height - : height + bottom_shadow; - const int x1 = offset_left; - const int x2 = offset_left + width + right_shadow - 1; - const int y1 = offset_top; - const int y2 = offset_top + current_height - 1; - - const int area_current_height = area->minimized ? area->min_height - : area->height + area->bottom_shadow; - const int area_x1 = area->offset_left; - const int area_x2 = area->offset_left + area->width + area->right_shadow - 1; - const int area_y1 = area->offset_top; - const int area_y2 = area->offset_top + area_current_height - 1; + const int current_height = minimized ? min_size.height + : size.height + shadow.height; + const int x1 = position.x; + const int x2 = position.x + size.width + shadow.width - 1; + const int y1 = position.y; + const int y2 = position.y + current_height - 1; + + const int area_current_height = area->minimized ? area->min_size.height + : area->size.height + area->shadow.height; + const int area_x1 = area->position.x; + const int area_x2 = area->position.x + area->size.width + area->shadow.width - 1; + const int area_y1 = area->position.y; + const int area_y2 = area->position.y + area_current_height - 1; return ( std::max(x1, area_x1) <= std::min(x2, area_x2) && std::max(y1, area_y1) <= std::min(y2, area_y2) ); @@ -514,10 +520,10 @@ inline auto FVTerm::FTermArea::isOverlapped (const FTermArea* area) const noexce //---------------------------------------------------------------------- inline auto FVTerm::FTermArea::checkPrintPos() const noexcept -> bool { - return cursor_x > 0 - && cursor_y > 0 - && cursor_x <= width + right_shadow - && cursor_y <= height + bottom_shadow; + return cursor.x > 0 + && cursor.y > 0 + && cursor.x <= size.width + shadow.width + && cursor.y <= size.height + shadow.height; } @@ -536,18 +542,18 @@ inline auto FVTerm::FTermArea::reprint (const FRect& box, const FSize& term_size return false; has_changes = true; - const int y_start = std::max(0, std::max(y_pos, offset_top)) - offset_top; + const int y_start = std::max(0, std::max(y_pos, position.y)) - position.y; const int box_y2 = y_pos + h - 1; - const int current_height = minimized ? min_height : height + bottom_shadow; - const int y2 = offset_top + current_height - 1; - const int y_end = std::min(int(term_size.getHeight()) - 1, std::min(box_y2, y2)) - offset_top; + const int current_height = minimized ? min_size.height : size.height + shadow.height; + const int y2 = position.y + current_height - 1; + const int y_end = std::min(int(term_size.getHeight()) - 1, std::min(box_y2, y2)) - position.y; for (auto y{y_start}; y <= y_end; y++) // Line loop { - const int x_start = std::max(0, std::max(x_pos, offset_left)) - offset_left; + const int x_start = std::max(0, std::max(x_pos, position.x)) - position.x; const int box_x2 = x_pos + w - 1; - const int x2 = offset_left + width + right_shadow - 1; - const int x_end = std::min(int(term_size.getWidth()) - 1 , std::min(box_x2, x2)) - offset_left; + const int x2 = position.x + size.width + shadow.width - 1; + const int x_end = std::min(int(term_size.getWidth()) - 1 , std::min(box_x2, x2)) - position.x; auto& line_changes = changes[std::size_t(y)]; line_changes.xmin = uInt(std::min(int(line_changes.xmin), x_start)); line_changes.xmax = uInt(std::max(int(line_changes.xmax), x_end)); diff --git a/final/widget/fscrollview.cpp b/final/widget/fscrollview.cpp index f86f8246..19317a15 100644 --- a/final/widget/fscrollview.cpp +++ b/final/widget/fscrollview.cpp @@ -170,8 +170,8 @@ void FScrollView::setX (int x, bool adjust) if ( viewport ) { - viewport->offset_left = scroll_geometry.getX(); - viewport->offset_top = scroll_geometry.getY(); + viewport->position.x = scroll_geometry.getX(); + viewport->position.y = scroll_geometry.getY(); } } @@ -187,8 +187,8 @@ void FScrollView::setY (int y, bool adjust) if ( viewport ) { - viewport->offset_left = scroll_geometry.getX(); - viewport->offset_top = scroll_geometry.getY(); + viewport->position.x = scroll_geometry.getX(); + viewport->position.y = scroll_geometry.getY(); } } @@ -202,8 +202,8 @@ void FScrollView::setPos (const FPoint& p, bool adjust) if ( adjust || ! viewport ) return; - viewport->offset_left = scroll_geometry.getX(); - viewport->offset_top = scroll_geometry.getY(); + viewport->position.x = scroll_geometry.getX(); + viewport->position.y = scroll_geometry.getY(); } //---------------------------------------------------------------------- @@ -698,8 +698,8 @@ void FScrollView::adjustSize() if ( viewport ) { - viewport->offset_left = scroll_geometry.getX(); - viewport->offset_top = scroll_geometry.getY(); + viewport->position.x = scroll_geometry.getX(); + viewport->position.y = scroll_geometry.getY(); } vbar->setMaximum (int(getScrollHeight() - getViewportHeight())); @@ -732,20 +732,20 @@ void FScrollView::copy2area() return; auto printarea = getCurrentPrintArea(); - const int ax = getTermX() - printarea->offset_left; - const int ay = getTermY() - printarea->offset_top; + const int ax = getTermX() - printarea->position.x; + const int ay = getTermY() - printarea->position.y; const int dx = viewport_geometry.getX(); const int dy = viewport_geometry.getY(); auto y_end = int(getViewportHeight()); auto x_end = int(getViewportWidth()); // viewport width does not fit into the printarea - if ( printarea->width <= ax + x_end ) - x_end = printarea->width - ax; + if ( printarea->size.width <= ax + x_end ) + x_end = printarea->size.width - ax; // viewport height does not fit into the printarea - if ( printarea->height <= ay + y_end ) - y_end = printarea->height - ay; + if ( printarea->size.height <= ay + y_end ) + y_end = printarea->size.height - ay; for (auto y{0}; y < y_end; y++) // line loop { @@ -775,9 +775,9 @@ inline auto FScrollView::getViewportCursorPos() -> FPoint { const int widget_offsetX = getTermX() - window->getTermX(); const int widget_offsetY = getTermY() - window->getTermY(); - const int x = widget_offsetX + viewport->input_cursor_x + const int x = widget_offsetX + viewport->input_cursor.x - viewport_geometry.getX(); - const int y = widget_offsetY + viewport->input_cursor_y + const int y = widget_offsetY + viewport->input_cursor.y - viewport_geometry.getY(); return { x, y }; } @@ -929,8 +929,8 @@ void FScrollView::changeSize (const FSize& size, bool adjust) } else if ( ! adjust && viewport ) { - viewport->offset_left = scroll_geometry.getX(); - viewport->offset_top = scroll_geometry.getY(); + viewport->position.x = scroll_geometry.getX(); + viewport->position.y = scroll_geometry.getY(); } if ( ! viewport ) @@ -1012,8 +1012,8 @@ void FScrollView::setViewportCursor() if ( ! isChild(getFocusWidget()) ) return; - const FPoint cursor_pos { viewport->input_cursor_x - 1 - , viewport->input_cursor_y - 1 }; + const FPoint cursor_pos { viewport->input_cursor.x - 1 + , viewport->input_cursor.y - 1 }; const FPoint window_cursor_pos{ getViewportCursorPos() }; auto printarea = getCurrentPrintArea(); printarea->setInputCursorPos ( window_cursor_pos.getX() diff --git a/final/widget/fwindow.cpp b/final/widget/fwindow.cpp index 45ad8ad3..1d3572b7 100644 --- a/final/widget/fwindow.cpp +++ b/final/widget/fwindow.cpp @@ -328,7 +328,7 @@ void FWindow::setX (int x, bool adjust) FWidget::setX (x, adjust); if ( isVirtualWindow() ) - getVWin()->offset_left = getTermX() - 1; + getVWin()->position.x = getTermX() - 1; } //---------------------------------------------------------------------- @@ -340,7 +340,7 @@ void FWindow::setY (int y, bool adjust) FWidget::setY (y, adjust); if ( isVirtualWindow() ) - getVWin()->offset_top = getTermY() - 1; + getVWin()->position.y = getTermY() - 1; } //---------------------------------------------------------------------- @@ -356,8 +356,8 @@ void FWindow::setPos (const FPoint& p, bool adjust) if ( isVirtualWindow() ) { auto virtual_win = getVWin(); - virtual_win->offset_left = getTermX() - 1; - virtual_win->offset_top = getTermY() - 1; + virtual_win->position.x = getTermX() - 1; + virtual_win->position.y = getTermY() - 1; } } @@ -430,10 +430,10 @@ void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust) else { if ( getX() != old_x ) - getVWin()->offset_left = getTermX() - 1; + getVWin()->position.x = getTermX() - 1; if ( getY() != old_y ) - getVWin()->offset_top = getTermY() - 1; + getVWin()->position.y = getTermY() - 1; } } @@ -445,8 +445,8 @@ void FWindow::move (const FPoint& pos) if ( isVirtualWindow() ) { auto virtual_win = getVWin(); - virtual_win->offset_left = getTermX() - 1; - virtual_win->offset_top = getTermY() - 1; + virtual_win->position.x = getTermX() - 1; + virtual_win->position.y = getTermY() - 1; } } @@ -748,10 +748,10 @@ void FWindow::adjustSize() else if ( isVirtualWindow() ) { if ( getTermX() != old_x ) - getVWin()->offset_left = getTermX() - 1; + getVWin()->position.x = getTermX() - 1; if ( getTermY() != old_y ) - getVWin()->offset_top = getTermY() - 1; + getVWin()->position.y = getTermY() - 1; } } @@ -830,7 +830,7 @@ inline auto FWindow::getVisibleTermGeometry (FWindow* win) -> FRect if ( win->isMinimized() ) { FRect minimized_term_geometry(term_geometry); - auto min_height = std::size_t(win->getVWin()->min_height); + auto min_height = std::size_t(win->getVWin()->min_size.height); minimized_term_geometry.setHeight(min_height); return minimized_term_geometry; } diff --git a/test/fvterm-test.cpp b/test/fvterm-test.cpp index f8bb35ff..6fa16329 100644 --- a/test/fvterm-test.cpp +++ b/test/fvterm-test.cpp @@ -921,21 +921,21 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( vwin->owner ); CPPUNIT_ASSERT ( vwin->hasOwner() ); CPPUNIT_ASSERT ( vwin->getOwner() == &p_fvterm ); - CPPUNIT_ASSERT ( vwin->offset_left == 5 ); - CPPUNIT_ASSERT ( vwin->offset_top == 5 ); - CPPUNIT_ASSERT ( vwin->width == 20 ); - CPPUNIT_ASSERT ( vwin->height == 20 ); - CPPUNIT_ASSERT ( vwin->min_width == 20 ); - CPPUNIT_ASSERT ( vwin->min_height == 1 ); - CPPUNIT_ASSERT ( vwin->right_shadow == 2 ); - CPPUNIT_ASSERT ( vwin->bottom_shadow == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 0 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 0 ); - CPPUNIT_ASSERT ( vwin->input_cursor_x == -1 ); - CPPUNIT_ASSERT ( vwin->input_cursor_y == -1 ); + CPPUNIT_ASSERT ( vwin->position.x == 5 ); + CPPUNIT_ASSERT ( vwin->position.y == 5 ); + CPPUNIT_ASSERT ( vwin->size.width == 20 ); + CPPUNIT_ASSERT ( vwin->size.height == 20 ); + CPPUNIT_ASSERT ( vwin->min_size.width == 20 ); + CPPUNIT_ASSERT ( vwin->min_size.height == 1 ); + CPPUNIT_ASSERT ( vwin->shadow.width == 2 ); + CPPUNIT_ASSERT ( vwin->shadow.height == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 0 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 0 ); + CPPUNIT_ASSERT ( vwin->input_cursor.x == -1 ); + CPPUNIT_ASSERT ( vwin->input_cursor.y == -1 ); vwin->setInputCursorPos (12, 4); - CPPUNIT_ASSERT ( vwin->input_cursor_x == 12 ); - CPPUNIT_ASSERT ( vwin->input_cursor_y == 4 ); + CPPUNIT_ASSERT ( vwin->input_cursor.x == 12 ); + CPPUNIT_ASSERT ( vwin->input_cursor.y == 4 ); p_fvterm.p_setAreaCursor ({3, 5}, true, vwin); CPPUNIT_ASSERT ( vwin->input_cursor_visible ); p_fvterm.p_setAreaCursor ({12, 4}, false, vwin); @@ -1017,11 +1017,11 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( vwin->layer == -1 ); FVTerm_protected::p_determineWindowLayers(); CPPUNIT_ASSERT ( FVTerm_protected::p_getLayer(p_fvterm) == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 0 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 0 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 0 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 0 ); p_fvterm.setCursor( {16, 8} ); - CPPUNIT_ASSERT ( vwin->cursor_x == 11 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 11 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); CPPUNIT_ASSERT ( finalcut::FKeyboard::getReadBlockingTime() == 100000 ); p_fvterm.setNonBlockingRead(); CPPUNIT_ASSERT ( finalcut::FKeyboard::getReadBlockingTime() == 5000 ); @@ -1044,18 +1044,18 @@ void FVTermTest::FVTermBasesTest() auto&& vdesktop = p_fvterm.p_getVirtualDesktop(); CPPUNIT_ASSERT ( vdesktop->hasOwner() ); CPPUNIT_ASSERT ( vdesktop->getOwner() == &p_fvterm ); - CPPUNIT_ASSERT ( vdesktop->offset_left == 0 ); - CPPUNIT_ASSERT ( vdesktop->offset_top == 0 ); - CPPUNIT_ASSERT ( vdesktop->width == 80 ); - CPPUNIT_ASSERT ( vdesktop->height == 24 ); - CPPUNIT_ASSERT ( vdesktop->min_width == 80 ); - CPPUNIT_ASSERT ( vdesktop->min_height == 1 ); - CPPUNIT_ASSERT ( vdesktop->right_shadow == 0); - CPPUNIT_ASSERT ( vdesktop->bottom_shadow == 0 ); - CPPUNIT_ASSERT ( vdesktop->cursor_x == 0 ); - CPPUNIT_ASSERT ( vdesktop->cursor_y == 0 ); - CPPUNIT_ASSERT ( vdesktop->input_cursor_x == -1 ); - CPPUNIT_ASSERT ( vdesktop->input_cursor_y == -1 ); + CPPUNIT_ASSERT ( vdesktop->position.x == 0 ); + CPPUNIT_ASSERT ( vdesktop->position.y == 0 ); + CPPUNIT_ASSERT ( vdesktop->size.width == 80 ); + CPPUNIT_ASSERT ( vdesktop->size.height == 24 ); + CPPUNIT_ASSERT ( vdesktop->min_size.width == 80 ); + CPPUNIT_ASSERT ( vdesktop->min_size.height == 1 ); + CPPUNIT_ASSERT ( vdesktop->shadow.width == 0); + CPPUNIT_ASSERT ( vdesktop->shadow.height == 0 ); + CPPUNIT_ASSERT ( vdesktop->cursor.x == 0 ); + CPPUNIT_ASSERT ( vdesktop->cursor.y == 0 ); + CPPUNIT_ASSERT ( vdesktop->input_cursor.x == -1 ); + CPPUNIT_ASSERT ( vdesktop->input_cursor.y == -1 ); CPPUNIT_ASSERT ( vdesktop->layer == -1 ); CPPUNIT_ASSERT ( ! vdesktop->input_cursor_visible ); CPPUNIT_ASSERT ( ! vdesktop->has_changes ); @@ -1082,18 +1082,18 @@ void FVTermTest::FVTermBasesTest() auto&& vterm = p_fvterm.p_getVirtualTerminal(); CPPUNIT_ASSERT ( vterm->hasOwner() ); CPPUNIT_ASSERT ( vterm->getOwner() == &p_fvterm ); - CPPUNIT_ASSERT ( vterm->offset_left == 0 ); - CPPUNIT_ASSERT ( vterm->offset_top == 0 ); - CPPUNIT_ASSERT ( vterm->width == 80 ); - CPPUNIT_ASSERT ( vterm->height == 24 ); - CPPUNIT_ASSERT ( vterm->min_width == 80 ); - CPPUNIT_ASSERT ( vterm->min_height == 1 ); - CPPUNIT_ASSERT ( vterm->right_shadow == 0); - CPPUNIT_ASSERT ( vterm->bottom_shadow == 0 ); - CPPUNIT_ASSERT ( vterm->cursor_x == 0 ); - CPPUNIT_ASSERT ( vterm->cursor_y == 0 ); - CPPUNIT_ASSERT ( vterm->input_cursor_x == -1 ); - CPPUNIT_ASSERT ( vterm->input_cursor_y == -1 ); + CPPUNIT_ASSERT ( vterm->position.x == 0 ); + CPPUNIT_ASSERT ( vterm->position.y == 0 ); + CPPUNIT_ASSERT ( vterm->size.width == 80 ); + CPPUNIT_ASSERT ( vterm->size.height == 24 ); + CPPUNIT_ASSERT ( vterm->min_size.width == 80 ); + CPPUNIT_ASSERT ( vterm->min_size.height == 1 ); + CPPUNIT_ASSERT ( vterm->shadow.width == 0); + CPPUNIT_ASSERT ( vterm->shadow.height == 0 ); + CPPUNIT_ASSERT ( vterm->cursor.x == 0 ); + CPPUNIT_ASSERT ( vterm->cursor.y == 0 ); + CPPUNIT_ASSERT ( vterm->input_cursor.x == -1 ); + CPPUNIT_ASSERT ( vterm->input_cursor.y == -1 ); CPPUNIT_ASSERT ( vterm->layer == -1 ); CPPUNIT_ASSERT ( ! vterm->input_cursor_visible ); vterm->input_cursor_visible = true; @@ -1122,7 +1122,7 @@ void FVTermTest::FVTermBasesTest() test::printOnArea (test_vterm_area, {test::getAreaSize(test_vterm_area), default_char}); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - for (auto i{0}; i < vwin->height; i++) + for (auto i{0}; i < vwin->size.height; i++) { CPPUNIT_ASSERT ( vwin->changes[i].xmin == 22 ); CPPUNIT_ASSERT ( vwin->changes[i].xmax == 0 ); @@ -1133,16 +1133,16 @@ void FVTermTest::FVTermBasesTest() p_fvterm.clearArea(L'▒'); // Fill with '▒' CPPUNIT_ASSERT ( vwin->has_changes ); - for (auto i{0}; i < vwin->height; i++) + for (auto i{0}; i < vwin->size.height; i++) { CPPUNIT_ASSERT ( vwin->changes[i].xmin == 0 ); CPPUNIT_ASSERT ( vwin->changes[i].xmax == 21 ); CPPUNIT_ASSERT ( vwin->changes[i].trans_count == 2 ); } - const auto full_height = vwin->height + vwin->bottom_shadow; + const auto full_height = vwin->size.height + vwin->shadow.height; - for (auto i{vwin->height}; i < full_height; i++) + for (auto i{vwin->size.height}; i < full_height; i++) { CPPUNIT_ASSERT ( vwin->changes[i].xmin == 0 ); CPPUNIT_ASSERT ( vwin->changes[i].xmax == 21 ); @@ -1159,19 +1159,19 @@ void FVTermTest::FVTermBasesTest() { { 0x00, 0x00, 0x08, 0x00} } // byte 0..3 }; - const auto full_width = std::size_t(vwin->width) - + std::size_t(vwin->right_shadow); + const auto full_width = std::size_t(vwin->size.width) + + std::size_t(vwin->shadow.width); - for (auto y{0u}; y < std::size_t(vwin->height); y++) + for (auto y{0u}; y < std::size_t(vwin->size.height); y++) { - for (auto x{0u}; x < std::size_t(vwin->width); x++) + for (auto x{0u}; x < std::size_t(vwin->size.width); x++) { CPPUNIT_ASSERT ( test::isFCharEqual(vwin->data[y * full_width + x], bg_char) ); } } // Check shadow - auto width = std::size_t(vwin->width); + auto width = std::size_t(vwin->size.width); finalcut::FChar shadow_char = { { L'\0', L'\0', L'\0', L'\0', L'\0' }, @@ -1229,12 +1229,12 @@ void FVTermTest::FVTermBasesTest() vwin->setInputCursorPos(4, 2); test::showFCharData(vwin->data[full_width + 1]); CPPUNIT_ASSERT ( vwin->has_changes ); - CPPUNIT_ASSERT ( vterm->input_cursor_x == -1 ); - CPPUNIT_ASSERT ( vterm->input_cursor_y == -1 ); + CPPUNIT_ASSERT ( vterm->input_cursor.x == -1 ); + CPPUNIT_ASSERT ( vterm->input_cursor.y == -1 ); CPPUNIT_ASSERT ( ! vterm->input_cursor_visible ); p_fvterm.p_processTerminalUpdate(); - CPPUNIT_ASSERT ( vterm->input_cursor_x == 9 ); - CPPUNIT_ASSERT ( vterm->input_cursor_y == 7 ); + CPPUNIT_ASSERT ( vterm->input_cursor.x == 9 ); + CPPUNIT_ASSERT ( vterm->input_cursor.y == 7 ); CPPUNIT_ASSERT ( vterm->input_cursor_visible ); CPPUNIT_ASSERT ( ! vwin->has_changes ); CPPUNIT_ASSERT ( ! test::isAreaEqual(test_vterm_area, vterm) ); @@ -1244,8 +1244,8 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); // Move - vwin->offset_left = 0; - vwin->offset_top = 0; + vwin->position.x = 0; + vwin->position.y = 0; p_fvterm.p_putArea ({1, 1}, nullptr); p_fvterm.p_processTerminalUpdate(); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); @@ -1264,8 +1264,8 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); - vwin->offset_left = -10; - vwin->offset_top = -10; + vwin->position.x = -10; + vwin->position.y = -10; p_fvterm.p_putArea ({-9, -9}, vwin); p_fvterm.p_processTerminalUpdate(); p_fvterm.p_restoreVTerm ({finalcut::FPoint{1, 1}, finalcut::FSize{22, 21}}); @@ -1274,8 +1274,8 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); - vwin->offset_left = 70; - vwin->offset_top = -10; + vwin->position.x = 70; + vwin->position.y = -10; p_fvterm.p_putArea ({71, -9}, vwin); p_fvterm.p_processTerminalUpdate(); p_fvterm.p_restoreVTerm ({finalcut::FPoint{1, 1}, finalcut::FSize{12, 11}}); @@ -1284,8 +1284,8 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); - vwin->offset_left = -10; - vwin->offset_top = 14; + vwin->position.x = -10; + vwin->position.y = 14; p_fvterm.p_putArea ({-9, 15}, vwin); p_fvterm.p_processTerminalUpdate(); p_fvterm.p_restoreVTerm ({finalcut::FPoint{71, 1}, finalcut::FSize{10, 11}}); @@ -1294,8 +1294,8 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); - vwin->offset_left = 70; - vwin->offset_top = 14; + vwin->position.x = 70; + vwin->position.y = 14; p_fvterm.p_putArea ({71, 15}, vwin); p_fvterm.p_processTerminalUpdate(); p_fvterm.p_restoreVTerm ({finalcut::FPoint{1, 15}, finalcut::FSize{12, 10}}); @@ -1305,8 +1305,8 @@ void FVTermTest::FVTermBasesTest() test::printArea (vterm); // Move outside - vwin->offset_left = -20; - vwin->offset_top = -20; + vwin->position.x = -20; + vwin->position.y = -20; p_fvterm.p_putArea ({-19, -19}, vwin); p_fvterm.p_processTerminalUpdate(); p_fvterm.p_restoreVTerm ({finalcut::FPoint{71, 15}, finalcut::FSize{10, 10}}); @@ -1314,20 +1314,20 @@ void FVTermTest::FVTermBasesTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); - vwin->offset_left = 80; - vwin->offset_top = -20; + vwin->position.x = 80; + vwin->position.y = -20; p_fvterm.p_putArea ({81, -19}, vwin); p_fvterm.p_processTerminalUpdate(); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - vwin->offset_left = -20; - vwin->offset_top = 24; + vwin->position.x = -20; + vwin->position.y = 24; p_fvterm.p_putArea ({-19, 25}, vwin); p_fvterm.p_processTerminalUpdate(); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - vwin->offset_left = 80; - vwin->offset_top = 24; + vwin->position.x = 80; + vwin->position.y = 24; p_fvterm.p_putArea ({81, 25}, vwin); p_fvterm.p_processTerminalUpdate(); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); @@ -1335,8 +1335,8 @@ void FVTermTest::FVTermBasesTest() // Virtual window is larger than virtual terminal auto large_geometry = finalcut::FRect(finalcut::FPoint{1, 1}, finalcut::FSize{90, 34}); p_fvterm.p_resizeArea (large_geometry, vwin); - vwin->cursor_x = 1; - vwin->cursor_y = 1; + vwin->cursor.x = 1; + vwin->cursor.y = 1; for (wchar_t i = 0; i < wchar_t(large_geometry.getHeight()); i++) { @@ -1344,14 +1344,14 @@ void FVTermTest::FVTermBasesTest() test::printOnArea (vwin, {large_geometry.getWidth(), bg_char}); } - vwin->offset_left = -5; - vwin->offset_top = -5; + vwin->position.x = -5; + vwin->position.y = -5; p_fvterm.p_putArea ({-4, -4}, vwin); - for (wchar_t i = 0; i < wchar_t(vterm->height); i++) + for (wchar_t i = 0; i < wchar_t(vterm->size.height); i++) { bg_char.ch[0] = L'a' + i; - test::printOnArea (test_vterm_area, {std::size_t(vterm->width), bg_char}); + test::printOnArea (test_vterm_area, {std::size_t(vterm->size.width), bg_char}); } CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); @@ -1363,28 +1363,28 @@ void FVTermTest::FVTermBasesTest() auto new_term_geometry = finalcut::FRect(finalcut::FPoint{1, 1}, new_term_size); p_fvterm.p_resizeArea (new_term_geometry, test_vterm_area); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - CPPUNIT_ASSERT ( vterm->width == 70); - CPPUNIT_ASSERT ( vterm->height == 18 ); + CPPUNIT_ASSERT ( vterm->size.width == 70); + CPPUNIT_ASSERT ( vterm->size.height == 18 ); test::printArea (vterm); p_fvterm.p_putArea ({-4, -4}, vwin); - for (wchar_t i = 0; i < wchar_t(vterm->height); i++) + for (wchar_t i = 0; i < wchar_t(vterm->size.height); i++) { bg_char.ch[0] = L'a' + i; - test::printOnArea (test_vterm_area, {std::size_t(vterm->width), bg_char}); + test::printOnArea (test_vterm_area, {std::size_t(vterm->size.width), bg_char}); } CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); test::printArea (vterm); // Reset line changes - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { - vterm->changes[i].xmin = uInt(vterm->width - 1); + vterm->changes[i].xmin = uInt(vterm->size.width - 1); vterm->changes[i].xmax = 0; } - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 69 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 0 ); @@ -1393,7 +1393,7 @@ void FVTermTest::FVTermBasesTest() // Force all lines of the virtual terminal to be output p_fvterm.putVTerm(); - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 0 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 69 ); @@ -1405,8 +1405,8 @@ void FVTermTest::FVTermBasesTest() new_term_geometry = finalcut::FRect(finalcut::FPoint{1, 1}, new_term_size); p_fvterm.p_resizeArea (new_term_geometry, test_vterm_area); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - CPPUNIT_ASSERT ( vterm->width == 75); - CPPUNIT_ASSERT ( vterm->height == 18 ); + CPPUNIT_ASSERT ( vterm->size.width == 75); + CPPUNIT_ASSERT ( vterm->size.height == 18 ); // No change new_term_size = finalcut::FSize{75, 18}; @@ -1414,8 +1414,8 @@ void FVTermTest::FVTermBasesTest() new_term_geometry = finalcut::FRect(finalcut::FPoint{1, 1}, new_term_size); p_fvterm.p_resizeArea (new_term_geometry, test_vterm_area); CPPUNIT_ASSERT ( test::isAreaEqual(test_vterm_area, vterm) ); - CPPUNIT_ASSERT ( vterm->width == 75); - CPPUNIT_ASSERT ( vterm->height == 18 ); + CPPUNIT_ASSERT ( vterm->size.width == 75); + CPPUNIT_ASSERT ( vterm->size.height == 18 ); // Deallocate area memory CPPUNIT_ASSERT ( test_vwin_area_ptr.get() ); @@ -1482,16 +1482,16 @@ void FVTermTest::FVTermPrintTest() return; } - CPPUNIT_ASSERT ( vwin->cursor_x == 0 ); // First column is 1 - CPPUNIT_ASSERT ( vwin->cursor_y == 0 ); // First row is 1 - CPPUNIT_ASSERT ( vwin->offset_left == 0 ); - CPPUNIT_ASSERT ( vwin->offset_top == 0 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 0 ); // First column is 1 + CPPUNIT_ASSERT ( vwin->cursor.y == 0 ); // First row is 1 + CPPUNIT_ASSERT ( vwin->position.x == 0 ); + CPPUNIT_ASSERT ( vwin->position.y == 0 ); auto move_geometry = finalcut::FRect ( finalcut::FPoint{12, 37} , finalcut::FSize{15, 10} ); p_fvterm.p_resizeArea (move_geometry, Shadow, vwin); - CPPUNIT_ASSERT ( vwin->offset_left == 12 ); - CPPUNIT_ASSERT ( vwin->offset_top == 37 ); + CPPUNIT_ASSERT ( vwin->position.x == 12 ); + CPPUNIT_ASSERT ( vwin->position.y == 37 ); // FChar struct finalcut::FChar default_char = @@ -1522,29 +1522,29 @@ void FVTermTest::FVTermPrintTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.setCursor({1, 0}); - CPPUNIT_ASSERT ( vwin->cursor_x == -11 ); - CPPUNIT_ASSERT ( vwin->cursor_y == -37 ); - vwin->offset_left = 0; - vwin->offset_top = 0; + CPPUNIT_ASSERT ( vwin->cursor.x == -11 ); + CPPUNIT_ASSERT ( vwin->cursor.y == -37 ); + vwin->position.x = 0; + vwin->position.y = 0; p_fvterm.setCursor({1, 0}); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); // First column is 1 - CPPUNIT_ASSERT ( vwin->cursor_y == 0 ); // First row is 1 + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); // First column is 1 + CPPUNIT_ASSERT ( vwin->cursor.y == 0 ); // First row is 1 p_fvterm.printf("%s/%d = %4.2f...", "1", 3, 1.0f/3.0f); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.setCursor({0, 1}); - CPPUNIT_ASSERT ( vwin->cursor_x == 0 ); // First column is 1 - CPPUNIT_ASSERT ( vwin->cursor_y == 1 ); // First row is 1 + CPPUNIT_ASSERT ( vwin->cursor.x == 0 ); // First column is 1 + CPPUNIT_ASSERT ( vwin->cursor.y == 1 ); // First row is 1 p_fvterm.printf("%s/%d = %4.2f...", "1", 3, 1.0f/3.0f); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.setCursor({1, 1}); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); // First column is 1 - CPPUNIT_ASSERT ( vwin->cursor_y == 1 ); // First row is 1 + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); // First column is 1 + CPPUNIT_ASSERT ( vwin->cursor.y == 1 ); // First row is 1 std::setlocale(LC_NUMERIC, "C"); p_fvterm.printf("%s/%d = %4.2f...", "1", 3, 1.0f/3.0f); - CPPUNIT_ASSERT ( vwin->cursor_x == 14 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 14 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 1 ); CPPUNIT_ASSERT ( ! test::isAreaEqual(test_vwin_area, vwin) ); test_vwin_area->data[0].ch[0] = '1'; test_vwin_area->data[1].ch[0] = '/'; @@ -1561,8 +1561,8 @@ void FVTermTest::FVTermPrintTest() test_vwin_area->data[12].ch[0] = '.'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 14 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 14 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 1 ); finalcut::FString string{}; // Empty string p_fvterm.print(vwin, string); @@ -1589,87 +1589,87 @@ void FVTermTest::FVTermPrintTest() test_vwin_area->data[17].ch[0] = 'e'; test_vwin_area->data[18].ch[0] = 't'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 2 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 2 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 2 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 2 ); p_fvterm.print(finalcut::FPoint{1, 3}); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); // Horizontal tabulation (HT) p_fvterm.print(L"1\t2"); test_vwin_area->data[32].ch[0] = '1'; test_vwin_area->data[40].ch[0] = '2'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); // Carriage Return + spaces p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"12\t2"); test_vwin_area->data[33].ch[0] = '2'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"123\t2"); test_vwin_area->data[34].ch[0] = '3'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"1234\t2"); test_vwin_area->data[35].ch[0] = '4'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"12345\t2"); test_vwin_area->data[36].ch[0] = '5'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"123456\t2"); test_vwin_area->data[37].ch[0] = '6'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r "); p_fvterm.print(finalcut::FPoint{1, 3}); p_fvterm.print(L"1234567\t2"); test_vwin_area->data[38].ch[0] = '7'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print(L"\r \r12345678\t2"); test_vwin_area->data[39].ch[0] = '8'; test_vwin_area->data[40].ch[0] = ' '; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 17 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 17 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); // Cursor is outside the window p_fvterm.print(L"invisible"); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 17 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 17 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 3 ); p_fvterm.print('\b'); // Backspace p_fvterm.print(L'…'); test_vwin_area->data[47].ch[0] = L'…'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 4 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 4 ); // std::vector finalcut::FChar fchar = @@ -1690,8 +1690,8 @@ void FVTermTest::FVTermPrintTest() term_string[5].ch[0] = 'r'; term_string[6].ch[0] = '\n'; p_fvterm.print(term_string); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); for (std::size_t i{48}; i < 54; i++) { @@ -1751,15 +1751,15 @@ void FVTermTest::FVTermPrintTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); // Printing text in the bottom row - int last_row = vwin->height + vwin->bottom_shadow; + int last_row = vwin->size.height + vwin->shadow.height; CPPUNIT_ASSERT ( last_row == 11 ); p_fvterm.print(finalcut::FPoint{1, last_row}); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == last_row ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == last_row ); CPPUNIT_ASSERT ( p_fvterm.print("Disqualification") == 16 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == last_row ); // Scrolling up was prevented + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == last_row ); // Scrolling up was prevented test_vwin_area->data[160].ch[0] = L'D'; test_vwin_area->data[161].ch[0] = L'i'; @@ -1780,14 +1780,14 @@ void FVTermTest::FVTermPrintTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print(finalcut::FPoint{1, 6}); - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 6 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 6 ); // Combined unicode characters if ( enc == finalcut::Encoding::VT100 ) { CPPUNIT_ASSERT ( p_fvterm.print(L"STARGΛ̊TE") == 9 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); test_vwin_area->data[80].ch[0] = L'S'; test_vwin_area->data[81].ch[0] = L'T'; test_vwin_area->data[82].ch[0] = L'A'; @@ -1801,7 +1801,7 @@ void FVTermTest::FVTermPrintTest() else if ( enc == finalcut::Encoding::UTF8 ) { CPPUNIT_ASSERT ( p_fvterm.print(L"STARGΛ̊TE") == 8 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 9 ); test_vwin_area->data[80].ch[0] = L'S'; test_vwin_area->data[81].ch[0] = L'T'; test_vwin_area->data[82].ch[0] = L'A'; @@ -1817,11 +1817,11 @@ void FVTermTest::FVTermPrintTest() // Line break p_fvterm.print(finalcut::FPoint{11, 7}); - CPPUNIT_ASSERT ( vwin->cursor_x == 11 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 7 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 11 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 7 ); CPPUNIT_ASSERT ( p_fvterm.print(L"FINAL CUT") == 9 ); - CPPUNIT_ASSERT ( vwin->cursor_x == 4 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 4 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 8 ); test_vwin_area->data[106].ch[0] = L'F'; test_vwin_area->data[107].ch[0] = L'I'; test_vwin_area->data[108].ch[0] = L'N'; @@ -1834,13 +1834,13 @@ void FVTermTest::FVTermPrintTest() // Stream p_fvterm.print() << ' '; // char - CPPUNIT_ASSERT ( vwin->cursor_x == 5 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 8 ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << 1.23; // double - CPPUNIT_ASSERT ( vwin->cursor_x == 13 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 13 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 8 ); test_vwin_area->data[116].ch[0] = L'1'; test_vwin_area->data[117].ch[0] = L'.'; test_vwin_area->data[118].ch[0] = L'2'; @@ -1852,60 +1852,60 @@ void FVTermTest::FVTermPrintTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << L' '; // wchar_t - CPPUNIT_ASSERT ( vwin->cursor_x == 14 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 14 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 8 ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); wchar_t kilohertz[] = L"kHz"; // wchar_t* p_fvterm.print() << kilohertz; - CPPUNIT_ASSERT ( vwin->cursor_x == 1 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 1 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 9 ); test_vwin_area->data[125].ch[0] = L'k'; test_vwin_area->data[126].ch[0] = L'H'; test_vwin_area->data[127].ch[0] = L'z'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << finalcut::UniChar::BlackRightPointingPointer; // UniChar - CPPUNIT_ASSERT ( vwin->cursor_x == 2 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 2 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 9 ); test_vwin_area->data[128].ch[0] = L'►'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << std::string("fan"); // std::string - CPPUNIT_ASSERT ( vwin->cursor_x == 5 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 9 ); test_vwin_area->data[129].ch[0] = L'f'; test_vwin_area->data[130].ch[0] = L'a'; test_vwin_area->data[131].ch[0] = L'n'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << std::wstring(L"tas"); // std::wstring - CPPUNIT_ASSERT ( vwin->cursor_x == 8 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 9 ); test_vwin_area->data[132].ch[0] = L't'; test_vwin_area->data[133].ch[0] = L'a'; test_vwin_area->data[134].ch[0] = L's'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << finalcut::FString(L"tic"); // FString - CPPUNIT_ASSERT ( vwin->cursor_x == 11 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 9 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 11 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 9 ); test_vwin_area->data[135].ch[0] = L't'; test_vwin_area->data[136].ch[0] = L'i'; test_vwin_area->data[137].ch[0] = L'c'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << finalcut::FPoint(3, 5); // FPoint - CPPUNIT_ASSERT ( vwin->cursor_x == 3 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 3 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); fchar.ch[0] = L'y'; fchar.ch[1] = L'\U00000304'; fchar.ch[2] = L'\0'; fchar.attr.bit.char_width = 1 & 0x03; p_fvterm.print() << fchar; // FChar - CPPUNIT_ASSERT ( vwin->cursor_x == 4 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 4 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); test_vwin_area->data[66].ch[0] = L'y'; test_vwin_area->data[66].ch[1] = L'\U00000304'; test_vwin_area->data[66].attr.bit.char_width = 1 & 0x03; @@ -1918,19 +1918,19 @@ void FVTermTest::FVTermPrintTest() fchar.bg_color = finalcut::FColor::Default; finalcut::FVTerm::FCharVector dash{2, fchar}; p_fvterm.print() << dash; // FCharVector - CPPUNIT_ASSERT ( vwin->cursor_x == 6 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 6 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); test_vwin_area->data[67].ch[0] = L'-'; test_vwin_area->data[68].ch[0] = L'-'; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin) ); p_fvterm.print() << finalcut::FStyle ( finalcut::Style::Italic | finalcut::Style::DoubleUnderline ); // FStyle - CPPUNIT_ASSERT ( vwin->cursor_x == 6 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 6 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); p_fvterm.print() << "F"; - CPPUNIT_ASSERT ( vwin->cursor_x == 7 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 7 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); test_vwin_area->data[69].ch[0] = L'F'; test_vwin_area->data[69].attr.bit.italic = true; test_vwin_area->data[69].attr.bit.dbl_underline = true; @@ -1938,11 +1938,11 @@ void FVTermTest::FVTermPrintTest() finalcut::FColorPair cpair{finalcut::FColor::Blue, finalcut::FColor::White}; p_fvterm.print() << cpair; // FColorPair - CPPUNIT_ASSERT ( vwin->cursor_x == 7 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 7 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); p_fvterm.print() << "C"; - CPPUNIT_ASSERT ( vwin->cursor_x == 8 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 8 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); test_vwin_area->data[70].ch[0] = L'C'; test_vwin_area->data[70].fg_color = finalcut::FColor::Blue; test_vwin_area->data[70].bg_color = finalcut::FColor::White; @@ -1952,8 +1952,8 @@ void FVTermTest::FVTermPrintTest() fvtermbuffer.print("++"); p_fvterm.print() << fvtermbuffer; // FVTermBuffer - CPPUNIT_ASSERT ( vwin->cursor_x == 10 ); - CPPUNIT_ASSERT ( vwin->cursor_y == 5 ); + CPPUNIT_ASSERT ( vwin->cursor.x == 10 ); + CPPUNIT_ASSERT ( vwin->cursor.y == 5 ); test_vwin_area->data[71] = test_vwin_area->data[70]; test_vwin_area->data[71].ch[0] = L'+'; test_vwin_area->data[72] = test_vwin_area->data[71]; @@ -2027,7 +2027,7 @@ void FVTermTest::FVTermChildAreaPrintTest() p_fvterm.p_addLayer(nullptr); CPPUNIT_ASSERT ( p_fvterm.value_ref() == 11 ); - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 80 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 0 ); @@ -2104,7 +2104,7 @@ void FVTermTest::FVTermChildAreaPrintTest() // Create a vterm comparison area finalcut::FVTerm::FTermArea* test_vterm_area{}; auto vterm_geometry = finalcut::FRect( finalcut::FPoint{0, 0} - , finalcut::FSize{std::size_t(vterm->width), std::size_t(vterm->height)} ); + , finalcut::FSize{std::size_t(vterm->size.width), std::size_t(vterm->size.height)} ); auto test_vterm_area_ptr = p_fvterm.p_createArea (vterm_geometry); test_vterm_area = test_vterm_area_ptr.get(); @@ -2741,7 +2741,7 @@ void FVTermTest::FVTermReduceUpdatesTest() CPPUNIT_ASSERT ( vterm->changes[i].trans_count == 0 ); } - for (auto i{15}; i < vterm->height; i++) + for (auto i{15}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 80 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 0 ); @@ -2754,18 +2754,18 @@ void FVTermTest::FVTermReduceUpdatesTest() p_fvterm.updateTerminal(); // Simulate printing - for (auto y{0}; y < vterm->height; y++) + for (auto y{0}; y < vterm->size.height; y++) { for (auto x{vterm->changes[y].xmin}; x < vterm->changes[y].xmax; x++) vterm->getFChar(int(x), int(y)).attr.bit.printed = true; - vterm->changes[y].xmin = uInt(vterm->width); + vterm->changes[y].xmin = uInt(vterm->size.width); vterm->changes[y].xmax = 0; } - for (auto y{0}; y < vterm->height; y++) + for (auto y{0}; y < vterm->size.height; y++) { - for (auto x{0}; x < vterm->width; x++) + for (auto x{0}; x < vterm->size.width; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, y).attr.bit.no_changes == false ); } @@ -2792,9 +2792,9 @@ void FVTermTest::FVTermReduceUpdatesTest() p_fvterm.p_addLayer(vwin); - for (auto y{0}; y < vterm->height; y++) + for (auto y{0}; y < vterm->size.height; y++) { - for (auto x{0}; x < vterm->width; x++) + for (auto x{0}; x < vterm->size.width; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, y).attr.bit.no_changes == false ); } @@ -2829,7 +2829,7 @@ void FVTermTest::FVTermReduceUpdatesTest() CPPUNIT_ASSERT ( vterm->changes[11].xmax == 9 ); CPPUNIT_ASSERT ( vterm->changes[11].trans_count == 0 ); - for (auto i{12}; i < vterm->height; i++) + for (auto i{12}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 80 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 0 ); @@ -2837,7 +2837,7 @@ void FVTermTest::FVTermReduceUpdatesTest() } // Reset xmin and xmax values + reduceTerminalLineUpdates() - for (auto i{0}; i < vterm->height; i++) + for (auto i{0}; i < vterm->size.height; i++) { vterm->changes[i].xmin = 0; vterm->changes[i].xmax = 14; @@ -2846,7 +2846,7 @@ void FVTermTest::FVTermReduceUpdatesTest() for (auto y{0}; y < 10; y++) { - for (auto x{0}; x < vterm->width; x++) + for (auto x{0}; x < vterm->size.width; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, y).attr.bit.no_changes == false ); } @@ -2856,12 +2856,12 @@ void FVTermTest::FVTermReduceUpdatesTest() for (auto x{3}; x < 14; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, 10).attr.bit.no_changes == true ); - for (auto x{14}; x < vterm->width; x++) + for (auto x{14}; x < vterm->size.width; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, 10).attr.bit.no_changes == false ); - for (auto y{11}; y < vterm->height; y++) + for (auto y{11}; y < vterm->size.height; y++) { - for (auto x{0}; x < vterm->width; x++) + for (auto x{0}; x < vterm->size.width; x++) CPPUNIT_ASSERT ( vterm->getFChar(x, y).attr.bit.no_changes == false ); } @@ -2896,7 +2896,7 @@ void FVTermTest::FVTermReduceUpdatesTest() CPPUNIT_ASSERT ( vterm->changes[11].xmax == 9 ); CPPUNIT_ASSERT ( vterm->changes[11].trans_count == 0 ); - for (auto i{12}; i < vterm->height; i++) + for (auto i{12}; i < vterm->size.height; i++) { CPPUNIT_ASSERT ( vterm->changes[i].xmin == 14 ); CPPUNIT_ASSERT ( vterm->changes[i].xmax == 13 ); @@ -3055,8 +3055,8 @@ void FVTermTest::getFVTermAreaTest() CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); // move area - vwin_area->offset_left += 2; - vwin_area->offset_top += 2; + vwin_area->position.x += 2; + vwin_area->position.y += 2; test::printOnArea (vwin_area, { 6, { {6, bg_char} } } ); p_fvterm.p_getArea (finalcut::FRect(finalcut::FPoint{5, 5}, finalcut::FSize{4, 4}), vwin_area); finalcut::FChar five_char = new_bg_char; @@ -3069,8 +3069,8 @@ void FVTermTest::getFVTermAreaTest() test::printArea (vwin_area); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left += 2; - vwin_area->offset_top += 2; + vwin_area->position.x += 2; + vwin_area->position.y += 2; test::printOnArea (vwin_area, { 6, { {6, bg_char} } } ); p_fvterm.p_getArea (finalcut::FRect(finalcut::FPoint{5, 5}, finalcut::FSize{4, 4}), vwin_area); test::printArea (vwin_area); @@ -3081,8 +3081,8 @@ void FVTermTest::getFVTermAreaTest() { 2, { {6, bg_char} } } } ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left += 1; - vwin_area->offset_top += 1; + vwin_area->position.x += 1; + vwin_area->position.y += 1; test::printOnArea (vwin_area, { 6, { {6, bg_char} } } ); p_fvterm.p_getArea (finalcut::FRect(finalcut::FPoint{5, 5}, finalcut::FSize{4, 4}), vwin_area); test::printArea (vwin_area); @@ -3092,8 +3092,8 @@ void FVTermTest::getFVTermAreaTest() { 3, { {6, bg_char} } } } ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left += 1; - vwin_area->offset_top += 1; + vwin_area->position.x += 1; + vwin_area->position.y += 1; test::printOnArea (vwin_area, { 6, { {6, bg_char} } } ); p_fvterm.p_getArea (finalcut::FRect(finalcut::FPoint{5, 5}, finalcut::FSize{4, 4}), vwin_area); test::printArea (vwin_area); @@ -3102,8 +3102,8 @@ void FVTermTest::getFVTermAreaTest() { 4, { {6, bg_char} } } } ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left += 1; - vwin_area->offset_top += 1; + vwin_area->position.x += 1; + vwin_area->position.y += 1; test::printOnArea (vwin_area, { 6, { {6, bg_char} } } ); p_fvterm.p_getArea (finalcut::FRect(finalcut::FPoint{5, 5}, finalcut::FSize{4, 4}), vwin_area); test::printArea (vwin_area); @@ -3151,17 +3151,17 @@ void FVTermTest::getFVTermAreaTest() { 1, { {1, forward_slash_char}, {1, one_char}, {1, four_char}, {1, back_slash_char}, {1, forward_slash_char}, {1, one_char} } } } ); CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); // Position independent - vwin_area->offset_left += 2; - vwin_area->offset_top += 2; + vwin_area->position.x += 2; + vwin_area->position.y += 2; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left = 512; - vwin_area->offset_top = 512; + vwin_area->position.x = 512; + vwin_area->position.y = 512; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left = -24; - vwin_area->offset_top = -100; + vwin_area->position.x = -24; + vwin_area->position.y = -100; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); - vwin_area->offset_left = 0; - vwin_area->offset_top = 0; + vwin_area->position.x = 0; + vwin_area->position.y = 0; CPPUNIT_ASSERT ( test::isAreaEqual(test_vwin_area, vwin_area) ); // Outside diff --git a/test/fvterm_check.h b/test/fvterm_check.h index 954e3ed2..f9e00e40 100644 --- a/test/fvterm_check.h +++ b/test/fvterm_check.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2022 Markus Gans * +* Copyright 2022-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -122,8 +122,8 @@ auto getAreaSize (finalcut::FVTerm::FTermArea* area) -> std::size_t if ( ! area ) return 0; - const auto full_width = std::size_t(area->width) + std::size_t(area->right_shadow); - const auto full_height = std::size_t(area->height) + std::size_t(area->bottom_shadow); + const auto full_width = std::size_t(area->size.width) + std::size_t(area->shadow.width); + const auto full_height = std::size_t(area->size.height) + std::size_t(area->shadow.height); return full_width * full_height; } @@ -138,10 +138,10 @@ auto isAreaEqual ( finalcut::FVTerm::FTermArea* area1 auto size2 = getAreaSize(area2); if ( size1 != size2 - || area1->width != area2->width - || area1->right_shadow != area2->right_shadow - || area1->height != area2->height - || area1->bottom_shadow != area2->bottom_shadow ) + || area1->size.width != area2->size.width + || area1->shadow.width != area2->shadow.width + || area1->size.height != area2->size.height + || area1->shadow.height != area2->shadow.height ) return false; for (std::size_t i{0U}; i < size1; i++) @@ -182,16 +182,16 @@ template < typename FCharT void printOnArea ( finalcut::FVTerm::FTermArea* area , const FCharT& fchar ) { - if ( area->cursor_x < 1 ) - area->cursor_x = 1; + if ( area->cursor.x < 1 ) + area->cursor.x = 1; - if ( area->cursor_y < 1 ) - area->cursor_y = 1; + if ( area->cursor.y < 1 ) + area->cursor.y = 1; - int ax = area->cursor_x - 1; - int ay = area->cursor_y - 1; - const int line_length = area->width + area->right_shadow; - const int line_height = area->height + area->bottom_shadow; + int ax = area->cursor.x - 1; + int ay = area->cursor.y - 1; + const int line_length = area->size.width + area->shadow.width; + const int line_height = area->size.height + area->shadow.height; const int size = line_length * line_height; if ( ay * line_length + ax > size ) @@ -199,17 +199,17 @@ void printOnArea ( finalcut::FVTerm::FTermArea* area auto tmp = ay * line_length + ax % size; ax = tmp % line_length; ay = tmp / line_height; - area->cursor_x = ax + 1; - area->cursor_y = ay + 1; + area->cursor.x = ax + 1; + area->cursor.y = ay + 1; } auto& ac = area->data[ay * line_length + ax]; // area character std::memcpy (&ac, &fchar, sizeof(ac)); // copy character to area - area->cursor_x = ((ax + 1) % line_length) + 1; - area->cursor_y = ((ax + 1) / line_length) + area->cursor_y; + area->cursor.x = ((ax + 1) % line_length) + 1; + area->cursor.y = ((ax + 1) / line_length) + area->cursor.y; - if ( area->cursor_y > line_height ) - area->cursor_y = ((area->cursor_y - 1) % line_height) + 1; + if ( area->cursor.y > line_height ) + area->cursor.y = ((area->cursor.y - 1) % line_height) + 1; } //---------------------------------------------------------------------- @@ -255,8 +255,8 @@ void printOnArea ( finalcut::FVTerm::FTermArea* area //---------------------------------------------------------------------- void printArea ( finalcut::FVTerm::FTermArea* area ) { - auto width = area->width + area->right_shadow; - auto height = area->height + area->bottom_shadow; + auto width = area->size.width + area->shadow.width; + auto height = area->size.height + area->shadow.height; auto size = getAreaSize(area); std::wcout << L'┌' << std::wstring(width, L'─') << L"┐\n"; @@ -305,8 +305,8 @@ void moveArea ( finalcut::FVTerm::FTermArea* area if ( ! area ) return; - area->offset_left = pos.getX(); - area->offset_top = pos.getY(); + area->position.x = pos.getX(); + area->position.y = pos.getY(); } } // namespace test