2bbc737604
Provide a platform-independent destination shortcut that preserves Ctrl+A for text fields and the terminal. Document the shortcut in help and cover navigation and focus exceptions with regression tests.
29 lines
1.1 KiB
Dart
29 lines
1.1 KiB
Dart
import 'package:flutter/services.dart';
|
|
|
|
import 'destination.dart';
|
|
|
|
/// The chord that bounces between Runs and Pipelines, as the help page reads
|
|
/// it. It is the same on every platform.
|
|
const shellRunsPipelinesShortcutLabel = 'Ctrl+A';
|
|
|
|
/// Whether [event] is Ctrl+A. Only Ctrl counts: Alt, Shift, Cmd and chords
|
|
/// with both Ctrl 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 shellRunsPipelinesShortcut(KeyEvent event, HardwareKeyboard keyboard) {
|
|
if (event is KeyUpEvent ||
|
|
keyboard.isAltPressed ||
|
|
keyboard.isShiftPressed ||
|
|
keyboard.isMetaPressed ||
|
|
!keyboard.isControlPressed) {
|
|
return false;
|
|
}
|
|
return event.logicalKey == LogicalKeyboardKey.keyA;
|
|
}
|
|
|
|
/// The destination Ctrl+A goes to from [current]: Pipelines from Runs, and
|
|
/// Runs from every other destination (Pipelines included).
|
|
AppDestination shellRunsPipelinesTarget(AppDestination current) =>
|
|
current == AppDestination.runs
|
|
? AppDestination.pipelines
|
|
: AppDestination.runs;
|