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>
126 lines
4.2 KiB
Dart
126 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// The widest a tab's title is drawn before it ends in an ellipsis (the
|
|
/// tooltip has it whole).
|
|
const double terminalTabTitleMaxWidth = 220;
|
|
|
|
/// One terminal's tab: its [title] (ellipsised, italic once the terminal
|
|
/// ended), a bell dot, and a close button, with the whole title and
|
|
/// [tooltip] (machine and folder) on hover or long press.
|
|
///
|
|
/// The selected tab is filled with the secondary container and outlined in
|
|
/// the accent, its title bold, so it reads as selected in either theme
|
|
/// without relying on colour alone. The close button is a standard
|
|
/// [IconButton]: at least 48 px square on touch platforms and 40 px on
|
|
/// desktops (the platform's visual density).
|
|
class TerminalTabChip extends StatelessWidget {
|
|
const TerminalTabChip({
|
|
super.key,
|
|
required this.title,
|
|
required this.tooltip,
|
|
required this.selected,
|
|
required this.running,
|
|
required this.bell,
|
|
required this.onSelect,
|
|
required this.onClose,
|
|
});
|
|
|
|
final String title;
|
|
final String tooltip;
|
|
final bool selected;
|
|
final bool running;
|
|
final bool bell;
|
|
final VoidCallback onSelect;
|
|
final VoidCallback onClose;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final foreground = selected
|
|
? scheme.onSecondaryContainer
|
|
: scheme.onSurfaceVariant;
|
|
final label = Text(
|
|
title,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
softWrap: false,
|
|
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
|
color: foreground,
|
|
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
|
fontStyle: running ? null : FontStyle.italic,
|
|
),
|
|
);
|
|
final shape = RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
side: BorderSide(
|
|
color: selected ? scheme.primary : scheme.outlineVariant,
|
|
width: selected ? 2 : 1,
|
|
),
|
|
);
|
|
return Semantics(
|
|
selected: selected,
|
|
child: Material(
|
|
shape: shape,
|
|
color: selected ? scheme.secondaryContainer : Colors.transparent,
|
|
clipBehavior: Clip.antiAlias,
|
|
// The title's ink fills the tab's height (the close button's).
|
|
child: IntrinsicHeight(
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Tooltip(
|
|
message: tooltip,
|
|
child: InkWell(
|
|
onTap: onSelect,
|
|
child: Semantics(
|
|
button: true,
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.only(
|
|
start: 12,
|
|
end: 4,
|
|
),
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(
|
|
maxWidth: terminalTabTitleMaxWidth,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Flexible(child: label),
|
|
if (bell)
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.only(
|
|
start: 6,
|
|
),
|
|
// The bell rang while the terminal was not
|
|
// shown.
|
|
child: Semantics(
|
|
label: 'Bell',
|
|
child: Badge(
|
|
key: const ValueKey('terminal-tab-bell'),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
IconButton(
|
|
tooltip: 'Close terminal',
|
|
onPressed: onClose,
|
|
color: foreground,
|
|
iconSize: 18,
|
|
icon: const Icon(Icons.close),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|