Terminal: xterm key encoding, no live reflow on resize, Alt+T/Ctrl+T reach the shell

- Live terminals no longer reflow (xterm.dart 4.0.0 left the cursor on the
  wrong row); narrowing cuts and erases cells past the width, rows scroll
  into scrollback keeping the cursor row; finished output still reflows.
- App-side key encoding before xterm.dart's defaults: Alt as Meta (ESC +
  the typed character), Ctrl symbol table, xterm modifier parameter for
  arrows/Home/End/PgUp/PgDn/Ins/Del/F-keys, DECCKM and DECKPAM, Alt+BS.
- Settings > Appearance > Terminal: Use Option as Meta key (Macs, on).
- Inside a focused terminal only Cmd+T and Ctrl+` toggle it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 23:32:29 +00:00
parent 5ab1ec9e00
commit 7d1ffe8ad3
22 changed files with 1408 additions and 61 deletions
@@ -0,0 +1,309 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_run.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_terminal_key_input.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_terminal_session.dart';
import 'package:xterm/core.dart';
/// Modifiers held, as [chatShellKeyEventBytes] reads them.
class _Held extends HardwareKeyboard {
_Held(String mods)
: shift = mods.contains('S'),
alt = mods.contains('A'),
ctrl = mods.contains('C'),
meta = mods.contains('M');
final bool shift, alt, ctrl, meta;
@override
bool get isShiftPressed => shift;
@override
bool get isAltPressed => alt;
@override
bool get isControlPressed => ctrl;
@override
bool get isMetaPressed => meta;
}
KeyDownEvent _down(
LogicalKeyboardKey logical, {
PhysicalKeyboardKey? physical,
String? character,
}) => KeyDownEvent(
physicalKey: physical ?? PhysicalKeyboardKey.keyA,
logicalKey: logical,
character: character,
timeStamp: Duration.zero,
);
/// The bytes a key sends with [mods] (S Shift, A Alt, C Ctrl, M Meta).
String? _bytes(
LogicalKeyboardKey logical, {
String mods = '',
String? character,
PhysicalKeyboardKey? physical,
Terminal? terminal,
bool optionAsMeta = true,
}) => chatShellKeyEventBytes(
_down(logical, physical: physical, character: character),
_Held(mods),
terminal ?? Terminal(),
optionAsMeta: optionAsMeta,
);
const _l = LogicalKeyboardKey.new;
void main() {
final linux = TargetPlatformVariant.only(TargetPlatform.linux);
final mac = TargetPlatformVariant.only(TargetPlatform.macOS);
testWidgets('Alt is Meta: ESC and the character typed, Shift and layout '
'included', (tester) async {
expect(_bytes(LogicalKeyboardKey.keyB, mods: 'A', character: 'b'), '\x1bb');
expect(_bytes(LogicalKeyboardKey.keyF, mods: 'A', character: 'f'), '\x1bf');
expect(_bytes(LogicalKeyboardKey.keyD, mods: 'A', character: 'd'), '\x1bd');
expect(
_bytes(LogicalKeyboardKey.keyB, mods: 'AS', character: 'B'),
'\x1bB',
);
expect(
_bytes(LogicalKeyboardKey.period, mods: 'A', character: '.'),
'\x1b.',
);
expect(
_bytes(LogicalKeyboardKey.digit1, mods: 'A', character: '1'),
'\x1b1',
);
// Without a character (some platforms send none with Alt): the key's.
expect(_bytes(LogicalKeyboardKey.keyT, mods: 'A'), '\x1bt');
expect(_bytes(LogicalKeyboardKey.period, mods: 'AS'), '\x1b>');
// A non-US layout's own character (AZERTY's A key types "q").
expect(_bytes(LogicalKeyboardKey.keyQ, mods: 'A', character: 'q'), '\x1bq');
expect(_bytes(LogicalKeyboardKey.backspace, mods: 'A'), '\x1b\x7f');
expect(_bytes(LogicalKeyboardKey.enter, mods: 'A'), '\x1b\r');
expect(
_bytes(LogicalKeyboardKey.space, mods: 'A', character: ' '),
'\x1b ',
);
}, variant: linux);
testWidgets('Ctrl sends the control code of letters and symbols', (
tester,
) async {
final table = <(LogicalKeyboardKey, String, String), String>{
(LogicalKeyboardKey.keyA, '', 'a'): '\x01',
(LogicalKeyboardKey.keyT, '', 't'): '\x14',
(LogicalKeyboardKey.keyT, 'S', 'T'): '\x14',
(LogicalKeyboardKey.slash, '', '/'): '\x1f',
(LogicalKeyboardKey.bracketRight, '', ']'): '\x1d',
(LogicalKeyboardKey.backslash, '', '\\'): '\x1c',
(LogicalKeyboardKey.bracketLeft, '', '['): '\x1b',
(LogicalKeyboardKey.minus, 'S', '_'): '\x1f',
(LogicalKeyboardKey.digit2, '', '2'): '\x00',
(LogicalKeyboardKey.digit2, 'S', '@'): '\x00',
(LogicalKeyboardKey.digit6, 'S', '^'): '\x1e',
(LogicalKeyboardKey.digit8, '', '8'): '\x7f',
(LogicalKeyboardKey.space, '', ' '): '\x00',
(LogicalKeyboardKey.keyB, 'A', 'b'): '\x1b\x02',
};
for (final MapEntry(key: (key, mods, character), value: bytes)
in table.entries) {
expect(
_bytes(key, mods: 'C$mods', character: character),
bytes,
reason: 'Ctrl+$mods $character',
);
}
// A control character as the event's character still maps by key.
expect(
_bytes(LogicalKeyboardKey.slash, mods: 'C', character: '\x1f'),
'\x1f',
);
expect(_bytes(LogicalKeyboardKey.backspace, mods: 'C'), '\b');
// Ctrl+1 has no control code: the emulator types it.
expect(
_bytes(LogicalKeyboardKey.digit1, mods: 'C', character: '1'),
isNull,
);
}, variant: linux);
testWidgets('modified special keys use the xterm modifier parameter', (
tester,
) async {
const up = LogicalKeyboardKey.arrowUp;
expect(_bytes(up), '\x1b[A');
expect(_bytes(up, mods: 'S'), '\x1b[1;2A');
expect(_bytes(LogicalKeyboardKey.arrowLeft, mods: 'A'), '\x1b[1;3D');
expect(_bytes(LogicalKeyboardKey.arrowDown, mods: 'AS'), '\x1b[1;4B');
expect(_bytes(LogicalKeyboardKey.arrowRight, mods: 'C'), '\x1b[1;5C');
expect(_bytes(up, mods: 'CS'), '\x1b[1;6A');
expect(_bytes(up, mods: 'CA'), '\x1b[1;7A');
expect(_bytes(up, mods: 'CAS'), '\x1b[1;8A');
expect(_bytes(LogicalKeyboardKey.home), '\x1b[H');
expect(_bytes(LogicalKeyboardKey.end, mods: 'S'), '\x1b[1;2F');
expect(_bytes(LogicalKeyboardKey.home, mods: 'C'), '\x1b[1;5H');
expect(_bytes(LogicalKeyboardKey.pageUp), '\x1b[5~');
expect(_bytes(LogicalKeyboardKey.pageUp, mods: 'S'), '\x1b[5;2~');
expect(_bytes(LogicalKeyboardKey.pageDown, mods: 'C'), '\x1b[6;5~');
expect(_bytes(LogicalKeyboardKey.insert), '\x1b[2~');
expect(_bytes(LogicalKeyboardKey.delete), '\x1b[3~');
expect(_bytes(LogicalKeyboardKey.delete, mods: 'A'), '\x1b[3;3~');
expect(_bytes(LogicalKeyboardKey.f1), '\x1bOP');
expect(_bytes(LogicalKeyboardKey.f1, mods: 'S'), '\x1b[1;2P');
expect(_bytes(LogicalKeyboardKey.f4, mods: 'C'), '\x1b[1;5S');
expect(_bytes(LogicalKeyboardKey.f5), '\x1b[15~');
expect(_bytes(LogicalKeyboardKey.f12, mods: 'C'), '\x1b[24;5~');
expect(_bytes(LogicalKeyboardKey.tab, mods: 'S'), '\x1b[Z');
expect(_bytes(LogicalKeyboardKey.tab), '\t');
expect(_bytes(LogicalKeyboardKey.enter), '\r');
expect(_bytes(LogicalKeyboardKey.escape), '\x1b');
expect(_bytes(LogicalKeyboardKey.backspace), '\x7f');
}, variant: linux);
testWidgets('application cursor keys and keypad mode', (tester) async {
final terminal = Terminal()..write('\x1b[?1h');
String? bytes(LogicalKeyboardKey key, [String mods = '']) =>
_bytes(key, mods: mods, terminal: terminal);
expect(bytes(LogicalKeyboardKey.arrowUp), '\x1bOA');
expect(bytes(LogicalKeyboardKey.arrowLeft), '\x1bOD');
expect(bytes(LogicalKeyboardKey.home), '\x1bOH');
expect(bytes(LogicalKeyboardKey.end), '\x1bOF');
// Modified keys are the same in either mode.
expect(bytes(LogicalKeyboardKey.arrowUp, 'C'), '\x1b[1;5A');
// The keypad's operators and Enter follow DECKPAM; digits keep typing.
expect(bytes(LogicalKeyboardKey.numpadAdd), isNull);
expect(bytes(LogicalKeyboardKey.numpadEnter), '\r');
terminal.write('\x1b=');
expect(bytes(LogicalKeyboardKey.numpadAdd), '\x1bOk');
expect(bytes(LogicalKeyboardKey.numpadEnter), '\x1bOM');
expect(bytes(LogicalKeyboardKey.numpadDivide), '\x1bOo');
expect(bytes(LogicalKeyboardKey.numpad1), isNull);
terminal.write('\x1b>\x1b[?1l');
expect(bytes(LogicalKeyboardKey.arrowUp), '\x1b[A');
expect(bytes(LogicalKeyboardKey.numpadAdd), isNull);
// Enter in line feed mode (LNM).
terminal.write('\x1b[20h');
expect(bytes(LogicalKeyboardKey.enter), '\r\n');
}, variant: linux);
testWidgets('plain typing, Cmd chords and AltGr are left to the emulator', (
tester,
) async {
expect(_bytes(LogicalKeyboardKey.keyA, character: 'a'), isNull);
expect(_bytes(LogicalKeyboardKey.keyA, mods: 'S', character: 'A'), isNull);
expect(_bytes(LogicalKeyboardKey.space, character: ' '), isNull);
expect(_bytes(LogicalKeyboardKey.keyK, mods: 'M', character: 'k'), isNull);
// German AltGr+Q types @.
expect(
_bytes(
LogicalKeyboardKey.keyQ,
mods: 'CA',
character: '@',
physical: PhysicalKeyboardKey.keyQ,
),
isNull,
);
}, variant: linux);
testWidgets('a Mac\'s Option is Meta while the setting is on', (
tester,
) async {
// Option+B types ∫; its logical key is B (natively) or ∫ (browsers).
expect(_bytes(LogicalKeyboardKey.keyB, mods: 'A', character: '∫'), '\x1bb');
expect(
_bytes(
_l(0x222b),
mods: 'A',
character: '∫',
physical: PhysicalKeyboardKey.keyB,
),
'\x1bb',
);
expect(
_bytes(
_l(0x0131),
mods: 'AS',
character: 'ı',
physical: PhysicalKeyboardKey.keyB,
),
'\x1bB',
);
expect(
_bytes(
_l(0x2265),
mods: 'A',
character: '≥',
physical: PhysicalKeyboardKey.period,
),
'\x1b.',
);
expect(_bytes(LogicalKeyboardKey.backspace, mods: 'A'), '\x1b\x7f');
expect(_bytes(LogicalKeyboardKey.slash, mods: 'C', character: '/'), '\x1f');
// Off, Option types its symbol; special keys keep the Alt parameter.
expect(
_bytes(
LogicalKeyboardKey.keyB,
mods: 'A',
character: '∫',
optionAsMeta: false,
),
isNull,
);
expect(
_bytes(LogicalKeyboardKey.backspace, mods: 'A', optionAsMeta: false),
'\x7f',
);
expect(
_bytes(LogicalKeyboardKey.arrowLeft, mods: 'A', optionAsMeta: false),
'\x1b[1;3D',
);
expect(
_bytes(LogicalKeyboardKey.arrowLeft, mods: 'A', optionAsMeta: true),
'\x1b[1;3D',
);
}, variant: mac);
ChatShellTerminalSession session(List<String> sent, bool Function() meta) =>
ChatShellTerminalSession(
ChatShellRun.fromJson({
'id': 'run_1',
'command': 'sh',
'directory': '/w',
'status': 'running',
'started_at': 1,
'output': '',
'output_bytes': 0,
'terminal': true,
'cols': 40,
'rows': 10,
})!,
onInput: sent.add,
onResize: (_, _) {},
optionAsMeta: meta,
);
testWidgets('the toolbar and soft keyboard keys go through the same '
'encoding', (tester) async {
final sent = <String>[];
final terminal = session(sent, () => true).terminal;
terminal.keyInput(TerminalKey.arrowUp);
terminal.write('\x1b[?1h');
terminal.keyInput(TerminalKey.arrowUp);
terminal.keyInput(TerminalKey.keyB, alt: true);
terminal.keyInput(TerminalKey.keyB, alt: true, shift: true);
terminal.keyInput(TerminalKey.slash, ctrl: true);
terminal.keyInput(TerminalKey.arrowLeft, alt: true);
// A plain letter is typed as its text instead.
expect(terminal.keyInput(TerminalKey.keyB), isFalse);
expect(sent, ['\x1b[A', '\x1bOA', '\x1bb', '\x1bB', '\x1f', '\x1b[1;3D']);
}, variant: linux);
testWidgets('on a Mac with Option as Meta off, the package does not '
'send its own Alt sequence', (tester) async {
final sent = <String>[];
var meta = false;
final terminal = session(sent, () => meta).terminal;
expect(terminal.keyInput(TerminalKey.keyB, alt: true), isFalse);
meta = true;
expect(terminal.keyInput(TerminalKey.keyB, alt: true), isTrue);
expect(sent, ['\x1bb']);
}, variant: mac);
}
@@ -0,0 +1,165 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_run.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_terminal_session.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_terminal_view.dart';
import 'package:xterm/core.dart';
ChatShellTerminalSession _session({int cols = 40, int rows = 10}) =>
ChatShellTerminalSession(
ChatShellRun.fromJson({
'id': 'run_1',
'command': 'sh',
'directory': '/w',
'status': 'running',
'started_at': 1,
'output': '',
'output_bytes': 0,
'terminal': true,
'cols': cols,
'rows': rows,
})!,
onInput: (_) {},
onResize: (_, _) {},
);
/// The rows on screen, trimmed.
List<String> _screen(Terminal terminal) {
final buffer = terminal.buffer;
final top = buffer.height - terminal.viewHeight;
return [
for (var y = 0; y < terminal.viewHeight; y++)
buffer.lines[top + y].getText().trimRight(),
];
}
String _cursorRow(Terminal terminal) => terminal
.buffer
.lines[terminal.buffer.absoluteCursorY]
.getText()
.trimRight();
/// Twelve output lines of 58 characters (two rows each at 40 columns), then
/// a prompt.
String _longLines() => [
for (var i = 0; i < 12; i++)
'line ${i.toString().padLeft(2, '0')} ${'x' * 50}',
r'$ ',
].join('\r\n');
void main() {
test('shrinking keeps the prompt on the cursor row at the bottom, and '
'growing brings the rows above back in order', () {
final terminal = _session().terminal..write(_longLines());
expect(terminal.buffer.cursorY, 9);
expect(_cursorRow(terminal), r'$');
terminal.resize(20, 5);
expect(terminal.buffer.cursorY, 4);
expect(_cursorRow(terminal), r'$');
// Line 11's second row (cut at 20 columns), then the prompt.
expect(_screen(terminal), [
'line 10 ${'x' * 12}',
'x' * 18,
'line 11 ${'x' * 12}',
'x' * 18,
r'$',
]);
// The shell redraws its prompt and runs a command: nothing lands on
// old rows and no rows merge.
terminal.write('\r\x1b[K\$ ls\r\nout\r\n\$ ');
expect(_screen(terminal).sublist(2), [r'$ ls', 'out', r'$']);
terminal.resize(40, 10);
expect(terminal.buffer.cursorY, 9);
expect(_cursorRow(terminal), r'$');
final screen = _screen(terminal);
expect(screen.sublist(7), [r'$ ls', 'out', r'$']);
// Rows cut while narrow stay cut: no stale text past column 20.
for (final row in screen) {
expect(row.length, lessThanOrEqualTo(20), reason: row);
}
});
test('a prompt redrawn while narrow does not grow stale text when the '
'terminal widens again', () {
final terminal = _session().terminal..write('\$ ${'abcdefghij' * 3}');
terminal.resize(10, 10);
terminal.write('\r\x1b[K\$ ');
terminal.resize(40, 10);
expect(_cursorRow(terminal), r'$');
expect(terminal.buffer.cursorX, 2);
});
test('a cleared screen and scrollback stay cleared across resizes', () {
final terminal = _session().terminal..write(_longLines());
terminal.write('\x1b[H\x1b[2J\x1b[3J\$ ');
terminal.resize(20, 5);
terminal.resize(40, 12);
expect(_screen(terminal), [r'$', for (var i = 0; i < 11; i++) '']);
expect(terminal.buffer.height, 12);
expect(terminal.buffer.absoluteCursorY, 0);
});
test('fewer rows than the output drop blank rows below the cursor first', () {
final terminal = _session().terminal..write('a\r\nb\r\n\$ ');
terminal.resize(40, 4);
expect(_screen(terminal), ['a', 'b', r'$', '']);
expect(terminal.buffer.absoluteCursorY, 2);
terminal.resize(40, 10);
expect(_screen(terminal).take(3), ['a', 'b', r'$']);
expect(terminal.buffer.absoluteCursorY, 2);
});
testWidgets('the view resizes the live terminal as its box changes, '
'keeping the prompt on the cursor row', (tester) async {
final session = _session(cols: 80, rows: 24);
final sizes = <(int, int)>[];
session.terminal.onResize = (cols, rows, _, _) => sizes.add((cols, rows));
session.terminal.write(_longLines());
var size = const Size(600, 300);
late StateSetter setSize;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: StatefulBuilder(
builder: (context, setState) {
setSize = setState;
return SizedBox.fromSize(
size: size,
child: ChatShellTerminalView(session: session, fill: true),
);
},
),
),
),
),
);
await tester.pump();
final wide = session.terminal.viewWidth;
// The prompt is the 13th line; the screen has room below it.
final row = session.terminal.buffer.cursorY;
expect(row, 12);
expect(_cursorRow(session.terminal), r'$');
setSize(() => size = const Size(250, 120));
await tester.pump();
final terminal = session.terminal;
expect(terminal.viewWidth, lessThan(wide));
expect(terminal.buffer.cursorY, terminal.viewHeight - 1);
expect(_cursorRow(terminal), r'$');
setSize(() => size = const Size(600, 300));
await tester.pump();
expect(terminal.viewWidth, wide);
// The rows that scrolled off come back above the prompt.
expect(terminal.buffer.cursorY, row);
expect(_cursorRow(terminal), r'$');
expect(_screen(terminal)[row - 1], startsWith('line 11'));
expect(_screen(terminal)[0], startsWith('line 00'));
expect(sizes.length, greaterThanOrEqualTo(3));
});
}
@@ -85,7 +85,8 @@ void main() {
);
});
test('narrowing rewraps without pushing the first line out of view', () {
test('narrowing a live terminal cuts rows instead of rewrapping, keeping '
'the first line and the cursor on its own', () {
final session = ChatShellTerminalSession(
_run('first\r\n${'u' * 30}\r\nprompt: '),
onInput: (_) {},
@@ -95,11 +96,26 @@ void main() {
final buffer = session.terminal.buffer;
expect(buffer.height, 6);
expect(buffer.lines[0].getText().trim(), 'first');
expect(buffer.lines[3].getText().trim(), 'prompt:');
expect(buffer.absoluteCursorY, 3);
expect(buffer.lines[1].getText().trim(), 'u' * 20);
expect(buffer.lines[2].getText().trim(), 'prompt:');
expect(buffer.absoluteCursorY, 2);
expect(buffer.cursorX, 8);
});
test('finished output still rewraps to the width it is shown at', () {
final session = ChatShellTerminalSession(
_run('first\r\n${'u' * 30}\r\nend', status: 'exited'),
onInput: (_) {},
onResize: (_, _) {},
);
session.terminal.resize(20, 6);
final buffer = session.terminal.buffer;
expect(buffer.lines[0].getText().trim(), 'first');
expect(buffer.lines[1].getText().trim(), 'u' * 20);
expect(buffer.lines[2].getText().trim(), 'u' * 10);
expect(buffer.lines[3].getText().trim(), 'end');
});
test('a finished run counts the rows its output takes at a width', () {
final session = ChatShellTerminalSession(
_run('a\r\n${'x' * 50}\r\nend\r\n', status: 'exited'),
@@ -110,6 +110,109 @@ void main() {
);
}
Future<void> press(
WidgetTester tester,
LogicalKeyboardKey key, {
List<LogicalKeyboardKey> modifiers = const [],
String? character,
PhysicalKeyboardKey? physical,
}) async {
for (final modifier in modifiers) {
await tester.sendKeyDownEvent(modifier);
}
await tester.sendKeyDownEvent(
key,
character: character,
physicalKey: physical,
);
await tester.sendKeyUpEvent(key, physicalKey: physical);
for (final modifier in modifiers.reversed) {
await tester.sendKeyUpEvent(modifier);
}
await tester.pump();
}
testWidgets('the focused terminal sends xterm bytes for Alt, Ctrl and '
'modified keys, and the copy and paste keys still work', (tester) async {
await openRunning(tester, output: r'$ ');
await tester.tap(find.byType(TerminalView));
await tester.pump();
const alt = [LogicalKeyboardKey.altLeft];
const ctrl = [LogicalKeyboardKey.controlLeft];
const shift = [LogicalKeyboardKey.shiftLeft];
await press(tester, LogicalKeyboardKey.keyB, modifiers: alt);
await press(tester, LogicalKeyboardKey.keyF, modifiers: alt);
await press(tester, LogicalKeyboardKey.period, modifiers: alt);
await press(
tester,
LogicalKeyboardKey.keyB,
modifiers: [...alt, ...shift],
character: 'B',
);
await press(tester, LogicalKeyboardKey.backspace, modifiers: alt);
await press(tester, LogicalKeyboardKey.slash, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.bracketRight, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.arrowUp, modifiers: shift);
await press(tester, LogicalKeyboardKey.arrowLeft, modifiers: alt);
await press(tester, LogicalKeyboardKey.arrowRight, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.keyT, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.keyX);
expect(
typed(),
'\x1bb\x1bf\x1b.\x1bB\x1b\x7f\x1f\x1d'
'\x1b[1;2A\x1b[1;3D\x1b[1;5C\x14x',
);
// Application cursor keys from the process's own mode switch.
gateway.emitOutput('run_t', '\x1b[?1h', 2);
await tester.pump();
gateway.calls.clear();
await press(tester, LogicalKeyboardKey.arrowUp);
expect(typed(), '\x1bOA');
// Ctrl-V is still paste, not ^V.
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
(call) async =>
call.method == 'Clipboard.getData' ? {'text': 'tok'} : null,
);
addTearDown(
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
null,
),
);
await press(tester, LogicalKeyboardKey.keyV, modifiers: ctrl);
for (var i = 0; i < 5; i++) {
await tester.pump(const Duration(milliseconds: 20));
}
expect(typed(), '\x1bOAtok');
await tester.pump(const Duration(milliseconds: 400));
}, variant: TargetPlatformVariant.only(TargetPlatform.linux));
testWidgets(
'on a Mac, Option is Meta in the terminal',
(tester) async {
await openRunning(tester, output: r'$ ');
await tester.tap(find.byType(TerminalView));
await tester.pump();
await press(
tester,
LogicalKeyboardKey.keyB,
modifiers: [LogicalKeyboardKey.altLeft],
character: '∫',
);
await press(
tester,
const LogicalKeyboardKey(0x2202),
modifiers: [LogicalKeyboardKey.altLeft],
character: '∂',
physical: PhysicalKeyboardKey.keyD,
);
expect(typed(), '\x1bb\x1bd');
await tester.pump(const Duration(milliseconds: 400));
},
variant: TargetPlatformVariant.only(TargetPlatform.macOS),
);
testWidgets('on Linux, Ctrl-C copies a selection and interrupts without one; '
'Ctrl-Insert copies too', (tester) async {
await openRunning(tester, output: 'Paste your token: ');