|
|
commit aa02a0297bed652ed4b8df4bd6e2dd1c1dc7c160
Author: Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Tue Mar 12 17:37:42 2024 +0100
Commit: Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Tue Mar 12 17:37:42 2024 +0100
Fix trimming of trailing whitespace in Fl_Terminal::text()
... and document a missing parameter.
src/Fl_Terminal.cxx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git src/Fl_Terminal.cxx src/Fl_Terminal.cxx
index 566cb08..4e3c8e4 100644
--- src/Fl_Terminal.cxx
+++ src/Fl_Terminal.cxx
@@ -3905,6 +3905,8 @@ int Fl_Terminal::handle(int e) {
free((void*)s); // free() the copy when done!
\endcode
+ \param[in] lines_below_cursor include lines below cursor, default: false
+
\return A string allocated with strdup(3) which must be free'd, text is UTF-8.
*/
const char* Fl_Terminal::text(bool lines_below_cursor) const {
@@ -3922,8 +3924,8 @@ const char* Fl_Terminal::text(bool lines_below_cursor) const {
const char *s = u8c->text_utf8(); // first byte of char
for (int i=0; i<u8c->length(); i++) lines += *s++; // append all bytes in multibyte char
// Count any trailing whitespace to trim
- if (u8c->length()==1 && *s==' ') trim++; // trailing whitespace? trim
- else trim = 0; // non-whitespace? don't trim
+ if (u8c->length()==1 && s[-1]==' ') trim++; // trailing whitespace? trim
+ else trim = 0; // non-whitespace? don't trim
}
// trim trailing whitespace from each line, if any
if (trim) lines.resize(lines.size() - trim);
[ Direct Link to Message ] | |
|
| |