Skip to content

Commit 90ba28f

Browse files
committed
The encoded output character will no longer be stored in an FChar structure
1 parent 9b14029 commit 90ba28f

17 files changed

Lines changed: 102 additions & 178 deletions

‎ChangeLog‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2026-10-18 Markus Gans <guru.mail@muenster.de>
2+
* The encoded output character will no longer be stored in an FChar
3+
structure
4+
15
2026-10-15 Markus Gans <guru.mail@muenster.de>
26
* Use change tracking to implement an early exit in
37
the FVTerm::updateVTerm() method

‎final/dialog/fdialog.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ void FDialog::setModal (bool state)
116116
//----------------------------------------------------------------------
117117
void FDialog::setBorder (bool state)
118118
{
119+
setFlags().feature.no_border = ! state;
120+
119121
if ( state )
120122
{
121123
setTopPadding(2);

‎final/ftypes.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,6 @@ struct FChar
11191119

11201120
// Data member
11211121
FUnicode ch{}; // Character code
1122-
FUnicode encoded_char{}; // Encoded output character
11231122
FCellColor color{}; // Foreground and background color
11241123
FAttribute attr{}; // Attributes
11251124

‎final/fwidget_functions.cpp‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,10 @@ void drawTransparentShadow (FWidget* w)
402402
uInt(region.shadow.height),
403403
{
404404
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
405-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
406405
default_color_pair,
407406
{ 0x00002000U } // transparent
408407
},
409408
{
410-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
411409
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
412410
{ wc_shadow.fg, wc_shadow.bg },
413411
{ 0x00004000U } // color_overlay
@@ -503,25 +501,21 @@ void drawBlockShadow (FWidget* w)
503501
{{
504502
{
505503
{ wchar_t(UniChar::LowerHalfBlock), L'\0', L'\0', L'\0', L'\0' }, // ▄
506-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
507504
{ wc_shadow.bg, FColor::Default },
508505
{ 0x00080000U } // char_width = 1
509506
},
510507
{
511508
{ wchar_t(UniChar::FullBlock), L'\0', L'\0', L'\0', L'\0' }, // █
512-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
513509
{ wc_shadow.bg, FColor::Default },
514510
{ 0x00080000U } // char_width = 1
515511
},
516512
{
517513
{ L' ', L'\0', L'\0', L'\0', L'\0' }, // ' '
518-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
519514
default_color_pair,
520515
{ 0x00080000U } // char_width = 1
521516
},
522517
{
523518
{ wchar_t(UniChar::UpperHalfBlock), L'\0', L'\0', L'\0', L'\0' }, // ▄
524-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
525519
{ wc_shadow.bg, FColor::Default },
526520
{ 0x00080000U } // char_width = 1
527521
}
@@ -555,7 +549,6 @@ void clearBlockShadow (FWidget* w)
555549
FChar spacer_char
556550
{
557551
{ L' ', L'\0', L'\0', L'\0', L'\0' }, // ' '
558-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
559552
default_color_pair,
560553
{ 0x00080000U } // char_width = 1
561554
};

‎final/output/tty/foptiattr.cpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,6 @@ auto FOptiAttr::changeAttribute (FChar& term, FChar& next) -> FTermcap::TermcapS
465465
detectSwitchOn (term, next);
466466
detectSwitchOff (term, next);
467467

468-
// Simulate invisible characters
469-
if ( ! F_secure.on.cap.data && next.isBitSet(FAttribute::set::invisible) )
470-
next.encoded_char.unicode_data[0] = ' ';
471-
472468
// Look for no changes
473469
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
474470
return {nullptr, 0};

‎final/output/tty/fterm.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ auto FTerm::isCursorHideable() -> bool
182182
//----------------------------------------------------------------------
183183
auto FTerm::isEncodable (const wchar_t& c) -> bool
184184
{
185-
const auto& ch = charEncode(c);
185+
const auto ch = charEncode(c);
186186
return ch > 0 && ch != c;
187187
}
188188

@@ -765,14 +765,14 @@ auto FTerm::getEncodingString() -> std::string
765765
}
766766

767767
//----------------------------------------------------------------------
768-
auto FTerm::charEncode (const wchar_t& c) -> wchar_t
768+
auto FTerm::charEncode (const wchar_t& c) -> uChar
769769
{
770770
static const auto& data = FTermData::getInstance();
771771
return charEncode (c, data.getTerminalEncoding());
772772
}
773773

774774
//----------------------------------------------------------------------
775-
auto FTerm::charEncode (const wchar_t& c, const Encoding& enc) -> wchar_t
775+
auto FTerm::charEncode (const wchar_t& c, const Encoding& enc) -> uChar
776776
{
777777
const auto& character = FCharMap::getCharEncodeMap();
778778
const auto& cend = character.cend();
@@ -784,7 +784,7 @@ auto FTerm::charEncode (const wchar_t& c, const Encoding& enc) -> wchar_t
784784
} );
785785

786786
if ( found == cend )
787-
return c;
787+
return uChar(c & 0xff);
788788

789789
const auto& ch_enc = FCharMap::getCharacter(*found, enc);
790790

‎final/output/tty/fterm.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ class FTerm final
224224

225225
static void setEncoding (Encoding);
226226
static auto getEncodingString() -> std::string;
227-
static auto charEncode (const wchar_t&) -> wchar_t;
228-
static auto charEncode (const wchar_t&, const Encoding&) -> wchar_t;
227+
static auto charEncode (const wchar_t&) -> uChar;
228+
static auto charEncode (const wchar_t&, const Encoding&) -> uChar;
229229

230230
static auto scrollTermForward() -> bool;
231231
static auto scrollTermReverse() -> bool;

‎final/output/tty/ftermoutput.cpp‎

Lines changed: 74 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,10 @@ auto FTermOutput::repeatCharacter (uInt& x, uInt xmax, uInt y, const FChar_itera
921921

922922
if ( rp.data && repetition_type == Repetition::ASCII )
923923
{
924-
newFontChanges (*iter);
925-
charsetChanges (*iter);
924+
newFontFilter (*iter);
925+
auto ch_enc = charsetEncode (*iter);
926926
appendAttributes (*iter);
927-
const auto term_ctrl = FTermcap::encodeParameter(rp, iter->ch.unicode_data[0], repetitions);
927+
const auto term_ctrl = FTermcap::encodeParameter(rp, ch_enc, repetitions);
928928
appendOutputBuffer (FTermControl{term_ctrl});
929929
term_pos->x_ref() += static_cast<int>(repetitions);
930930
}
@@ -1194,53 +1194,51 @@ inline void FTermOutput::markAsPrinted (uInt from, uInt to, uInt y) const noexce
11941194
}
11951195

11961196
//----------------------------------------------------------------------
1197-
inline void FTermOutput::newFontChanges (FChar& next_char) const
1197+
inline void FTermOutput::newFontFilter (FChar& next_char) const noexcept
11981198
{
11991199
// NewFont special cases
12001200
if ( ! internal::var::is_new_font )
12011201
return;
12021202

1203-
if ( next_char.ch.unicode_data[0] == UniChar::LowerHalfBlock )
1203+
auto& first_char = next_char.ch.unicode_data[0];
1204+
1205+
if ( first_char == UniChar::LowerHalfBlock )
12041206
{
1205-
next_char.ch.unicode_data[0] = wchar_t(UniChar::UpperHalfBlock);
1207+
first_char = wchar_t(UniChar::UpperHalfBlock);
12061208
next_char.setBit(FAttribute::set::reverse);
1209+
return;
12071210
}
1208-
else if ( isReverseNewFontchar(next_char.ch.unicode_data[0]) )
1211+
1212+
if ( isReverseNewFontchar(first_char) )
12091213
next_char.setBit(FAttribute::set::reverse); // Show in reverse video
12101214
}
12111215

12121216
//----------------------------------------------------------------------
1213-
inline void FTermOutput::charsetChanges (FChar& next_char) const
1217+
inline auto FTermOutput::charsetEncode (FChar& next_char) const noexcept -> uChar
12141218
{
1215-
if ( internal::terminal::encoding == Encoding::UTF8 )
1216-
return;
1217-
1218-
std::memcpy( next_char.encoded_char.data(),
1219-
next_char.ch.data(),
1220-
sizeof(wchar_t) * UNICODE_MAX );
1221-
12221219
const auto& ch = next_char.ch.unicode_data[0];
1223-
const auto& ch_enc = FTerm::charEncode(ch);
12241220

1225-
if ( ch_enc == ch )
1226-
return;
1221+
if ( internal::terminal::encoding == Encoding::UTF8 )
1222+
return uChar(ch & 0xff);
12271223

1228-
auto& first_enc_char = next_char.encoded_char.unicode_data[0];
1224+
const auto ch_enc = FTerm::charEncode(ch);
12291225

1230-
if ( ch_enc == 0 )
1231-
{
1232-
first_enc_char = wchar_t(FTerm::charEncode(ch, Encoding::ASCII));
1233-
return;
1234-
}
1226+
if ( uChar(ch_enc & 0xff) == ch )
1227+
return ch_enc;
12351228

1236-
first_enc_char = ch_enc;
1229+
if ( ch_enc == 0 )
1230+
return FTerm::charEncode(ch, Encoding::ASCII);
12371231

12381232
if ( internal::terminal::encoding == Encoding::VT100 )
1233+
{
12391234
next_char.attr.data |= FAttribute::set::alt_charset; // Set alt charset
1240-
else if ( internal::terminal::encoding == Encoding::PC )
1235+
return ch_enc;
1236+
}
1237+
1238+
if ( internal::terminal::encoding == Encoding::PC )
12411239
{
12421240
if ( ch_enc >= 0x20 )
1243-
return;
1241+
return ch_enc;
12441242

12451243
// Character 0x00..0x1f
12461244
next_char.attr.data |= FAttribute::set::pc_charset; // Set pc charset
@@ -1249,16 +1247,18 @@ inline void FTermOutput::charsetChanges (FChar& next_char) const
12491247
const auto is_xterm = fterm_data->isTermType(FTermType::xterm);
12501248

12511249
if ( is_putty || ! is_xterm )
1252-
return;
1250+
return ch_enc;
12531251

12541252
if ( FTerm::hasUTF8() )
1255-
first_enc_char = int(FTerm::charEncode(ch, Encoding::ASCII));
1253+
return FTerm::charEncode(ch, Encoding::ASCII);
12561254
else
12571255
{
1258-
first_enc_char += 0x5f;
12591256
next_char.attr.data |= FAttribute::set::alt_charset; // Set alt charset
1257+
return ch_enc + 0x5f;
12601258
}
12611259
}
1260+
1261+
return ch_enc;
12621262
}
12631263

12641264
//----------------------------------------------------------------------
@@ -1286,13 +1286,18 @@ inline void FTermOutput::appendCharacter_n (const FChar_iterator& next_char_iter
12861286
//----------------------------------------------------------------------
12871287
inline void FTermOutput::appendChar (FChar& next_char)
12881288
{
1289-
newFontChanges (next_char);
1290-
charsetChanges (next_char);
1291-
appendAttributes (next_char);
1292-
characterFilter (next_char);
1293-
12941289
if ( internal::terminal::encoding == Encoding::UTF8 )
12951290
{
1291+
newFontFilter (next_char);
1292+
characterFilter (next_char.ch.unicode_data[0]);
1293+
appendAttributes (next_char);
1294+
1295+
if ( needsInvisibleSimulation(next_char) )
1296+
{
1297+
appendOutputBuffer (' '); // Simulate invisible character
1298+
return;
1299+
}
1300+
12961301
for (const auto& ch : next_char.ch)
12971302
{
12981303
if ( ch == L'\0')
@@ -1306,12 +1311,31 @@ inline void FTermOutput::appendChar (FChar& next_char)
13061311
}
13071312
else // ASCII, VT100, or PC encoding
13081313
{
1309-
appendOutputBuffer ( FOutputBuffer::OutputType::String
1310-
, reinterpret_cast<char*>(&next_char.encoded_char.unicode_data[0])
1311-
, 1 );
1314+
newFontFilter (next_char);
1315+
characterFilter (next_char.ch.unicode_data[0]);
1316+
auto ch_enc = char(charsetEncode (next_char));
1317+
appendAttributes (next_char);
1318+
1319+
if ( needsInvisibleSimulation(next_char) )
1320+
{
1321+
appendOutputBuffer (' '); // Simulate invisible character
1322+
return;
1323+
}
1324+
1325+
appendOutputBuffer (ch_enc);
13121326
}
13131327
}
13141328

1329+
//----------------------------------------------------------------------
1330+
inline auto FTermOutput::needsInvisibleSimulation (const FChar& next_char) -> bool
1331+
{
1332+
const auto& mk = TCAP(t_enter_secure_mode);
1333+
return ! mk.data && next_char.isBitSet(FAttribute::set::invisible);
1334+
// true = The next character is invisible, but this terminal does
1335+
// not support that feature. Therefore, you must simulate
1336+
// an invisible character.
1337+
}
1338+
13151339
//----------------------------------------------------------------------
13161340
inline void FTermOutput::appendAttributes (FChar& next_attr)
13171341
{
@@ -1391,17 +1415,16 @@ void FTermOutput::appendLowerRight (const FChar_iterator& last_char_iter)
13911415
}
13921416

13931417
//----------------------------------------------------------------------
1394-
inline void FTermOutput::characterFilter (FChar& next_char)
1418+
inline void FTermOutput::characterFilter (wchar_t& w_char) noexcept
13951419
{
13961420
if ( ! internal::var::has_sub_map )
13971421
return;
13981422

13991423
static const auto& sub_map = getFTerm().getCharSubstitutionMap();
1400-
auto& first_enc_char = next_char.encoded_char.unicode_data[0];
1401-
const auto& entry = sub_map.getMappedChar(first_enc_char);
1424+
const auto found = sub_map.getMappedChar(w_char);
14021425

1403-
if ( entry )
1404-
first_enc_char = entry;
1426+
if ( found )
1427+
w_char = found;
14051428
}
14061429

14071430
//----------------------------------------------------------------------
@@ -1463,6 +1486,14 @@ inline void FTermOutput::appendOutputBuffer (const UniChar& ch)
14631486
appendOutputBuffer(wchar_t(ch));
14641487
}
14651488

1489+
//----------------------------------------------------------------------
1490+
inline void FTermOutput::appendOutputBuffer (char ch)
1491+
{
1492+
appendOutputBuffer( FOutputBuffer::OutputType::String
1493+
, reinterpret_cast<char*>(&ch)
1494+
, 1 );
1495+
}
1496+
14661497
//----------------------------------------------------------------------
14671498
inline void FTermOutput::appendOutputBuffer ( FOutputBuffer::OutputType type
14681499
, const char* data

‎final/output/tty/ftermoutput.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,21 @@ class FTermOutput final : public FOutput
296296
void flushTimeAdjustment() noexcept;
297297
void markAsPrinted (uInt, uInt) const noexcept;
298298
void markAsPrinted (uInt, uInt, uInt) const noexcept;
299-
void newFontChanges (FChar&) const;
300-
void charsetChanges (FChar&) const;
299+
void newFontFilter (FChar&) const noexcept;
300+
auto charsetEncode (FChar&) const noexcept -> uChar;
301301
void appendCharacter (const FChar_iterator&);
302302
void appendCharacter_n (const FChar_iterator&, uInt);
303303
void appendChar (FChar&);
304+
auto needsInvisibleSimulation (const FChar&) -> bool;
304305
void appendAttributes (FChar&);
305306
void appendLowerRight (const FChar_iterator&);
306-
void characterFilter (FChar&);
307+
void characterFilter (wchar_t&) noexcept;
307308
auto moveCursorLeft() -> CursorMoved;
308309
void checkFreeBufferSize();
309310
void appendOutputBuffer (const FTermControl&);
310311
void appendOutputBuffer (wchar_t);
311312
void appendOutputBuffer (const UniChar&);
313+
void appendOutputBuffer (char);
312314
void appendOutputBuffer (FOutputBuffer::OutputType, const char*, uInt32);
313315

314316
// Data members

‎final/vterm/fvterm.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,6 @@ inline void FVTerm::resetTextRegionToDefault ( FTermRegion* region
11691169
static constexpr FChar default_char
11701170
{
11711171
{ L' ', L'\0', L'\0', L'\0', L'\0' },
1172-
{ L'\0', L'\0', L'\0', L'\0', L'\0' },
11731172
default_color_pair,
11741173
{ 0x00080000U } // char_width = 1
11751174
};

0 commit comments

Comments
 (0)