Files
pipelines/app/lib/features/terminal/terminal_float_frame.dart
T
alan 30934aa71c Toggle the terminal with Alt/Ctrl/Cmd+T, animate it, focus it, and cycle its tabs with Ctrl+Tab
Alt+T, Ctrl+T and Cmd+T join Ctrl+` as early focus-manager key handlers, so
they toggle the panel, window or narrow page from anywhere without reaching
the shell or a text field. Opening with no terminal starts one. The shown
terminal takes the keyboard (also on reload and tab changes) and hiding gives
it back. The panel slides from the bottom edge as the app shrinks, the window
scales and fades, both on Motion.standard and off under reduced motion.
While shown, Ctrl+Tab/Ctrl+Shift+Tab move between terminal tabs instead of
chat panes. The tooltip and menu list the shortcuts the platform delivers.
2026-11-09 23:43:56 +00:00

48 lines
1.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'terminal_layout.dart';
/// Margin a maximised window keeps from the edges of the app.
const double terminalFloatMargin = 8;
/// [rect] moved and shrunk to fit inside [bounds], at least the minimum
/// window size where the bounds allow it.
Rect fitTerminalFloat(Rect rect, Size bounds) {
final width = rect.width
.clamp(terminalFloatMinSize.width, double.infinity)
.clamp(0.0, bounds.width);
final height = rect.height
.clamp(terminalFloatMinSize.height, double.infinity)
.clamp(0.0, bounds.height);
final left = rect.left.clamp(0.0, bounds.width - width);
final top = rect.top.clamp(0.0, bounds.height - height);
return Rect.fromLTWH(left, top, width, height);
}
/// The window's card: a Material surface with elevation, or a Cupertino
/// rounded box with a hairline and shadow.
Widget terminalFloatChrome(BuildContext context, bool cupertino, Widget child) {
if (!cupertino) {
return Material(
elevation: 8,
clipBehavior: Clip.antiAlias,
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.surfaceContainer,
child: child,
);
}
return DecoratedBox(
decoration: BoxDecoration(
color: CupertinoColors.secondarySystemBackground.resolveFrom(context),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: CupertinoColors.separator.resolveFrom(context)),
boxShadow: const [BoxShadow(blurRadius: 16, color: Color(0x33000000))],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Material(type: MaterialType.transparency, child: child),
),
);
}