2bcb62b5d8
SGR 9 (strikethrough) and 53 (overline) were stored but never drawn, and SGR 8 (conceal) still showed the text. They are drawn now, and underline styles use the matching line style: double (21, 4:2), curly (4:3, wavy), dotted (4:4) and dashed (4:5). Concealed cells keep their background. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.4 KiB
Dart
77 lines
2.4 KiB
Dart
import 'package:flutter/painting.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:xterm/xterm.dart';
|
|
|
|
import 'paint_fixture.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final size = fixturePainter().cellSize;
|
|
final w = size.width.ceil();
|
|
final h = size.height.ceil();
|
|
|
|
Future<Pixels> cell(CellData data) => Pixels.paint(
|
|
w,
|
|
h * 2, // room for decorations drawn below the cell
|
|
(canvas) => fixturePainter().paintCell(canvas, Offset.zero, data),
|
|
);
|
|
|
|
/// The rows of the cell that contain painted pixels.
|
|
Future<List<int>> inkRows(CellData data) async {
|
|
final pixels = await cell(data);
|
|
return [
|
|
for (var y = 0; y < h * 2; y++)
|
|
if (pixels.rowHasInk(y)) y,
|
|
];
|
|
}
|
|
|
|
test('a plain space draws nothing', () async {
|
|
expect(await inkRows(cellOf(' ')), isEmpty);
|
|
});
|
|
|
|
test('strikethrough (SGR 9) draws a line through the middle', () async {
|
|
final rows = await inkRows(cellOf(' ', flags: CellAttr.strikethrough));
|
|
expect(rows, isNotEmpty);
|
|
expect(rows.every((y) => y > h * 0.2 && y < h * 0.8), isTrue);
|
|
});
|
|
|
|
test('overline (SGR 53) draws at the top, underline at the bottom', () async {
|
|
final over = await inkRows(cellOf(' ', flags: CellAttr.overline));
|
|
expect(over, isNotEmpty);
|
|
expect(over.first, lessThan(h * 0.3));
|
|
|
|
final under = await inkRows(cellOf(' ', flags: CellAttr.underline));
|
|
expect(under, isNotEmpty);
|
|
expect(under.last, greaterThan(h * 0.6));
|
|
});
|
|
|
|
test('double underline (SGR 21) draws two lines', () async {
|
|
const doubled = CellAttr.underline | (2 << CellAttr.underlineStyleShift);
|
|
final single = await inkRows(cellOf(' ', flags: CellAttr.underline));
|
|
final two = await inkRows(cellOf(' ', flags: doubled));
|
|
expect(two.length, greaterThan(single.length));
|
|
});
|
|
|
|
test(
|
|
'concealed text (SGR 8) keeps its background, hides the glyph',
|
|
() async {
|
|
final shown = await cell(cellOf('M'));
|
|
expect(shown.count(foregroundColor), greaterThan(0));
|
|
|
|
final hidden = await cell(cellOf('M', flags: CellAttr.invisible));
|
|
expect(hidden.count(foregroundColor), 0);
|
|
|
|
final inverse = await cell(
|
|
cellOf('M', flags: CellAttr.invisible | CellAttr.inverse),
|
|
);
|
|
expect(
|
|
inverse.count(foregroundColor),
|
|
greaterThan(0),
|
|
reason: 'background',
|
|
);
|
|
expect(inverse.count(backgroundColor), 0, reason: 'no glyph');
|
|
},
|
|
);
|
|
}
|