arct_tui/panels/
mod.rs

1//! Panel definitions and implementations
2
3pub mod shell;
4pub mod context;
5pub mod explanation;
6pub mod help;
7pub mod lesson;
8pub mod lesson_menu;
9pub mod onboarding;
10pub mod settings;
11pub mod achievements;
12pub mod progress;
13pub mod challenges;
14pub mod notification;
15
16use ratatui::{layout::Rect, Frame};
17
18/// Panel identifiers
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum PanelId {
21    Shell,
22    Output,
23    Context,
24    Explanation,
25}
26
27impl PanelId {
28    /// Get the next panel in order
29    pub fn next(self) -> Self {
30        match self {
31            Self::Shell => Self::Output,
32            Self::Output => Self::Context,
33            Self::Context => Self::Explanation,
34            Self::Explanation => Self::Shell,
35        }
36    }
37
38    /// Get the previous panel in order
39    pub fn previous(self) -> Self {
40        match self {
41            Self::Shell => Self::Explanation,
42            Self::Output => Self::Shell,
43            Self::Context => Self::Output,
44            Self::Explanation => Self::Context,
45        }
46    }
47
48    /// Get panel title
49    pub fn title(self) -> &'static str {
50        match self {
51            Self::Shell => "Shell",
52            Self::Output => "Output",
53            Self::Context => "Context",
54            Self::Explanation => "Learning",
55        }
56    }
57}
58
59/// Trait for all panels
60pub trait Panel {
61    /// Render the panel
62    fn render(&self, frame: &mut Frame, area: Rect, focused: bool);
63
64    /// Handle input (if focused)
65    fn handle_input(&mut self, key: crossterm::event::KeyEvent) -> bool;
66}