Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/interactive/app/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B>(
&mut self,
window: &mut MainWindow,
Expand Down Expand Up @@ -273,6 +278,9 @@ impl AppState {
return Ok(Some(result?));
}
}
Char('U') => {
self.toggle_ui_split();
}
_ => {
handled = false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/interactive/app/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub struct AppState {
pub root_paths: Vec<PathBuf>,
/// 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 {
Expand All @@ -64,6 +66,7 @@ impl AppState {
walk_options,
root_paths: input,
allow_entry_check: true,
ui_split: false,
}
}
}
2 changes: 1 addition & 1 deletion src/interactive/widgets/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing space is needed for… spacing :).

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(
Expand Down
1 change: 1 addition & 0 deletions src/interactive/widgets/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ impl HelpPane {
);
hotkey("<Space>", "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.",
Expand Down
12 changes: 6 additions & 6 deletions src/interactive/widgets/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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])
Expand Down
Loading