Skip to content

Commit b77ea92

Browse files
committed
Avoid printing scrollbar overrun on emit callback
1 parent bdc141f commit b77ea92

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2023-04-04 Markus Gans <guru.mail@muenster.de>
2+
* Avoid printing scrollbar overrun on emit callback
3+
14
2023-04-02 Markus Gans <guru.mail@muenster.de>
25
* Implementation of the mouse selection in the FTextView. Can be
36
activated by setSelectable()

final/widget/fscrollbar.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,10 @@ void FScrollbar::avoidScrollOvershoot()
763763
//----------------------------------------------------------------------
764764
void FScrollbar::processScroll()
765765
{
766+
startDrawing(); // Avoid printing an overshoot on the emit callback
766767
emitCallback("change-value");
767768
avoidScrollOvershoot();
769+
finishDrawing();
768770
}
769771

770772
//----------------------------------------------------------------------

final/widget/ftextview.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ auto FTextView::getSelectedText() const -> FString
121121
line = iter->text.toWString();
122122

123123
if ( iter == last )
124-
line = line.substr(0, end_col + 1);
124+
line.resize(end_col + 1);
125125

126126
selected_text += FString(line) + L'\n'; // Add newline character
127127
++iter;

test/fkeyboard-test.cpp

+6-3
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 2018-2023 Markus Gans *
6+
* Copyright 2018-2024 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 *
@@ -330,7 +330,8 @@ class FKeyboardTest : public CPPUNIT_NS::TestFixture
330330
// End of test suite definition
331331
CPPUNIT_TEST_SUITE_END();
332332
void init();
333-
void input (std::string);
333+
template<typename CharT>
334+
void input (CharT&&);
334335
void processInput();
335336
void clear();
336337
void keyPressed();
@@ -3183,14 +3184,16 @@ void FKeyboardTest::init()
31833184
}
31843185

31853186
//----------------------------------------------------------------------
3186-
void FKeyboardTest::input (std::string s)
3187+
template<typename CharT>
3188+
void FKeyboardTest::input (CharT&& string)
31873189
{
31883190
// Simulates keystrokes
31893191

31903192
const char EOT = 0x04; // End of Transmission
31913193
auto stdin_no = finalcut::FTermios::getStdIn();
31923194
fflush(stdout);
31933195

3196+
std::string s = std::forward<CharT>(string);
31943197
std::string::const_iterator iter;
31953198
iter = s.begin();
31963199

0 commit comments

Comments
 (0)