6832ec789e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.6 KiB
Dart
77 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../terminal/terminal_layout.dart';
|
|
import 'settings_group.dart';
|
|
|
|
/// The text sizes the setting offers (besides Default and the current one).
|
|
const List<double> _fontSizes = [10, 11, 12, 13, 14, 15, 16, 18, 20, 24];
|
|
|
|
/// Appearance → Terminal's text size, scrollback and bell controls.
|
|
List<Widget> settingsTerminalControls(TerminalLayout layout) => [
|
|
SettingsGroupItem(child: _FontSize(layout: layout)),
|
|
SettingsGroupItem(child: _Scrollback(layout: layout)),
|
|
SwitchListTile(
|
|
key: const ValueKey('settings-terminal-bell'),
|
|
title: const Text('Visual bell'),
|
|
subtitle: const Text(
|
|
'A bell from the program flashes the terminal\'s border, and dots its '
|
|
'tab while it is not shown.',
|
|
),
|
|
value: layout.bell,
|
|
onChanged: layout.setBell,
|
|
),
|
|
];
|
|
|
|
String _lines(int lines) => lines >= 1000 && lines % 1000 == 0
|
|
? '${lines ~/ 1000}k lines'
|
|
: '$lines lines';
|
|
|
|
class _FontSize extends StatelessWidget {
|
|
const _FontSize({required this.layout});
|
|
final TerminalLayout layout;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final current = layout.fontSize;
|
|
final sizes = {..._fontSizes, ?current}.toList()..sort();
|
|
// Keyed by the value, so a zoom from the keyboard shows here at once.
|
|
return DropdownMenu<double>(
|
|
key: ValueKey('settings-terminal-font-size-$current'),
|
|
expandedInsets: EdgeInsets.zero,
|
|
label: const Text('Text size'),
|
|
helperText:
|
|
'Ctrl or Cmd with + and - zooms a focused terminal; '
|
|
'with 0 it resets.',
|
|
initialSelection: current ?? 0,
|
|
dropdownMenuEntries: [
|
|
const DropdownMenuEntry(value: 0, label: 'Default'),
|
|
for (final size in sizes)
|
|
DropdownMenuEntry(value: size, label: '${size.round()} pt'),
|
|
],
|
|
onSelected: (size) =>
|
|
layout.setFontSize(size == null || size == 0 ? null : size),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Scrollback extends StatelessWidget {
|
|
const _Scrollback({required this.layout});
|
|
final TerminalLayout layout;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => DropdownMenu<int>(
|
|
key: ValueKey('settings-terminal-scrollback-${layout.scrollback}'),
|
|
expandedInsets: EdgeInsets.zero,
|
|
label: const Text('Scrollback'),
|
|
helperText: 'Lines each terminal keeps; applies to open terminals too.',
|
|
initialSelection: layout.scrollback,
|
|
dropdownMenuEntries: [
|
|
for (final lines in terminalScrollbackChoices)
|
|
DropdownMenuEntry(value: lines, label: _lines(lines)),
|
|
],
|
|
onSelected: (lines) {
|
|
if (lines != null) layout.setScrollback(lines);
|
|
},
|
|
);
|
|
}
|