Screen characters got a union structure for a faster attribute compare operation

This commit is contained in:
Markus Gans 2017-08-20 17:30:30 +02:00
parent 3854de73d3
commit 37e4f7e222
10 changed files with 595 additions and 448 deletions

View File

@ -1,3 +1,7 @@
2017-08-20 Markus Gans <guru.mail@muenster.de>
* Screen characters got a union structure for a faster
attribute compare operation
2017-08-11 Markus Gans <guru.mail@muenster.de>
* Some code changes for GCC 7
* Implementation of a copy constructor for FPoint and FRect

View File

@ -71,7 +71,7 @@ class FApplication : public FWidget
void setMainWidget (FWidget*);
// Inquiry
bool isQuit();
static bool isQuit();
// Methods
int exec(); // run

View File

@ -18,6 +18,9 @@ FListViewItem::FListViewItem (const FListViewItem& item)
: FObject(item.getParent())
, column_line(item.column_line)
, data_pointer(item.data_pointer)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
FObject* parent = getParent();
@ -26,16 +29,20 @@ FListViewItem::FListViewItem (const FListViewItem& item)
}
//----------------------------------------------------------------------
FListViewItem::FListViewItem (FListViewItem* item)
: FObject(item->getParent())
, column_line(item->column_line)
, data_pointer(item->data_pointer)
FListViewItem::FListViewItem (FListViewItem* parent)
: FObject(parent)
, column_line()
, data_pointer(0)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Add the FListViewItem to the parent
FObject* parent = getParent();
if ( ! parent )
return;
if ( parent && parent->isInstanceOf("FListView") )
static_cast<FListView*>(parent)->insert (this);
parent->addChild (this);
parent->expandable = true;
}
//----------------------------------------------------------------------
@ -43,6 +50,9 @@ FListViewItem::FListViewItem (FListView* parent)
: FObject(parent)
, column_line()
, data_pointer(0)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Add the FListViewItem to the parent
if ( parent )
@ -56,6 +66,9 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
: FObject(parent)
, column_line(cols)
, data_pointer(data)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Replace the control codes characters
std::vector<FString>::iterator iter = column_line.begin();
@ -71,15 +84,42 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
parent->insert (this);
}
//----------------------------------------------------------------------
FListViewItem::FListViewItem ( const std::vector<FString>& cols
, FWidget::data_ptr data
, FListViewItem* parent )
: FObject(parent)
, column_line(cols)
, data_pointer(data)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Replace the control codes characters
std::vector<FString>::iterator iter = column_line.begin();
while ( iter != column_line.end() )
{
*iter = iter->replaceControlCodes();
++iter;
}
if ( parent )
parent->expandable = true;
}
//----------------------------------------------------------------------
FListViewItem::~FListViewItem()
{ }
// public methods of FListViewItem
//----------------------------------------------------------------------
FString FListViewItem::getText (int column) const
{
if (column < 0 || column_line.empty() || column >= int(column_line.size()) )
if ( column < 0
|| column_line.empty()
|| column >= int(column_line.size()) )
return *fc::empty_string;
return column_line[uInt(column)];
@ -88,7 +128,9 @@ FString FListViewItem::getText (int column) const
//----------------------------------------------------------------------
void FListViewItem::setText (int column, const FString& text)
{
if (column < 0 || column_line.empty() || column >= int(column_line.size()) )
if ( column < 0
|| column_line.empty()
|| column >= int(column_line.size()) )
return;
FObject* parent = getParent();
@ -109,6 +151,61 @@ void FListViewItem::setText (int column, const FString& text)
column_line[uInt(column)] = text;
}
//----------------------------------------------------------------------
void FListViewItem::insert (FListViewItem* child)
{
// Add a FListViewItem as child element
if ( ! child || ! hasChildren() )
return;
addChild (child);
expandable = true;
}
//----------------------------------------------------------------------
void FListViewItem::expand()
{
if ( is_expand || ! hasChildren() )
return;
is_expand = true;
}
//----------------------------------------------------------------------
void FListViewItem::collapse()
{
if ( ! is_expand )
return;
is_expand = false;
}
//----------------------------------------------------------------------
int FListViewItem::getVisibleLines()
{
if ( visible_lines > 1 )
return visible_lines;
if ( ! isExpand() || ! hasChildren() )
{
visible_lines = 1;
return visible_lines;
}
FObjectList children = this->getChildren();
FObjectList::const_iterator iter = children.begin();
while ( iter != children.end() )
{
FListViewItem* child = static_cast<FListViewItem*>(*iter);
visible_lines += child->getVisibleLines();
++iter;
}
return visible_lines;
}
//----------------------------------------------------------------------
// class FListView
//----------------------------------------------------------------------
@ -123,9 +220,10 @@ FListView::FListView (FWidget* parent)
, vbar(0)
, hbar(0)
, drag_scroll(fc::noScroll)
, scroll_timer(false)
, scroll_repeat(100)
, scroll_distance(1)
, scroll_timer(false)
, tree_view(false)
, current(0)
, xoffset(0)
, yoffset(0)

View File

@ -54,6 +54,9 @@ class FListViewItem : public FObject
FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr = 0
, FListView* = 0 );
FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr = 0
, FListViewItem* = 0 );
// Destructor
~FListViewItem();
@ -63,16 +66,33 @@ class FListViewItem : public FObject
// Accessors
const char* getClassName() const;
uInt getCount() const;
uInt getColumnCount() const;
FString getText (int) const;
// Mutator
void setText (int, const FString&);
// Inquiry
bool isExpand();
// Methods
void insert (FListViewItem*);
void expand();
void collapse();
private:
// Inquiry
bool isExpandable();
// Methods
int getVisibleLines();
// Data Member
std::vector<FString> column_line;
FWidget::data_ptr data_pointer;
int visible_lines;
bool expandable;
bool is_expand;
// Friend class
friend class FListView;
@ -86,9 +106,17 @@ inline const char* FListViewItem::getClassName() const
{ return "FListViewItem"; }
//----------------------------------------------------------------------
inline uInt FListViewItem::getCount() const
inline uInt FListViewItem::getColumnCount() const
{ return uInt(column_line.size()); }
//----------------------------------------------------------------------
inline bool FListViewItem::isExpand()
{ return is_expand; }
//----------------------------------------------------------------------
inline bool FListViewItem::isExpandable()
{ return expandable; }
//----------------------------------------------------------------------
// class FListView
@ -122,6 +150,9 @@ class FListView : public FWidget
void setGeometry (int, int, int, int, bool = true);
void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&);
bool setTreeView (bool);
bool setTreeView();
bool unsetTreeView();
// Methods
virtual int addColumn (const FString&, int = USE_MAX_SIZE);
@ -204,9 +235,10 @@ class FListView : public FWidget
FScrollbar* vbar;
FScrollbar* hbar;
fc::dragScroll drag_scroll;
bool scroll_timer;
int scroll_repeat;
int scroll_distance;
bool scroll_timer;
bool tree_view;
int current;
int xoffset;
int yoffset;
@ -228,6 +260,18 @@ inline const char* FListView::getClassName() const
inline FListViewItem* FListView::getCurrentItem() const
{ return data[uInt(current-1)]; }
//----------------------------------------------------------------------
inline bool FListView::setTreeView (bool on)
{ return tree_view = (on) ? true : false; }
//----------------------------------------------------------------------
inline bool FListView::setTreeView()
{ return setTreeView(true); }
//----------------------------------------------------------------------
inline bool FListView::unsetTreeView()
{ return setTreeView(false); }
//----------------------------------------------------------------------
inline FListView::listViewItems::iterator FListView::index2iterator (int index)
{

View File

@ -535,51 +535,51 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
{
unsetTermAttributes(term);
if ( off.pc_charset )
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.alt_charset )
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
}
else
{
if ( off.pc_charset )
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.alt_charset )
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
if ( off.bold )
if ( off.attr.bit.bold )
unsetTermBold(term);
if ( off.dim )
if ( off.attr.bit.dim )
unsetTermDim(term);
if ( off.italic )
if ( off.attr.bit.italic )
unsetTermItalic(term);
if ( off.underline )
if ( off.attr.bit.underline )
unsetTermUnderline(term);
if ( off.blink )
if ( off.attr.bit.blink )
unsetTermBlink(term);
if ( off.reverse )
if ( off.attr.bit.reverse )
unsetTermReverse(term);
if ( off.standout )
if ( off.attr.bit.standout )
unsetTermStandout(term);
if ( off.invisible )
if ( off.attr.bit.invisible )
unsetTermInvisible(term);
if ( off.protect )
if ( off.attr.bit.protect )
unsetTermProtected(term);
if ( off.crossed_out )
if ( off.attr.bit.crossed_out )
unsetTermCrossedOut(term);
if ( off.dbl_underline )
if ( off.attr.bit.dbl_underline )
unsetTermDoubleUnderline(term);
}
}
@ -587,33 +587,33 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
if ( colorChange(term, next) )
change_color (term, next);
}
else if ( F_set_attributes.cap && ! term->pc_charset )
else if ( F_set_attributes.cap && ! term->attr.bit.pc_charset )
{
if ( switchOn() || switchOff() )
setTermAttributes ( term
, next->standout
, next->underline
, next->reverse
, next->blink
, next->dim
, next->bold
, next->invisible
, next->protect
, next->alt_charset );
, next->attr.bit.standout
, next->attr.bit.underline
, next->attr.bit.reverse
, next->attr.bit.blink
, next->attr.bit.dim
, next->attr.bit.bold
, next->attr.bit.invisible
, next->attr.bit.protect
, next->attr.bit.alt_charset );
if ( off.pc_charset )
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( next->italic )
if ( next->attr.bit.italic )
setTermItalic(term);
if ( next->crossed_out )
if ( next->attr.bit.crossed_out )
setTermCrossedOut(term);
if ( next->dbl_underline )
if ( next->attr.bit.dbl_underline )
setTermDoubleUnderline(term);
if ( next->pc_charset )
if ( next->attr.bit.pc_charset )
setTermPCcharset(term);
if ( colorChange(term, next) )
@ -622,56 +622,56 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
if ( cygwin_terminal )
{
if ( next->bold )
if ( next->attr.bit.bold )
setTermBold(term);
if ( next->reverse )
if ( next->attr.bit.reverse )
setTermReverse(term);
if ( next->standout )
if ( next->attr.bit.standout )
setTermStandout(term);
}
}
}
else
{
if ( off.pc_charset )
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.alt_charset )
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
if ( off.bold )
if ( off.attr.bit.bold )
unsetTermBold(term);
if ( off.dim )
if ( off.attr.bit.dim )
unsetTermDim(term);
if ( off.italic )
if ( off.attr.bit.italic )
unsetTermItalic(term);
if ( off.underline )
if ( off.attr.bit.underline )
unsetTermUnderline(term);
if ( off.blink )
if ( off.attr.bit.blink )
unsetTermBlink(term);
if ( off.reverse )
if ( off.attr.bit.reverse )
unsetTermReverse(term);
if ( off.standout )
if ( off.attr.bit.standout )
unsetTermStandout(term);
if ( off.invisible )
if ( off.attr.bit.invisible )
unsetTermInvisible(term);
if ( off.protect )
if ( off.attr.bit.protect )
unsetTermProtected(term);
if ( off.crossed_out )
if ( off.attr.bit.crossed_out )
unsetTermCrossedOut(term);
if ( off.dbl_underline )
if ( off.attr.bit.dbl_underline )
unsetTermDoubleUnderline(term);
detectSwitchOff (term, next);
@ -684,48 +684,48 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
detectSwitchOn (term, next);
if ( on.alt_charset )
if ( on.attr.bit.alt_charset )
setTermAltCharset(term);
if ( on.pc_charset )
if ( on.attr.bit.pc_charset )
setTermPCcharset(term);
if ( on.bold )
if ( on.attr.bit.bold )
setTermBold(term);
if ( on.dim )
if ( on.attr.bit.dim )
setTermDim(term);
if ( on.italic )
if ( on.attr.bit.italic )
setTermItalic(term);
if ( on.underline )
if ( on.attr.bit.underline )
setTermUnderline(term);
if ( on.blink )
if ( on.attr.bit.blink )
setTermBlink(term);
if ( on.reverse )
if ( on.attr.bit.reverse )
setTermReverse(term);
if ( on.standout )
if ( on.attr.bit.standout )
setTermStandout(term);
if ( on.invisible )
if ( on.attr.bit.invisible )
setTermInvisible(term);
if ( on.protect )
if ( on.attr.bit.protect )
setTermProtected(term);
if ( on.crossed_out )
if ( on.attr.bit.crossed_out )
setTermCrossedOut(term);
if ( on.dbl_underline )
if ( on.attr.bit.dbl_underline )
setTermDoubleUnderline(term);
}
if ( term && fake_reverse )
term->reverse = true;
term->attr.bit.reverse = true;
return attr_buf;
}
@ -736,7 +736,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
inline bool FOptiAttr::setTermBold (char_data*& term)
{
if ( term && append_sequence(F_enter_bold_mode.cap) )
return (term->bold = true);
return (term->attr.bit.bold = true);
else
return false;
}
@ -751,8 +751,8 @@ inline bool FOptiAttr::unsetTermBold (char_data*& term)
reset(term);
else
{
term->bold = false;
term->dim = false;
term->attr.bit.bold = false;
term->attr.bit.dim = false;
}
return true;
@ -765,7 +765,7 @@ inline bool FOptiAttr::unsetTermBold (char_data*& term)
inline bool FOptiAttr::setTermDim (char_data*& term)
{
if ( term && append_sequence(F_enter_dim_mode.cap) )
return (term->dim = true);
return (term->attr.bit.dim = true);
else
return false;
}
@ -780,8 +780,8 @@ inline bool FOptiAttr::unsetTermDim (char_data*& term)
reset(term);
else
{
term->bold = false;
term->dim = false;
term->attr.bit.bold = false;
term->attr.bit.dim = false;
}
return true;
@ -794,7 +794,7 @@ inline bool FOptiAttr::unsetTermDim (char_data*& term)
inline bool FOptiAttr::setTermItalic (char_data*& term)
{
if ( term && append_sequence(F_enter_italics_mode.cap) )
return (term->italic = true);
return (term->attr.bit.italic = true);
else
return false;
}
@ -807,7 +807,7 @@ inline bool FOptiAttr::unsetTermItalic (char_data*& term)
if ( F_exit_italics_mode.caused_reset )
reset(term);
else
term->italic = false;
term->attr.bit.italic = false;
return true;
}
@ -819,7 +819,7 @@ inline bool FOptiAttr::unsetTermItalic (char_data*& term)
inline bool FOptiAttr::setTermUnderline (char_data*& term)
{
if ( term && append_sequence(F_enter_underline_mode.cap) )
return (term->underline = true);
return (term->attr.bit.underline = true);
else
return false;
}
@ -834,8 +834,8 @@ inline bool FOptiAttr::unsetTermUnderline (char_data*& term)
reset(term);
else
{
term->underline = false;
term->dbl_underline = false;
term->attr.bit.underline = false;
term->attr.bit.dbl_underline = false;
}
return true;
@ -848,7 +848,7 @@ inline bool FOptiAttr::unsetTermUnderline (char_data*& term)
inline bool FOptiAttr::setTermBlink (char_data*& term)
{
if ( term && append_sequence(F_enter_blink_mode.cap) )
return (term->blink = true);
return (term->attr.bit.blink = true);
else
return false;
}
@ -861,7 +861,7 @@ inline bool FOptiAttr::unsetTermBlink (char_data*& term)
if ( F_exit_blink_mode.caused_reset )
reset(term);
else
term->blink = false;
term->attr.bit.blink = false;
return true;
}
@ -873,7 +873,7 @@ inline bool FOptiAttr::unsetTermBlink (char_data*& term)
inline bool FOptiAttr::setTermReverse (char_data*& term)
{
if ( term && append_sequence(F_enter_reverse_mode.cap) )
return (term->reverse = true);
return (term->attr.bit.reverse = true);
else
return false;
}
@ -886,7 +886,7 @@ inline bool FOptiAttr::unsetTermReverse (char_data*& term)
if ( F_exit_reverse_mode.caused_reset )
reset(term);
else
term->reverse = false;
term->attr.bit.reverse = false;
return true;
}
@ -898,7 +898,7 @@ inline bool FOptiAttr::unsetTermReverse (char_data*& term)
inline bool FOptiAttr::setTermStandout (char_data*& term)
{
if ( term && append_sequence(F_enter_standout_mode.cap) )
return (term->standout = true);
return (term->attr.bit.standout = true);
else
return false;
}
@ -911,7 +911,7 @@ inline bool FOptiAttr::unsetTermStandout (char_data*& term)
if ( F_exit_standout_mode.caused_reset )
reset(term);
else
term->standout = false;
term->attr.bit.standout = false;
return true;
}
@ -923,7 +923,7 @@ inline bool FOptiAttr::unsetTermStandout (char_data*& term)
inline bool FOptiAttr::setTermInvisible (char_data*& term)
{
if ( term && append_sequence(F_enter_secure_mode.cap) )
return (term->invisible = true);
return (term->attr.bit.invisible = true);
else
return false;
}
@ -936,7 +936,7 @@ inline bool FOptiAttr::unsetTermInvisible (char_data*& term)
if ( F_exit_secure_mode.caused_reset )
reset(term);
else
term->invisible = false;
term->attr.bit.invisible = false;
return true;
}
@ -948,7 +948,7 @@ inline bool FOptiAttr::unsetTermInvisible (char_data*& term)
inline bool FOptiAttr::setTermProtected (char_data*& term)
{
if ( term && append_sequence(F_enter_protected_mode.cap) )
return (term->protect = true);
return (term->attr.bit.protect = true);
else
return false;
}
@ -961,7 +961,7 @@ inline bool FOptiAttr::unsetTermProtected (char_data*& term)
if ( F_exit_protected_mode.caused_reset )
reset(term);
else
term->protect = false;
term->attr.bit.protect = false;
return true;
}
@ -973,7 +973,7 @@ inline bool FOptiAttr::unsetTermProtected (char_data*& term)
inline bool FOptiAttr::setTermCrossedOut (char_data*& term)
{
if ( term && append_sequence(F_enter_crossed_out_mode.cap) )
return (term->crossed_out = true);
return (term->attr.bit.crossed_out = true);
else
return false;
}
@ -986,7 +986,7 @@ inline bool FOptiAttr::unsetTermCrossedOut (char_data*& term)
if ( F_exit_crossed_out_mode.caused_reset )
reset(term);
else
term->crossed_out = false;
term->attr.bit.crossed_out = false;
return true;
}
@ -998,7 +998,7 @@ inline bool FOptiAttr::unsetTermCrossedOut (char_data*& term)
inline bool FOptiAttr::setTermDoubleUnderline (char_data*& term)
{
if ( term && append_sequence(F_enter_dbl_underline_mode.cap) )
return (term->dbl_underline = true);
return (term->attr.bit.dbl_underline = true);
else
return false;
}
@ -1013,8 +1013,8 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (char_data*& term)
reset(term);
else
{
term->underline = false;
term->dbl_underline = false;
term->attr.bit.underline = false;
term->attr.bit.dbl_underline = false;
}
return true;
@ -1036,19 +1036,19 @@ bool FOptiAttr::setTermAttributes ( char_data*& term
append_sequence (sgr);
resetColor(term);
term->standout = p1;
term->underline = p2;
term->reverse = p3;
term->blink = p4;
term->dim = p5;
term->bold = p6;
term->invisible = p7;
term->protect = p8;
term->alt_charset = p9;
term->pc_charset = false;
term->italic = false;
term->crossed_out = false;
term->dbl_underline = false;
term->attr.bit.standout = p1;
term->attr.bit.underline = p2;
term->attr.bit.reverse = p3;
term->attr.bit.blink = p4;
term->attr.bit.dim = p5;
term->attr.bit.bold = p6;
term->attr.bit.invisible = p7;
term->attr.bit.protect = p8;
term->attr.bit.alt_charset = p9;
term->attr.bit.pc_charset = false;
term->attr.bit.italic = false;
term->attr.bit.crossed_out = false;
term->attr.bit.dbl_underline = false;
return true;
}
@ -1073,7 +1073,7 @@ inline bool FOptiAttr::setTermAltCharset (char_data*& term)
{
if ( term && append_sequence(F_enter_alt_charset_mode.cap) )
{
term->alt_charset = true;
term->attr.bit.alt_charset = true;
return true;
}
else
@ -1085,7 +1085,7 @@ inline bool FOptiAttr::unsetTermAltCharset (char_data*& term)
{
if ( term && append_sequence(F_exit_alt_charset_mode.cap) )
{
term->alt_charset = false;
term->attr.bit.alt_charset = false;
return true;
}
else
@ -1097,7 +1097,7 @@ inline bool FOptiAttr::setTermPCcharset (char_data*& term)
{
if ( term && append_sequence(F_enter_pc_charset_mode.cap) )
{
term->pc_charset = true;
term->attr.bit.pc_charset = true;
return true;
}
else
@ -1109,7 +1109,7 @@ inline bool FOptiAttr::unsetTermPCcharset (char_data*& term)
{
if ( term && append_sequence(F_exit_pc_charset_mode.cap) )
{
term->pc_charset = false;
term->attr.bit.pc_charset = false;
return true;
}
else
@ -1160,19 +1160,19 @@ bool FOptiAttr::hasAttribute (char_data*& attr)
{
if ( attr )
{
return attr->bold == 1
|| attr->dim == 1
|| attr->italic == 1
|| attr->underline == 1
|| attr->blink == 1
|| attr->reverse == 1
|| attr->standout == 1
|| attr->invisible == 1
|| attr->protect == 1
|| attr->crossed_out == 1
|| attr->dbl_underline == 1
|| attr->alt_charset == 1
|| attr->pc_charset == 1;
return attr->attr.bit.bold == 1
|| attr->attr.bit.dim == 1
|| attr->attr.bit.italic == 1
|| attr->attr.bit.underline == 1
|| attr->attr.bit.blink == 1
|| attr->attr.bit.reverse == 1
|| attr->attr.bit.standout == 1
|| attr->attr.bit.invisible == 1
|| attr->attr.bit.protect == 1
|| attr->attr.bit.crossed_out == 1
|| attr->attr.bit.dbl_underline == 1
|| attr->attr.bit.alt_charset == 1
|| attr->attr.bit.pc_charset == 1;
}
return false;
@ -1241,19 +1241,19 @@ inline void FOptiAttr::prevent_no_color_video_attributes (char_data*& attr)
switch ( bit & attr_without_color )
{
case standout_mode:
if ( attr->standout )
attr->standout = false;
if ( attr->attr.bit.standout )
attr->attr.bit.standout = false;
break;
case underline_mode:
if ( attr->underline )
attr->underline = false;
if ( attr->attr.bit.underline )
attr->attr.bit.underline = false;
break;
case reverse_mode:
if ( attr->reverse )
if ( attr->attr.bit.reverse )
{
attr->reverse = false;
attr->attr.bit.reverse = false;
if ( attr->fg_color != attr->bg_color )
fake_reverse = true;
@ -1261,38 +1261,38 @@ inline void FOptiAttr::prevent_no_color_video_attributes (char_data*& attr)
break;
case blink_mode:
if ( attr->blink )
attr->blink = false;
if ( attr->attr.bit.blink )
attr->attr.bit.blink = false;
break;
case dim_mode:
if ( attr->dim )
attr->dim = false;
if ( attr->attr.bit.dim )
attr->attr.bit.dim = false;
break;
case bold_mode:
if ( attr->bold )
attr->bold = false;
if ( attr->attr.bit.bold )
attr->attr.bit.bold = false;
break;
case invisible_mode:
if ( attr->invisible )
attr->invisible = false;
if ( attr->attr.bit.invisible )
attr->attr.bit.invisible = false;
break;
case protected_mode:
if ( attr->protect )
attr->protect = false;
if ( attr->attr.bit.protect )
attr->attr.bit.protect = false;
break;
case alt_charset_mode:
if ( attr->alt_charset )
attr->alt_charset = false;
if ( attr->attr.bit.alt_charset )
attr->attr.bit.alt_charset = false;
break;
case italic_mode:
if ( attr->italic )
attr->italic = false;
if ( attr->attr.bit.italic )
attr->attr.bit.italic = false;
break;
default:
@ -1408,19 +1408,19 @@ inline void FOptiAttr::resetAttribute (char_data*& attr)
{
if ( attr )
{
attr->bold = \
attr->dim = \
attr->italic = \
attr->underline = \
attr->blink = \
attr->reverse = \
attr->standout = \
attr->invisible = \
attr->protect = \
attr->crossed_out = \
attr->dbl_underline = \
attr->alt_charset = \
attr->pc_charset = 0;
attr->attr.bit.bold = \
attr->attr.bit.dim = \
attr->attr.bit.italic = \
attr->attr.bit.underline = \
attr->attr.bit.blink = \
attr->attr.bit.reverse = \
attr->attr.bit.standout = \
attr->attr.bit.invisible = \
attr->attr.bit.protect = \
attr->attr.bit.crossed_out = \
attr->attr.bit.dbl_underline = \
attr->attr.bit.alt_charset = \
attr->attr.bit.pc_charset = 0;
}
}
@ -1469,19 +1469,19 @@ inline void FOptiAttr::detectSwitchOn (char_data*& term, char_data*& next)
if ( ! (term && next) )
return;
on.bold = ! term->bold && next->bold;
on.dim = ! term->dim && next->dim;
on.italic = ! term->italic && next->italic;
on.underline = ! term->underline && next->underline;
on.blink = ! term->blink && next->blink;
on.reverse = ! term->reverse && next->reverse;
on.standout = ! term->standout && next->standout;
on.invisible = ! term->invisible && next->invisible;
on.protect = ! term->protect && next->protect;
on.crossed_out = ! term->crossed_out && next->crossed_out;
on.dbl_underline = ! term->dbl_underline && next->dbl_underline;
on.alt_charset = ! term->alt_charset && next->alt_charset;
on.pc_charset = ! term->pc_charset && next->pc_charset;
on.attr.bit.bold = ! term->attr.bit.bold && next->attr.bit.bold;
on.attr.bit.dim = ! term->attr.bit.dim && next->attr.bit.dim;
on.attr.bit.italic = ! term->attr.bit.italic && next->attr.bit.italic;
on.attr.bit.underline = ! term->attr.bit.underline && next->attr.bit.underline;
on.attr.bit.blink = ! term->attr.bit.blink && next->attr.bit.blink;
on.attr.bit.reverse = ! term->attr.bit.reverse && next->attr.bit.reverse;
on.attr.bit.standout = ! term->attr.bit.standout && next->attr.bit.standout;
on.attr.bit.invisible = ! term->attr.bit.invisible && next->attr.bit.invisible;
on.attr.bit.protect = ! term->attr.bit.protect && next->attr.bit.protect;
on.attr.bit.crossed_out = ! term->attr.bit.crossed_out && next->attr.bit.crossed_out;
on.attr.bit.dbl_underline = ! term->attr.bit.dbl_underline && next->attr.bit.dbl_underline;
on.attr.bit.alt_charset = ! term->attr.bit.alt_charset && next->attr.bit.alt_charset;
on.attr.bit.pc_charset = ! term->attr.bit.pc_charset && next->attr.bit.pc_charset;
}
//----------------------------------------------------------------------
@ -1490,19 +1490,19 @@ inline void FOptiAttr::detectSwitchOff (char_data*& term, char_data*& next)
if ( ! (term && next) )
return;
off.bold = term->bold && ! next->bold;
off.dim = term->dim && ! next->dim;
off.italic = term->italic && ! next->italic;
off.underline = term->underline && ! next->underline;
off.blink = term->blink && ! next->blink;
off.reverse = term->reverse && ! next->reverse;
off.standout = term->standout && ! next->standout;
off.invisible = term->invisible && ! next->invisible;
off.protect = term->protect && ! next->protect;
off.crossed_out = term->crossed_out && ! next->crossed_out;
off.dbl_underline = term->dbl_underline && ! next->dbl_underline;
off.alt_charset = term->alt_charset && ! next->alt_charset;
off.pc_charset = term->pc_charset && ! next->pc_charset;
off.attr.bit.bold = term->attr.bit.bold && ! next->attr.bit.bold;
off.attr.bit.dim = term->attr.bit.dim && ! next->attr.bit.dim;
off.attr.bit.italic = term->attr.bit.italic && ! next->attr.bit.italic;
off.attr.bit.underline = term->attr.bit.underline && ! next->attr.bit.underline;
off.attr.bit.blink = term->attr.bit.blink && ! next->attr.bit.blink;
off.attr.bit.reverse = term->attr.bit.reverse && ! next->attr.bit.reverse;
off.attr.bit.standout = term->attr.bit.standout && ! next->attr.bit.standout;
off.attr.bit.invisible = term->attr.bit.invisible && ! next->attr.bit.invisible;
off.attr.bit.protect = term->attr.bit.protect && ! next->attr.bit.protect;
off.attr.bit.crossed_out = term->attr.bit.crossed_out && ! next->attr.bit.crossed_out;
off.attr.bit.dbl_underline = term->attr.bit.dbl_underline && ! next->attr.bit.dbl_underline;
off.attr.bit.alt_charset = term->attr.bit.alt_charset && ! next->attr.bit.alt_charset;
off.attr.bit.pc_charset = term->attr.bit.pc_charset && ! next->attr.bit.pc_charset;
}
//----------------------------------------------------------------------

View File

@ -39,6 +39,12 @@ class FOptiAttr
int code; // character code
short fg_color; // foreground color
short bg_color; // background color
union attribute
{
struct
{
// Attribute byte #1
uChar bold : 1; // bold
uChar dim : 1; // dim
uChar italic : 1; // italic
@ -47,6 +53,7 @@ class FOptiAttr
uChar reverse : 1; // reverse
uChar standout : 1; // standout
uChar invisible : 1; // invisible
// Attribute byte #2
uChar protect : 1; // protect mode
uChar crossed_out : 1; // crossed out
uChar dbl_underline : 1; // double underline
@ -55,9 +62,17 @@ class FOptiAttr
uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background
// Attribute byte #3
uChar no_changes : 1; // no changes required
uChar printed : 1; // is printed to VTerm
uChar : 6; // padding bits
} bit;
uChar byte1;
uChar byte2;
uChar byte3;
} attr;
} char_data;
// Constructor
@ -267,22 +282,8 @@ inline bool operator == ( const FOptiAttr::char_data& lhs,
return lhs.code == rhs.code
&& lhs.fg_color == rhs.fg_color
&& lhs.bg_color == rhs.bg_color
&& lhs.bold == rhs.bold
&& lhs.dim == rhs.dim
&& lhs.italic == rhs.italic
&& lhs.underline == rhs.underline
&& lhs.blink == rhs.blink
&& lhs.reverse == rhs.reverse
&& lhs.standout == rhs.standout
&& lhs.invisible == rhs.invisible
&& lhs.protect == rhs.protect
&& lhs.crossed_out == rhs.crossed_out
&& lhs.dbl_underline == rhs.dbl_underline
&& lhs.alt_charset == rhs.alt_charset
&& lhs.pc_charset == rhs.pc_charset
&& lhs.transparent == rhs.transparent
&& lhs.trans_shadow == rhs.trans_shadow
&& lhs.inherit_bg == rhs.inherit_bg;
&& lhs.attr.byte1 == rhs.attr.byte1
&& lhs.attr.byte2 == rhs.attr.byte2;
}
//----------------------------------------------------------------------

View File

@ -119,8 +119,8 @@ int FTermBuffer::write (const FString& s)
char_data nc; // next character
nc = FVTerm::getAttribute();
nc.code = *p;
nc.no_changes = false;
nc.printed = false;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
data.push_back(nc);
@ -138,8 +138,8 @@ int FTermBuffer::write (register int c)
char_data nc; // next character
nc = FVTerm::getAttribute();
nc.code = c;
nc.no_changes = false;
nc.printed = false;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
data.push_back(nc);
return 1;

View File

@ -479,24 +479,24 @@ int FVTerm::print (term_area* area, const FString& s)
nc.code = *p;
nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color;
nc.bold = next_attribute.bold;
nc.dim = next_attribute.dim;
nc.italic = next_attribute.italic;
nc.underline = next_attribute.underline;
nc.blink = next_attribute.blink;
nc.reverse = next_attribute.reverse;
nc.standout = next_attribute.standout;
nc.invisible = next_attribute.invisible;
nc.protect = next_attribute.protect;
nc.crossed_out = next_attribute.crossed_out;
nc.dbl_underline = next_attribute.dbl_underline;
nc.alt_charset = next_attribute.alt_charset;
nc.pc_charset = next_attribute.pc_charset;
nc.transparent = next_attribute.transparent;
nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg;
nc.no_changes = false;
nc.printed = false;
nc.attr.bit.bold = next_attribute.attr.bit.bold;
nc.attr.bit.dim = next_attribute.attr.bit.dim;
nc.attr.bit.italic = next_attribute.attr.bit.italic;
nc.attr.bit.underline = next_attribute.attr.bit.underline;
nc.attr.bit.blink = next_attribute.attr.bit.blink;
nc.attr.bit.reverse = next_attribute.attr.bit.reverse;
nc.attr.bit.standout = next_attribute.attr.bit.standout;
nc.attr.bit.invisible = next_attribute.attr.bit.invisible;
nc.attr.bit.protect = next_attribute.attr.bit.protect;
nc.attr.bit.crossed_out = next_attribute.attr.bit.crossed_out;
nc.attr.bit.dbl_underline = next_attribute.attr.bit.dbl_underline;
nc.attr.bit.alt_charset = next_attribute.attr.bit.alt_charset;
nc.attr.bit.pc_charset = next_attribute.attr.bit.pc_charset;
nc.attr.bit.transparent = next_attribute.attr.bit.transparent;
nc.attr.bit.trans_shadow = next_attribute.attr.bit.trans_shadow;
nc.attr.bit.inherit_bg = next_attribute.attr.bit.inherit_bg;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
if ( area->cursor_x > 0
&& area->cursor_y > 0
@ -509,16 +509,16 @@ int FVTerm::print (term_area* area, const FString& s)
if ( *ac != nc ) // compare with an overloaded operator
{
if ( ( ! ac->transparent && nc.transparent )
|| ( ! ac->trans_shadow && nc.trans_shadow )
|| ( ! ac->inherit_bg && nc.inherit_bg ) )
if ( ( ! ac->attr.bit.transparent && nc.attr.bit.transparent )
|| ( ! ac->attr.bit.trans_shadow && nc.attr.bit.trans_shadow )
|| ( ! ac->attr.bit.inherit_bg && nc.attr.bit.inherit_bg ) )
{
// add one transparent character form line
area->changes[ay].trans_count++;
}
else if ( ( ac->transparent && ! nc.transparent )
|| ( ac->trans_shadow && ! nc.trans_shadow )
|| ( ac->inherit_bg && ! nc.inherit_bg ) )
else if ( ( ac->attr.bit.transparent && ! nc.attr.bit.transparent )
|| ( ac->attr.bit.trans_shadow && ! nc.attr.bit.trans_shadow )
|| ( ac->attr.bit.inherit_bg && ! nc.attr.bit.inherit_bg ) )
{
// remove one transparent character from line
area->changes[ay].trans_count--;
@ -645,16 +645,16 @@ int FVTerm::print (term_area* area, const std::vector<char_data>& termString)
if ( *ac != nc ) // compare with an overloaded operator
{
if ( ( ! ac->transparent && nc.transparent )
|| ( ! ac->trans_shadow && nc.trans_shadow )
|| ( ! ac->inherit_bg && nc.inherit_bg ) )
if ( ( ! ac->attr.bit.transparent && nc.attr.bit.transparent )
|| ( ! ac->attr.bit.trans_shadow && nc.attr.bit.trans_shadow )
|| ( ! ac->attr.bit.inherit_bg && nc.attr.bit.inherit_bg ) )
{
// add one transparent character form line
area->changes[ay].trans_count++;
}
else if ( ( ac->transparent && ! nc.transparent )
|| ( ac->trans_shadow && ! nc.trans_shadow )
|| ( ac->inherit_bg && ! nc.inherit_bg ) )
else if ( ( ac->attr.bit.transparent && ! nc.attr.bit.transparent )
|| ( ac->attr.bit.trans_shadow && ! nc.attr.bit.trans_shadow )
|| ( ac->attr.bit.inherit_bg && ! nc.attr.bit.inherit_bg ) )
{
// remove one transparent character from line
area->changes[ay].trans_count--;
@ -729,24 +729,24 @@ int FVTerm::print (term_area* area, register int c)
nc.code = c;
nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color;
nc.bold = next_attribute.bold;
nc.dim = next_attribute.dim;
nc.italic = next_attribute.italic;
nc.underline = next_attribute.underline;
nc.blink = next_attribute.blink;
nc.reverse = next_attribute.reverse;
nc.standout = next_attribute.standout;
nc.invisible = next_attribute.invisible;
nc.protect = next_attribute.protect;
nc.crossed_out = next_attribute.crossed_out;
nc.dbl_underline = next_attribute.dbl_underline;
nc.alt_charset = next_attribute.alt_charset;
nc.pc_charset = next_attribute.pc_charset;
nc.transparent = next_attribute.transparent;
nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg;
nc.no_changes = false;
nc.printed = false;
nc.attr.bit.bold = next_attribute.attr.bit.bold;
nc.attr.bit.dim = next_attribute.attr.bit.dim;
nc.attr.bit.italic = next_attribute.attr.bit.italic;
nc.attr.bit.underline = next_attribute.attr.bit.underline;
nc.attr.bit.blink = next_attribute.attr.bit.blink;
nc.attr.bit.reverse = next_attribute.attr.bit.reverse;
nc.attr.bit.standout = next_attribute.attr.bit.standout;
nc.attr.bit.invisible = next_attribute.attr.bit.invisible;
nc.attr.bit.protect = next_attribute.attr.bit.protect;
nc.attr.bit.crossed_out = next_attribute.attr.bit.crossed_out;
nc.attr.bit.dbl_underline = next_attribute.attr.bit.dbl_underline;
nc.attr.bit.alt_charset = next_attribute.attr.bit.alt_charset;
nc.attr.bit.pc_charset = next_attribute.attr.bit.pc_charset;
nc.attr.bit.transparent = next_attribute.attr.bit.transparent;
nc.attr.bit.trans_shadow = next_attribute.attr.bit.trans_shadow;
nc.attr.bit.inherit_bg = next_attribute.attr.bit.inherit_bg;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
if ( area->cursor_x > 0
&& area->cursor_y > 0
@ -759,17 +759,17 @@ int FVTerm::print (term_area* area, register int c)
if ( *ac != nc ) // compare with an overloaded operator
{
if ( ( ! ac->transparent && nc.transparent )
|| ( ! ac->trans_shadow && nc.trans_shadow )
|| ( ! ac->inherit_bg && nc.inherit_bg ) )
if ( ( ! ac->attr.bit.transparent && nc.attr.bit.transparent )
|| ( ! ac->attr.bit.trans_shadow && nc.attr.bit.trans_shadow )
|| ( ! ac->attr.bit.inherit_bg && nc.attr.bit.inherit_bg ) )
{
// add one transparent character form line
area->changes[ay].trans_count++;
}
if ( ( ac->transparent && ! nc.transparent )
|| ( ac->trans_shadow && ! nc.trans_shadow )
|| ( ac->inherit_bg && ! nc.inherit_bg ) )
if ( ( ac->attr.bit.transparent && ! nc.attr.bit.transparent )
|| ( ac->attr.bit.trans_shadow && ! nc.attr.bit.trans_shadow )
|| ( ac->attr.bit.inherit_bg && ! nc.attr.bit.inherit_bg ) )
{
// remove one transparent character from line
area->changes[ay].trans_count--;
@ -1023,24 +1023,24 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
default_char.code = ' ';
default_char.fg_color = fc::Default;
default_char.bg_color = fc::Default;
default_char.bold = 0;
default_char.dim = 0;
default_char.italic = 0;
default_char.underline = 0;
default_char.blink = 0;
default_char.reverse = 0;
default_char.standout = 0;
default_char.invisible = 0;
default_char.protect = 0;
default_char.crossed_out = 0;
default_char.dbl_underline = 0;
default_char.alt_charset = 0;
default_char.pc_charset = 0;
default_char.transparent = 0;
default_char.trans_shadow = 0;
default_char.inherit_bg = 0;
default_char.no_changes = 0;
default_char.printed = 0;
default_char.attr.bit.bold = 0;
default_char.attr.bit.dim = 0;
default_char.attr.bit.italic = 0;
default_char.attr.bit.underline = 0;
default_char.attr.bit.blink = 0;
default_char.attr.bit.reverse = 0;
default_char.attr.bit.standout = 0;
default_char.attr.bit.invisible = 0;
default_char.attr.bit.protect = 0;
default_char.attr.bit.crossed_out = 0;
default_char.attr.bit.dbl_underline = 0;
default_char.attr.bit.alt_charset = 0;
default_char.attr.bit.pc_charset = 0;
default_char.attr.bit.transparent = 0;
default_char.attr.bit.trans_shadow = 0;
default_char.attr.bit.inherit_bg = 0;
default_char.attr.bit.no_changes = 0;
default_char.attr.bit.printed = 0;
std::fill_n (area->text, area_size, default_char);
@ -1156,16 +1156,16 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
int line_len = win->width + win->right_shadow;
tmp = &win->text[(ty+y-win_y) * line_len + (tx+x-win_x)];
if ( ! tmp->transparent ) // current character not transparent
if ( ! tmp->attr.bit.transparent ) // current character not transparent
{
if ( tmp->trans_shadow ) // transparent shadow
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
{
// keep the current vterm character
std::memcpy (&s_ch, sc, sizeof(char_data));
s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color;
s_ch.reverse = false;
s_ch.standout = false;
s_ch.attr.bit.reverse = false;
s_ch.attr.bit.standout = false;
if ( s_ch.code == fc::LowerHalfBlock
|| s_ch.code == fc::UpperHalfBlock
@ -1177,7 +1177,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
sc = &s_ch;
}
else if ( tmp->inherit_bg )
else if ( tmp->attr.bit.inherit_bg )
{
// add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(char_data));
@ -1254,11 +1254,11 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y) * line_len + (x-win_x)];
if ( tmp->trans_shadow )
if ( tmp->attr.bit.trans_shadow )
{
is_covered = half_covered;
}
else if ( ! tmp->transparent )
else if ( ! tmp->attr.bit.transparent )
{
is_covered = fully_covered;
break;
@ -1426,8 +1426,8 @@ void FVTerm::updateVTerm (term_area* area)
oc = getOverlappedCharacter (gx+1 - ol, gy+1, area->widget);
ch.fg_color = oc.fg_color;
ch.bg_color = oc.bg_color;
ch.reverse = false;
ch.standout = false;
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock
@ -1437,28 +1437,28 @@ void FVTerm::updateVTerm (term_area* area)
|| ch.code == fc::FullBlock )
ch.code = ' ';
ch.no_changes = bool(tc->printed && *tc == ch);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
}
else if ( ac->transparent ) // transparent
else if ( ac->attr.bit.transparent ) // transparent
{
// restore one character on vterm
char_data ch;
ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget);
ch.no_changes = bool(tc->printed && *tc == ch);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
}
else // not transparent
{
if ( ac->trans_shadow ) // transparent shadow
if ( ac->attr.bit.trans_shadow ) // transparent shadow
{
// get covered character + add the current color
char_data ch;
ch = getCoveredCharacter (gx+1 - ol, gy+1, area->widget);
ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color;
ch.reverse = false;
ch.standout = false;
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock
@ -1468,30 +1468,30 @@ void FVTerm::updateVTerm (term_area* area)
|| ch.code == fc::FullBlock )
ch.code = ' ';
ch.no_changes = bool(tc->printed && *tc == ch);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
}
else if ( ac->inherit_bg )
else if ( ac->attr.bit.inherit_bg )
{
// add the covered background to this character
char_data ch, cc;
std::memcpy (&ch, ac, sizeof(char_data));
cc = getCoveredCharacter (gx+1 - ol, gy+1, area->widget);
ch.bg_color = cc.bg_color;
ch.no_changes = bool(tc->printed && *tc == ch);
ch.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == ch);
std::memcpy (tc, &ch, sizeof(char_data));
}
else // default
{
if ( tc->printed && *tc == *ac )
if ( tc->attr.bit.printed && *tc == *ac )
{
std::memcpy (tc, ac, sizeof(char_data));
tc->no_changes = true;
tc->attr.bit.no_changes = true;
}
else
{
std::memcpy (tc, ac, sizeof(char_data));
tc->no_changes = false;
tc->attr.bit.no_changes = false;
}
}
}
@ -1774,7 +1774,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
tc = &vterm->text[(ay+y) * vterm->width + (ax+x)];
ac = &area->text[y * line_len + ol + x];
if ( ac->transparent ) // transparent
if ( ac->attr.bit.transparent ) // transparent
{
// restore one character on vterm
char_data ch;
@ -1783,15 +1783,15 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
}
else // not transparent
{
if ( ac->trans_shadow ) // transparent shadow
if ( ac->attr.bit.trans_shadow ) // transparent shadow
{
// get covered character + add the current color
char_data ch;
ch = getCoveredCharacter (ax+x+1, ay+y+1, area->widget);
ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color;
ch.reverse = false;
ch.standout = false;
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock
@ -1803,7 +1803,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
std::memcpy (tc, &ch, sizeof(char_data));
}
else if ( ac->inherit_bg )
else if ( ac->attr.bit.inherit_bg )
{
// add the covered background to this character
char_data ch, cc;
@ -1975,7 +1975,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
{
if ( clearTerm (fillchar) )
{
nc.printed = true;
nc.attr.bit.printed = true;
std::fill_n (vterm->text, area_size, nc);
}
else
@ -1996,7 +1996,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
else
{
char_data t_char = nc;
t_char.transparent = true;
t_char.attr.bit.transparent = true;
for (int y=0; y < area->height; y++)
{
@ -2020,9 +2020,9 @@ void FVTerm::clearArea (term_area* area, int fillchar)
area->changes[i].xmin = 0;
area->changes[i].xmax = w - 1;
if ( nc.transparent
|| nc.trans_shadow
|| nc.inherit_bg )
if ( nc.attr.bit.transparent
|| nc.attr.bit.trans_shadow
|| nc.attr.bit.inherit_bg )
area->changes[i].trans_count = w;
else if ( area->right_shadow != 0 )
area->changes[i].trans_count = uInt(area->right_shadow);
@ -2127,19 +2127,19 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
tmp = &win->text[(y-win_y) * line_len + (x-win_x)];
// current character not transparent
if ( ! tmp->transparent )
if ( ! tmp->attr.bit.transparent )
{
if ( tmp->trans_shadow ) // transparent shadow
if ( tmp->attr.bit.trans_shadow ) // transparent shadow
{
// keep the current vterm character
std::memcpy (&s_ch, cc, sizeof(char_data));
s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color;
s_ch.reverse = false;
s_ch.standout = false;
s_ch.attr.bit.reverse = false;
s_ch.attr.bit.standout = false;
cc = &s_ch;
}
else if ( tmp->inherit_bg )
else if ( tmp->attr.bit.inherit_bg )
{
// add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(char_data));
@ -2276,24 +2276,24 @@ void FVTerm::init()
term_attribute.code = '\0';
term_attribute.fg_color = fc::Default;
term_attribute.bg_color = fc::Default;
term_attribute.bold = \
term_attribute.dim = \
term_attribute.italic = \
term_attribute.underline = \
term_attribute.blink = \
term_attribute.reverse = \
term_attribute.standout = \
term_attribute.invisible = \
term_attribute.protect = \
term_attribute.crossed_out = \
term_attribute.dbl_underline = \
term_attribute.alt_charset = \
term_attribute.pc_charset = \
term_attribute.transparent = \
term_attribute.trans_shadow = \
term_attribute.inherit_bg = \
term_attribute.no_changes = \
term_attribute.printed = false;
term_attribute.attr.bit.bold = \
term_attribute.attr.bit.dim = \
term_attribute.attr.bit.italic = \
term_attribute.attr.bit.underline = \
term_attribute.attr.bit.blink = \
term_attribute.attr.bit.reverse = \
term_attribute.attr.bit.standout = \
term_attribute.attr.bit.invisible = \
term_attribute.attr.bit.protect = \
term_attribute.attr.bit.crossed_out = \
term_attribute.attr.bit.dbl_underline = \
term_attribute.attr.bit.alt_charset = \
term_attribute.attr.bit.pc_charset = \
term_attribute.attr.bit.transparent = \
term_attribute.attr.bit.trans_shadow = \
term_attribute.attr.bit.inherit_bg = \
term_attribute.attr.bit.no_changes = \
term_attribute.attr.bit.printed = false;
// next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(char_data));
@ -2506,10 +2506,10 @@ void FVTerm::updateTerminalLine (uInt y)
{
char_data* print_char;
print_char = &vt->text[y * uInt(vt->width) + x];
print_char->printed = true;
print_char->attr.bit.printed = true;
// skip character with no changes
if ( print_char->no_changes )
if ( print_char->attr.bit.no_changes )
{
uInt count = 1;
@ -2517,7 +2517,7 @@ void FVTerm::updateTerminalLine (uInt y)
{
char_data* ch = &vt->text[y * uInt(vt->width) + i];
if ( ch->no_changes )
if ( ch->attr.bit.no_changes )
count++;
else
break;
@ -2705,7 +2705,7 @@ inline void FVTerm::markAsPrinted (uInt pos, uInt line)
{
// Marks a character as printed
vterm->text[line * uInt(vterm->width) + pos].printed = true;
vterm->text[line * uInt(vterm->width) + pos].attr.bit.printed = true;
}
//----------------------------------------------------------------------
@ -2714,7 +2714,7 @@ inline void FVTerm::markAsPrinted (uInt from, uInt to, uInt line)
// Marks characters in the specified range [from .. to] as printed
for (uInt x=from; x <= to; x++)
vterm->text[line * uInt(vterm->width) + x].printed = true;
vterm->text[line * uInt(vterm->width) + x].attr.bit.printed = true;
}
//----------------------------------------------------------------------
@ -2778,10 +2778,10 @@ inline void FVTerm::charsetChanges (char_data*& next_char)
next_char->code = int(ch_enc);
if ( Encoding == fc::VT100 )
next_char->alt_charset = true;
next_char->attr.bit.alt_charset = true;
else if ( Encoding == fc::PC )
{
next_char->pc_charset = true;
next_char->attr.bit.pc_charset = true;
if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 ) // Character 0x00..0x1f
next_char->code = int(charEncode(code, fc::ASCII));

View File

@ -482,23 +482,23 @@ inline void FVTerm::setColor (register short fg, register short bg)
inline void FVTerm::setNormal()
{
// reset all character attributes
next_attribute.bold = \
next_attribute.dim = \
next_attribute.italic = \
next_attribute.underline = \
next_attribute.blink = \
next_attribute.reverse = \
next_attribute.standout = \
next_attribute.invisible = \
next_attribute.protect = \
next_attribute.crossed_out = \
next_attribute.dbl_underline = \
next_attribute.alt_charset = \
next_attribute.pc_charset = \
next_attribute.transparent = \
next_attribute.trans_shadow = \
next_attribute.inherit_bg = \
next_attribute.no_changes = false;
next_attribute.attr.bit.bold = \
next_attribute.attr.bit.dim = \
next_attribute.attr.bit.italic = \
next_attribute.attr.bit.underline = \
next_attribute.attr.bit.blink = \
next_attribute.attr.bit.reverse = \
next_attribute.attr.bit.standout = \
next_attribute.attr.bit.invisible = \
next_attribute.attr.bit.protect = \
next_attribute.attr.bit.crossed_out = \
next_attribute.attr.bit.dbl_underline = \
next_attribute.attr.bit.alt_charset = \
next_attribute.attr.bit.pc_charset = \
next_attribute.attr.bit.transparent = \
next_attribute.attr.bit.trans_shadow = \
next_attribute.attr.bit.inherit_bg = \
next_attribute.attr.bit.no_changes = false;
next_attribute.fg_color = fc::Default;
next_attribute.bg_color = fc::Default;
@ -506,7 +506,7 @@ inline void FVTerm::setNormal()
//----------------------------------------------------------------------
inline bool FVTerm::setBold (register bool on)
{ return (next_attribute.bold = on); }
{ return (next_attribute.attr.bit.bold = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setBold()
@ -518,7 +518,7 @@ inline bool FVTerm::unsetBold()
//----------------------------------------------------------------------
inline bool FVTerm::setDim (register bool on)
{ return (next_attribute.dim = on); }
{ return (next_attribute.attr.bit.dim = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setDim()
@ -530,7 +530,7 @@ inline bool FVTerm::unsetDim()
//----------------------------------------------------------------------
inline bool FVTerm::setItalic (register bool on)
{ return (next_attribute.italic = on); }
{ return (next_attribute.attr.bit.italic = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setItalic()
@ -542,7 +542,7 @@ inline bool FVTerm::unsetItalic()
//----------------------------------------------------------------------
inline bool FVTerm::setUnderline (register bool on)
{ return (next_attribute.underline = on); }
{ return (next_attribute.attr.bit.underline = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setUnderline()
@ -554,7 +554,7 @@ inline bool FVTerm::unsetUnderline()
//----------------------------------------------------------------------
inline bool FVTerm::setBlink (register bool on)
{ return (next_attribute.blink = on); }
{ return (next_attribute.attr.bit.blink = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setBlink()
@ -566,7 +566,7 @@ inline bool FVTerm::unsetBlink()
//----------------------------------------------------------------------
inline bool FVTerm::setReverse (register bool on)
{ return (next_attribute.reverse = on); }
{ return (next_attribute.attr.bit.reverse = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setReverse()
@ -578,7 +578,7 @@ inline bool FVTerm::unsetReverse()
//----------------------------------------------------------------------
inline bool FVTerm::setStandout (register bool on)
{ return (next_attribute.standout = on); }
{ return (next_attribute.attr.bit.standout = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setStandout()
@ -590,7 +590,7 @@ inline bool FVTerm::unsetStandout()
//----------------------------------------------------------------------
inline bool FVTerm::setInvisible (register bool on)
{ return (next_attribute.invisible = on); }
{ return (next_attribute.attr.bit.invisible = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setInvisible()
@ -602,7 +602,7 @@ inline bool FVTerm::unsetInvisible()
//----------------------------------------------------------------------
inline bool FVTerm::setProtected (register bool on)
{ return (next_attribute.protect = on); }
{ return (next_attribute.attr.bit.protect = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setProtected()
@ -614,7 +614,7 @@ inline bool FVTerm::unsetProtected()
//----------------------------------------------------------------------
inline bool FVTerm::setCrossedOut (register bool on)
{ return (next_attribute.crossed_out = on); }
{ return (next_attribute.attr.bit.crossed_out = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setCrossedOut()
@ -626,7 +626,7 @@ inline bool FVTerm::unsetCrossedOut()
//----------------------------------------------------------------------
inline bool FVTerm::setDoubleUnderline (register bool on)
{ return (next_attribute.dbl_underline = on); }
{ return (next_attribute.attr.bit.dbl_underline = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setDoubleUnderline()
@ -638,7 +638,7 @@ inline bool FVTerm::unsetDoubleUnderline()
//----------------------------------------------------------------------
inline bool FVTerm::setAltCharset (register bool on)
{ return (next_attribute.alt_charset = on); }
{ return (next_attribute.attr.bit.alt_charset = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setAltCharset()
@ -650,7 +650,7 @@ inline bool FVTerm::unsetAltCharset()
//----------------------------------------------------------------------
inline bool FVTerm::setPCcharset (register bool on)
{ return (next_attribute.pc_charset = on); }
{ return (next_attribute.attr.bit.pc_charset = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setPCcharset()
@ -662,7 +662,7 @@ inline bool FVTerm::unsetPCcharset()
//----------------------------------------------------------------------
inline bool FVTerm::setTransparent (register bool on)
{ return (next_attribute.transparent = on); }
{ return (next_attribute.attr.bit.transparent = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setTransparent()
@ -674,7 +674,7 @@ inline bool FVTerm::unsetTransparent()
//----------------------------------------------------------------------
inline bool FVTerm::setTransShadow (register bool on)
{ return (next_attribute.trans_shadow = on); }
{ return (next_attribute.attr.bit.trans_shadow = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setTransShadow()
@ -686,7 +686,7 @@ inline bool FVTerm::unsetTransShadow()
//----------------------------------------------------------------------
inline bool FVTerm::setInheritBackground (register bool on)
{ return (next_attribute.inherit_bg = on); }
{ return (next_attribute.attr.bit.inherit_bg = on); }
//----------------------------------------------------------------------
inline bool FVTerm::setInheritBackground()
@ -702,67 +702,67 @@ inline bool FVTerm::isCursorHidden()
//----------------------------------------------------------------------
inline bool FVTerm::isBold()
{ return next_attribute.bold; }
{ return next_attribute.attr.bit.bold; }
//----------------------------------------------------------------------
inline bool FVTerm::isDim()
{ return next_attribute.dim; }
{ return next_attribute.attr.bit.dim; }
//----------------------------------------------------------------------
inline bool FVTerm::isItalic()
{ return next_attribute.italic; }
{ return next_attribute.attr.bit.italic; }
//----------------------------------------------------------------------
inline bool FVTerm::isUnderline()
{ return next_attribute.underline; }
{ return next_attribute.attr.bit.underline; }
//----------------------------------------------------------------------
inline bool FVTerm::isBlink()
{ return next_attribute.blink; }
{ return next_attribute.attr.bit.blink; }
//----------------------------------------------------------------------
inline bool FVTerm::isReverse()
{ return next_attribute.reverse; }
{ return next_attribute.attr.bit.reverse; }
//----------------------------------------------------------------------
inline bool FVTerm::isStandout()
{ return next_attribute.standout; }
{ return next_attribute.attr.bit.standout; }
//----------------------------------------------------------------------
inline bool FVTerm::isInvisible()
{ return next_attribute.invisible; }
{ return next_attribute.attr.bit.invisible; }
//----------------------------------------------------------------------
inline bool FVTerm::isProtected()
{ return next_attribute.protect; }
{ return next_attribute.attr.bit.protect; }
//----------------------------------------------------------------------
inline bool FVTerm::isCrossedOut()
{ return next_attribute.crossed_out; }
{ return next_attribute.attr.bit.crossed_out; }
//----------------------------------------------------------------------
inline bool FVTerm::isDoubleUnderline()
{ return next_attribute.dbl_underline; }
{ return next_attribute.attr.bit.dbl_underline; }
//----------------------------------------------------------------------
inline bool FVTerm::isAltCharset()
{ return next_attribute.alt_charset; }
{ return next_attribute.attr.bit.alt_charset; }
//----------------------------------------------------------------------
inline bool FVTerm::isPCcharset()
{ return next_attribute.pc_charset; }
{ return next_attribute.attr.bit.pc_charset; }
//----------------------------------------------------------------------
inline bool FVTerm::isTransparent()
{ return next_attribute.transparent; }
{ return next_attribute.attr.bit.transparent; }
//----------------------------------------------------------------------
inline bool FVTerm::isTransShadow()
{ return next_attribute.trans_shadow; }
{ return next_attribute.attr.bit.trans_shadow; }
//----------------------------------------------------------------------
inline bool FVTerm::isInheritBackground()
{ return next_attribute.inherit_bg; }
{ return next_attribute.attr.bit.inherit_bg; }
//----------------------------------------------------------------------
inline FVTerm& FVTerm::print()

View File

@ -1102,22 +1102,22 @@ void FWidget::redraw()
default_char.code = ' ';
default_char.fg_color = fc::Black;
default_char.bg_color = fc::Black;
default_char.bold = 0;
default_char.dim = 0;
default_char.italic = 0;
default_char.underline = 0;
default_char.blink = 0;
default_char.reverse = 0;
default_char.standout = 0;
default_char.invisible = 0;
default_char.protect = 0;
default_char.crossed_out = 0;
default_char.dbl_underline = 0;
default_char.alt_charset = 0;
default_char.pc_charset = 0;
default_char.transparent = 0;
default_char.trans_shadow = 0;
default_char.inherit_bg = 0;
default_char.attr.bit.bold = 0;
default_char.attr.bit.dim = 0;
default_char.attr.bit.italic = 0;
default_char.attr.bit.underline = 0;
default_char.attr.bit.blink = 0;
default_char.attr.bit.reverse = 0;
default_char.attr.bit.standout = 0;
default_char.attr.bit.invisible = 0;
default_char.attr.bit.protect = 0;
default_char.attr.bit.crossed_out = 0;
default_char.attr.bit.dbl_underline = 0;
default_char.attr.bit.alt_charset = 0;
default_char.attr.bit.pc_charset = 0;
default_char.attr.bit.transparent = 0;
default_char.attr.bit.trans_shadow = 0;
default_char.attr.bit.inherit_bg = 0;
if ( window_list && ! window_list->empty() )
{