ghostscope_ui/
action.rs

1/// Central Action enum for TEA architecture
2/// All possible actions/messages that can modify application state
3#[derive(Debug, Clone)]
4pub enum Action {
5    // Global actions
6    Quit,
7    Resize(u16, u16),
8
9    // Panel focus actions
10    FocusNext,
11    FocusPrevious,
12    FocusPanel(PanelType),
13    ToggleFullscreen,
14    SwitchLayout,
15
16    // Window navigation
17    EnterWindowNavMode,
18    ExitWindowNavMode,
19    WindowNavMove(WindowDirection),
20
21    // Input actions
22    InsertChar(char),
23    DeleteChar,
24    MoveCursor(CursorDirection),
25    DeleteWord,
26    DeletePreviousWord,
27    DeleteToEnd,
28    DeleteToBeginning,
29    MoveToBeginning,
30    MoveToEnd,
31
32    // Command actions
33    SubmitCommand,
34    SubmitCommandWithText {
35        command: String,
36    }, // For history search mode
37    HistoryUp,
38    HistoryDown,
39    HistoryPrevious, // Ctrl+p - go to previous command
40    HistoryNext,     // Ctrl+n - go to next command
41    EnterCommandMode,
42    ExitCommandMode, // Exit command mode and return to previous mode
43    EnterInputMode,
44
45    // Command mode navigation actions
46    CommandCursorUp,
47    CommandCursorDown,
48    CommandCursorLeft,
49    CommandCursorRight,
50    CommandHalfPageUp,   // Ctrl+U in command mode
51    CommandHalfPageDown, // Ctrl+D in command mode
52
53    // Script editing actions
54    EnterScriptMode(String),
55    ExitScriptMode,
56    SubmitScript,
57    CancelScript,
58    InsertNewline,
59    InsertTab,
60
61    // Response handling
62    AddResponseWithStyle {
63        content: String,
64        styled_lines: Option<Vec<ratatui::text::Line<'static>>>,
65        response_type: ResponseType,
66    },
67    AddStyledWelcomeMessage {
68        styled_lines: Vec<ratatui::text::Line<'static>>,
69        response_type: ResponseType,
70    },
71    CommandCompleted,
72    CommandFailed(String),
73
74    // Runtime communication
75    SendRuntimeCommand(RuntimeCommand),
76    HandleRuntimeStatus(RuntimeStatus),
77    HandleTraceEvent(ghostscope_protocol::ParsedTraceEvent),
78
79    // Source panel actions
80    LoadSource {
81        path: String,
82        line: Option<usize>,
83    },
84    EnterFileSearch,
85    ExitFileSearch,
86    EnterTextSearch,
87    ExitTextSearch,
88    NavigateSource(SourceNavigation),
89    SourceSearchInput(char),
90    SourceSearchBackspace,
91    SourceSearchConfirm,
92    SourceFileSearchInput(char),
93    SourceFileSearchBackspace,
94    SourceFileSearchConfirm,
95    SourceNumberInput(char),
96    SourceGoToLine,
97    SourceGoToBottom,
98    SetTraceFromSourceLine, // Space key - set trace at current cursor line
99
100    // eBPF panel actions
101    NavigateEbpf(EbpfNavigation),
102
103    // Save actions (handled in UI directly)
104    SaveEbpfOutput {
105        filename: Option<String>,
106    },
107    SaveCommandSession {
108        filename: Option<String>,
109    },
110    StopSaveOutput,  // Stop realtime eBPF output logging
111    StopSaveSession, // Stop realtime command session logging
112
113    // Internal actions
114    NoOp, // No operation - used to prevent event fallback without side effects
115
116    // UI configuration actions
117    SetSourcePanelVisibility(bool),
118}
119
120#[derive(Debug, Clone, Copy, PartialEq)]
121pub enum PanelType {
122    Source,
123    EbpfInfo,
124    InteractiveCommand,
125}
126
127#[derive(Debug, Clone, Copy, PartialEq)]
128pub enum CursorDirection {
129    Left,
130    Right,
131    Up,
132    Down,
133    Home,
134    End,
135}
136
137#[derive(Debug, Clone, Copy, PartialEq)]
138pub enum WindowDirection {
139    Left,  // h
140    Right, // l
141    Up,    // k
142    Down,  // j
143}
144
145#[derive(Debug, Clone, Copy, PartialEq)]
146pub enum SourceNavigation {
147    Up,
148    Down,
149    Left,
150    Right,
151    PageUp,
152    PageDown,
153    HalfPageUp,   // Ctrl+U - up 10 lines
154    HalfPageDown, // Ctrl+D - down 10 lines
155    WordForward,  // w - next word
156    WordBackward, // b - previous word
157    LineStart,    // ^ - first non-whitespace character
158    LineEnd,      // $ - end of line
159    GoToLine(usize),
160    NextMatch,
161    PrevMatch,
162}
163
164#[derive(Debug, Clone, Copy, PartialEq)]
165pub enum EbpfNavigation {
166    Up,
167    Down,
168    PageUp,
169    PageDown,
170    GoToLine(usize),
171}
172
173#[derive(Debug, Clone, Copy, PartialEq)]
174pub enum ResponseType {
175    Success,
176    Error,
177    Warning,
178    Info,
179    Progress,
180    ScriptDisplay,
181}
182
183// Import from events.rs
184pub use crate::events::{RuntimeCommand, RuntimeStatus};