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

This commit is contained in:
Matthias Melcher 2018-12-29 02:03:49 +01:00
parent 29fe0c43df
commit 95ab1dd73e
3 changed files with 6 additions and 9 deletions

View File

@ -212,7 +212,7 @@ public:
and used to modify how the rest of the line is printed: 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, 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>'\@l'</tt> Use a LARGE (24 point) font
\li <tt>'\@m'</tt> Use a medium large (18 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 \li <tt>'\@s'</tt> Use a <SMALL>small</SMALL> (11 point) font

View File

@ -378,8 +378,7 @@ int Fl_Browser::item_height(void *item) const {
Fl_Font font = textfont(); // default font Fl_Font font = textfont(); // default font
int tsize = textsize(); // default size int tsize = textsize(); // default size
if ( format_char() ) { // can be NULL if ( format_char() ) { // can be NULL
while (*str==format_char()) { while (*str==format_char() && *str++ && *str!=format_char()) {
str++;
switch (*str++) { switch (*str++) {
case 'l': case 'L': tsize = 24; break; case 'l': case 'L': tsize = 24; break;
case 'm': case 'M': tsize = 18; 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 'C': while (isdigit(*str & 255)) str++; break; // skip a color number
case 'F': font = (Fl_Font)strtol(str,&str,10); break; case 'F': font = (Fl_Font)strtol(str,&str,10); break;
case 'S': tsize = strtol(str,&str,10); break; case 'S': tsize = strtol(str,&str,10); break;
case 0: case '@': str--;
case '.': goto END_FORMAT; case '.': goto END_FORMAT;
} }
} }
@ -458,9 +456,6 @@ int Fl_Browser::item_width(void *item) const {
case '.': case '.':
done = 1; done = 1;
break; break;
case '@':
str--;
done = 1;
} }
if (done) if (done)
@ -578,8 +573,6 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
break; break;
case '.': case '.':
goto BREAK; goto BREAK;
case '@':
str--; goto BREAK;
} }
} }
} }

View File

@ -45,6 +45,9 @@ That was a blank line above this.
@C2Green @C2Green
@C4Blue @C4Blue
@@ start line with '@'
@.@ alternative start line with '@'
You should try different browser types: You should try different browser types:
Fl_Browser Fl_Browser
Fl_Select_Browser Fl_Select_Browser
@ -164,6 +167,7 @@ int main(int argc, char **argv) {
browser->callback(b_cb); browser->callback(b_cb);
// browser->scrollbar_right(); // browser->scrollbar_right();
//browser->has_scrollbar(Fl_Browser::BOTH_ALWAYS); //browser->has_scrollbar(Fl_Browser::BOTH_ALWAYS);
//browser->format_char('#');
if (!browser->load(fname)) { if (!browser->load(fname)) {
int done = 0; int done = 0;
#ifdef _MSC_VER #ifdef _MSC_VER