Add tabbed help UI with enhanced navigation
- Refactor `render_help` to display tabbed UI for help topics. - Introduce `help_tab_index` to manage selected tab state. - Allow navigation between help tabs using Tab, h/l, and number keys (1-5). - Enhance visual design of help sections using styled tabs and categorized content. - Update input handling to reset tab state upon exit from help mode.
This commit is contained in:
@@ -60,6 +60,7 @@ pub struct ChatApp {
|
||||
saved_sessions: Vec<SessionMeta>, // Cached list of saved sessions
|
||||
selected_session_index: usize, // Index of selected session in browser
|
||||
save_name_buffer: String, // Buffer for entering save name
|
||||
help_tab_index: usize, // Currently selected help tab (0-4)
|
||||
}
|
||||
|
||||
impl ChatApp {
|
||||
@@ -108,6 +109,7 @@ impl ChatApp {
|
||||
saved_sessions: Vec::new(),
|
||||
selected_session_index: 0,
|
||||
save_name_buffer: String::new(),
|
||||
help_tab_index: 0,
|
||||
};
|
||||
|
||||
(app, session_rx)
|
||||
@@ -232,6 +234,10 @@ impl ChatApp {
|
||||
self.selected_session_index
|
||||
}
|
||||
|
||||
pub fn help_tab_index(&self) -> usize {
|
||||
self.help_tab_index
|
||||
}
|
||||
|
||||
pub fn cycle_focus_forward(&mut self) {
|
||||
self.focused_panel = match self.focused_panel {
|
||||
FocusedPanel::Chat => {
|
||||
@@ -1041,7 +1047,7 @@ impl ChatApp {
|
||||
}
|
||||
}
|
||||
}
|
||||
"load" | "open" => {
|
||||
"load" | "open" | "o" => {
|
||||
// Load saved sessions and enter browser mode
|
||||
match self.storage.list_sessions() {
|
||||
Ok(sessions) => {
|
||||
@@ -1175,9 +1181,27 @@ impl ChatApp {
|
||||
_ => {}
|
||||
},
|
||||
InputMode::Help => match key.code {
|
||||
KeyCode::Esc | KeyCode::Enter => {
|
||||
KeyCode::Esc | KeyCode::Enter | KeyCode::Char('q') => {
|
||||
self.mode = InputMode::Normal;
|
||||
self.help_tab_index = 0; // Reset to first tab
|
||||
}
|
||||
KeyCode::Tab | KeyCode::Right | KeyCode::Char('l') => {
|
||||
// Next tab
|
||||
if self.help_tab_index < 4 {
|
||||
self.help_tab_index += 1;
|
||||
}
|
||||
}
|
||||
KeyCode::BackTab | KeyCode::Left | KeyCode::Char('h') => {
|
||||
// Previous tab
|
||||
if self.help_tab_index > 0 {
|
||||
self.help_tab_index -= 1;
|
||||
}
|
||||
}
|
||||
KeyCode::Char('1') => self.help_tab_index = 0,
|
||||
KeyCode::Char('2') => self.help_tab_index = 1,
|
||||
KeyCode::Char('3') => self.help_tab_index = 2,
|
||||
KeyCode::Char('4') => self.help_tab_index = 3,
|
||||
KeyCode::Char('5') => self.help_tab_index = 4,
|
||||
_ => {}
|
||||
},
|
||||
InputMode::SessionBrowser => match key.code {
|
||||
|
||||
Reference in New Issue
Block a user