Skip to main content

trueno_gpu/monitor/tui_layout/
controls.rs

1//! Keyboard controls for TUI interaction.
2
3// ============================================================================
4// Keyboard Controls
5// ============================================================================
6
7/// Keyboard action
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum KeyAction {
10    /// Quit application
11    Quit,
12    /// Force refresh
13    Refresh,
14    /// Toggle stress test mode
15    ToggleStress,
16    /// Focus next section
17    FocusNext,
18    /// Navigate up
19    NavigateUp,
20    /// Navigate down
21    NavigateDown,
22    /// Expand/collapse current item
23    Expand,
24    /// Show help overlay
25    Help,
26    /// Show alerts panel
27    Alerts,
28    /// Export metrics to JSON
29    Export,
30    /// Pause/resume monitoring
31    TogglePause,
32}
33
34impl KeyAction {
35    /// Get keyboard shortcut for this action
36    #[must_use]
37    pub fn key(&self) -> char {
38        match self {
39            Self::Quit => 'q',
40            Self::Refresh => 'r',
41            Self::ToggleStress => 's',
42            Self::FocusNext => '\t',
43            Self::NavigateUp => '\u{2191}',
44            Self::NavigateDown => '\u{2193}',
45            Self::Expand => '\n',
46            Self::Help => '?',
47            Self::Alerts => 'a',
48            Self::Export => 'e',
49            Self::TogglePause => 'p',
50        }
51    }
52
53    /// Get description for help display
54    #[must_use]
55    pub fn description(&self) -> &'static str {
56        match self {
57            Self::Quit => "Quit",
58            Self::Refresh => "Refresh",
59            Self::ToggleStress => "Stress Test",
60            Self::FocusNext => "Focus",
61            Self::NavigateUp => "Up",
62            Self::NavigateDown => "Down",
63            Self::Expand => "Expand",
64            Self::Help => "Help",
65            Self::Alerts => "Alerts",
66            Self::Export => "Export",
67            Self::TogglePause => "Pause",
68        }
69    }
70}