Browse Source

Fixing STR #2901, wrongly escaping the formatting character code in Fl_Browser.

pull/11/head
Matthias Melcher 7 years ago
parent
commit
95ab1dd73e
  1. 2
      FL/Fl_Browser.H
  2. 9
      src/Fl_Browser.cxx
  3. 4
      test/browser.cxx

2
FL/Fl_Browser.H

@ -212,7 +212,7 @@ public: @@ -212,7 +212,7 @@ public:
and used to modify how the rest of the line is printed:
\li <tt>'\@.'</tt> Print rest of line, don't look for more '\@' signs
\li <tt>'\@\@'</tt> Print rest of line starting with '\@'
\li <tt>'\@\@'</tt> Doubling the format character prints the format character once, followed by the rest of line
\li <tt>'\@l'</tt> Use a LARGE (24 point) font
\li <tt>'\@m'</tt> Use a medium large (18 point) font
\li <tt>'\@s'</tt> Use a <SMALL>small</SMALL> (11 point) font

9
src/Fl_Browser.cxx

@ -378,8 +378,7 @@ int Fl_Browser::item_height(void *item) const { @@ -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 { @@ -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 { @@ -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 { @@ -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;
}
}
}

4
test/browser.cxx

@ -45,6 +45,9 @@ That was a blank line above this. @@ -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) { @@ -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

Loading…
Cancel
Save