Skip to main content

kimun_notes/components/
mod.rs

1pub mod autocomplete;
2pub mod autosave_timer;
3pub mod backlinks_panel;
4pub mod dialog_manager;
5pub mod dialogs;
6pub mod event_state;
7pub mod events;
8pub mod file_list;
9pub mod footer_bar;
10pub mod indexing;
11pub mod note_browser;
12pub mod settings;
13pub mod sidebar;
14pub mod single_line_input;
15pub mod text_editor;
16
17use ratatui::Frame;
18use ratatui::layout::Rect;
19
20use crate::components::event_state::EventState;
21use crate::components::events::{AppTx, InputEvent};
22use crate::settings::themes::Theme;
23
24pub trait Component {
25    /// Handle an event. Send `AppEvent`s through `tx` for app-level effects.
26    /// Returns whether this component consumed the event.
27    fn handle_input(&mut self, event: &InputEvent, tx: &AppTx) -> EventState {
28        let _ = (event, tx);
29        EventState::NotConsumed
30    }
31
32    fn render(&mut self, f: &mut Frame, rect: Rect, theme: &Theme, focused: bool);
33
34    /// Context-sensitive shortcut hints shown in the hints bar when this
35    /// component is focused.  Each entry is `(key_display, label)`.
36    fn hint_shortcuts(&self) -> Vec<(String, String)> {
37        vec![]
38    }
39}