Refactor ASCII rasterizer to support terminal ANSI mode and improve menu text rendering

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-18 16:06:20 +01:00
parent 839fae700f
commit be03bd45c8
8 changed files with 204 additions and 88 deletions

View File

@@ -22,7 +22,9 @@ class _WolfAsciiRendererState extends BaseWolfRendererState<WolfAsciiRenderer> {
static const int _renderHeight = 100;
List<List<ColoredChar>> _asciiFrame = [];
final AsciiRasterizer _asciiRasterizer = AsciiRasterizer();
final AsciiRasterizer _asciiRasterizer = AsciiRasterizer(
mode: AsciiRasterizerMode.terminalGrid,
);
@override
void initState() {
@@ -84,22 +86,16 @@ 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
Color? currentBackground = row[0].backgroundArgb == null
? null
: Color(
0xFF000000 | (row[0].rawBackgroundColor! & 0x00FFFFFF),
);
: Color(row[0].backgroundArgb!);
StringBuffer currentSegment = StringBuffer(row[0].char);
for (int i = 1; i < row.length; i++) {
final Color nextColor = Color(row[i].argb);
final Color? nextBackground =
row[i].rawBackgroundColor == null
final Color? nextBackground = row[i].backgroundArgb == null
? null
: Color(
0xFF000000 |
(row[i].rawBackgroundColor! & 0x00FFFFFF),
);
: Color(row[i].backgroundArgb!);
if (nextColor == currentColor &&
nextBackground == currentBackground) {
currentSegment.write(row[i].char);