Skip to content

Commit ce56fa7

Browse files
committed
feat(cli) :resizeable layout fixes(#2669)
1 parent 1d22485 commit ce56fa7

File tree

2 files changed

+75
-6
lines changed

2 files changed

+75
-6
lines changed

src/keys/key_list.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ pub struct KeysList {
128128
pub commit_history_next: GituiKeyEvent,
129129
pub commit: GituiKeyEvent,
130130
pub newline: GituiKeyEvent,
131+
pub alt_up: GituiKeyEvent,
132+
pub alt_down: GituiKeyEvent,
133+
pub alt_left: GituiKeyEvent,
134+
pub alt_right: GituiKeyEvent,
131135
}
132136

133137
#[rustfmt::skip]
@@ -157,6 +161,10 @@ impl Default for KeysList {
157161
end: GituiKeyEvent::new(KeyCode::End, KeyModifiers::empty()),
158162
move_up: GituiKeyEvent::new(KeyCode::Up, KeyModifiers::empty()),
159163
move_down: GituiKeyEvent::new(KeyCode::Down, KeyModifiers::empty()),
164+
alt_up: GituiKeyEvent::new(KeyCode::Up,KeyModifiers::ALT),
165+
alt_down:GituiKeyEvent::new(KeyCode::Down,KeyModifiers::ALT),
166+
alt_left: GituiKeyEvent::new(KeyCode::Left,KeyModifiers::ALT),
167+
alt_right:GituiKeyEvent::new(KeyCode::Right,KeyModifiers::ALT),
160168
popup_up: GituiKeyEvent::new(KeyCode::Up, KeyModifiers::empty()),
161169
popup_down: GituiKeyEvent::new(KeyCode::Down, KeyModifiers::empty()),
162170
page_down: GituiKeyEvent::new(KeyCode::PageDown, KeyModifiers::empty()),

src/tabs/status.rs

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ pub struct Status {
8181
git_action_executed: bool,
8282
options: SharedOptions,
8383
key_config: SharedKeyConfig,
84+
horizontal_split: (u16, u16), // Left vs Right
85+
vertical_split_wd: (u16, u16), // Top vs Bottom when WorkingDir
86+
vertical_split_index: (u16, u16),
8487
}
8588

8689
impl DrawableComponent for Status {
@@ -112,8 +115,12 @@ impl DrawableComponent for Status {
112115
]
113116
} else {
114117
[
115-
Constraint::Percentage(50),
116-
Constraint::Percentage(50),
118+
Constraint::Percentage(
119+
self.horizontal_split.0,
120+
),
121+
Constraint::Percentage(
122+
self.horizontal_split.1,
123+
),
117124
]
118125
}
119126
.as_ref(),
@@ -125,13 +132,21 @@ impl DrawableComponent for Status {
125132
.constraints(
126133
if self.diff_target == DiffTarget::WorkingDir {
127134
[
128-
Constraint::Percentage(60),
129-
Constraint::Percentage(40),
135+
Constraint::Percentage(
136+
self.vertical_split_wd.0,
137+
),
138+
Constraint::Percentage(
139+
self.vertical_split_wd.1,
140+
),
130141
]
131142
} else {
132143
[
133-
Constraint::Percentage(40),
134-
Constraint::Percentage(60),
144+
Constraint::Percentage(
145+
self.vertical_split_index.0,
146+
),
147+
Constraint::Percentage(
148+
self.vertical_split_index.1,
149+
),
135150
]
136151
}
137152
.as_ref(),
@@ -200,6 +215,9 @@ impl Status {
200215
key_config: env.key_config.clone(),
201216
options: env.options.clone(),
202217
repo: env.repo.clone(),
218+
horizontal_split: (50, 50),
219+
vertical_split_wd: (60, 40),
220+
vertical_split_index: (40, 60),
203221
}
204222
}
205223

@@ -947,6 +965,49 @@ impl Component for Status {
947965
) {
948966
self.queue.push(InternalEvent::ViewSubmodules);
949967
Ok(EventState::Consumed)
968+
} else if key_match(k, self.key_config.keys.alt_left)
969+
{
970+
if self.horizontal_split.0 > 10 {
971+
self.horizontal_split.0 -= 5;
972+
self.horizontal_split.1 += 5;
973+
}
974+
Ok(EventState::Consumed)
975+
} else if key_match(k, self.key_config.keys.alt_right)
976+
{
977+
if self.horizontal_split.1 > 10 {
978+
self.horizontal_split.0 += 5;
979+
self.horizontal_split.1 -= 5;
980+
}
981+
Ok(EventState::Consumed)
982+
} else if key_match(k, self.key_config.keys.alt_up) {
983+
let (top, bottom) = match self.diff_target {
984+
DiffTarget::WorkingDir => {
985+
&mut self.vertical_split_wd
986+
}
987+
DiffTarget::Stage => {
988+
&mut self.vertical_split_index
989+
}
990+
};
991+
if *bottom > 10 {
992+
*top += 5;
993+
*bottom -= 5;
994+
}
995+
Ok(EventState::Consumed)
996+
} else if key_match(k, self.key_config.keys.alt_down)
997+
{
998+
let (top, bottom) = match self.diff_target {
999+
DiffTarget::WorkingDir => {
1000+
&mut self.vertical_split_wd
1001+
}
1002+
DiffTarget::Stage => {
1003+
&mut self.vertical_split_index
1004+
}
1005+
};
1006+
if *top > 10 {
1007+
*top -= 5;
1008+
*bottom += 5;
1009+
}
1010+
Ok(EventState::Consumed)
9501011
} else {
9511012
Ok(EventState::NotConsumed)
9521013
};

0 commit comments

Comments
 (0)