FVTerm code cleanup

This commit is contained in:
Markus Gans 2020-10-23 01:07:59 +02:00
parent a4a3d93203
commit e0cc130074
4 changed files with 138 additions and 191 deletions

View File

@ -442,9 +442,9 @@ FTermDebugData& FTerm::getFTermDebugData()
#endif // DEBUG #endif // DEBUG
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isNormal (const FChar* const& ch) bool FTerm::isNormal (const FChar& ch)
{ {
return FOptiAttr::isNormal(ch); return FOptiAttr::isNormal(&ch);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -799,9 +799,9 @@ void FVTerm::restoreVTerm (const FRect& box)
for (int tx{0}; tx < w; tx++) for (int tx{0}; tx < w; tx++)
{ {
const int xpos = x + tx; const int xpos = x + tx;
auto tc = &vterm->data[ypos * vterm->width + xpos]; // terminal character auto& tc = vterm->data[ypos * vterm->width + xpos]; // terminal character
auto sc = generateCharacter(FPoint{xpos, ypos}); // shown character auto sc = generateCharacter(FPoint{xpos, ypos}); // shown character
std::memcpy (tc, &sc, sizeof(*tc)); std::memcpy (&tc, &sc, sizeof(tc));
} }
if ( int(vterm->changes[ypos].xmin) > x ) if ( int(vterm->changes[ypos].xmin) > x )
@ -817,26 +817,17 @@ void FVTerm::restoreVTerm (const FRect& box)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::updateVTermCursor (const FTermArea* area) const bool FVTerm::updateVTermCursor (const FTermArea* area) const
{ {
if ( ! area ) if ( ! (area && isActive(area) && area->visible) )
return false;
if ( ! isActive(area) )
return false;
if ( ! area->visible )
return false; return false;
if ( area->input_cursor_visible ) if ( area->input_cursor_visible )
{ {
// area offset
const int ax = area->offset_left;
const int ay = area->offset_top;
// area cursor position // area cursor position
const int cx = area->input_cursor_x; const int cx = area->input_cursor_x;
const int cy = area->input_cursor_y; const int cy = area->input_cursor_y;
// terminal position // terminal position = area offset + area cursor position
const int x = ax + cx; const int x = area->offset_left + cx;
const int y = ay + cy; const int y = area->offset_top + cy;
if ( isInsideArea (FPoint{cx, cy}, area) if ( isInsideArea (FPoint{cx, cy}, area)
&& isInsideTerminal (FPoint{x, y}) && isInsideTerminal (FPoint{x, y})
@ -1009,12 +1000,13 @@ void FVTerm::putArea (const FTermArea* area) const
continue; continue;
tx -= ol; tx -= ol;
bool update = updateVTermCharacter(area, FPoint{x, y}, FPoint{tx, ty});
if ( updateVTermCharacter(area, FPoint{x, y}, FPoint{tx, ty}) ) if ( ! modified && ! update )
modified = true;
if ( ! modified )
line_xmin++; // Don't update covered character line_xmin++; // Don't update covered character
if ( update )
modified = true;
} }
int _xmin = ax + line_xmin - ol; int _xmin = ax + line_xmin - ol;
@ -1079,7 +1071,7 @@ void FVTerm::putArea (const FPoint& pos, const FTermArea* area)
// Line has only covered characters // Line has only covered characters
const auto& ac = area->data[y * width + ol]; // area character const auto& ac = area->data[y * width + ol]; // area character
auto& tc = vterm->data[(ay + y) * vterm->width + ax]; // terminal character auto& tc = vterm->data[(ay + y) * vterm->width + ax]; // terminal character
putAreaLine (&ac, &tc, length); putAreaLine (ac, tc, std::size_t(length));
} }
else else
{ {
@ -1090,7 +1082,7 @@ void FVTerm::putArea (const FPoint& pos, const FTermArea* area)
const int cy = ay + y; const int cy = ay + y;
const auto& ac = area->data[y * width + ol + x]; // area character const auto& ac = area->data[y * width + ol + x]; // area character
auto& tc = vterm->data[cy * vterm->width + cx]; // terminal character auto& tc = vterm->data[cy * vterm->width + cx]; // terminal character
putAreaCharacter (FPoint{cx + 1, cy + 1}, area->widget, &ac, &tc); putAreaCharacter (FPoint{cx, cy}, area, ac, tc);
} }
} }
@ -1446,28 +1438,17 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedColor ( const FTermArea* area void FVTerm::updateOverlappedColor ( const FChar& area_char
, const FPoint& area_pos , FChar&& over_char
, const FPoint& terminal_pos ) , FChar& vterm_char )
{ {
// Add the overlapping color to this character // Add the overlapping color to this character
const int x = area_pos.getX();
const int y = area_pos.getY();
const int tx = terminal_pos.getX();
const int ty = terminal_pos.getY();
const int width = area->width + area->right_shadow;
// Area character
const auto& ac = area->data[y * width + x];
// Terminal character
auto& tc = vterm->data[ty * vterm->width + tx];
// New character // New character
FChar nc{}; FChar nc{};
std::memcpy (&nc, &ac, sizeof(nc)); std::memcpy (&nc, &area_char, sizeof(nc));
// Overlapped character nc.fg_color = over_char.fg_color;
auto oc = getOverlappedCharacter (terminal_pos + FPoint{1, 1}, area->widget); nc.bg_color = over_char.bg_color;
nc.fg_color = oc.fg_color;
nc.bg_color = oc.bg_color;
nc.attr.bit.reverse = false; nc.attr.bit.reverse = false;
nc.attr.bit.standout = false; nc.attr.bit.standout = false;
@ -1479,109 +1460,73 @@ void FVTerm::updateOverlappedColor ( const FTermArea* area
|| nc.ch == fc::FullBlock ) || nc.ch == fc::FullBlock )
nc.ch = ' '; nc.ch = ' ';
nc.attr.bit.no_changes = bool(tc.attr.bit.printed && tc == nc); nc.attr.bit.no_changes = bool(vterm_char.attr.bit.printed && vterm_char == nc);
std::memcpy (&tc, &nc, sizeof(tc)); std::memcpy (&vterm_char, &nc, sizeof(vterm_char));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedCharacter ( const FTermArea* area void FVTerm::updateOverlappedCharacter ( FChar&& cover_char
, const FPoint& terminal_pos ) , FChar& vterm_char )
{ {
// Restore one character on vterm // Restore one character on vterm
// Terminal character cover_char.attr.bit.no_changes = \
const int tx = terminal_pos.getX(); bool(vterm_char.attr.bit.printed && vterm_char == cover_char);
const int ty = terminal_pos.getY(); std::memcpy (&vterm_char, &cover_char, sizeof(vterm_char));
auto tc = &vterm->data[ty * vterm->width + tx];
// Overlapped character
auto oc = getCoveredCharacter (terminal_pos + FPoint{1, 1}, area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(*tc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateShadedCharacter ( const FTermArea* area void FVTerm::updateShadedCharacter ( const FChar& area_char
, const FPoint& area_pos , FChar&& cover_char
, const FPoint& terminal_pos ) , FChar& vterm_char )
{ {
// Get covered character + add the current color // Get covered character + add the current color
const int x = area_pos.getX(); cover_char.fg_color = area_char.fg_color;
const int y = area_pos.getY(); cover_char.bg_color = area_char.bg_color;
const int tx = terminal_pos.getX(); cover_char.attr.bit.reverse = false;
const int ty = terminal_pos.getY(); cover_char.attr.bit.standout = false;
const int width = area->width + area->right_shadow;
// Area character
const auto& ac = area->data[y * width + x];
// Terminal character
auto& tc = vterm->data[ty * vterm->width + tx];
// Overlapped character
auto oc = getCoveredCharacter (terminal_pos + FPoint{1, 1}, area->widget);
oc.fg_color = ac.fg_color;
oc.bg_color = ac.bg_color;
oc.attr.bit.reverse = false;
oc.attr.bit.standout = false;
if ( oc.ch == fc::LowerHalfBlock if ( cover_char.ch == fc::LowerHalfBlock
|| oc.ch == fc::UpperHalfBlock || cover_char.ch == fc::UpperHalfBlock
|| oc.ch == fc::LeftHalfBlock || cover_char.ch == fc::LeftHalfBlock
|| oc.ch == fc::RightHalfBlock || cover_char.ch == fc::RightHalfBlock
|| oc.ch == fc::MediumShade || cover_char.ch == fc::MediumShade
|| oc.ch == fc::FullBlock ) || cover_char.ch == fc::FullBlock )
oc.ch = ' '; cover_char.ch = ' ';
oc.attr.bit.no_changes = bool(tc.attr.bit.printed && tc == oc); cover_char.attr.bit.no_changes = \
std::memcpy (&tc, &oc, sizeof(tc)); bool(vterm_char.attr.bit.printed && vterm_char == cover_char);
std::memcpy (&vterm_char, &cover_char, sizeof(vterm_char));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateInheritBackground ( const FTermArea* area void FVTerm::updateInheritBackground ( const FChar& area_char
, const FPoint& area_pos , FChar&& cover_char
, const FPoint& terminal_pos ) , FChar& vterm_char )
{ {
// Add the covered background to this character // Add the covered background to this character
const int x = area_pos.getX();
const int y = area_pos.getY();
const int tx = terminal_pos.getX();
const int ty = terminal_pos.getY();
const int width = area->width + area->right_shadow;
// Area character
const auto& ac = area->data[y * width + x];
// Terminal character
auto& tc = vterm->data[ty * vterm->width + tx];
// New character // New character
FChar nc{}; FChar nc{};
std::memcpy (&nc, &ac, sizeof(nc)); std::memcpy (&nc, &area_char, sizeof(nc));
// Covered character nc.bg_color = cover_char.bg_color;
auto cc = getCoveredCharacter (terminal_pos + FPoint{1, 1}, area->widget); nc.attr.bit.no_changes = \
nc.bg_color = cc.bg_color; bool(vterm_char.attr.bit.printed && vterm_char == nc);
nc.attr.bit.no_changes = bool(tc.attr.bit.printed && tc == nc); std::memcpy (&vterm_char, &nc, sizeof(vterm_char));
std::memcpy (&tc, &nc, sizeof(tc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateCharacter ( const FTermArea* area void FVTerm::updateCharacter (const FChar& area_char, FChar& vterm_char)
, const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Copy a area character to the virtual terminal // Copy a area character to the virtual terminal
const int x = area_pos.getX(); std::memcpy (&vterm_char, &area_char, sizeof(vterm_char));
const int y = area_pos.getY();
const int tx = terminal_pos.getX();
const int ty = terminal_pos.getY();
const int width = area->width + area->right_shadow;
// Area character
const auto& ac = area->data[y * width + x];
// Terminal character
auto& tc = vterm->data[ty * vterm->width + tx];
std::memcpy (&tc, &ac, sizeof(tc));
if ( tc.attr.bit.printed && tc == ac ) if ( vterm_char.attr.bit.printed && vterm_char == area_char )
tc.attr.bit.no_changes = true; vterm_char.attr.bit.no_changes = true;
else else
tc.attr.bit.no_changes = false; vterm_char.attr.bit.no_changes = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1589,11 +1534,14 @@ bool FVTerm::updateVTermCharacter ( const FTermArea* area
, const FPoint& area_pos , const FPoint& area_pos
, const FPoint& terminal_pos ) , const FPoint& terminal_pos )
{ {
const int x = area_pos.getX();
const int y = area_pos.getY();
const int width = area->width + area->right_shadow;
// Area character // Area character
const auto& ac = area->data[y * width + x]; const int width = area->width + area->right_shadow;
const int area_index = area_pos.getY() * width + area_pos.getX();
const auto& ac = area->data[area_index];
// Terminal character
const int terminal_index = terminal_pos.getY() * vterm->width
+ terminal_pos.getX();
auto& tc = vterm->data[terminal_index];
// Get covered state // Get covered state
const auto is_covered = isCovered(terminal_pos, area); const auto is_covered = isCovered(terminal_pos, area);
@ -1603,25 +1551,33 @@ bool FVTerm::updateVTermCharacter ( const FTermArea* area
if ( is_covered == half_covered ) if ( is_covered == half_covered )
{ {
updateOverlappedColor(area, area_pos, terminal_pos); // Overlapped character
auto oc = getOverlappedCharacter (terminal_pos, area);
updateOverlappedColor (ac, std::move(oc), tc);
} }
else if ( ac.attr.bit.transparent ) // Transparent else if ( ac.attr.bit.transparent ) // Transparent
{ {
updateOverlappedCharacter(area, terminal_pos); // Covered character
auto cc = getCoveredCharacter (terminal_pos, area);
updateOverlappedCharacter (std::move(cc), tc);
} }
else // Not transparent else // Not transparent
{ {
if ( ac.attr.bit.color_overlay ) // Transparent shadow if ( ac.attr.bit.color_overlay ) // Transparent shadow
{ {
updateShadedCharacter (area, area_pos, terminal_pos); // Covered character
auto cc = getCoveredCharacter (terminal_pos, area);
updateShadedCharacter (ac, std::move(cc), tc);
} }
else if ( ac.attr.bit.inherit_background ) else if ( ac.attr.bit.inherit_background )
{ {
updateInheritBackground (area, area_pos, terminal_pos); // Covered character
auto cc = getCoveredCharacter (terminal_pos, area);
updateInheritBackground (ac, std::move(cc), tc);
} }
else // Default else // Default
{ {
updateCharacter (area, area_pos, terminal_pos); updateCharacter (ac, tc);
} }
} }
@ -1799,12 +1755,12 @@ FChar FVTerm::generateCharacter (const FPoint& pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FChar FVTerm::getCharacter ( character_type char_type FChar FVTerm::getCharacter ( character_type char_type
, const FPoint& pos , const FPoint& pos
, FVTerm* obj ) , const FTermArea* area )
{ {
// Gets the overlapped or the covered character for a given position // Gets the overlapped or the covered character for a given position
const int x = pos.getX() - 1; const int x = pos.getX();
const int y = pos.getY() - 1; const int y = pos.getY();
int xx = ( x > 0 ) ? x : 0; int xx = ( x > 0 ) ? x : 0;
int yy = ( y > 0 ) ? y : 0; int yy = ( y > 0 ) ? y : 0;
@ -1816,11 +1772,11 @@ FChar FVTerm::getCharacter ( character_type char_type
auto cc = &vdesktop->data[yy * vdesktop->width + xx]; // covered character auto cc = &vdesktop->data[yy * vdesktop->width + xx]; // covered character
if ( ! FWidget::getWindowList() || FWidget::getWindowList()->empty() ) if ( ! area || ! FWidget::getWindowList() || FWidget::getWindowList()->empty() )
return *cc; return *cc;
// Get the window layer of this object // Get the window layer of this object
const auto& w = static_cast<FWidget*>(obj); const auto& w = static_cast<FWidget*>(area->widget);
const int layer = FWindow::getWindowLayer(w); const int layer = FWindow::getWindowLayer(w);
for (auto&& win_obj : *FWidget::getWindowList()) for (auto&& win_obj : *FWidget::getWindowList())
@ -1834,7 +1790,7 @@ FChar FVTerm::getCharacter ( character_type char_type
else else
significant_char = bool(layer < FWindow::getWindowLayer(win_obj)); significant_char = bool(layer < FWindow::getWindowLayer(win_obj));
if ( obj && win_obj != obj && significant_char ) if ( area->widget && area->widget != win_obj && significant_char )
{ {
const auto& win = win_obj->getVWin(); const auto& win = win_obj->getVWin();
@ -1857,17 +1813,17 @@ FChar FVTerm::getCharacter ( character_type char_type
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) FChar FVTerm::getCoveredCharacter (const FPoint& pos, const FTermArea* area)
{ {
// Gets the covered character for a given position // Gets the covered character for a given position
return getCharacter (covered_character, pos, obj); return getCharacter (covered_character, pos, area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) FChar FVTerm::getOverlappedCharacter (const FPoint& pos, const FTermArea* area)
{ {
// Gets the overlapped character for a given position // Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos, obj); return getCharacter (overlapped_character, pos, area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1974,32 +1930,31 @@ void FVTerm::finish()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::putAreaLine (const FChar* ac, FChar* tc, int length) void FVTerm::putAreaLine (const FChar& area_char, FChar& vterm_char, std::size_t length)
{ {
// copy "length" characters from area to terminal // copy "length" characters from area to terminal
std::memcpy (tc, ac, sizeof(*tc) * unsigned(length)); std::memcpy (&vterm_char, &area_char, sizeof(vterm_char) * length);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj void FVTerm::putAreaCharacter ( const FPoint& pos, const FTermArea* area
, const FChar* ac , const FChar& area_char, FChar& vterm_char )
, FChar* tc )
{ {
if ( ac->attr.bit.transparent ) // Transparent if ( area_char.attr.bit.transparent ) // Transparent
{ {
// Restore one character on vterm // Restore one character on vterm
FChar ch = getCoveredCharacter (pos, obj); FChar ch = getCoveredCharacter (pos, area);
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (&vterm_char, &ch, sizeof(vterm_char));
} }
else // Mot transparent else // Mot transparent
{ {
if ( ac->attr.bit.color_overlay ) // Transparent shadow if ( area_char.attr.bit.color_overlay ) // Transparent shadow
{ {
// Get covered character + add the current color // Get covered character + add the current color
FChar ch = getCoveredCharacter (pos, obj); FChar ch = getCoveredCharacter (pos, area);
ch.fg_color = ac->fg_color; ch.fg_color = area_char.fg_color;
ch.bg_color = ac->bg_color; ch.bg_color = area_char.bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
ch.attr.bit.standout = false; ch.attr.bit.standout = false;
@ -2011,19 +1966,19 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
|| ch.ch == fc::FullBlock ) || ch.ch == fc::FullBlock )
ch.ch = ' '; ch.ch = ' ';
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (&vterm_char, &ch, sizeof(vterm_char));
} }
else if ( ac->attr.bit.inherit_background ) else if ( area_char.attr.bit.inherit_background )
{ {
// Add the covered background to this character // Add the covered background to this character
FChar ch{}; FChar ch{};
std::memcpy (&ch, ac, sizeof(ch)); std::memcpy (&ch, &area_char, sizeof(ch));
FChar cc = getCoveredCharacter (pos, obj); FChar cc = getCoveredCharacter (pos, area);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (&vterm_char, &ch, sizeof(vterm_char));
} }
else // Default else // Default
std::memcpy (tc, ac, sizeof(*tc)); std::memcpy (&vterm_char, &area_char, sizeof(vterm_char));
} }
} }
@ -2072,8 +2027,8 @@ bool FVTerm::clearTerm (int fillchar) const
const auto& cd = TCAP(fc::t_clr_eos); const auto& cd = TCAP(fc::t_clr_eos);
const auto& cb = TCAP(fc::t_clr_eol); const auto& cb = TCAP(fc::t_clr_eol);
const bool ut = FTermcap::background_color_erase; const bool ut = FTermcap::background_color_erase;
const bool normal = FTerm::isNormal(next_attribute);
auto next = &next_attribute; auto next = &next_attribute;
const bool normal = FTerm::isNormal(next);
appendAttributes(next); appendAttributes(next);
if ( ! ( (cl || cd || cb) && (normal || ut) ) if ( ! ( (cl || cd || cb) && (normal || ut) )
@ -2173,9 +2128,9 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
FTermArea*& vt = vterm; FTermArea*& vt = vterm;
const auto& ce = TCAP(fc::t_clr_eol); const auto& ce = TCAP(fc::t_clr_eol);
auto min_char = &vt->data[y * uInt(vt->width) + xmin]; const auto& min_char = vt->data[y * uInt(vt->width) + xmin];
if ( ce && min_char->ch == ' ' ) if ( ce && min_char.ch == ' ' )
{ {
uInt beginning_whitespace = 1; uInt beginning_whitespace = 1;
const bool normal = FTerm::isNormal(min_char); const bool normal = FTerm::isNormal(min_char);
@ -2183,9 +2138,9 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
for (uInt x = xmin + 1; x < uInt(vt->width); x++) for (uInt x = xmin + 1; x < uInt(vt->width); x++)
{ {
auto ch = &vt->data[y * uInt(vt->width) + x]; const auto& ch = vt->data[y * uInt(vt->width) + x];
if ( *min_char == *ch ) if ( min_char == ch )
beginning_whitespace++; beginning_whitespace++;
else else
break; break;
@ -2208,9 +2163,9 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
FTermArea*& vt = vterm; FTermArea*& vt = vterm;
const auto& cb = TCAP(fc::t_clr_bol); const auto& cb = TCAP(fc::t_clr_bol);
auto first_char = &vt->data[y * uInt(vt->width)]; const auto& first_char = vt->data[y * uInt(vt->width)];
if ( cb && first_char->ch == ' ' ) if ( cb && first_char.ch == ' ' )
{ {
uInt leading_whitespace = 1; uInt leading_whitespace = 1;
const bool normal = FTerm::isNormal(first_char); const bool normal = FTerm::isNormal(first_char);
@ -2218,9 +2173,9 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
for (uInt x{1}; x < uInt(vt->width); x++) for (uInt x{1}; x < uInt(vt->width); x++)
{ {
auto ch = &vt->data[y * uInt(vt->width) + x]; const auto& ch = vt->data[y * uInt(vt->width) + x];
if ( *first_char == *ch ) if ( first_char == ch )
leading_whitespace++; leading_whitespace++;
else else
break; break;
@ -2246,9 +2201,9 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
FTermArea*& vt = vterm; FTermArea*& vt = vterm;
const auto& ce = TCAP(fc::t_clr_eol); const auto& ce = TCAP(fc::t_clr_eol);
auto last_char = &vt->data[(y + 1) * uInt(vt->width) - 1]; const auto& last_char = vt->data[(y + 1) * uInt(vt->width) - 1];
if ( ce && last_char->ch == ' ' ) if ( ce && last_char.ch == ' ' )
{ {
uInt trailing_whitespace = 1; uInt trailing_whitespace = 1;
const bool normal = FTerm::isNormal(last_char); const bool normal = FTerm::isNormal(last_char);
@ -2256,9 +2211,9 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
for (uInt x = uInt(vt->width) - 1; x > 0 ; x--) for (uInt x = uInt(vt->width) - 1; x > 0 ; x--)
{ {
auto ch = &vt->data[y * uInt(vt->width) + x]; const auto& ch = vt->data[y * uInt(vt->width) + x];
if ( *last_char == *ch ) if ( last_char == ch )
trailing_whitespace++; trailing_whitespace++;
else else
break; break;
@ -2535,9 +2490,10 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
const auto& vt = vterm; const auto& vt = vterm;
const auto& ec = TCAP(fc::t_erase_chars); const auto& ec = TCAP(fc::t_erase_chars);
auto print_char = &vt->data[y * uInt(vt->width) + x]; auto& print_char = vt->data[y * uInt(vt->width) + x];
auto print_ch = &print_char;
if ( ! ec || print_char->ch != ' ' ) if ( ! ec || print_char.ch != ' ' )
return not_used; return not_used;
uInt whitespace{1}; uInt whitespace{1};
@ -2545,9 +2501,9 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
for (uInt i = x + 1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
auto ch = &vt->data[y * uInt(vt->width) + i]; const auto& ch = vt->data[y * uInt(vt->width) + i];
if ( *print_char == *ch ) if ( print_char == ch )
whitespace++; whitespace++;
else else
break; break;
@ -2555,7 +2511,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
if ( whitespace == 1 ) if ( whitespace == 1 )
{ {
appendCharacter (print_char); appendCharacter (print_ch);
markAsPrinted (x, y); markAsPrinted (x, y);
} }
else else
@ -2566,7 +2522,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
if ( whitespace > erase_char_length + cursor_address_length if ( whitespace > erase_char_length + cursor_address_length
&& (ut || normal) ) && (ut || normal) )
{ {
appendAttributes (print_char); appendAttributes (print_ch);
appendOutputBuffer (FTermcap::encodeParameter(ec, whitespace, 0, 0, 0, 0, 0, 0, 0, 0)); appendOutputBuffer (FTermcap::encodeParameter(ec, whitespace, 0, 0, 0, 0, 0, 0, 0, 0));
if ( x + whitespace - 1 < xmax || draw_trailing_ws ) if ( x + whitespace - 1 < xmax || draw_trailing_ws )
@ -2582,7 +2538,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
for (uInt i{0}; i < whitespace; i++) for (uInt i{0}; i < whitespace; i++)
{ {
appendCharacter (print_char); appendCharacter (print_ch);
x++; x++;
} }
} }

View File

@ -216,7 +216,7 @@ class FTerm final
#endif #endif
// Inquiries // Inquiries
static bool isNormal (const FChar* const&); static bool isNormal (const FChar&);
static bool isRaw(); static bool isRaw();
static bool hasUTF8(); static bool hasUTF8();
static bool hasVT100(); static bool hasVT100();

View File

@ -352,20 +352,11 @@ class FVTerm
static bool reallocateTextArea ( FTermArea* static bool reallocateTextArea ( FTermArea*
, std::size_t ); , std::size_t );
static covered_state isCovered (const FPoint&, const FTermArea*); static covered_state isCovered (const FPoint&, const FTermArea*);
static void updateOverlappedColor ( const FTermArea* static void updateOverlappedColor (const FChar&, FChar&&, FChar&);
, const FPoint& static void updateOverlappedCharacter (FChar&&, FChar&);
, const FPoint& ); static void updateShadedCharacter (const FChar&, FChar&&, FChar&);
static void updateOverlappedCharacter ( const FTermArea* static void updateInheritBackground (const FChar&, FChar&&, FChar&);
, const FPoint& ); static void updateCharacter (const FChar&, FChar&);
static void updateShadedCharacter ( const FTermArea*
, const FPoint&
, const FPoint& );
static void updateInheritBackground ( const FTermArea*
, const FPoint&
, const FPoint& );
static void updateCharacter ( const FTermArea*
, const FPoint&
, const FPoint& );
static bool updateVTermCharacter ( const FTermArea* static bool updateVTermCharacter ( const FTermArea*
, const FPoint& , const FPoint&
, const FPoint& ); , const FPoint& );
@ -377,15 +368,15 @@ class FVTerm
static FChar generateCharacter (const FPoint&); static FChar generateCharacter (const FPoint&);
static FChar getCharacter ( character_type static FChar getCharacter ( character_type
, const FPoint& , const FPoint&
, FVTerm* ); , const FTermArea* );
static FChar getCoveredCharacter (const FPoint&, FVTerm*); static FChar getCoveredCharacter (const FPoint&, const FTermArea*);
static FChar getOverlappedCharacter (const FPoint&, FVTerm*); static FChar getOverlappedCharacter (const FPoint&, const FTermArea*);
void init(); void init();
static void init_characterLengths (const FOptiMove*); static void init_characterLengths (const FOptiMove*);
void finish(); void finish();
static void putAreaLine (const FChar*, FChar*, int); static void putAreaLine (const FChar&, FChar&, std::size_t);
static void putAreaCharacter ( const FPoint&, FVTerm* static void putAreaCharacter ( const FPoint&, const FTermArea*
, const FChar*, FChar* ); , const FChar&, FChar& );
static void getAreaCharacter ( const FPoint&, const FTermArea* static void getAreaCharacter ( const FPoint&, const FTermArea*
, FChar*& ); , FChar*& );
bool clearTerm (int = ' ') const; bool clearTerm (int = ' ') const;