The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
import 'dart:ui';
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:xterm/xterm.dart';
// The painter is xterm's own, vendored and patched here (third_party/xterm,
// README.autonomous.md) — not API the package offers.
// ignore: implementation_imports
import 'package:xterm/src/ui/painter.dart';
/// A canvas that counts the glyphs it is asked to draw.
class _GlyphCounter implements Canvas {
int glyphs = 0;
@override
void drawParagraph(Paragraph paragraph, Offset offset) => glyphs++;
@override
void drawRect(Rect rect, Paint paint) {}
@override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
/// Every frame paints every cell on screen, so what a cell costs is paid ~2,000
/// times a frame on a phone.
void main() {
int glyphsDrawnFor(String output) {
final terminal = Terminal()..write(output);
final canvas = _GlyphCounter();
TerminalPainter(
theme: TerminalThemes.defaultTheme,
textStyle: const TerminalStyle(),
textScaler: TextScaler.noScaling,
).paintLine(canvas, Offset.zero, terminal.buffer.lines[0]);
return canvas.glyphs;
}
test('a space costs no glyph', () {
// `a b` is one run ([GlyphRun]): the blanks between ride in it, and the
// ones after it are not drawn.
expect(glyphsDrawnFor('a b '), 1);
expect(glyphsDrawnFor(' '), 0);
});
test('an underlined space still draws its underline', () {
expect(glyphsDrawnFor('\x1b[4m \x1b[0m'), 1);
});
}