WIP fixing menu rendering in CLI ASCII mode

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-18 14:08:21 +01:00
parent dc1acb7a2f
commit 839fae700f
8 changed files with 413 additions and 301 deletions

View File

@@ -84,26 +84,47 @@ class AsciiFrameWidget extends StatelessWidget {
// Merge adjacent cells with the same color to keep the rich
// text tree smaller and reduce per-frame layout overhead.
Color currentColor = Color(row[0].argb);
Color? currentBackground = row[0].rawBackgroundColor == null
? null
: Color(
0xFF000000 | (row[0].rawBackgroundColor! & 0x00FFFFFF),
);
StringBuffer currentSegment = StringBuffer(row[0].char);
for (int i = 1; i < row.length; i++) {
if (Color(row[i].argb) == currentColor) {
final Color nextColor = Color(row[i].argb);
final Color? nextBackground =
row[i].rawBackgroundColor == null
? null
: Color(
0xFF000000 |
(row[i].rawBackgroundColor! & 0x00FFFFFF),
);
if (nextColor == currentColor &&
nextBackground == currentBackground) {
currentSegment.write(row[i].char);
} else {
optimizedSpans.add(
TextSpan(
text: currentSegment.toString(),
style: TextStyle(color: currentColor),
style: TextStyle(
color: currentColor,
backgroundColor: currentBackground,
),
),
);
currentColor = Color(row[i].argb);
currentColor = nextColor;
currentBackground = nextBackground;
currentSegment = StringBuffer(row[i].char);
}
}
optimizedSpans.add(
TextSpan(
text: currentSegment.toString(),
style: TextStyle(color: currentColor),
style: TextStyle(
color: currentColor,
backgroundColor: currentBackground,
),
),
);
}