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;