Skip to content

Commit f04ab56

Browse files
committed
The FVTerm::addLayer() method decreases the range of saved vertical adjustments
1 parent 33d73b6 commit f04ab56

File tree

10 files changed

+47
-29
lines changed

10 files changed

+47
-29
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2025-11-18 Markus Gans <guru.mail@muenster.de>
2+
* The FVTerm::addLayer() method decreases the range of saved vertical
3+
adjustments
4+
15
2025-11-09 Markus Gans <guru.mail@muenster.de>
26
* The virtual terminal allows for faster tracking of changes by also
37
saving vertical adjustments

examples/rotozoomer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool is_benchmark, int num_lo
172172
inline auto RotoZoomer::getSine (int i, int shift) const noexcept -> float
173173
{
174174
// Sine lookup
175-
return sin_table[unsigned((i + shift + MAX_LOOPS) % MAX_LOOPS)];
175+
const auto effective_index = i + shift;
176+
const auto index = (effective_index % MAX_LOOPS + MAX_LOOPS) % MAX_LOOPS;
177+
return sin_table[unsigned(index)];
176178
}
177179

178180
//----------------------------------------------------------------------

examples/xpmimage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* *
44
* This file is part of the FINAL CUT widget toolkit *
55
* *
6-
* Copyright 2022-2023 Markus Gans *
6+
* Copyright 2022-2025 Markus Gans *
77
* *
88
* FINAL CUT is free software; you can redistribute it and/or modify *
99
* it under the terms of the GNU Lesser General Public License as *
@@ -906,7 +906,7 @@ void XpmImage::getValues (const std::string& line)
906906
throw std::invalid_argument("less 4 numbers");
907907

908908
if ( num_colors > 65535 || cpp > 15 )
909-
throw std::out_of_range("values too high");
909+
throw std::out_of_range("XpmImage::getValues values too high");
910910
}
911911

912912
//----------------------------------------------------------------------

final/util/fstring.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ FString::FString (size_type len, const UniChar& c)
8080

8181
//----------------------------------------------------------------------
8282
FString::FString (const FString& s) // copy constructor
83-
{
84-
internal_assign(std::wstring{s.string});
85-
}
83+
: string{s.string}
84+
{ }
8685

8786
//----------------------------------------------------------------------
8887
FString::FString (FString&& s) noexcept // move constructor
@@ -859,7 +858,7 @@ auto FString::setFormatedNumber (uInt64 num, FString separator) -> FString&
859858
auto FString::insert (const FString& s, int pos) -> const FString&
860859
{
861860
if ( isNegative(pos) || uInt(pos) > string.length() )
862-
throw std::out_of_range("");
861+
throw std::out_of_range("FString::insert index out of range");
863862

864863
string.insert(uInt(pos), s.string, 0, s.getLength());
865864
return *this;

final/vterm/fvterm.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,9 @@ void FVTerm::addLayer (FTermArea* area) const noexcept
924924
prev_has_no_trans = has_no_trans;
925925
}
926926

927+
if ( line_changes_batch.empty() )
928+
return;
929+
927930
for (const auto& line : line_changes_batch)
928931
{
929932
const auto line_xmin = static_cast<unsigned>(line.xmin);
@@ -967,8 +970,14 @@ void FVTerm::addLayer (FTermArea* area) const noexcept
967970
}
968971
}
969972

970-
vterm->changes_in_row.ymin = std::min(vterm->changes_in_row.ymin, uInt(area_y));
971-
vterm->changes_in_row.ymax = std::max(vterm->changes_in_row.ymax, uInt(area_y + y_end - 1));
973+
const auto& first = line_changes_batch.front();
974+
const auto& last = line_changes_batch.back();
975+
const auto begin = uInt(area_y + first.ypos - y_start);
976+
const auto end = uInt(area_y + last.ypos + last.count - 1 - y_start);
977+
978+
auto& changes_in_row = vterm->changes_in_row;
979+
changes_in_row.ymin = std::min(changes_in_row.ymin, begin);
980+
changes_in_row.ymax = std::max(changes_in_row.ymax, end);
972981
vterm->has_changes = true;
973982
updateVTermCursor(area);
974983
}

final/widget/fbutton.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* *
44
* This file is part of the FINAL CUT widget toolkit *
55
* *
6-
* Copyright 2012-2024 Markus Gans *
6+
* Copyright 2012-2025 Markus Gans *
77
* *
88
* FINAL CUT is free software; you can redistribute it and/or modify *
99
* it under the terms of the GNU Lesser General Public License as *
@@ -601,9 +601,11 @@ inline void FButton::resetStyle() const
601601
}
602602

603603
//----------------------------------------------------------------------
604-
inline void FButton::printTrailingSpaces (std::size_t pos)
604+
inline void FButton::printTrailingSpaces()
605605
{
606-
for (pos = center_offset + column_width; pos < getWidth() - 2; pos++)
606+
const auto start = center_offset + column_width;
607+
608+
for (std::size_t pos = start; pos < getWidth() - 2; pos++)
607609
print (space_char); //
608610
}
609611

@@ -622,7 +624,7 @@ inline void FButton::drawButtonTextLine (const FString& button_text)
622624
printButtonText (button_text, pos);
623625
printEllipsis(); // Print ellipsis if necessary
624626
resetStyle(); // Reset style for monochrome or low color terminal
625-
printTrailingSpaces (pos);
627+
printTrailingSpaces();
626628
}
627629

628630
//----------------------------------------------------------------------

final/widget/fbutton.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* *
44
* This file is part of the FINAL CUT widget toolkit *
55
* *
6-
* Copyright 2012-2024 Markus Gans *
6+
* Copyright 2012-2025 Markus Gans *
77
* *
88
* FINAL CUT is free software; you can redistribute it and/or modify *
99
* it under the terms of the GNU Lesser General Public License as *
@@ -143,7 +143,7 @@ class FButton : public FWidget
143143
void resetHotkeyStyle() const;
144144
void printEllipsis();
145145
void resetStyle() const;
146-
void printTrailingSpaces (std::size_t);
146+
void printTrailingSpaces();
147147
void drawButtonTextLine (const FString&);
148148
void draw() override;
149149
void initializeDrawing();

final/widget/ftextview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void FTextView::replaceRange (const FString& str, int from, int to)
323323
}
324324
catch (const std::out_of_range&)
325325
{
326-
throw std::out_of_range(""); // Invalid range
326+
throw std::out_of_range("FTextView::replaceRange index out of range"); // Invalid range
327327
}
328328

329329
insert(str, from);
@@ -333,7 +333,7 @@ void FTextView::replaceRange (const FString& str, int from, int to)
333333
void FTextView::deleteRange (int from, int to)
334334
{
335335
if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
336-
throw std::out_of_range(""); // Invalid range
336+
throw std::out_of_range("FTextView::deleteRange index out of range"); // Invalid range
337337

338338
auto iter = data.cbegin();
339339
data.erase (iter + from, iter + to + 1);

test/flogger-test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* *
44
* This file is part of the FINAL CUT widget toolkit *
55
* *
6-
* Copyright 2020-2023 Markus Gans *
6+
* Copyright 2020-2025 Markus Gans *
77
* *
88
* FINAL CUT is free software; you can redistribute it and/or modify *
99
* it under the terms of the GNU Lesser General Public License as *
@@ -304,7 +304,7 @@ void FLoggerTest::fileTest()
304304
std::size_t i{0};
305305

306306
while ( std::getline(file_stream, line) )
307-
{
307+
{
308308
CPPUNIT_ASSERT ( line == strings[i] );
309309
i++;
310310
}

test/fvterm-test.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ void FVTermTest::FVTermChildAreaPrintTest()
20002000
auto&& vterm = p_fvterm.p_getVirtualTerminal();
20012001
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 24 );
20022002
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 0 );
2003-
2003+
20042004
// Create the virtual window for the p_fvterm object
20052005
finalcut::FRect geometry {finalcut::FPoint{34, 1}, finalcut::FSize{12, 12}};
20062006
auto vwin_ptr = p_fvterm.p_createArea (geometry);
@@ -2044,7 +2044,6 @@ void FVTermTest::FVTermChildAreaPrintTest()
20442044
CPPUNIT_ASSERT ( vwin->visible );
20452045
CPPUNIT_ASSERT ( ! vterm->has_changes );
20462046
p_fvterm.p_addLayer(vwin);
2047-
CPPUNIT_ASSERT ( vterm->has_changes );
20482047
CPPUNIT_ASSERT ( p_fvterm.value_ref() == 1 );
20492048
p_fvterm.p_addLayer(vwin);
20502049
CPPUNIT_ASSERT ( p_fvterm.value_ref() == 2 );
@@ -2064,9 +2063,6 @@ void FVTermTest::FVTermChildAreaPrintTest()
20642063
CPPUNIT_ASSERT ( vterm->changes_in_line[i].trans_count == 0 );
20652064
}
20662065

2067-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 1 );
2068-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 12 );
2069-
20702066
CPPUNIT_ASSERT ( ! vwin->has_changes );
20712067
p_fvterm.print() << finalcut::FColorPair(finalcut::FColor::Red, finalcut::FColor::White)
20722068
<< finalcut::FPoint(36, 4) << L"=========="
@@ -2077,14 +2073,20 @@ void FVTermTest::FVTermChildAreaPrintTest()
20772073
<< finalcut::FPoint(36, 9) << L"= ="
20782074
<< finalcut::FPoint(36, 10) << L"= ="
20792075
<< finalcut::FPoint(36, 11) << L"==========";
2076+
20802077
CPPUNIT_ASSERT ( vwin->has_changes );
20812078
test::printArea (vwin);
20822079

20832080
p_fvterm.p_addLayer(vwin);
2081+
CPPUNIT_ASSERT ( ! vterm->has_changes );
2082+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 24 );
2083+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 0 );
20842084
vwin->visible = true; // show()
20852085
vterm->has_changes = false;
20862086
p_fvterm.p_addLayer(vwin);
20872087
CPPUNIT_ASSERT ( vterm->has_changes );
2088+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 3 );
2089+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 10 );
20882090

20892091
for (auto i{0}; i < 3; i++)
20902092
{
@@ -2107,8 +2109,8 @@ void FVTermTest::FVTermChildAreaPrintTest()
21072109
CPPUNIT_ASSERT ( vterm->changes_in_line[i].trans_count == 0 );
21082110
}
21092111

2110-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 1 );
2111-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 12 );
2112+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 3 );
2113+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 10 );
21122114

21132115
finalcut::FChar space_char_1 =
21142116
{
@@ -3106,7 +3108,7 @@ void FVTermTest::FVTermReduceUpdatesTest()
31063108

31073109
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 0 );
31083110
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 14 );
3109-
3111+
31103112
finalcut::FApplication::start();
31113113
finalcut::FApplication fapp(0, nullptr);
31123114
p_fvterm.p_finishDrawing();
@@ -3198,8 +3200,8 @@ void FVTermTest::FVTermReduceUpdatesTest()
31983200
CPPUNIT_ASSERT ( vterm->changes_in_line[i].trans_count == 0 );
31993201
}
32003202

3201-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 0 );
3202-
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 14 );
3203+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymin == 6 );
3204+
CPPUNIT_ASSERT ( vterm->changes_in_row.ymax == 11 );
32033205

32043206
// Reset xmin and xmax values + reduceTerminalLineUpdates()
32053207
for (auto i{0}; i < vterm->size.height; i++)

0 commit comments

Comments
 (0)