From 95ab1dd73e9c5ea845ce03340b2861ea8a652b7e Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 29 Dec 2018 02:03:49 +0100 Subject: Fixing STR #2901, wrongly escaping the formatting character code in Fl_Browser. --- FL/Fl_Browser.H | 2 +- src/Fl_Browser.cxx | 9 +-------- test/browser.cxx | 4 ++++ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/FL/Fl_Browser.H b/FL/Fl_Browser.H index 467c6bf0c..350dbf709 100644 --- a/FL/Fl_Browser.H +++ b/FL/Fl_Browser.H @@ -212,7 +212,7 @@ public: and used to modify how the rest of the line is printed: \li '\@.' Print rest of line, don't look for more '\@' signs - \li '\@\@' Print rest of line starting with '\@' + \li '\@\@' Doubling the format character prints the format character once, followed by the rest of line \li '\@l' Use a LARGE (24 point) font \li '\@m' Use a medium large (18 point) font \li '\@s' Use a small (11 point) font diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx index 7621c6598..375d3ad33 100644 --- a/src/Fl_Browser.cxx +++ b/src/Fl_Browser.cxx @@ -378,8 +378,7 @@ int Fl_Browser::item_height(void *item) const { Fl_Font font = textfont(); // default font int tsize = textsize(); // default size if ( format_char() ) { // can be NULL - while (*str==format_char()) { - str++; + while (*str==format_char() && *str++ && *str!=format_char()) { switch (*str++) { case 'l': case 'L': tsize = 24; break; case 'm': case 'M': tsize = 18; break; @@ -391,7 +390,6 @@ int Fl_Browser::item_height(void *item) const { case 'C': while (isdigit(*str & 255)) str++; break; // skip a color number case 'F': font = (Fl_Font)strtol(str,&str,10); break; case 'S': tsize = strtol(str,&str,10); break; - case 0: case '@': str--; case '.': goto END_FORMAT; } } @@ -458,9 +456,6 @@ int Fl_Browser::item_width(void *item) const { case '.': done = 1; break; - case '@': - str--; - done = 1; } if (done) @@ -578,8 +573,6 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const { break; case '.': goto BREAK; - case '@': - str--; goto BREAK; } } } diff --git a/test/browser.cxx b/test/browser.cxx index 48edd302b..a3485ca15 100644 --- a/test/browser.cxx +++ b/test/browser.cxx @@ -45,6 +45,9 @@ That was a blank line above this. @C2Green @C4Blue +@@ start line with '@' +@.@ alternative start line with '@' + You should try different browser types: Fl_Browser Fl_Select_Browser @@ -164,6 +167,7 @@ int main(int argc, char **argv) { browser->callback(b_cb); // browser->scrollbar_right(); //browser->has_scrollbar(Fl_Browser::BOTH_ALWAYS); + //browser->format_char('#'); if (!browser->load(fname)) { int done = 0; #ifdef _MSC_VER -- cgit v1.2.3 From c099837a3e80e8f2c1634e5f1861d268e82622fe Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 29 Dec 2018 02:08:40 +0100 Subject: Also testing # as a format_char() --- test/browser.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/browser.cxx b/test/browser.cxx index a3485ca15..e0ea9e799 100644 --- a/test/browser.cxx +++ b/test/browser.cxx @@ -47,6 +47,10 @@ That was a blank line above this. @@ start line with '@' @.@ alternative start line with '@' +@l@@ start tall line with '@' +@s@@ start small line with '@' +#s## start line with '#' +#s#.# alternative start line with '#' You should try different browser types: Fl_Browser -- cgit v1.2.3 From bf48acdbe53bd9fdebaa731831cea946f394350d Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 29 Dec 2018 02:16:40 +0100 Subject: Adding documentation for '@N', inactive color. --- FL/Fl_Browser.H | 6 ++++-- test/browser.cxx | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/FL/Fl_Browser.H b/FL/Fl_Browser.H index 350dbf709..191d98271 100644 --- a/FL/Fl_Browser.H +++ b/FL/Fl_Browser.H @@ -212,7 +212,8 @@ public: and used to modify how the rest of the line is printed: \li '\@.' Print rest of line, don't look for more '\@' signs - \li '\@\@' Doubling the format character prints the format character once, followed by the rest of line + \li '\@\@' Doubling the format character prints the format + character once, followed by the rest of line \li '\@l' Use a LARGE (24 point) font \li '\@m' Use a medium large (18 point) font \li '\@s' Use a small (11 point) font @@ -222,8 +223,9 @@ public: font (sets font to FL_COURIER) \li '\@c' Center the line horizontally \li '\@r' Right-justify the text + \li '\@N' Use fl_inactive_color() to draw the text \li '\@B0', '\@B1', ... '\@B255' Fill the backgound with - fl_color(n) + fl_color(n) \li '\@C0', '\@C1', ... '\@C255' Use fl_color(n) to draw the text \li '\@F0', '\@F1', ... Use fl_font(n) to draw the text \li '\@S1', '\@S2', ... Use point size n to draw the text diff --git a/test/browser.cxx b/test/browser.cxx index e0ea9e799..749a7ed83 100644 --- a/test/browser.cxx +++ b/test/browser.cxx @@ -44,6 +44,7 @@ That was a blank line above this. @C1RED @C2Green @C4Blue +@N@.Inactive @@ start line with '@' @.@ alternative start line with '@' -- cgit v1.2.3