Fit chat terminals to their output, keep pastes and keys in the terminal

Finished terminals are sized synchronously from their rows at the view's
width (the post-frame fit made the transcript re-anchor forever); blank rows
xterm.dart keeps when rewrapping are dropped; desktop typing uses key events;
the composer leaves Cmd/Ctrl-V to a focused terminal; Ctrl-A reaches the
process. The probe fixture gains coloured terminal runs and an interactive
login. Notes record behaviour, protocol, security and verification.
This commit is contained in:
2026-11-09 20:51:59 +00:00
parent 89882d90f3
commit 2332143e5b
10 changed files with 429 additions and 52 deletions
@@ -1,3 +1,5 @@
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:xterm/xterm.dart';
@@ -71,15 +73,16 @@ TerminalStyle chatShellTerminalStyle(BuildContext context, bool cupertino) {
);
}
/// The height of one terminal row in [style] at the context's text scale,
/// measured the way the emulator measures its cells.
double chatShellTerminalLineHeight(BuildContext context, TerminalStyle style) {
final painter = TextPainter(
text: TextSpan(text: 'mmmmmmmmmm', style: style.toTextStyle()),
textDirection: TextDirection.ltr,
textScaler: MediaQuery.textScalerOf(context),
)..layout();
final height = painter.height;
painter.dispose();
return height;
/// The size of one terminal cell in [style] at the context's text scale,
/// measured exactly as the emulator measures it.
Size chatShellTerminalCellSize(BuildContext context, TerminalStyle style) {
final text = style.toTextStyle();
final builder = ui.ParagraphBuilder(text.getParagraphStyle())
..pushStyle(text.getTextStyle(textScaler: MediaQuery.textScalerOf(context)))
..addText('mmmmmmmmmm');
final paragraph = builder.build()
..layout(const ui.ParagraphConstraints(width: double.infinity));
final size = Size(paragraph.maxIntrinsicWidth / 10, paragraph.height);
paragraph.dispose();
return size;
}