diff --git a/CHANGELOG.md b/CHANGELOG.md index e5b377c997..5933f6cdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * increase MSRV from 1.81 to 1.82 [[@cruessler](https://github.com/cruessler)] ### Added +* Added dynamic layout resizing in the status view (Alt+Arrow keys to adjust splits)[[@Hari-Oggy](https://github.com/Hari-Oggy)] ([#2669](https://github.com/extrawurst/gitui/issues/2669)) * Support pre-push hook [[@xlai89](https://github.com/xlai89)] ([#1933](https://github.com/extrawurst/gitui/issues/1933)) * Message tab supports pageUp and pageDown [[@xlai89](https://github.com/xlai89)] ([#2623](https://github.com/extrawurst/gitui/issues/2623)) * Files and status tab support pageUp and pageDown [[@fatpandac](https://github.com/fatpandac)] ([#1951](https://github.com/extrawurst/gitui/issues/1951)) diff --git a/src/keys/key_list.rs b/src/keys/key_list.rs index 24a9507a49..3ec14bf5fd 100644 --- a/src/keys/key_list.rs +++ b/src/keys/key_list.rs @@ -128,6 +128,10 @@ pub struct KeysList { pub commit_history_next: GituiKeyEvent, pub commit: GituiKeyEvent, pub newline: GituiKeyEvent, + pub alt_up: GituiKeyEvent, + pub alt_down: GituiKeyEvent, + pub alt_left: GituiKeyEvent, + pub alt_right: GituiKeyEvent, pub goto_line: GituiKeyEvent, } @@ -158,6 +162,10 @@ impl Default for KeysList { end: GituiKeyEvent::new(KeyCode::End, KeyModifiers::empty()), move_up: GituiKeyEvent::new(KeyCode::Up, KeyModifiers::empty()), move_down: GituiKeyEvent::new(KeyCode::Down, KeyModifiers::empty()), + alt_up: GituiKeyEvent::new(KeyCode::Up,KeyModifiers::ALT), + alt_down:GituiKeyEvent::new(KeyCode::Down,KeyModifiers::ALT), + alt_left: GituiKeyEvent::new(KeyCode::Left,KeyModifiers::ALT), + alt_right:GituiKeyEvent::new(KeyCode::Right,KeyModifiers::ALT), popup_up: GituiKeyEvent::new(KeyCode::Up, KeyModifiers::empty()), popup_down: GituiKeyEvent::new(KeyCode::Down, KeyModifiers::empty()), page_down: GituiKeyEvent::new(KeyCode::PageDown, KeyModifiers::empty()), diff --git a/src/tabs/status.rs b/src/tabs/status.rs index d5e1db8c81..75eb2ce0c9 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -81,6 +81,9 @@ pub struct Status { git_action_executed: bool, options: SharedOptions, key_config: SharedKeyConfig, + horizontal_split: (u16, u16), // Left vs Right + vertical_split_wd: (u16, u16), // Top vs Bottom when WorkingDir + vertical_split_index: (u16, u16), } impl DrawableComponent for Status { @@ -112,8 +115,12 @@ impl DrawableComponent for Status { ] } else { [ - Constraint::Percentage(50), - Constraint::Percentage(50), + Constraint::Percentage( + self.horizontal_split.0, + ), + Constraint::Percentage( + self.horizontal_split.1, + ), ] } .as_ref(), @@ -125,13 +132,21 @@ impl DrawableComponent for Status { .constraints( if self.diff_target == DiffTarget::WorkingDir { [ - Constraint::Percentage(60), - Constraint::Percentage(40), + Constraint::Percentage( + self.vertical_split_wd.0, + ), + Constraint::Percentage( + self.vertical_split_wd.1, + ), ] } else { [ - Constraint::Percentage(40), - Constraint::Percentage(60), + Constraint::Percentage( + self.vertical_split_index.0, + ), + Constraint::Percentage( + self.vertical_split_index.1, + ), ] } .as_ref(), @@ -200,6 +215,9 @@ impl Status { key_config: env.key_config.clone(), options: env.options.clone(), repo: env.repo.clone(), + horizontal_split: (50, 50), + vertical_split_wd: (60, 40), + vertical_split_index: (40, 60), } } @@ -947,6 +965,49 @@ impl Component for Status { ) { self.queue.push(InternalEvent::ViewSubmodules); Ok(EventState::Consumed) + } else if key_match(k, self.key_config.keys.alt_left) + { + if self.horizontal_split.0 > 10 { + self.horizontal_split.0 -= 5; + self.horizontal_split.1 += 5; + } + Ok(EventState::Consumed) + } else if key_match(k, self.key_config.keys.alt_right) + { + if self.horizontal_split.1 > 10 { + self.horizontal_split.0 += 5; + self.horizontal_split.1 -= 5; + } + Ok(EventState::Consumed) + } else if key_match(k, self.key_config.keys.alt_up) { + let (top, bottom) = match self.diff_target { + DiffTarget::WorkingDir => { + &mut self.vertical_split_wd + } + DiffTarget::Stage => { + &mut self.vertical_split_index + } + }; + if *bottom > 10 { + *top += 5; + *bottom -= 5; + } + Ok(EventState::Consumed) + } else if key_match(k, self.key_config.keys.alt_down) + { + let (top, bottom) = match self.diff_target { + DiffTarget::WorkingDir => { + &mut self.vertical_split_wd + } + DiffTarget::Stage => { + &mut self.vertical_split_index + } + }; + if *top > 10 { + *top -= 5; + *bottom += 5; + } + Ok(EventState::Consumed) } else { Ok(EventState::NotConsumed) };