Files
pipelines/app/lib/features/settings/settings_terminal_section.dart
T
alan b59ab5fad7 Terminal round 3: readable palettes, panel and card sizing, rail, tabs
- 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>
2026-11-26 02:25:16 +00:00

89 lines
3.2 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../terminal/terminal_layout.dart';
import 'settings_group.dart';
import 'settings_terminal_controls.dart';
import 'settings_theme.dart';
/// Appearance → Terminal: whether the terminal docks at the bottom of the
/// window or floats over it (Ctrl+` shows and hides it either way), the
/// Option key, text size, colours, scrollback length and visual bell.
class SettingsTerminalSection extends StatelessWidget {
const SettingsTerminalSection({super.key, required this.layout});
final TerminalLayout layout;
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: layout,
builder: (context, _) {
final Widget choice = SegmentedButton<TerminalMode>(
segments: [
for (final mode in TerminalMode.values)
ButtonSegment(
value: mode,
label: Text(
mode.label,
key: ValueKey('settings-terminal-${mode.name}'),
),
icon: Icon(
mode == TerminalMode.panel
? Icons.call_to_action_outlined
: Icons.picture_in_picture_alt_outlined,
),
),
],
selected: {layout.mode},
onSelectionChanged: (modes) => layout.setMode(modes.first),
);
return SettingsGroup(
title: 'Terminal',
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Saved on this device. Ctrl+` shows or hides the terminal; on '
'a narrow window it opens full screen. A terminal starts at '
'the machine\'s login prompt: type that account\'s password '
'once, and it stays logged in while hidden. Terminals end '
'when the server restarts; run tmux inside one to keep work.',
),
if (layout.saveFailed)
Text(
'Could not save; applies until reload.',
style: TextStyle(color: settingsErrorColor(context)),
),
],
),
children: [
SettingsGroupItem(
child: Semantics(
label: 'Terminal placement',
child: Align(
alignment: AlignmentDirectional.centerStart,
child: choice,
),
),
),
// Alt is always Meta elsewhere; only a Mac's Option types symbols.
if (defaultTargetPlatform == TargetPlatform.macOS ||
defaultTargetPlatform == TargetPlatform.iOS)
SwitchListTile(
key: const ValueKey('settings-terminal-option-as-meta'),
title: const Text('Use Option as Meta key'),
subtitle: const Text(
'Option+B, Option+F and Option+D move and delete by word in '
'the shell (ESC b, ESC f, ESC d). Off, Option types its '
'symbol (∫, ƒ, ∂).',
),
value: layout.optionAsMeta,
onChanged: layout.setOptionAsMeta,
),
...settingsTerminalControls(layout),
],
);
},
);
}