Skip to content

Commit

Permalink
Avoid printing scrollbar overrun on emit callback
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Apr 4, 2024
1 parent bdc141f commit b77ea92
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023-04-04 Markus Gans <guru.mail@muenster.de>
* Avoid printing scrollbar overrun on emit callback

2023-04-02 Markus Gans <guru.mail@muenster.de>
* Implementation of the mouse selection in the FTextView. Can be
activated by setSelectable()
Expand Down
2 changes: 2 additions & 0 deletions final/widget/fscrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,10 @@ void FScrollbar::avoidScrollOvershoot()
//----------------------------------------------------------------------
void FScrollbar::processScroll()
{
startDrawing(); // Avoid printing an overshoot on the emit callback
emitCallback("change-value");
avoidScrollOvershoot();
finishDrawing();
}

//----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion final/widget/ftextview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ auto FTextView::getSelectedText() const -> FString
line = iter->text.toWString();

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

selected_text += FString(line) + L'\n'; // Add newline character
++iter;
Expand Down
9 changes: 6 additions & 3 deletions test/fkeyboard-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2023 Markus Gans *
* Copyright 2018-2024 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 *
Expand Down Expand Up @@ -330,7 +330,8 @@ class FKeyboardTest : public CPPUNIT_NS::TestFixture
// End of test suite definition
CPPUNIT_TEST_SUITE_END();
void init();
void input (std::string);
template<typename CharT>
void input (CharT&&);
void processInput();
void clear();
void keyPressed();
Expand Down Expand Up @@ -3183,14 +3184,16 @@ void FKeyboardTest::init()
}

//----------------------------------------------------------------------
void FKeyboardTest::input (std::string s)
template<typename CharT>
void FKeyboardTest::input (CharT&& string)
{
// Simulates keystrokes

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

std::string s = std::forward<CharT>(string);
std::string::const_iterator iter;
iter = s.begin();

Expand Down

0 comments on commit b77ea92

Please sign in to comment.