FLTK logo

[master] aa02a02 - Fix trimming of trailing whitespace in Fl_Terminal::text()

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] aa02a02 - Fix trimming of trailing whitespace in Fl_Terminal::text() "Albrecht Schlosser" 09:47 Mar 12  
 
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 ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.