diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs index fb14cff..ffb4b65 100644 --- a/src/interactive/app/eventloop.rs +++ b/src/interactive/app/eventloop.rs @@ -220,6 +220,11 @@ impl AppState { EntryCheck::new(self.scan.is_some(), self.allow_entry_check) } + fn toggle_ui_split( + &mut self, + ) { + self.ui_split = !self.ui_split; + } fn process_terminal_event( &mut self, window: &mut MainWindow, @@ -273,6 +278,9 @@ impl AppState { return Ok(Some(result?)); } } + Char('U') => { + self.toggle_ui_split(); + } _ => { handled = false; } diff --git a/src/interactive/app/state.rs b/src/interactive/app/state.rs index 3a0da28..b660989 100644 --- a/src/interactive/app/state.rs +++ b/src/interactive/app/state.rs @@ -46,6 +46,8 @@ pub struct AppState { pub root_paths: Vec, /// If true, listed entries will be validated for presence when switching directories. pub allow_entry_check: bool, + /// If true, marking files splits to the bottom rather than the right + pub ui_split: bool, } impl AppState { @@ -64,6 +66,7 @@ impl AppState { walk_options, root_paths: input, allow_entry_check: true, + ui_split: false, } } } diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index f2dbef5..ec6a7b6 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -192,7 +192,7 @@ fn title( fn draw_bottom_right_help(bound: Rect, buf: &mut Buffer) { let bound = line_bound(bound, bound.height.saturating_sub(1) as usize); - let help_text = " mark-move = d | mark-toggle = space | toggle-all = a "; + let help_text = " mark-move = d | mark-toggle = space | toggle-all = a"; let help_text_block_width = block_width(help_text); if help_text_block_width <= bound.width { draw_text_nowrap_fn( diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 054a386..178387d 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -179,6 +179,7 @@ impl HelpPane { ); hotkey("", "Toggle the currently selected entry.", None); hotkey("a", "Toggle all entries.", None); + hotkey("U", "Toggle UI split Vertical/Horizontal.", None); hotkey( "/", "Git-style glob search, case-insensitive.", diff --git a/src/interactive/widgets/main.rs b/src/interactive/widgets/main.rs index 11cf277..69d098d 100644 --- a/src/interactive/widgets/main.rs +++ b/src/interactive/widgets/main.rs @@ -59,12 +59,12 @@ impl MainWindow { Header.render(header_bg_color, header_area, buffer); let (entries_area, help_pane, mark_pane) = { - let (left_pane, right_pane) = content_layout(content_area); + let (left_pane, right_pane) = content_layout(content_area, state.ui_split); match (&mut self.help_pane, &mut self.mark_pane) { (Some(ref mut pane), None) => (left_pane, Some((right_pane, pane)), None), (None, Some(ref mut pane)) => (left_pane, None, Some((right_pane, pane))), (Some(ref mut help), Some(ref mut mark)) => { - let (top_area, bottom_area) = right_pane_layout(right_pane); + let (top_area, bottom_area) = right_pane_layout(right_pane, state.ui_split); (left_pane, Some((top_area, help)), Some((bottom_area, mark))) } (None, None) => (content_area, None, None), @@ -143,17 +143,17 @@ impl MainWindow { } } -fn right_pane_layout(right_pane: Rect) -> (Rect, Rect) { +fn right_pane_layout(right_pane: Rect, ui_split: bool) -> (Rect, Rect) { let regions = Layout::default() - .direction(Direction::Vertical) + .direction(if ui_split { Direction::Horizontal } else {Direction::Vertical}) .constraints([Percentage(50), Percentage(50)].as_ref()) .split(right_pane); (regions[0], regions[1]) } -fn content_layout(content_area: Rect) -> (Rect, Rect) { +fn content_layout(content_area: Rect, ui_split: bool) -> (Rect, Rect) { let regions = Layout::default() - .direction(Direction::Horizontal) + .direction(if ui_split { Direction::Vertical } else {Direction::Horizontal}) .constraints([Percentage(50), Percentage(50)].as_ref()) .split(content_area); (regions[0], regions[1])