Add global keyboard shortcuts cheatsheet

Expose the existing shortcut help as a global Ctrl+?/Cmd+? cheatsheet while preserving Ctrl+/ search behavior. Register the current shortcuts and cover composer, terminal, layout, and close interactions with focused tests.
This commit is contained in:
2026-11-12 14:41:20 +00:00
parent a3fb506a57
commit 3e0b1e55c7
9 changed files with 1002 additions and 50 deletions
+35
View File
@@ -0,0 +1,35 @@
import 'package:flutter/widgets.dart';
import '../features/settings/keyboard_shortcuts_help.dart';
/// Opens and closes the keyboard shortcuts cheatsheet from the shell's global
/// key handler. Ctrl+? (or Escape) closes it, and it is only ever popped once:
/// closing clears the token first, and a dismissal by the barrier or close
/// button clears it when the route completes.
class ShellCheatsheet {
Object? _token;
bool get isOpen => _token != null;
void toggle(BuildContext context) {
if (isOpen) {
close(context);
} else {
open(context);
}
}
void open(BuildContext context) {
if (isOpen) return;
final token = _token = Object();
showKeyboardShortcutsHelp(context).whenComplete(() {
if (identical(_token, token)) _token = null;
});
}
void close(BuildContext context) {
if (!isOpen) return;
_token = null;
Navigator.of(context, rootNavigator: true).maybePop();
}
}