| 1 | //! Common actions shared by keyboard-driven GPUI controls. |
| 2 | |
| 3 | use gpui::{Action, actions}; |
| 4 | use serde::Deserialize; |
| 5 | |
| 6 | #[derive(Clone, Action, PartialEq, Eq, Deserialize)] |
| 7 | #[action(namespace = ui, no_json)] |
| 8 | pub struct Confirm { |
| 9 | /// Whether the confirmation uses the secondary action. |
| 10 | pub secondary: bool, |
| 11 | } |
| 12 | |
| 13 | actions!( |
| 14 | ui, |
| 15 | [ |
| 16 | Cancel, |
| 17 | SelectUp, |
| 18 | SelectDown, |
| 19 | SelectLeft, |
| 20 | SelectRight, |
| 21 | SelectFirst, |
| 22 | SelectLast, |
| 23 | SelectPrevColumn, |
| 24 | SelectNextColumn, |
| 25 | SelectPageUp, |
| 26 | SelectPageDown |
| 27 | ] |
| 28 | ); |
| 29 | |
| 30 | #[cfg(test)] |
| 31 | mod tests { |
| 32 | use super::*; |
| 33 | |
| 34 | #[test] |
| 35 | fn confirm_keeps_its_secondary_payload() { |
| 36 | assert!(Confirm { secondary: true }.secondary); |
| 37 | assert!(!Confirm { secondary: false }.secondary); |
| 38 | } |
| 39 | } |