summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2018-12-28 17:25:28 -0800
committerGitHub <noreply@github.com>2018-12-28 17:25:28 -0800
commitbf9dfa2afdaa7a20d1152151519d3e34a1758a92 (patch)
tree8e7da81c8be479870979fc76ef29e92b50c8119d
parent6097bde83cfbaadf2247ae25c9272ee4a821fb35 (diff)
parentbf48acdbe53bd9fdebaa731831cea946f394350d (diff)
Merge pull request #11 from MatthiasWM/master
Fixing STR #2901, Fl_Browser formatting char
-rw-r--r--FL/Fl_Browser.H6
-rw-r--r--src/Fl_Browser.cxx9
-rw-r--r--test/browser.cxx9
3 files changed, 14 insertions, 10 deletions
diff --git a/FL/Fl_Browser.H b/FL/Fl_Browser.H
index 467c6bf0c..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 <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
@@ -222,8 +223,9 @@ public:
font (sets font to FL_COURIER)
\li <tt>'\@c'</tt> Center the line horizontally
\li <tt>'\@r'</tt> Right-justify the text
+ \li <tt>'\@N'</tt> Use fl_inactive_color() to draw the text
\li <tt>'\@B0', '\@B1', ... '\@B255'</tt> Fill the backgound with
- fl_color(n)
+ fl_color(n)
\li <tt>'\@C0', '\@C1', ... '\@C255'</tt> Use fl_color(n) to draw the text
\li <tt>'\@F0', '\@F1', ...</tt> Use fl_font(n) to draw the text
\li <tt>'\@S1', '\@S2', ...</tt> Use point size n to draw the text
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx
index 196796b97..72aa8de37 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..749a7ed83 100644
--- a/test/browser.cxx
+++ b/test/browser.cxx
@@ -44,6 +44,14 @@ That was a blank line above this.
@C1RED
@C2Green
@C4Blue
+@N@.Inactive
+
+@@ 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
@@ -164,6 +172,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