mermaid_cli/tui/state/ui.rs
1//! UI state management
2//!
3//! Visual presentation and widget states.
4
5use crate::tui::theme::Theme;
6use crate::tui::widgets::{ChatState, InputState};
7
8/// UI state - visual presentation and widget states
9pub struct UIState {
10 /// Chat widget state (scroll, scrolling flag)
11 pub chat_state: ChatState,
12 /// Input widget state (cursor position for display)
13 pub input_state: InputState,
14 /// UI theme
15 pub theme: Theme,
16 /// Selected message index (for navigation)
17 pub selected_message: Option<usize>,
18 /// Whether focus is in the attachment area (above input)
19 pub attachment_focused: bool,
20 /// Which attachment is selected when attachment_focused is true
21 pub selected_attachment: usize,
22 /// Attachment area rect from last render (for Ctrl+Click detection)
23 pub attachment_area_y: Option<u16>,
24}
25
26impl UIState {
27 /// Create a new UIState with default values
28 pub fn new() -> Self {
29 Self {
30 chat_state: ChatState::default(),
31 input_state: InputState::default(),
32 theme: Theme::dark(),
33 selected_message: None,
34 attachment_focused: false,
35 selected_attachment: 0,
36 attachment_area_y: None,
37 }
38 }
39}
40
41impl Default for UIState {
42 fn default() -> Self {
43 Self::new()
44 }
45}