From b0b5282c9af29f058378bc2c2fcaa38ff3a4e7ee Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 26 Jun 2017 23:35:34 +0200 Subject: [PATCH] FString::rtrim() and FString::left() now return an FString object with the correct character length --- ChangeLog | 4 ++++ src/flistbox.cpp | 4 ++-- src/fstring.cpp | 5 ++++- test/listbox.cpp | 3 --- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 231f2570..58fdeea3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-06-26 Markus Gans + * FString::rtrim() and FString::left() now return an FString + object with the correct character length + 2017-06-18 Markus Gans * Move the dragScroll enumeration into the fc namespace diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 0b2ddeea..53fc521a 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -384,7 +384,7 @@ void FListBox::clear() void FListBox::onKeyPress (FKeyEvent* ev) { int element_count = int(getCount()); - int padding_space = 2; // 1 leading space + 1 tailing space + const int padding_space = 2; // 1 leading space + 1 tailing space int current_before = current; int xoffset_before = xoffset; int xoffset_end = max_line_width - getClientWidth() + padding_space; @@ -1572,7 +1572,7 @@ void FListBox::drawList() uInt last_pos = uInt(current - yoffset) - 1; uInt current_pos = uInt(last_current - yoffset) - 1; start = std::min(last_pos, current_pos); - end = std::max(last_pos, current_pos)+1; + end = std::max(last_pos, current_pos) + 1; } iter = index2iterator(int(start) + yoffset); diff --git a/src/fstring.cpp b/src/fstring.cpp index 844cfcfe..a9694a7b 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -829,7 +829,8 @@ FString FString::rtrim() const p = s.string; last = p + length; - while ( std::iswspace(wint_t(*--last)) && last > p ); + while ( std::iswspace(wint_t(*--last)) && last > p ) + s.length--; if ( last == p && std::iswspace(wint_t(*last)) ) s.clear(); @@ -873,6 +874,7 @@ FString FString::left (uInt len) const return s; p = s.string; + s.length = len; *(p+len) = '\0'; return s; } @@ -1572,6 +1574,7 @@ FString FString::replace (const FString& from, const FString& to) p++; } } + return s; } diff --git a/test/listbox.cpp b/test/listbox.cpp index 1c054847..6ab7124b 100644 --- a/test/listbox.cpp +++ b/test/listbox.cpp @@ -97,9 +97,6 @@ Listbox::Listbox (FWidget* parent) list2->setGeometry(21, 1, 10, 10); list2->setText ("double"); - for (double i=1; i<=15; i++) - double_list->push_back(2*i + (i/100)); - // // Import via lazy conversion on print //