feat: switch views with ctrl h/l
1 file changed, +32 -2
+32-2src/app.rs
| @@ -8,12 +8,20 @@ use jv::views::{browser::BrowserView, code::CodeView, schema_diagram::SchemaDiag | ||
| 8 | 8 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 9 | 9 | pub enum AppMode { |
| 10 | 10 | Jv, |
| 11 | - Schema, | |
| 12 | 11 | Groups, |
| 12 | + Schema, | |
| 13 | 13 | Code, |
| 14 | 14 | Settings, |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | +const MODE_ORDER: [AppMode; 5] = [ | |
| 18 | + AppMode::Jv, | |
| 19 | + AppMode::Groups, | |
| 20 | + AppMode::Schema, | |
| 21 | + AppMode::Code, | |
| 22 | + AppMode::Settings, | |
| 23 | +]; | |
| 24 | + | |
| 17 | 25 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 18 | 26 | pub enum ViewTab { |
| 19 | 27 | Table, |
| @@ -699,8 +707,8 @@ impl JvApp { | ||
| 699 | 707 | ui.spacing_mut().item_spacing.x = 4.0; |
| 700 | 708 | for (mode, label, icon) in [ |
| 701 | 709 | (AppMode::Jv, "jv", regular::BROWSERS), |
| 702 | - (AppMode::Schema, "Schema", regular::GRAPH), | |
| 703 | 710 | (AppMode::Groups, "Groups", regular::TREE_STRUCTURE), |
| 711 | + (AppMode::Schema, "Schema", regular::GRAPH), | |
| 704 | 712 | (AppMode::Code, "Code", regular::CODE), |
| 705 | 713 | (AppMode::Settings, "Settings", regular::GEAR_SIX), |
| 706 | 714 | ] { |
| @@ -737,6 +745,28 @@ impl JvApp { | ||
| 737 | 745 | } |
| 738 | 746 | } |
| 739 | 747 | }); |
| 748 | + | |
| 749 | + // Ctrl-H/L: switch between modes | |
| 750 | + let ctrl_l = ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::L)); | |
| 751 | + let ctrl_h = ui.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::H)); | |
| 752 | + if ctrl_l || ctrl_h { | |
| 753 | + let cur = MODE_ORDER.iter().position(|m| *m == self.active_mode).unwrap_or(0); | |
| 754 | + let next = if ctrl_l { | |
| 755 | + (cur + 1) % MODE_ORDER.len() | |
| 756 | + } else { | |
| 757 | + (cur + MODE_ORDER.len() - 1) % MODE_ORDER.len() | |
| 758 | + }; | |
| 759 | + let mode = MODE_ORDER[next]; | |
| 760 | + self.active_mode = mode; | |
| 761 | + self.active_tab = match mode { | |
| 762 | + AppMode::Jv => ViewTab::Table, | |
| 763 | + AppMode::Schema => ViewTab::Table, | |
| 764 | + AppMode::Groups => ViewTab::Table, | |
| 765 | + AppMode::Code => ViewTab::Code, | |
| 766 | + AppMode::Settings => ViewTab::Table, | |
| 767 | + }; | |
| 768 | + } | |
| 769 | + | |
| 740 | 770 | ui.add_space(2.0); |
| 741 | 771 | |
| 742 | 772 | // Tab bar (conditional per mode) |