Use new type FColor for color values

This commit is contained in:
Markus Gans 2018-11-07 22:06:58 +01:00
parent 9fc1910c18
commit cd8e4f78ae
20 changed files with 210 additions and 193 deletions

View File

@ -1,3 +1,6 @@
2018-11-07 Markus Gans <guru.mail@muenster.de>
* Use new type FColor for color values
2018-11-05 Markus Gans <guru.mail@muenster.de>
* FButton now uses the widget flags directly

View File

@ -49,7 +49,7 @@ class AttribDlg : public finalcut::FDialog
void cb_back (finalcut::FWidget* = 0, data_ptr = 0);
// Data Members
short bgcolor;
FColor bgcolor;
private:
// Disable copy constructor
@ -130,10 +130,12 @@ void AttribDlg::cb_next (finalcut::FWidget*, data_ptr)
if ( isMonochron() )
return;
bgcolor++;
if ( bgcolor >= getMaxColor() )
if ( bgcolor == FColor(getMaxColor() - 1) )
bgcolor = finalcut::fc::Default;
else if ( bgcolor == finalcut::fc::Default )
bgcolor = 0;
else
bgcolor++;
redraw();
}
@ -144,10 +146,12 @@ void AttribDlg::cb_back (finalcut::FWidget*, data_ptr)
if ( isMonochron() )
return;
bgcolor--;
if ( bgcolor < finalcut::fc::Default )
bgcolor = short(getMaxColor() - 1);
if ( bgcolor == 0 )
bgcolor = finalcut::fc::Default;
else if ( bgcolor == finalcut::fc::Default )
bgcolor = FColor(getMaxColor() - 1);
else
bgcolor--;
redraw();
}
@ -466,7 +470,7 @@ void AttribDemo::draw()
setColor(wc.label_fg, wc.label_bg);
setPrintPos (1, 15);
short bg = static_cast<AttribDlg*>(getParent())->bgcolor;
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:");
if ( bg == finalcut::fc::Default )

View File

@ -93,21 +93,21 @@ FButton::~FButton() // destructor
// public methods of FButton
//----------------------------------------------------------------------
void FButton::setForegroundColor (short color)
void FButton::setForegroundColor (FColor color)
{
FWidget::setForegroundColor(color);
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setBackgroundColor (short color)
void FButton::setBackgroundColor (FColor color)
{
FWidget::setBackgroundColor(color);
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setHotkeyForegroundColor (short color)
void FButton::setHotkeyForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
@ -115,7 +115,7 @@ void FButton::setHotkeyForegroundColor (short color)
}
//----------------------------------------------------------------------
void FButton::setFocusForegroundColor (short color)
void FButton::setFocusForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
@ -125,7 +125,7 @@ void FButton::setFocusForegroundColor (short color)
}
//----------------------------------------------------------------------
void FButton::setFocusBackgroundColor (short color)
void FButton::setFocusBackgroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
@ -135,7 +135,7 @@ void FButton::setFocusBackgroundColor (short color)
}
//----------------------------------------------------------------------
void FButton::setInactiveForegroundColor (short color)
void FButton::setInactiveForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
@ -145,7 +145,7 @@ void FButton::setInactiveForegroundColor (short color)
}
//----------------------------------------------------------------------
void FButton::setInactiveBackgroundColor (short color)
void FButton::setInactiveBackgroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )

View File

@ -552,7 +552,7 @@ void FOptiAttr::initialize()
}
//----------------------------------------------------------------------
short FOptiAttr::vga2ansi (short color)
FColor FOptiAttr::vga2ansi (FColor color)
{
// VGA | ANSI
// i R G B | i B G R
@ -574,7 +574,9 @@ short FOptiAttr::vga2ansi (short color)
// 1 1 1 0 | 1 0 1 1
// 1 1 1 1 | 1 1 1 1
if ( color >= 0 && color < 16 )
if ( color == fc::Default )
color = 0;
else if ( color < 16 )
{
static const short lookup_table[] =
{
@ -584,8 +586,6 @@ short FOptiAttr::vga2ansi (short color)
color = lookup_table[color];
}
else if ( color < 0 )
color = 0;
return color;
}
@ -610,7 +610,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next)
next->code = ' ';
// Look for no changes
if ( ! (switchOn() || switchOff() || colorChange(term, next)) )
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
return 0;
if ( hasNoAttribute(next) )
@ -1227,7 +1227,9 @@ void FOptiAttr::setAttributesOff (charData*& term)
//----------------------------------------------------------------------
bool FOptiAttr::hasColor (charData*& attr)
{
if ( attr && attr->fg_color < 0 && attr->bg_color < 0 )
if ( attr
&& attr->fg_color == fc::Default
&& attr->bg_color == fc::Default )
return false;
else
return true;
@ -1263,7 +1265,7 @@ bool FOptiAttr::hasNoAttribute (charData*& attr)
}
//----------------------------------------------------------------------
inline bool FOptiAttr::colorChange (charData*& term, charData*& next)
inline bool FOptiAttr::hasColorChanged (charData*& term, charData*& next)
{
if ( term && next )
{
@ -1370,7 +1372,7 @@ inline void FOptiAttr::deactivateAttributes ( charData*& term
setAttributesOff(term);
}
if ( colorChange(term, next) )
if ( hasColorChanged(term, next) )
change_color (term, next);
}
@ -1420,7 +1422,7 @@ inline void FOptiAttr::changeAttributeSGR ( charData*& term
&& pc_charset_usable )
setTermPCcharset(term);
if ( colorChange(term, next) )
if ( hasColorChanged(term, next) )
change_color(term, next);
}
@ -1430,7 +1432,7 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term
{
setAttributesOff(term);
if ( colorChange(term, next) )
if ( hasColorChanged(term, next) )
change_color (term, next);
detectSwitchOn (term, next); // After reset all attributes
@ -1440,7 +1442,7 @@ inline void FOptiAttr::changeAttributeSeparately ( charData*& term
//----------------------------------------------------------------------
void FOptiAttr::change_color (charData*& term, charData*& next)
{
short fg, bg;
FColor fg, bg;
if ( ! (term && next) )
return;
@ -1452,15 +1454,19 @@ void FOptiAttr::change_color (charData*& term, charData*& next)
return;
}
next->fg_color %= max_color;
next->bg_color %= max_color;
if ( next->fg_color != fc::Default )
next->fg_color %= max_color;
if ( next->bg_color != fc::Default )
next->bg_color %= max_color;
fg = next->fg_color;
bg = next->bg_color;
if ( fg == fc::Default || bg == fc::Default )
change_to_default_color (term, next, fg, bg);
if ( fake_reverse && fg < 0 && bg < 0 )
if ( fake_reverse && fg == fc::Default && bg == fc::Default )
return;
if ( fake_reverse
@ -1481,7 +1487,7 @@ void FOptiAttr::change_color (charData*& term, charData*& next)
//----------------------------------------------------------------------
inline void FOptiAttr::change_to_default_color ( charData*& term
, charData*& next
, short& fg, short& bg )
, FColor& fg, FColor& bg )
{
if ( ansi_default_color )
{
@ -1520,7 +1526,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
//----------------------------------------------------------------------
inline void FOptiAttr::change_current_color ( charData*& term
, short fg, short bg )
, FColor fg, FColor bg )
{
char* color_str;
char* AF = F_set_a_foreground.cap;
@ -1535,8 +1541,8 @@ inline void FOptiAttr::change_current_color ( charData*& term
if ( AF && AB )
{
short ansi_fg = vga2ansi(fg);
short ansi_bg = vga2ansi(bg);
FColor ansi_fg = vga2ansi(fg);
FColor ansi_bg = vga2ansi(bg);
if ( (term->fg_color != fg || frev)
&& (color_str = tparm(AF, ansi_fg, 0, 0, 0, 0, 0, 0, 0, 0)) )

View File

@ -690,9 +690,9 @@ int FOptiMove::relativeMove ( char move[]
if ( move )
{
if ( *move )
std::strncat (move, hmove, BUF_SIZE - std::strlen(move) - 1);
std::strncat (move, hmove, BUF_SIZE - std::strlen(move));
else
std::strncpy (move, hmove, BUF_SIZE - 1);
std::strncpy (move, hmove, BUF_SIZE);
move[BUF_SIZE - 1] = '\0';
}
@ -816,7 +816,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
{
std::strncpy ( hmove
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE - 1);
, BUF_SIZE );
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_right_cursor.duration;
}
@ -854,7 +854,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
if ( htime_r < htime )
{
std::strncpy (hmove, str, BUF_SIZE - 1);
std::strncpy (hmove, str, BUF_SIZE);
hmove[BUF_SIZE - 1] = '\0';
htime = htime_r;
}
@ -936,7 +936,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
if ( move_xy )
{
char* move_ptr = move_buf;
std::strncpy (move_ptr, move_xy, BUF_SIZE - 1);
std::strncpy (move_ptr, move_xy, BUF_SIZE);
move_ptr[BUF_SIZE - 1] = '\0';
move_time = F_cursor_address.duration;
return true;

View File

@ -485,14 +485,13 @@ void FTerm::detectTermSize()
if ( ret != 0 || win_size.ws_col == 0 || win_size.ws_row == 0 )
{
char* str;
term_geometry.setPos (1, 1);
// Use COLUMNS or fallback to the xterm default width of 80 characters
str = std::getenv("COLUMNS");
term_geometry.setWidth(str ? std::size_t(std::atoi(str)) : 80);
char* Columns = std::getenv("COLUMNS");
term_geometry.setWidth(Columns ? std::size_t(std::atoi(Columns)) : 80);
// Use LINES or fallback to the xterm default height of 24 characters
str = std::getenv("LINES");
term_geometry.setHeight(str ? std::size_t(std::atoi(str)) : 24);
char* Lines = std::getenv("LINES");
term_geometry.setHeight(Lines ? std::size_t(std::atoi(Lines)) : 24);
}
else
{
@ -565,7 +564,7 @@ void FTerm::resetColorMap()
}
//----------------------------------------------------------------------
void FTerm::setPalette (short index, int r, int g, int b)
void FTerm::setPalette (FColor index, int r, int g, int b)
{
// Redefine RGB color value for a palette entry

View File

@ -145,7 +145,8 @@ void FTermDetection::getSystemTermType()
}
// 2nd fallback: use vt100 if not found
std::strncpy (termtype, C_STR("vt100"), 5);
std::strncpy (termtype, C_STR("vt100"), sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
}
//----------------------------------------------------------------------

View File

@ -118,7 +118,7 @@ void FTermLinux::setUTF8 (bool on)
}
//----------------------------------------------------------------------
bool FTermLinux::setPalette (short index, int r, int g, int b)
bool FTermLinux::setPalette (FColor index, int r, int g, int b)
{
if ( ! FTerm::isLinuxTerm() )
return false;
@ -838,7 +838,7 @@ int FTermLinux::setBlinkAsIntensity (bool on)
}
//----------------------------------------------------------------------
bool FTermLinux::setVGAPalette (short index, int r, int g, int b)
bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
{
// Set the vga color map

View File

@ -164,7 +164,7 @@ void FVTerm::setPrintCursor (int x, int y)
}
//----------------------------------------------------------------------
short FVTerm::rgb2ColorIndex (short r, short g, short b)
FColor FVTerm::rgb2ColorIndex (short r, short g, short b)
{
// Converts a 24-bit RGB color to a 256-color compatible approximation
@ -550,7 +550,7 @@ int FVTerm::print (term_area* area, charData& term_char)
}
// copy character to area
std::memcpy (ac, &nc, sizeof(nc));
std::memcpy (ac, &nc, sizeof(*ac));
if ( ax < short(area->changes[ay].xmin) )
area->changes[ay].xmin = uInt(ax);
@ -858,7 +858,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
int xpos = x + tx;
tc = &vterm->text[ypos * vterm->width + xpos];
sc = generateCharacter(xpos, ypos);
std::memcpy (tc, &sc, sizeof(sc));
std::memcpy (tc, &sc, sizeof(*tc));
}
if ( short(vterm->changes[ypos].xmin) > x )
@ -959,7 +959,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
charData* tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
std::memcpy (&nc, ac, sizeof(*ac));
std::memcpy (&nc, ac, sizeof(nc));
// Overlapped character
charData oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget);
nc.fg_color = oc.fg_color;
@ -976,7 +976,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
nc.code = ' ';
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(nc));
std::memcpy (tc, &nc, sizeof(*tc));
}
//----------------------------------------------------------------------
@ -989,7 +989,7 @@ void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty)
// Overlapped character
charData oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(oc));
std::memcpy (tc, &oc, sizeof(*tc));
}
//----------------------------------------------------------------------
@ -1021,7 +1021,7 @@ void FVTerm::updateShadedCharacter ( term_area* area
oc.code = ' ';
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(oc));
std::memcpy (tc, &oc, sizeof(*tc));
}
//----------------------------------------------------------------------
@ -1039,12 +1039,12 @@ void FVTerm::updateInheritBackground ( term_area* area
charData* tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
std::memcpy (&nc, ac, sizeof(*ac));
std::memcpy (&nc, ac, sizeof(nc));
// Covered character
charData cc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(nc));
std::memcpy (tc, &nc, sizeof(*tc));
}
//----------------------------------------------------------------------
@ -1060,7 +1060,7 @@ void FVTerm::updateCharacter ( term_area* area
charData* ac = &area->text[y * line_len + x];
// Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(*ac));
std::memcpy (tc, ac, sizeof(*tc));
if ( tc->attr.bit.printed && *tc == *ac )
tc->attr.bit.no_changes = true;
@ -1388,7 +1388,7 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
charData* ac; // area character
tc = &vterm->text[(ay + y) * vterm->width + ax];
ac = &area->text[y * area->width];
std::memcpy (ac, tc, sizeof(*tc) * unsigned(length));
std::memcpy (ac, tc, sizeof(*ac) * unsigned(length));
if ( short(area->changes[y].xmin) > 0 )
area->changes[y].xmin = 0;
@ -1444,7 +1444,7 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
int line_len = area->width + area->right_shadow;
tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1];
ac = &area->text[(dy + _y) * line_len + dx];
std::memcpy (ac, tc, sizeof(*tc) * unsigned(length));
std::memcpy (ac, tc, sizeof(*ac) * unsigned(length));
if ( short(area->changes[dy + _y].xmin) > dx )
area->changes[dy + _y].xmin = uInt(dx);
@ -1572,14 +1572,14 @@ void FVTerm::scrollAreaForward (term_area* area)
int pos2 = (y + 1) * total_width;
sc = &area->text[pos2];
dc = &area->text[pos1];
std::memcpy (dc, sc, sizeof(*sc) * unsigned(length));
std::memcpy (dc, sc, sizeof(*dc) * unsigned(length));
area->changes[y].xmin = 0;
area->changes[y].xmax = uInt(area->width - 1);
}
// insert a new line below
lc = &area->text[(y_max * total_width) - area->right_shadow - 1];
std::memcpy (&nc, lc, sizeof(*lc));
std::memcpy (&nc, lc, sizeof(nc));
nc.code = ' ';
dc = &area->text[y_max * total_width];
std::fill_n (dc, area->width, nc);
@ -1633,14 +1633,14 @@ void FVTerm::scrollAreaReverse (term_area* area)
int pos2 = y * total_width;
sc = &area->text[pos1];
dc = &area->text[pos2];
std::memcpy (dc, sc, sizeof(*sc) * unsigned(length));
std::memcpy (dc, sc, sizeof(*dc) * unsigned(length));
area->changes[y].xmin = 0;
area->changes[y].xmax = uInt(area->width - 1);
}
// insert a new line above
lc = &area->text[total_width];
std::memcpy (&nc, lc, sizeof(*lc));
std::memcpy (&nc, lc, sizeof(nc));
nc.code = ' ';
dc = &area->text[0];
std::fill_n (dc, area->width, nc);
@ -1675,7 +1675,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
uInt w;
// Current attributes with a space character
std::memcpy (&nc, &next_attribute, sizeof(next_attribute));
std::memcpy (&nc, &next_attribute, sizeof(nc));
nc.code = fillchar;
if ( ! (area && area->text) )
@ -1770,7 +1770,7 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
if ( tmp->attr.bit.trans_shadow ) // Transparent shadow
{
// Keep the current vterm character
std::memcpy (&s_ch, sc, sizeof(*sc));
std::memcpy (&s_ch, sc, sizeof(s_ch));
s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color;
s_ch.attr.bit.reverse = false;
@ -1789,7 +1789,7 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
else if ( tmp->attr.bit.inherit_bg )
{
// Add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(*tmp));
std::memcpy (&i_ch, tmp, sizeof(i_ch));
i_ch.bg_color = sc->bg_color; // Last background color
sc = &i_ch;
}
@ -2007,7 +2007,7 @@ void FVTerm::init (bool disable_alt_screen)
term_attribute.attr.byte[0] = 0;
// next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(term_attribute));
std::memcpy (&next_attribute, &term_attribute, sizeof(next_attribute));
// Receive the terminal capabilities
tcap = FTermcap::getTermcapMap();
@ -2086,7 +2086,7 @@ void FVTerm::putAreaLine (charData* ac, charData* tc, int length)
{
// copy "length" characters from area to terminal
std::memcpy (tc, ac, sizeof(*ac) * unsigned(length));
std::memcpy (tc, ac, sizeof(*tc) * unsigned(length));
}
//----------------------------------------------------------------------
@ -2099,7 +2099,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
// Restore one character on vterm
charData ch;
ch = getCoveredCharacter (x, y, obj);
std::memcpy (tc, &ch, sizeof(ch));
std::memcpy (tc, &ch, sizeof(*tc));
}
else // Mot transparent
{
@ -2121,19 +2121,19 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
|| ch.code == fc::FullBlock )
ch.code = ' ';
std::memcpy (tc, &ch, sizeof(ch));
std::memcpy (tc, &ch, sizeof(*tc));
}
else if ( ac->attr.bit.inherit_bg )
{
// Add the covered background to this character
charData ch, cc;
std::memcpy (&ch, ac, sizeof(*ac));
std::memcpy (&ch, ac, sizeof(ch));
cc = getCoveredCharacter (x, y, obj);
ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(ch));
std::memcpy (tc, &ch, sizeof(*tc));
}
else // Default
std::memcpy (tc, ac, sizeof(*ac));
std::memcpy (tc, ac, sizeof(*tc));
}
}
@ -2153,7 +2153,7 @@ void FVTerm::getAreaCharacter ( int x, int y, term_area* area
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
{
// Keep the current vterm character
std::memcpy (&s_ch, cc, sizeof(*cc));
std::memcpy (&s_ch, cc, sizeof(s_ch));
s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color;
s_ch.attr.bit.reverse = false;
@ -2163,7 +2163,7 @@ void FVTerm::getAreaCharacter ( int x, int y, term_area* area
else if ( tmp->attr.bit.inherit_bg )
{
// Add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(*tmp));
std::memcpy (&i_ch, tmp, sizeof(i_ch));
i_ch.bg_color = cc->bg_color; // last background color
cc = &i_ch;
}

View File

@ -79,13 +79,13 @@ class FButton : public FWidget
FString& getText();
// Mutators
void setForegroundColor (short);
void setBackgroundColor (short);
void setHotkeyForegroundColor (short);
void setFocusForegroundColor (short);
void setFocusBackgroundColor (short);
void setInactiveForegroundColor (short);
void setInactiveBackgroundColor (short);
void setForegroundColor (FColor);
void setBackgroundColor (FColor);
void setHotkeyForegroundColor (FColor);
void setFocusForegroundColor (FColor);
void setFocusBackgroundColor (FColor);
void setInactiveForegroundColor (FColor);
void setInactiveBackgroundColor (FColor);
bool setNoUnderline(bool);
bool setNoUnderline();
bool unsetNoUnderline();

View File

@ -27,6 +27,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <final/ftypes.h>
// Typecast to c-string
#define C_STR const_cast<char*>
@ -650,7 +652,6 @@ enum metakeys
// Console color names
enum colornames
{
Default = -1,
Black = 0,
Blue = 1,
Green = 2,
@ -907,7 +908,8 @@ enum colornames
Grey82 = 252, // #d0d0d0
Grey85 = 253, // #dadada
Grey89 = 254, // #e4e4e4
Grey93 = 255 // #eeeeee
Grey93 = 255, // #eeeeee
Default = static_cast<FColor>(-1)
};
// Mouse/keyboard state values

View File

@ -57,7 +57,7 @@ class FColorPalette
virtual ~FColorPalette();
// Typedefs
typedef void (*funcp)(short, int, int, int);
typedef void (*funcp)(FColor, int, int, int);
// Accessor
virtual const char* getClassName() const;

View File

@ -77,9 +77,9 @@ class FOptiAttr
// Typedefs
typedef struct
{
int code; // character code
short fg_color; // foreground color
short bg_color; // background color
int code; // character code
FColor fg_color; // foreground color
FColor bg_color; // background color
union attribute
{
@ -211,12 +211,12 @@ class FOptiAttr
void set_orig_orig_colors (char[]);
// Inquiry
static bool isNormal (charData*&);
static bool isNormal (charData*&);
// Methods
void initialize();
static short vga2ansi (short);
char* changeAttribute (charData*&, charData*&);
void initialize();
static FColor vga2ansi (FColor);
char* changeAttribute (charData*&, charData*&);
private:
// Typedefs and Enumerations
@ -306,15 +306,15 @@ class FOptiAttr
static bool hasNoAttribute (charData*&);
// Methods
bool colorChange (charData*&, charData*&);
bool hasColorChanged (charData*&, charData*&);
void resetColor (charData*&);
void prevent_no_color_video_attributes (charData*&, bool = false);
void deactivateAttributes (charData*&, charData*&);
void changeAttributeSGR (charData*&, charData*&);
void changeAttributeSeparately (charData*&, charData*&);
void change_color (charData*&, charData*&);
void change_to_default_color (charData*&, charData*&, short&, short&);
void change_current_color (charData*&, short, short);
void change_to_default_color (charData*&, charData*&, FColor&, FColor&);
void change_current_color (charData*&, FColor, FColor);
void resetAttribute (charData*&);
void reset (charData*&);
bool caused_reset_attributes (char[], uChar = all_tests);

View File

@ -244,7 +244,7 @@ class FTerm
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap();
static void resetColorMap();
static void setPalette (short, int, int, int);
static void setPalette (FColor, int, int, int);
static void setBeep (int, int);
static void resetBeep();
static void beep();

View File

@ -83,7 +83,7 @@ class FTermLinux
// Mutators
static void setFTermDetection (FTermDetection*);
static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool);
static bool setPalette (short, int, int, int);
static bool setPalette (FColor, int, int, int);
static void setUTF8 (bool);
// Inquiries
@ -155,7 +155,7 @@ class FTermLinux
static uChar getAttributeMode();
static void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool);
static bool setVGAPalette (short, int, int, int);
static bool setVGAPalette (FColor, int, int, int);
static bool saveVGAPalette();
static bool resetVGAPalette();
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)

View File

@ -55,6 +55,8 @@ typedef int64_t sInt64;
typedef long double lDouble;
typedef uInt16 FColor;
} // namespace

View File

@ -153,8 +153,8 @@ class FVTerm
void showCursor();
void setPrintCursor (const FPoint&);
void setPrintCursor (int, int);
short rgb2ColorIndex (short, short, short);
void setColor (short, short);
FColor rgb2ColorIndex (short, short, short);
void setColor (FColor, FColor);
static void setNormal();
static bool setBold (bool);
@ -671,7 +671,7 @@ inline void FVTerm::setPrintCursor (const FPoint& pos)
{ setPrintCursor (pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline void FVTerm::setColor (short fg, short bg)
inline void FVTerm::setColor (FColor fg, FColor bg)
{
// Changes colors
next_attribute.fg_color = fg;

View File

@ -239,8 +239,8 @@ class FWidget : public FVTerm, public FObject
bool ignorePadding (bool); // ignore padding from
bool ignorePadding(); // the parent widget
bool acceptPadding();
void setForegroundColor (short);
void setBackgroundColor (short);
void setForegroundColor (FColor);
void setBackgroundColor (FColor);
void setColor();
virtual void setX (int, bool = true); // positioning
virtual void setY (int, bool = true);
@ -505,8 +505,8 @@ class FWidget : public FVTerm, public FObject
FPoint wshadow;
// default widget foreground and background color
short foreground_color;
short background_color;
FColor foreground_color;
FColor background_color;
FString statusbar_message;
static FStatusBar* statusbar;
@ -792,7 +792,7 @@ inline bool FWidget::acceptPadding()
{ return (ignore_padding = false); }
//----------------------------------------------------------------------
inline void FWidget::setForegroundColor (short color)
inline void FWidget::setForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
@ -800,7 +800,7 @@ inline void FWidget::setForegroundColor (short color)
}
//----------------------------------------------------------------------
inline void FWidget::setBackgroundColor (short color)
inline void FWidget::setBackgroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )

View File

@ -55,90 +55,90 @@ class FWidgetColors
void set16ColorTheme();
// Data Members
short term_fg;
short term_bg;
short list_fg;
short list_bg;
short selected_list_fg;
short selected_list_bg;
short current_element_focus_fg;
short current_element_focus_bg;
short current_element_fg;
short current_element_bg;
short current_inc_search_element_fg;
short selected_current_element_focus_fg;
short selected_current_element_focus_bg;
short selected_current_element_fg;
short selected_current_element_bg;
short label_fg;
short label_bg;
short label_inactive_fg;
short label_inactive_bg;
short label_hotkey_fg;
short label_hotkey_bg;
short label_emphasis_fg;
short label_ellipsis_fg;
short inputfield_active_focus_fg;
short inputfield_active_focus_bg;
short inputfield_active_fg;
short inputfield_active_bg;
short inputfield_inactive_fg;
short inputfield_inactive_bg;
short dialog_fg;
short dialog_resize_fg;
short dialog_emphasis_fg;
short dialog_bg;
short error_box_fg;
short error_box_emphasis_fg;
short error_box_bg;
short tooltip_fg;
short tooltip_bg;
short shadow_fg;
short shadow_bg;
short toggle_button_active_focus_fg;
short toggle_button_active_focus_bg;
short toggle_button_active_fg;
short toggle_button_active_bg;
short toggle_button_inactive_fg;
short toggle_button_inactive_bg;
short button_active_focus_fg;
short button_active_focus_bg;
short button_active_fg;
short button_active_bg;
short button_inactive_fg;
short button_inactive_bg;
short button_hotkey_fg;
short titlebar_active_fg;
short titlebar_active_bg;
short titlebar_inactive_fg;
short titlebar_inactive_bg;
short titlebar_button_fg;
short titlebar_button_bg;
short titlebar_button_focus_fg;
short titlebar_button_focus_bg;
short menu_active_focus_fg;
short menu_active_focus_bg;
short menu_active_fg;
short menu_active_bg;
short menu_inactive_fg;
short menu_inactive_bg;
short menu_hotkey_fg;
short menu_hotkey_bg;
short statusbar_fg;
short statusbar_bg;
short statusbar_hotkey_fg;
short statusbar_hotkey_bg;
short statusbar_separator_fg;
short statusbar_active_fg;
short statusbar_active_bg;
short statusbar_active_hotkey_fg;
short statusbar_active_hotkey_bg;
short scrollbar_fg;
short scrollbar_bg;
short scrollbar_button_fg;
short scrollbar_button_bg;
short progressbar_fg;
short progressbar_bg;
FColor term_fg;
FColor term_bg;
FColor list_fg;
FColor list_bg;
FColor selected_list_fg;
FColor selected_list_bg;
FColor current_element_focus_fg;
FColor current_element_focus_bg;
FColor current_element_fg;
FColor current_element_bg;
FColor current_inc_search_element_fg;
FColor selected_current_element_focus_fg;
FColor selected_current_element_focus_bg;
FColor selected_current_element_fg;
FColor selected_current_element_bg;
FColor label_fg;
FColor label_bg;
FColor label_inactive_fg;
FColor label_inactive_bg;
FColor label_hotkey_fg;
FColor label_hotkey_bg;
FColor label_emphasis_fg;
FColor label_ellipsis_fg;
FColor inputfield_active_focus_fg;
FColor inputfield_active_focus_bg;
FColor inputfield_active_fg;
FColor inputfield_active_bg;
FColor inputfield_inactive_fg;
FColor inputfield_inactive_bg;
FColor dialog_fg;
FColor dialog_resize_fg;
FColor dialog_emphasis_fg;
FColor dialog_bg;
FColor error_box_fg;
FColor error_box_emphasis_fg;
FColor error_box_bg;
FColor tooltip_fg;
FColor tooltip_bg;
FColor shadow_fg;
FColor shadow_bg;
FColor toggle_button_active_focus_fg;
FColor toggle_button_active_focus_bg;
FColor toggle_button_active_fg;
FColor toggle_button_active_bg;
FColor toggle_button_inactive_fg;
FColor toggle_button_inactive_bg;
FColor button_active_focus_fg;
FColor button_active_focus_bg;
FColor button_active_fg;
FColor button_active_bg;
FColor button_inactive_fg;
FColor button_inactive_bg;
FColor button_hotkey_fg;
FColor titlebar_active_fg;
FColor titlebar_active_bg;
FColor titlebar_inactive_fg;
FColor titlebar_inactive_bg;
FColor titlebar_button_fg;
FColor titlebar_button_bg;
FColor titlebar_button_focus_fg;
FColor titlebar_button_focus_bg;
FColor menu_active_focus_fg;
FColor menu_active_focus_bg;
FColor menu_active_fg;
FColor menu_active_bg;
FColor menu_inactive_fg;
FColor menu_inactive_bg;
FColor menu_hotkey_fg;
FColor menu_hotkey_bg;
FColor statusbar_fg;
FColor statusbar_bg;
FColor statusbar_hotkey_fg;
FColor statusbar_hotkey_bg;
FColor statusbar_separator_fg;
FColor statusbar_active_fg;
FColor statusbar_active_bg;
FColor statusbar_active_hotkey_fg;
FColor statusbar_active_hotkey_bg;
FColor scrollbar_fg;
FColor scrollbar_bg;
FColor scrollbar_button_fg;
FColor scrollbar_button_bg;
FColor progressbar_fg;
FColor progressbar_bg;
};
#pragma pack(pop)

View File

@ -212,7 +212,7 @@ void FOptiAttrTest::fakeReverseTest()
finalcut::FOptiAttr::charData* to = \
new finalcut::FOptiAttr::charData();
CPPUNIT_ASSERT ( oa.changeAttribute(from, to) == 0 );
return;
// Gray text on blue background
to->fg_color = finalcut::fc::LightGray;
to->bg_color = finalcut::fc::Blue;