1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Hotkey Dialog Component
//!
//! A reusable, generic hotkey configuration dialog for TUI applications.
//!
//! This module provides a complete hotkey dialog implementation that can be
//! customized for any application through trait-based abstraction.
//!
//! # Architecture
//!
//! The hotkey dialog uses three main abstractions:
//!
//! - [`HotkeyCategory`] - Trait for defining hotkey categories (implemented by your enum)
//! - [`HotkeyProvider`] - Trait for providing hotkey data
//! - [`HotkeyEntryData`] - Generic struct representing a single hotkey
//!
//! # Example
//!
//! ```rust,ignore
//! use ratatui_interact::components::hotkey_dialog::{
//! HotkeyCategory, HotkeyProvider, HotkeyEntryData,
//! HotkeyDialogState, HotkeyDialogStyle, HotkeyDialog,
//! handle_hotkey_dialog_key, handle_hotkey_dialog_mouse,
//! };
//!
//! // 1. Define your category enum
//! #[derive(Clone, Copy, PartialEq, Eq, Default)]
//! enum MyCategory {
//! #[default]
//! Global,
//! Navigation,
//! Editing,
//! }
//!
//! impl HotkeyCategory for MyCategory {
//! fn all() -> &'static [Self] { &[Self::Global, Self::Navigation, Self::Editing] }
//! fn display_name(&self) -> &str { /* ... */ }
//! fn next(&self) -> Self { /* ... */ }
//! fn prev(&self) -> Self { /* ... */ }
//! }
//!
//! // 2. Implement the provider
//! struct MyProvider;
//!
//! impl HotkeyProvider for MyProvider {
//! type Category = MyCategory;
//!
//! fn entries_for_category(&self, category: Self::Category) -> Vec<HotkeyEntryData> {
//! match category {
//! MyCategory::Global => vec![
//! HotkeyEntryData::global("Ctrl+C", "Quit"),
//! HotkeyEntryData::global("F1", "Help"),
//! ],
//! // ... other categories
//! }
//! }
//!
//! fn search(&self, query: &str) -> Vec<(Self::Category, HotkeyEntryData)> {
//! // Search implementation
//! }
//! }
//!
//! // 3. Use in your application
//! let mut state = HotkeyDialogState::<MyCategory>::new();
//! let provider = MyProvider;
//! let style = HotkeyDialogStyle::default();
//!
//! // Render
//! HotkeyDialog::new(&mut state, &provider, &style).render(frame, area);
//!
//! // Handle events
//! let action = handle_hotkey_dialog_key(&mut state, key_event);
//! ```
//!
//! # Features
//!
//! - **Search filtering**: Type to filter hotkeys across all categories
//! - **Category navigation**: Arrow keys to navigate between categories
//! - **Mouse support**: Click to select categories and hotkeys
//! - **Scrolling**: Page up/down and mouse scroll for long lists
//! - **Customizable styling**: Colors, sizes, and text can be customized
//! - **Focus management**: Tab between search, categories, and hotkey list
pub use ;
pub use ;
pub use HotkeyDialogStyle;
pub use ;
pub use ;