b59ab5fad7
- Colours: terminal background is the theme's lowest surface; the 16 ANSI colours come from a chosen palette (Theme colours, Classic, Calm, Vivid; Settings > Terminal > Colours, saved as `palette`) adjusted in lightness to the background: colours 4.5:1, bright ones lighter than normal, white light and black dark in both themes so white-on-red/blue/magenta and black-on-green/yellow/cyan (ls setuid, setgid, sticky) keep 3:1. Selection, find matches and the current match keep text at 4.5:1. - Bottom panel opens at 40% of the window, at least 16 rows, until dragged; the dragged height is remembered (old saved 300 px default reads as never resized). - Navigation rail scrolls its tabs (and below 240 px Settings too), so items never overlap under a tall panel. - Chat command cards: Expand / Collapse grows a live terminal to 60% of the window (finished output only to its rows); collapsed stays 12 rows. - Terminal tabs: ellipsised titles (220 px) with the whole title in the tooltip, selected tab filled, outlined and bold, close buttons are IconButtons (48 px touch, 40 px desktop). - Capture fixture: ?terminalColors=1 and ?terminalPalette=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
3.9 KiB
Dart
133 lines
3.9 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'terminal_hub.dart';
|
|
import 'terminal_layout.dart';
|
|
import 'terminal_menu.dart';
|
|
import 'terminal_shortcuts.dart';
|
|
import 'terminal_tab.dart';
|
|
import 'terminal_tab_chip.dart';
|
|
|
|
/// The terminal's header: one tab per terminal (title, and the machine when
|
|
/// tabs come from several), New terminal (choosing the machine when more
|
|
/// than one is connected), the mode menu, and the host's own [trailing]
|
|
/// window buttons.
|
|
class TerminalTabStrip extends StatelessWidget {
|
|
const TerminalTabStrip({
|
|
super.key,
|
|
required this.hub,
|
|
required this.layout,
|
|
this.trailing = const [],
|
|
this.showModes = true,
|
|
});
|
|
|
|
final TerminalHub hub;
|
|
final TerminalLayout layout;
|
|
final List<Widget> trailing;
|
|
|
|
/// False on the narrow page, which has no panel or window to choose.
|
|
final bool showModes;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final selected = hub.selected;
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
child: Row(
|
|
children: [
|
|
for (final (index, tab) in hub.tabs.indexed)
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.only(end: 4),
|
|
child: Semantics(
|
|
identifier: 'terminal-tab-$index',
|
|
child: _tab(tab, tab == selected),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
_newTerminal(),
|
|
if (showModes)
|
|
TerminalMenuButton<_Option>(
|
|
label: 'Terminal options',
|
|
info: TerminalShortcutLabels.current().summary,
|
|
icon: Icons.more_vert,
|
|
choices: [
|
|
for (final mode in TerminalMode.values)
|
|
TerminalChoice(
|
|
_Option(mode),
|
|
mode.label,
|
|
checked: layout.mode == mode,
|
|
key: ValueKey('terminal-mode-${mode.name}'),
|
|
),
|
|
const TerminalChoice(
|
|
_Option(null),
|
|
'Hide terminal',
|
|
key: ValueKey('terminal-hide'),
|
|
),
|
|
],
|
|
onSelected: (option) => option.mode == null
|
|
? layout.hide()
|
|
: layout.setMode(option.mode!),
|
|
),
|
|
...trailing,
|
|
],
|
|
);
|
|
}
|
|
|
|
String _label(TerminalTab tab) =>
|
|
hub.multiMachine ? '${tab.title} · ${tab.machineName}' : tab.title;
|
|
|
|
Widget _tab(TerminalTab tab, bool selected) {
|
|
final title = _label(tab);
|
|
return TerminalTabChip(
|
|
title: title,
|
|
// The whole title (the tab may ellipsise it), then where it runs.
|
|
tooltip: '$title\n${tab.machineName}: ${tab.cwd}',
|
|
selected: selected,
|
|
running: tab.info.running,
|
|
bell: tab.bellUnseen,
|
|
onSelect: () => hub.select(tab),
|
|
onClose: () => unawaited(hub.close(tab)),
|
|
);
|
|
}
|
|
|
|
Widget _newTerminal() {
|
|
final machines = hub.connected;
|
|
if (machines.length > 1) {
|
|
return TerminalMenuButton<String>(
|
|
label: 'New terminal',
|
|
icon: Icons.add,
|
|
choices: [
|
|
for (final machine in machines)
|
|
TerminalChoice(
|
|
machine.id,
|
|
machine.name,
|
|
key: ValueKey('terminal-new-${machine.id}'),
|
|
),
|
|
],
|
|
onSelected: (id) => unawaited(hub.open(machineId: id)),
|
|
);
|
|
}
|
|
final enabled = machines.isNotEmpty;
|
|
void open() => unawaited(hub.open());
|
|
return IconButton(
|
|
tooltip: 'New terminal',
|
|
onPressed: enabled ? open : null,
|
|
icon: const Icon(Icons.add),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A mode to switch to, or (null) hiding the terminal.
|
|
class _Option {
|
|
const _Option(this.mode);
|
|
final TerminalMode? mode;
|
|
}
|