Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 8 additions & 0 deletions src/keys/key_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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()),
Expand Down
73 changes: 67 additions & 6 deletions src/tabs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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)
};
Expand Down