Design switcher: Alt+L lists every design, previews live, Enter keeps it
The chat switcher's popup and keys over the AppDesign registry: filter, Ctrl+N/P and arrows preview the selected design app-wide without storing it (AppDesignController.preview), Enter keeps it, Esc or Alt+L again returns to the design it opened with. The current design is checked. Listed in Settings -> Keyboard shortcuts and the cheatsheet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import 'shell_chat_actions_shortcut.dart';
|
||||
import 'shell_chat_shortcut.dart';
|
||||
import 'shell_cheatsheet.dart';
|
||||
import 'shell_cheatsheet_shortcut.dart';
|
||||
import 'shell_design_shortcut.dart';
|
||||
import 'shell_list_shortcuts.dart';
|
||||
import 'shell_runs_pipelines_shortcut.dart';
|
||||
import 'shell_search_shortcut_labels.dart';
|
||||
@@ -35,6 +36,7 @@ class AdaptiveShell extends StatefulWidget {
|
||||
this.onOpenChat,
|
||||
this.onChatQuickSwitch,
|
||||
this.onChatAction,
|
||||
this.onDesignSwitch,
|
||||
this.attentionCount = 0,
|
||||
this.runningRunCount,
|
||||
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
||||
@@ -84,6 +86,11 @@ class AdaptiveShell extends StatefulWidget {
|
||||
/// needing the operator. Null leaves both chords unhandled.
|
||||
final ValueChanged<ShellChatAction>? onChatAction;
|
||||
|
||||
/// Runs on Alt+L (see [shellDesignShortcut]) from any destination: the host
|
||||
/// toggles its design switcher, shown from the given context. Null leaves
|
||||
/// the chord unhandled.
|
||||
final ValueChanged<BuildContext>? onDesignSwitch;
|
||||
|
||||
/// Runs needing the operator today, retained in the tab's accessible label.
|
||||
final int attentionCount;
|
||||
|
||||
@@ -419,6 +426,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
}
|
||||
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits, Alt+N, Alt+J).
|
||||
if (primaryFocusIsTypingSurface()) return false;
|
||||
final designSwitch = widget.onDesignSwitch;
|
||||
if (designSwitch != null && shellDesignShortcut(event, keyboard)) {
|
||||
if (event is KeyDownEvent) designSwitch(context);
|
||||
return true;
|
||||
}
|
||||
final chatAction = widget.onChatAction == null
|
||||
? null
|
||||
: shellChatActionShortcut(event, keyboard);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// Whether [event] opens or closes the design switcher: Alt+L (Option+L on
|
||||
/// a Mac, L for look) with no other modifier, from any destination. Option+L
|
||||
/// types a symbol (¬) on a Mac, so the key is matched by position as well.
|
||||
/// Repeats of a held chord match too, so the caller can swallow them; only
|
||||
/// the first press acts.
|
||||
///
|
||||
/// The chord sits beside Alt+K (the chat switcher) and works the same way.
|
||||
/// Alt+T (the terminal) and Alt+D (the browser's address bar) are taken, and
|
||||
/// no Ctrl or Cmd chord is free for it: Ctrl+L and Cmd+L are the browser's
|
||||
/// address bar and the terminal's clear screen, Ctrl+Alt+T and Ctrl+Alt+L
|
||||
/// open a terminal and lock the screen on Linux desktops. No browser,
|
||||
/// GNOME, KDE or macOS takes Alt+L. The terminal keeps it for readline
|
||||
/// (downcase-word), so the caller leaves it to the terminal while it has the
|
||||
/// keyboard.
|
||||
bool shellDesignShortcut(KeyEvent event, HardwareKeyboard keyboard) {
|
||||
if (event is KeyUpEvent ||
|
||||
!keyboard.isAltPressed ||
|
||||
keyboard.isControlPressed ||
|
||||
keyboard.isMetaPressed ||
|
||||
keyboard.isShiftPressed) {
|
||||
return false;
|
||||
}
|
||||
return event.logicalKey == LogicalKeyboardKey.keyL ||
|
||||
event.physicalKey == PhysicalKeyboardKey.keyL;
|
||||
}
|
||||
|
||||
/// The chord as it reads on [platform], for the help page.
|
||||
String shellDesignShortcutLabel([TargetPlatform? platform]) {
|
||||
final target = platform ?? defaultTargetPlatform;
|
||||
final apple = target == TargetPlatform.macOS || target == TargetPlatform.iOS;
|
||||
return apple ? 'Option+L' : 'Alt+L';
|
||||
}
|
||||
Reference in New Issue
Block a user