diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-03-12 17:37:42 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-03-12 17:37:42 +0100 |
| commit | aa02a0297bed652ed4b8df4bd6e2dd1c1dc7c160 (patch) | |
| tree | ef9afe7515b9cd2b361d422a2b23123800414b43 /src | |
| parent | d30e4aa0af9d21f8b58ccd04f63f529ffcaf6add (diff) | |
Fix trimming of trailing whitespace in Fl_Terminal::text()
... and document a missing parameter.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Terminal.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Fl_Terminal.cxx b/src/Fl_Terminal.cxx index 566cb0820..4e3c8e45d 100644 --- a/src/Fl_Terminal.cxx +++ b/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); |
