Added textcolor() and color(), doc fixes.

textcolor() needed for consistency, color() behavior documented.

Both added to the test/terminal app.

Elaborated on the special background "see through" color value + behavior,
tested with color() in test/terminal app.
This commit is contained in:
Greg Ercolano 2023-11-14 12:23:23 -08:00
parent 155909ec30
commit 605328e045
3 changed files with 231 additions and 172 deletions

View File

@ -250,6 +250,10 @@
- The printf() and vprintf() functions are limited to strings no longer than - The printf() and vprintf() functions are limited to strings no longer than
1024 characters (including NULL). For printing longer strings, use append() 1024 characters (including NULL). For printing longer strings, use append()
which has no string limits. which has no string limits.
\par
- For background colors textbgcolor() and textbgcolor_default(), the special
color value 0xffffffff lets the widget's box() color() show through behind
the text.
**/ **/
class Fl_Terminal : public Fl_Group { class Fl_Terminal : public Fl_Group {
@ -953,6 +957,8 @@ public:
// API: Text font/size/color // API: Text font/size/color
void textfont(Fl_Font val); void textfont(Fl_Font val);
void textsize(Fl_Fontsize val); void textsize(Fl_Fontsize val);
void textcolor(Fl_Color val);
void color(Fl_Color val);
void textfgcolor(Fl_Color val); void textfgcolor(Fl_Color val);
void textbgcolor(Fl_Color val); void textbgcolor(Fl_Color val);
void textfgcolor_default(Fl_Color val); void textfgcolor_default(Fl_Color val);
@ -961,6 +967,10 @@ public:
Fl_Font textfont(void) const { return current_style_.fontface(); } Fl_Font textfont(void) const { return current_style_.fontface(); }
/// Return text font size used to draw all text in the terminal. /// Return text font size used to draw all text in the terminal.
Fl_Fontsize textsize(void) const { return current_style_.fontsize(); } Fl_Fontsize textsize(void) const { return current_style_.fontsize(); }
// Return base widget Fl_Group's box() color()
Fl_Color color(void) const { return Fl_Group::color(); }
// Return textcolor(). This is a convenience method that returns textfgcolor_default()
Fl_Color textcolor(void) const { return textfgcolor_default(); }
/// Return text's current foreground color. /// Return text's current foreground color.
Fl_Color textfgcolor(void) const { return current_style_.fgcolor(); } Fl_Color textfgcolor(void) const { return current_style_.fgcolor(); }
/// Return text's current background color. /// Return text's current background color.

View File

@ -603,7 +603,7 @@ int Fl_Terminal::Utf8Char::pwidth_int(void) const {
// influenced by the attribute bits /if/ \p col matches the \p grp widget's own color(). // influenced by the attribute bits /if/ \p col matches the \p grp widget's own color().
// //
Fl_Color Fl_Terminal::Utf8Char::attr_color(Fl_Color col, const Fl_Widget *grp) const { Fl_Color Fl_Terminal::Utf8Char::attr_color(Fl_Color col, const Fl_Widget *grp) const {
// Don't modify color if it's the special 'see thru' color 0x0 or widget's color() // Don't modify color if it's the special 'see thru' color 0xffffffff or widget's color()
if (grp && ((col == 0xffffffff) || (col == grp->color()))) return grp->color(); if (grp && ((col == 0xffffffff) || (col == grp->color()))) return grp->color();
switch (attrib_ & (Fl_Terminal::BOLD|Fl_Terminal::DIM)) { switch (attrib_ & (Fl_Terminal::BOLD|Fl_Terminal::DIM)) {
case 0: return col; // not bold or dim? no change case 0: return col; // not bold or dim? no change
@ -1445,7 +1445,36 @@ void Fl_Terminal::textbgcolor_xterm(uchar val) {
} }
/** /**
Set text foreground drawing color to fltk color \p val. Set the text color for the terminal.
This is a convenience method that sets *both* textfgcolor() and textfgcolor_default(),
ensuring both are set to the same value.
*/
void Fl_Terminal::textcolor(Fl_Color val) {
textfgcolor(val);
textfgcolor_default(val);
}
/**
Sets the background color for the terminal's Fl_Group::box().
If the textbgcolor() and textbgcolor_default() are set to the special
"see through" color 0xffffffff when any text was added, changing color()
affects the color that shows through behind that existing text.
Otherwise, whatever specific background color was set for existing text
will persist after changing color().
To see the effects of a change to color(), follow up with a call to redraw().
The default value is 0x0.
*/
void Fl_Terminal::color(Fl_Color val) {
Fl_Group::color(val);
}
/**
Set text foreground drawing color to fltk color \p val used by any new text added.
Use this for temporary color changes, similar to \<ESC\>[38;2;\<R\>;\<G\>;\<B\>m Use this for temporary color changes, similar to \<ESC\>[38;2;\<R\>;\<G\>;\<B\>m
This setting does _not_ affect the 'default' text colors used by \<ESC\>[0m, This setting does _not_ affect the 'default' text colors used by \<ESC\>[0m,
@ -1465,12 +1494,11 @@ void Fl_Terminal::textfgcolor(Fl_Color val) {
} }
/** /**
Set text background color to fltk color \p val. Set text background color to fltk color \p val used by any new text added.
Use this for temporary color changes, similar to \<ESC\>[48;2;\<R\>;\<G\>;\<B\>m Use this for temporary color changes, similar to \<ESC\>[48;2;\<R\>;\<G\>;\<B\>m
This setting does _not_ affect the 'default' text colors used by \<ESC\>[0m, This setting does _not_ affect the 'default' text colors used by \<ESC\>[0m,
\<ESC\>c, reset_terminal(), etc. To change both the current _and_ \<ESC\>c, reset_terminal(), etc. To set that too, also set textbgcolor_default(Fl_Color), e.g.
default bg color, also use textbgcolor_default(Fl_Color). Example:
\par \par
\code \code
// Set both 'current' and 'default' colors // Set both 'current' and 'default' colors
@ -1479,6 +1507,10 @@ void Fl_Terminal::textfgcolor(Fl_Color val) {
tty->textbgcolor_default(darkamber); // set 'default' bg color used by ESC[0m reset tty->textbgcolor_default(darkamber); // set 'default' bg color used by ESC[0m reset
\endcode \endcode
The special color value 0xffffffff (all ff's) is the "see through" color, which lets
the widget's own Fl_Group::color() show through behind the text. This special text background
color is the _default_, and is what most situations need.
\see textbgcolor_default(Fl_Color) \see textbgcolor_default(Fl_Color)
*/ */
void Fl_Terminal::textbgcolor(Fl_Color val) { void Fl_Terminal::textbgcolor(Fl_Color val) {
@ -1489,8 +1521,7 @@ void Fl_Terminal::textbgcolor(Fl_Color val) {
Set the default text foreground color used by \c \<ESC\>c, \c \<ESC\>[0m, Set the default text foreground color used by \c \<ESC\>c, \c \<ESC\>[0m,
and reset_terminal(). and reset_terminal().
Does not affect the 'current' text fg color; use textfgcolor(Fl_Color) to Does not affect the 'current' text foreground color; use textfgcolor(Fl_Color) to set that.
set that.
\see textfgcolor(Fl_Color) \see textfgcolor(Fl_Color)
*/ */
@ -1499,11 +1530,14 @@ void Fl_Terminal::textfgcolor_default(Fl_Color val) {
} }
/** /**
Set the default text background color used by \c \<ESC\>c, \c \<ESC\>[0m, Set the default text background color used by any new text added
and reset_terminal(). after a reset (\c \<ESC\>c, \c \<ESC\>[0m, or reset_terminal()).
Does not affect the 'current' text fg color; use textbgcolor(Fl_Color) to Does not affect the 'current' text background color; use textbgcolor(Fl_Color) to set that.
set that.
The special color value 0xffffffff (all ff's) is the "see through" color, which lets
the widget's own Fl_Group::color() show through behind the text. This special text background
color is the _default_, and is what most situations need.
\see textbgcolor(Fl_Color) \see textbgcolor(Fl_Color)
*/ */
@ -2240,8 +2274,8 @@ void Fl_Terminal::handle_SGR(void) { // ESC[...m?
case 0: case 0:
// RGB mode values? // RGB mode values?
switch (val) { switch (val) {
case 38: // fg RGB mode? e.g. ESC[38;2;<R>;<G>;<B>m case 38: // fg RGB mode? e.g. ESC[38;2;<R>;<G>;<B>m
case 48: // bg RGB mode? e.g. ESC[48;2;<R>;<G>;<B>m case 48: // bg RGB mode? e.g. ESC[48;2;<R>;<G>;<B>m
rgbmode = 1; rgbmode = 1;
rgbcode = val; rgbcode = val;
continue; continue;
@ -2943,7 +2977,7 @@ Fl_Terminal::Fl_Terminal(int X,int Y,int W,int H,const char*L) : Fl_Group(X,Y,W,
vscroll_->callback(scrollbar_cb, (void*)this); vscroll_->callback(scrollbar_cb, (void*)this);
resizable(0); resizable(0);
Fl_Group::box(FL_DOWN_FRAME); Fl_Group::box(FL_DOWN_FRAME);
color(0x0); // black bg by default Fl_Group::color(0x0); // black bg by default
update_screen(true); // update internal vars after setting screen size/font update_screen(true); // update internal vars after setting screen size/font
clear_screen_home(); // clear screen, home cursor clear_screen_home(); // clear screen, home cursor
clear_history(); // clear history buffer clear_history(); // clear history buffer
@ -3030,8 +3064,8 @@ void Fl_Terminal::draw_row_bg(int grow, int X, int Y) const {
: (u8c->attrib() & Fl_Terminal::INVERSE) // Inverse mode? : (u8c->attrib() & Fl_Terminal::INVERSE) // Inverse mode?
? u8c->attr_fg_color(this) // ..use fg color for bg ? u8c->attr_fg_color(this) // ..use fg color for bg
: u8c->attr_bg_color(this); // ..use bg color for bg : u8c->attr_bg_color(this); // ..use bg color for bg
// Draw only if color != 0x0 ('show through' color) or widget's own color(). // Draw only if color != 0xffffffff ('see through' color) or widget's own color().
if (bg_col != 0xffffffff && bg_col != color()) { if (bg_col != 0xffffffff && bg_col != Fl_Group::color()) {
fl_color(bg_col); fl_color(bg_col);
fl_rectf(X, bg_y, pwidth, bg_h); fl_rectf(X, bg_y, pwidth, bg_h);
} }
@ -3133,7 +3167,7 @@ void Fl_Terminal::draw(void) {
// FL_XXX_FRAME types allow Fl_Terminal to have a /flat/ background. // FL_XXX_FRAME types allow Fl_Terminal to have a /flat/ background.
// FL_XXX_BOX types inherit Fl::scheme() which can provide unwanted gradients. // FL_XXX_BOX types inherit Fl::scheme() which can provide unwanted gradients.
// //
fl_color(color()); fl_color(Fl_Group::color());
// Draw flat field (inside border drawn by Fl_Group::draw() above) // Draw flat field (inside border drawn by Fl_Group::draw() above)
int X = x() + Fl::box_dx(box()); int X = x() + Fl::box_dx(box());
int Y = y() + Fl::box_dy(box()); int Y = y() + Fl::box_dy(box());

View File

@ -1267,7 +1267,7 @@ test_firstpage(false);} {}
} }
Function {show_colorbars()} { Function {show_colorbars()} {
comment {Show colorbars in terminal comment {Show colorbars in terminal
} return_type void } open return_type void
} { } {
code {// If cursor floating, do a crlf first code {// If cursor floating, do a crlf first
if (G_tty->cursor_col()!=0) G_tty->append("\\n"); if (G_tty->cursor_col()!=0) G_tty->append("\\n");
@ -1321,8 +1321,8 @@ G_tty->append("\\033[2J\\033[H");
} }
} }
// Restore fg/bg colors // Restore fg/bg colors
G_tty->textfgcolor(fgsave ); G_tty->textfgcolor(fgsave);
G_tty->textbgcolor(bgsave );} {} G_tty->textbgcolor(bgsave);} {}
} }
Function {unicode_alignment()} { Function {unicode_alignment()} {
comment {Show unicode alignment test comment {Show unicode alignment test
@ -1396,6 +1396,16 @@ G_tty->append_ascii("\\033[33;2m<<END_OF_OUTPUT>>\\033[0m\\n");
G_tty->redraw();} {} G_tty->redraw();} {}
} }
decl {////// GUI LAYOUT //////} {private local decl {////// GUI LAYOUT //////} {private local
}
Function {parse_color(const char *val_str, Fl_Color &col)} {
comment {Parse color in 'val_str', returns 0 and color in 'col', or -1 on error} return_type int
} {
code {unsigned long ival;
if (sscanf(val_str, "\#%lx", &ival) == 1 ) { col = Fl_Color(ival); return 0; }
if (sscanf(val_str, "%ld", &ival) == 1 ) { col = Fl_Color(ival); return 0; }
fl_alert("Illegal color value '%s'\\n(can be e.g. '12' or '\#0c', etc)", val_str);
return -1;} {}
} }
Function {update_inputs()} { Function {update_inputs()} {
comment {Resync the inputs with widget's values} return_type void comment {Resync the inputs with widget's values} return_type void
@ -1443,17 +1453,24 @@ switch ( G_tty->box() ) {
// color() // color()
{ {
char s[80]; char s[80];
sprintf(s, "\#%08x", G_tty->color()); sprintf(s, "\#%08x", G_tty->color()); color_input->value(s);
color_input->value(s);
} }
// textcolor()
{
char s[80];
sprintf(s, "\#%08x", G_tty->textcolor()); textcolor_input->value(s);
}
// textfg/bgcolor() // textfg/bgcolor()
{ {
char s[80]; char s[80];
sprintf(s, "\#%08x", G_tty->textfgcolor()); sprintf(s, "\#%08x", G_tty->textfgcolor()); textfgcolor_input->value(s);
textfgcolor_input->value(s); sprintf(s, "\#%08x", G_tty->textbgcolor()); textbgcolor_input->value(s);
sprintf(s, "\#%08x", G_tty->textbgcolor()); // defaults
textbgcolor_input->value(s); sprintf(s, "\#%08x", G_tty->textfgcolor_default()); textfgcolor_default_input->value(s);
sprintf(s, "\#%08x", G_tty->textbgcolor_default()); textbgcolor_default_input->value(s);
} }
// cursorfg/bg color // cursorfg/bg color
@ -1477,10 +1494,8 @@ switch ( G_tty->box() ) {
// selectionfg/bgcolor() // selectionfg/bgcolor()
{ {
char s[80]; char s[80];
sprintf(s, "\#%08x", G_tty->selectionfgcolor()); sprintf(s, "\#%08x", G_tty->selectionfgcolor()); selectionfgcolor_input->value(s);
selectionfgcolor_input->value(s); sprintf(s, "\#%08x", G_tty->selectionbgcolor()); selectionbgcolor_input->value(s);
sprintf(s, "\#%08x", G_tty->selectionbgcolor());
selectionbgcolor_input->value(s);
}} {} }} {}
} }
Function {make_window()} {open Function {make_window()} {open
@ -1488,26 +1503,26 @@ switch ( G_tty->box() ) {
Fl_Window win { Fl_Window win {
label {Fl_Terminal Test} label {Fl_Terminal Test}
callback {exit(0);} open callback {exit(0);} open
xywh {626 129 772 863} type Double visible xywh {626 129 857 838} type Double visible
} { } {
Fl_Spinner scrollhistory_input { Fl_Spinner scrollhistory_input {
label {Scroll History} label {Scroll History}
callback {int val = int(scrollhistory_input->value() + .5); callback {int val = int(scrollhistory_input->value() + .5);
G_tty->history_rows(val);} G_tty->history_rows(val);}
tooltip {Scrollback history size. tooltip {Scrollback history size.
10,000 max.} xywh {115 10 115 20} labelsize 12 minimum 0 maximum 10000 textsize 12 10,000 max.} xywh {109 10 115 20} labelsize 10 minimum 0 maximum 10000 textsize 10
} }
Fl_Spinner fontsize_input { Fl_Spinner fontsize_input {
label {Font Size} label {Font Size}
callback {int val = int(fontsize_input->value() + .5); callback {int val = int(fontsize_input->value() + .5);
G_tty->textsize(val);} G_tty->textsize(val);}
xywh {115 38 115 20} labelsize 12 textsize 12 xywh {109 38 115 20} labelsize 10 textsize 10
} }
Fl_Spinner scrollbarsize_input { Fl_Spinner scrollbarsize_input {
label {Scrollbar Size} label {Scrollbar Size}
callback {int val = int(scrollbarsize_input->value() + .5); callback {int val = int(scrollbarsize_input->value() + .5);
G_tty->scrollbar_size(val); G_tty->redraw();} G_tty->scrollbar_size(val); G_tty->redraw();}
tooltip {Size of scrollbar width in pixels} xywh {115 67 115 20} labelsize 12 textsize 12 tooltip {Size of scrollbar width in pixels} xywh {109 67 115 20} labelsize 10 textsize 10
} }
Fl_Spinner redraw_rate_spinner { Fl_Spinner redraw_rate_spinner {
label {Min Redraw Time} label {Min Redraw Time}
@ -1515,16 +1530,16 @@ G_tty->scrollbar_size(val); G_tty->redraw();}
//printf("Setting redraw rate to %.2f\\n", rate); //printf("Setting redraw rate to %.2f\\n", rate);
G_tty->redraw_rate(rate);} G_tty->redraw_rate(rate);}
tooltip {Minimum time between redraws tooltip {Minimum time between redraws
Default is 0.10 secs.} xywh {115 94 115 20} type Float labelsize 12 minimum 0.05 maximum 5 step 0.1 textsize 12 Default is 0.10 secs.} xywh {109 94 115 20} type Float labelsize 10 minimum 0.05 maximum 5 step 0.1 textsize 10
} }
Fl_Choice scheme_widget { Fl_Choice scheme_widget {
label scheme open label scheme open
tooltip Scheme xywh {115 120 115 23} down_box BORDER_BOX labelsize 12 textsize 12 tooltip Scheme xywh {109 120 115 20} down_box BORDER_BOX labelsize 10 textsize 10
class Fl_Scheme_Choice class Fl_Scheme_Choice
} {} } {}
Fl_Choice box_choice { Fl_Choice box_choice {
label {box()} open label {box()} open
tooltip {The border box for the Fl_Terminal} xywh {115 147 115 23} down_box BORDER_BOX labelsize 12 textsize 12 tooltip {The border box for the Fl_Terminal} xywh {109 147 115 20} down_box BORDER_BOX labelsize 10 textsize 10
} { } {
MenuItem {} { MenuItem {} {
label FL_UP_FRAME label FL_UP_FRAME
@ -1606,64 +1621,6 @@ G_tty->redraw();}
xywh {10 10 100 20} labelsize 8 xywh {10 10 100 20} labelsize 8
} }
} }
Fl_Input selectionfgcolor_input {
label {selectionfgcolor()}
callback {ulong ival;
const char *val_str = selectionfgcolor_input->value();
if (sscanf(val_str, "\#%lx", &ival) != 1)
if (sscanf(val_str, "%ld", &ival) != 1) {
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->selectionfgcolor(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The mouse selection foreground color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {115 185 115 20} labelsize 10 when 28 textfont 4 textsize 12
}
Fl_Input selectionbgcolor_input {
label {selectionbgcolor()}
callback {ulong ival;
const char *val_str = selectionbgcolor_input->value();
if (sscanf(val_str, "\#%lx", &ival) != 1)
if (sscanf(val_str, "%ld", &ival) != 1) {
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->selectionbgcolor(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The mouse selection background color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {115 210 115 20} labelsize 10 when 28 textfont 4 textsize 12
}
Fl_Check_Button showunknown_radio {
label {show_unknown()}
callback {G_tty->show_unknown(showunknown_radio->value() ? true : false);
G_tty->redraw();}
tooltip {Shows unknown escape sequences/unprintable chars as "¿" character} xywh {255 9 105 22} down_box DOWN_BOX labelsize 10
}
Fl_Check_Button interactivecursor_radio {
label {Interactive Cursor}
callback {bool val = interactivecursor_radio->value() ? true : false;
G_tty->interactive_cursor(val);}
tooltip {Allow Up/Dn/Lt/Rt keys to move cursor
when terminal has focus} xywh {365 9 125 22} down_box DOWN_BOX labelsize 10
}
Fl_Check_Button ansi_radio {
label {ansi()}
callback {G_tty->ansi(ansi_radio->value() ? true : false);}
tooltip {Handle ANSI/xterm escape sequences} xywh {255 30 95 20} down_box DOWN_BOX labelsize 10
}
Fl_Check_Button stdout_radio {
label {Echo tests to stdout}
tooltip {Also send test output to stdout} xywh {365 28 121 20} down_box DOWN_BOX labelsize 10
}
Fl_Box {} {
label {Lt, Rt, Top, Bot}
xywh {345 50 145 20} labelsize 10
}
Fl_Input margins_input { Fl_Input margins_input {
label Margins label Margins
callback {int lt,rt,top,bot; callback {int lt,rt,top,bot;
@ -1677,92 +1634,150 @@ G_tty->margin_right(rt);
G_tty->margin_top(top); G_tty->margin_top(top);
G_tty->margin_bottom(bot); G_tty->margin_bottom(bot);
G_tty->redraw();} G_tty->redraw();}
xywh {345 70 145 20} labelsize 12 when 28 textsize 12 xywh {110 187 114 20} labelsize 10 when 28 textsize 10
} }
Fl_Input color_input { Fl_Check_Button showunknown_radio {
label {color()} label {show_unknown()}
callback {ulong ival; callback {G_tty->show_unknown(showunknown_radio->value() ? true : false);
const char *val_str = color_input->value(); G_tty->redraw();}
if (sscanf(val_str, "\#%lx", &ival) != 1) tooltip {Shows unknown escape sequences/unprintable chars as "¿" character} xywh {331 7 105 20} down_box DOWN_BOX labelsize 9
if (sscanf(val_str, "%ld", &ival) != 1) { }
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)"); Fl_Check_Button interactivecursor_radio {
update_inputs(); label {Interactive Cursor}
return; callback {bool val = interactivecursor_radio->value() ? true : false;
} G_tty->interactive_cursor(val);}
G_tty->color(Fl_Color(ival)); tooltip {Allow Up/Dn/Lt/Rt keys to move cursor
when terminal has focus} xywh {473 7 125 20} down_box DOWN_BOX labelsize 9
}
Fl_Check_Button ansi_radio {
label {ansi()}
callback {G_tty->ansi(ansi_radio->value() ? true : false);}
tooltip {Handle ANSI/xterm escape sequences} xywh {331 27 95 20} down_box DOWN_BOX labelsize 9
}
Fl_Check_Button stdout_radio {
label {Echo tests to stdout}
tooltip {Also send test output to stdout} xywh {473 27 121 20} down_box DOWN_BOX labelsize 9
}
Fl_Box {} {
label {Lt, Rt, Top, Bot}
xywh {110 172 114 15} labelsize 10
}
Fl_Input textcolor_input {
label {textcolor()}
callback {Fl_Color c;
if (parse_color(textcolor_input->value(), c) == -1 ) return;
G_tty->textcolor(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival); //DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} G_tty->redraw();}
tooltip {The widget's background color() tooltip {The widget's text color. Has the effect of simultaneously setting:
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {345 95 145 20} labelsize 12 when 28 textfont 4 textsize 12 > textfgcolor()
>textfgcolor_default()
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {333 55 77 20} labelsize 9 when 28 textfont 4 textsize 9
} }
Fl_Input textfgcolor_input { Fl_Input textfgcolor_input {
label {textfgcolor()} label {textfgcolor()}
callback {ulong ival; callback {Fl_Color c;
const char *val_str = textfgcolor_input->value(); if (parse_color(textfgcolor_input->value(), c) == -1 ) return;
if (sscanf(val_str, "\#%lx", &ival) != 1) G_tty->textfgcolor(c);
if (sscanf(val_str, "%ld", &ival) != 1) { update_inputs();
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->textfgcolor(Fl_Color(ival));
G_tty->textfgcolor_default(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival); //DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} G_tty->redraw();}
tooltip {The text foreground color. tooltip {The text foreground color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {345 120 145 20} labelsize 12 when 28 textfont 4 textsize 12 Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {333 79 77 20} labelsize 9 when 28 textfont 4 textsize 9
} }
Fl_Input textbgcolor_input { Fl_Input textfgcolor_default_input {
label {textbgcolor()} label {textfgcolor_default()}
callback {ulong ival; callback {Fl_Color c;
const char *val_str = textbgcolor_input->value(); if (parse_color(textfgcolor_default_input->value(), c) == -1 ) return;
if (sscanf(val_str, "\#%lx", &ival) != 1) G_tty->textfgcolor_default(c);
if (sscanf(val_str, "%ld", &ival) != 1) { update_inputs();
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->textbgcolor(Fl_Color(ival));
G_tty->textbgcolor_default(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival); //DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} G_tty->redraw();}
tooltip {The text background color. tooltip {The text foreground default color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {345 145 145 20} labelsize 12 when 28 textfont 4 textsize 12 Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {333 103 77 20} labelsize 9 when 28 textfont 4 textsize 9
} }
Fl_Input cursorfgcolor_input { Fl_Input cursorfgcolor_input {
label {cursorfgcolor()} label {cursorfgcolor()}
callback {ulong ival; callback {Fl_Color c;
const char *val_str = cursorfgcolor_input->value(); if (parse_color(cursorfgcolor_input->value(), c) == -1 ) return;
if (sscanf(val_str, "\#%lx", &ival) != 1) G_tty->cursorfgcolor(c);
if (sscanf(val_str, "%ld", &ival) != 1) { update_inputs();
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->cursorfgcolor(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival); //DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} G_tty->redraw();}
tooltip {Foreground color for text under the cursor.} xywh {345 170 145 20} labelsize 12 when 28 textfont 4 textsize 12 tooltip {Foreground color for text under the cursor.} xywh {333 127 77 20} labelsize 9 when 28 textfont 4 textsize 9
}
Fl_Input selectionfgcolor_input {
label {selectionfgcolor()}
callback {Fl_Color c;
if (parse_color(selectionfgcolor_input->value(), c) == -1 ) return;
G_tty->selectionfgcolor(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The mouse selection foreground color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {333 151 77 20} labelsize 9 when 28 textfont 4 textsize 9
}
Fl_Input color_input {
label {color()}
callback {Fl_Color c;
if (parse_color(color_input->value(), c) == -1 ) return;
G_tty->color(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The widget's background color().
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {521 55 77 20} labelsize 9 when 28 textfont 4 textsize 9
}
Fl_Input textbgcolor_input {
label {textbgcolor()}
callback {Fl_Color c;
if (parse_color(textbgcolor_input->value(), c) == -1 ) return;
G_tty->textbgcolor(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The text background color.
Refer to the docs for the special value 0xffffffff.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {521 79 77 20} labelsize 9 when 28 textfont 4 textsize 9
}
Fl_Input textbgcolor_default_input {
label {textbgcolor_default()}
callback {Fl_Color c;
if (parse_color(textbgcolor_default_input->value(), c) == -1 ) return;
G_tty->textbgcolor_default(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} selected
tooltip {The text background default color.
Refer to the docs for the special value 0xffffffff.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {521 103 77 20} labelsize 9 when 28 textfont 4 textsize 9
} }
Fl_Input cursorbgcolor_input { Fl_Input cursorbgcolor_input {
label {cursorbgcolor()} label {cursorbgcolor()}
callback {ulong ival; callback {Fl_Color c;
const char *val_str = cursorbgcolor_input->value(); if (parse_color(cursorbgcolor_input->value(), c) == -1 ) return;
if (sscanf(val_str, "\#%lx", &ival) != 1) G_tty->cursorbgcolor(c);
if (sscanf(val_str, "%ld", &ival) != 1) { update_inputs();
fl_alert("Illegal color value (can be e.g. '12' or '\#0c', etc)");
update_inputs();
return;
}
G_tty->cursorbgcolor(Fl_Color(ival));
//DEBUG ::printf("IVAL is %08lx\\n",ival); //DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();} G_tty->redraw();}
tooltip {Background color for the cursor. tooltip {Background color for the cursor.
This is the cursor block's color} xywh {345 195 145 20} labelsize 12 when 28 textfont 4 textsize 12 This is the cursor block's color} xywh {521 127 77 20} labelsize 9 when 28 textfont 4 textsize 9
}
Fl_Input selectionbgcolor_input {
label {selectionbgcolor()}
callback {Fl_Color c;
if (parse_color(selectionbgcolor_input->value(), c) == -1 ) return;
G_tty->selectionbgcolor(c);
update_inputs();
//DEBUG ::printf("IVAL is %08lx\\n",ival);
G_tty->redraw();}
tooltip {The mouse selection background color.
Can be decimal (e.g. 12) or hex (e.g. \#0c, \#0000000c, etc)} xywh {521 151 77 20} labelsize 9 when 28 textfont 4 textsize 9
} }
Fl_Choice {} { Fl_Choice {} {
label {Terminal Color} label {Terminal Color}
xywh {345 220 145 20} down_box BORDER_BOX labelsize 12 textsize 12 xywh {364 187 145 20} down_box BORDER_BOX labelsize 12 textsize 12
} { } {
MenuItem {} { MenuItem {} {
label {White on DarkAmber} label {White on DarkAmber}
@ -1812,7 +1827,7 @@ add_lines(50);}
} }
Fl_Group {} { Fl_Group {} {
label {Terminal Ops} label {Terminal Ops}
xywh {505 15 120 210} box ENGRAVED_FRAME labelsize 11 xywh {608 21 115 210} box ENGRAVED_FRAME labelsize 11
} { } {
Fl_Button {} { Fl_Button {} {
label {Clear Screen} label {Clear Screen}
@ -1821,31 +1836,31 @@ G_tty->redraw();
// Reset the 'Add +50' line counter to 1 // Reset the 'Add +50' line counter to 1
G_lines = 1;} G_lines = 1;}
tooltip {Clear terminal screen. tooltip {Clear terminal screen.
Moves what was on the screen to the scroll history.} xywh {520 31 90 25} labelsize 11 Moves what was on the screen to the scroll history.} xywh {620 37 90 25} labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {Clear History} label {Clear History}
callback {G_tty->append("\\033[3J"); // clr history callback {G_tty->append("\\033[3J"); // clr history
G_tty->redraw();} G_tty->redraw();}
tooltip {Clear scrollback history.} xywh {520 62 90 25} labelsize 11 tooltip {Clear scrollback history.} xywh {620 68 90 25} labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {Reset Terminal} label {Reset Terminal}
callback {G_tty->append("\\033c"); // reset terminal callback {G_tty->append("\\033c"); // reset terminal
G_tty->redraw();} G_tty->redraw();}
tooltip {Reset terminal. tooltip {Reset terminal.
Clears: screen, history, sets default tabstops, etc.} xywh {520 93 90 25} labelsize 11 Clears: screen, history, sets default tabstops, etc.} xywh {620 99 90 25} labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {Home Cursor} label {Home Cursor}
callback {G_tty->append("\\033[H");} callback {G_tty->append("\\033[H");}
tooltip {Moves cursor to home position (top/left) using ESC[H} xywh {520 124 90 25} labelsize 11 tooltip {Moves cursor to home position (top/left) using ESC[H} xywh {620 130 90 25} labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {Speed Test} label {Speed Test}
callback {speed_test();} callback {speed_test();}
tooltip {Runs a full screen random chars/colors tooltip {Runs a full screen random chars/colors
Shortcut: S} xywh {520 155 90 25} shortcut 0x73 labelsize 11 Shortcut: S} xywh {620 161 90 25} shortcut 0x73 labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {Ring Debug} label {Ring Debug}
@ -1858,50 +1873,50 @@ if (scrollhistory_input->value() > 35) {
// Show debug window // Show debug window
G_tty->show_ring_debug_window();} G_tty->show_ring_debug_window();}
tooltip {Show the Fl_Terminal raw ring buffer contents. tooltip {Show the Fl_Terminal raw ring buffer contents.
(Warning: This slows the UI and uses continuous cpu until closed)} xywh {520 187 90 25} labelsize 11 (Warning: This slows the UI and uses continuous cpu until closed)} xywh {620 193 90 25} labelsize 11
} }
} }
Fl_Group {} { Fl_Group {} {
label {Terminal Tests} label {Terminal Tests}
xywh {640 15 120 210} box ENGRAVED_FRAME labelsize 11 xywh {731 21 115 210} box ENGRAVED_FRAME labelsize 11
} { } {
Fl_Button {} { Fl_Button {} {
label {Unicode label {Unicode
Alignment} Alignment}
callback {unicode_alignment();} callback {unicode_alignment();}
tooltip {Show a Unicode screen alignment test tooltip {Show a Unicode screen alignment test
Checks that troublesome Unicode chars don't cause misalignment} xywh {655 25 90 30} labelsize 9 Checks that troublesome Unicode chars don't cause misalignment} xywh {742 31 90 30} labelsize 9
} }
Fl_Button {} { Fl_Button {} {
label {+50 Lines} label {+50 Lines}
callback {add_lines(50);} callback {add_lines(50);}
tooltip {Add 50 lines of text to terminal. tooltip {Add 50 lines of text to terminal.
Tests screen history, scrollup} xywh {655 60 90 30} labelsize 9 Tests screen history, scrollup} xywh {742 66 90 30} labelsize 9
} }
Fl_Button {} { Fl_Button {} {
label {Color Bars} label {Color Bars}
callback {show_colorbars();} callback {show_colorbars();}
tooltip {Show colorbar test tooltip {Show colorbar test
Tests API for setting colors Tests API for setting colors
Does *NOT* use ESC codes} xywh {655 95 90 30} labelsize 11 Does *NOT* use ESC codes} xywh {742 101 90 30} labelsize 11
} }
Fl_Box {} { Fl_Box {} {
label {Self Tests} label {Self Tests}
xywh {655 167 90 15} labelsize 10 xywh {746 173 90 15} labelsize 10
} }
Fl_Button {} { Fl_Button {} {
label {@<<} label {@<<}
callback {NextEscapeTest(-1);} callback {NextEscapeTest(-1);}
comment {Move to previous test} comment {Move to previous test}
tooltip {Reverse through the ESC code self tests tooltip {Reverse through the ESC code self tests
Shortcut: SHIFT+E} xywh {655 185 40 30} shortcut 0x10065 labelsize 11 Shortcut: SHIFT+E} xywh {742 191 40 30} shortcut 0x10065 labelsize 11
} }
Fl_Button {} { Fl_Button {} {
label {@>>} label {@>>}
callback {NextEscapeTest(1);} callback {NextEscapeTest(1);}
comment {Move to next test} comment {Move to next test}
tooltip {Advance through the ESC code self tests tooltip {Advance through the ESC code self tests
Shortcut: 'e'} xywh {705 185 40 30} shortcut 0x65 labelsize 11 Shortcut: 'e'} xywh {792 191 40 30} shortcut 0x65 labelsize 11
} }
} }
Fl_Input showfile_input { Fl_Input showfile_input {
@ -1915,7 +1930,7 @@ showfile_input->activate();
command_input->activate(); command_input->activate();
Fl::focus(showfile_input); // return focus Fl::focus(showfile_input); // return focus
win->redraw();} win->redraw();}
tooltip {Type in the pathname of a file to cat to the screen} xywh {109 250 650 25} labelsize 12 when 10 textfont 4 tooltip {Type in the pathname of a file to cat to the screen} xywh {109 238 737 25} labelsize 12 when 10 textfont 4
} }
Fl_Input command_input { Fl_Input command_input {
label Command label Command
@ -1930,10 +1945,10 @@ Fl::focus(command_input); // return focus
win->redraw();} win->redraw();}
tooltip {Command to run. tooltip {Command to run.
Hit ENTER to run command. Hit ENTER to run command.
The command's stdout will appear in terminal.} xywh {109 285 650 25} labelsize 12 when 12 textfont 4 The command's stdout will appear in terminal.} xywh {109 269 737 25} labelsize 12 when 12 textfont 4
} }
Fl_Group tty {open Fl_Group tty {open
xywh {10 320 750 530} box DOWN_FRAME color 0 xywh {10 302 836 524} box DOWN_FRAME color 0
class MyTerminal class MyTerminal
} {} } {}
} }