Merge branch 'main' into pipelines/run-20261113-1520-search-opens-the-selected-chat-5f6a
This commit is contained in:
@@ -97,7 +97,7 @@ class KeyboardShortcutRegistry {
|
||||
keys: shellChatShortcutLabels(platform).join(', '),
|
||||
caveat: web
|
||||
? 'Shows the open chat and focuses its message input. The browser may reserve Ctrl+K.'
|
||||
: 'Shows the open chat and focuses its message input. In the terminal Ctrl+K stays kill-line; Alt+K still opens Chat.',
|
||||
: 'Shows the open chat and focuses its message input. In the terminal Ctrl+K stays kill-line; ${_apple ? 'Option+K and Cmd+K still open' : 'Alt+K still opens'} Chat.',
|
||||
),
|
||||
const KeyboardShortcutEntry(
|
||||
group: KeyboardShortcutGroup.navigation,
|
||||
|
||||
@@ -416,9 +416,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
return true;
|
||||
}
|
||||
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
|
||||
// Alt+K still opens Chat there.
|
||||
// Alt+K and Cmd+K still open Chat there.
|
||||
if (shellChatShortcut(event, keyboard) &&
|
||||
(keyboard.isAltPressed || !primaryFocusIsTypingSurface())) {
|
||||
(keyboard.isAltPressed ||
|
||||
keyboard.isMetaPressed ||
|
||||
!primaryFocusIsTypingSurface())) {
|
||||
if (event is KeyDownEvent) _openChat();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,29 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// Whether [event] opens the Chat destination from any destination: Ctrl+K,
|
||||
/// or Alt+K (Option+K on Apple platforms). Alt+K is recognised by key position
|
||||
/// too, because Option+K yields a dead-key symbol on a Mac. Shift, Cmd and
|
||||
/// chords with both Ctrl and Alt are not the shortcut. Repeats of a held chord
|
||||
/// Cmd+K (Meta+K), or Alt+K (Option+K on Apple platforms). Alt+K is
|
||||
/// recognised by key position too, because Option+K yields a dead-key symbol
|
||||
/// on a Mac. Shift and chords of more than one of Ctrl, Cmd and Alt are not
|
||||
/// the shortcut. Repeats of a held chord
|
||||
/// match as well, so the caller can swallow them; only its first press acts.
|
||||
bool shellChatShortcut(KeyEvent event, HardwareKeyboard keyboard) {
|
||||
if (event is KeyUpEvent ||
|
||||
keyboard.isShiftPressed ||
|
||||
keyboard.isMetaPressed) {
|
||||
return false;
|
||||
}
|
||||
final control = keyboard.isControlPressed;
|
||||
if (event is KeyUpEvent || keyboard.isShiftPressed) return false;
|
||||
final alt = keyboard.isAltPressed;
|
||||
if (control == alt) return false;
|
||||
final held = [
|
||||
keyboard.isControlPressed,
|
||||
keyboard.isMetaPressed,
|
||||
alt,
|
||||
].where((pressed) => pressed).length;
|
||||
if (held != 1) return false;
|
||||
if (event.logicalKey == LogicalKeyboardKey.keyK) return true;
|
||||
return alt && event.physicalKey == PhysicalKeyboardKey.keyK;
|
||||
}
|
||||
|
||||
/// The chords that open Chat as they read on this platform, for the help
|
||||
/// page. Alt (Option on Apple platforms) leads, as it does for the floating
|
||||
/// chats; Ctrl+K is the other chord everywhere.
|
||||
/// chats; Cmd+K follows on Apple platforms and Ctrl+K works everywhere.
|
||||
List<String> shellChatShortcutLabels([TargetPlatform? platform]) {
|
||||
final target = platform ?? defaultTargetPlatform;
|
||||
final apple = target == TargetPlatform.macOS || target == TargetPlatform.iOS;
|
||||
return [apple ? 'Option+K' : 'Alt+K', 'Ctrl+K'];
|
||||
return apple ? ['Option+K', 'Cmd+K', 'Ctrl+K'] : ['Alt+K', 'Ctrl+K'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user