resize method
Resizes the renderer viewport and updates layout/buffers.
Implementation
@override
void resize(int width, int height) {
_buffer = Buffer.blank(width, height);
final style = Style(foreground: const Color(100, 200, 255));
if (width == 1 && height == 1) {
_buffer!.writeString(0, 0, '🔎', style);
return;
}
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
String? char;
if (x == 0 && y == 0) {
char = '┌';
} else if (x == width - 1 && y == 0) {
char = '┐';
} else if (x == 0 && y == height - 1) {
char = '└';
} else if (x == width - 1 && y == height - 1) {
char = '┘';
} else if (x == 0 || x == width - 1) {
char = '│';
} else if (y == 0 || y == height - 1) {
char = '─';
}
if (char != null) {
_buffer!.setAttributes(
x,
y,
char: char,
fg: style.foreground?.argb ?? 0,
bg: style.background?.argb ?? 0,
modifiers: style.modifiers,
);
} else {
_buffer!.setAttributes(x, y, char: ' ', fg: 0, bg: 0, modifiers: 0);
}
}
}
// Use writeString to handle double-width character properly
_buffer!.writeString(width ~/ 2, height ~/ 2, '🔎', style);
}