diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-04-14 11:01:28 +0100 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-04-14 11:01:28 +0100 |
| commit | 413a24b77fd78f19385522f96137e80f146f2485 (patch) | |
| tree | 4b75540d509539118c8ad06ac494ceaadbb98acb /src/client | |
| parent | fix(style): run rustfmt (diff) | |
| download | sl0ppij-413a24b77fd78f19385522f96137e80f146f2485.tar.gz sl0ppij-413a24b77fd78f19385522f96137e80f146f2485.tar.xz sl0ppij-413a24b77fd78f19385522f96137e80f146f2485.zip | |
fix(bug): remove buggy expansion boundaries
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/layout.rs | 2 | ||||
| -rw-r--r-- | src/client/pane_resizer.rs | 4 | ||||
| -rw-r--r-- | src/client/tab.rs | 123 |
3 files changed, 31 insertions, 98 deletions
diff --git a/src/client/layout.rs b/src/client/layout.rs index 2d1daaf4..2524f894 100644 --- a/src/client/layout.rs +++ b/src/client/layout.rs @@ -177,8 +177,6 @@ pub struct Layout { pub split_size: Option<SplitSize>, #[serde(skip_serializing_if = "Option::is_none")] pub plugin: Option<PathBuf>, - #[serde(default)] - pub expansion_boundary: bool, } impl Layout { diff --git a/src/client/pane_resizer.rs b/src/client/pane_resizer.rs index 16eda5c8..f9ec71b8 100644 --- a/src/client/pane_resizer.rs +++ b/src/client/pane_resizer.rs @@ -12,9 +12,7 @@ pub struct PaneResizer<'a> { } // TODO: currently there are some functions here duplicated with Tab -// the reason for this is that we need to get rid of the expansion_boundary -// otherwise we'll have a big separation of concerns issue -// once that is done, all resizing functions should move here +// all resizing functions should move here impl<'a> PaneResizer<'a> { pub fn new( diff --git a/src/client/tab.rs b/src/client/tab.rs index 07e0f042..8750589f 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -68,7 +68,6 @@ pub struct Tab { pub send_pty_instructions: SenderWithContext<PtyInstruction>, pub send_plugin_instructions: SenderWithContext<PluginInstruction>, pub send_app_instructions: SenderWithContext<AppInstruction>, - expansion_boundary: Option<PositionAndSize>, should_clear_display_before_rendering: bool, pub mode_info: ModeInfo, } @@ -246,7 +245,6 @@ impl Tab { send_app_instructions, send_pty_instructions, send_plugin_instructions, - expansion_boundary: None, should_clear_display_before_rendering: false, mode_info, } @@ -287,9 +285,6 @@ impl Tab { let mut new_pids = new_pids.iter(); for (layout, position_and_size) in positions_and_size { // Just a regular terminal - if layout.expansion_boundary { - self.expansion_boundary = Some(*position_and_size); - } if let Some(plugin) = &layout.plugin { let (pid_tx, pid_rx) = channel(); self.send_plugin_instructions @@ -359,9 +354,7 @@ impl Tab { let (id_of_terminal_to_check, terminal_to_check) = id_and_terminal_to_check; let terminal_size = (terminal_to_check.rows() * CURSOR_HEIGHT_WIDTH_RATIO) * terminal_to_check.columns(); - let terminal_pos_and_size = terminal_to_check.position_and_size(); let terminal_can_be_split = terminal_to_check.columns() >= MIN_TERMINAL_WIDTH - && self.pos_and_size_is_within_expansion_boundary(terminal_pos_and_size) && terminal_to_check.rows() >= MIN_TERMINAL_HEIGHT && ((terminal_to_check.columns() > terminal_to_check.min_width() * 2) || (terminal_to_check.rows() > terminal_to_check.min_height() * 2)); @@ -621,19 +614,17 @@ impl Tab { let active_terminal = self.panes.get_mut(&active_pane_id).unwrap(); active_terminal.reset_size_and_position_override(); } else { - let expand_to = self.expansion_boundary.unwrap_or(self.full_screen_ws); let panes = self.get_panes(); - let pane_ids_to_hide = panes.filter_map(|(&id, pane)| { - let position_and_size_for_pane = pane.position_and_size(); - if id != active_pane_id - && self - .pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - { - Some(id) - } else { - None - } - }); + let pane_ids_to_hide = + panes.filter_map( + |(&id, _)| { + if id != active_pane_id { + Some(id) + } else { + None + } + }, + ); self.panes_to_hide = pane_ids_to_hide.collect(); if self.panes_to_hide.is_empty() { // nothing to do, pane is already as fullscreen as it can be, let's bail @@ -641,9 +632,9 @@ impl Tab { } else { let active_terminal = self.panes.get_mut(&active_pane_id).unwrap(); active_terminal.override_size_and_position( - expand_to.x, - expand_to.y, - &expand_to, + self.full_screen_ws.x, + self.full_screen_ws.y, + &self.full_screen_ws, ); } } @@ -1497,21 +1488,6 @@ impl Tab { self.increase_pane_width_left(&terminal_id, count); } } - fn pos_and_size_is_within_expansion_boundary(&self, pos_and_size: PositionAndSize) -> bool { - match self.expansion_boundary { - Some(expansion_boundary) => { - pos_and_size.x >= expansion_boundary.x - && pos_and_size.x < expansion_boundary.x + expansion_boundary.columns - && pos_and_size.y >= expansion_boundary.y - && pos_and_size.y < expansion_boundary.y + expansion_boundary.rows - && pos_and_size.x + pos_and_size.columns - <= expansion_boundary.x + expansion_boundary.columns - && pos_and_size.y + pos_and_size.rows - <= expansion_boundary.y + expansion_boundary.rows - } - None => true, // no expansion boundary, no problem - } - } fn can_increase_pane_and_surroundings_right( &self, pane_id: &PaneId, @@ -1527,17 +1503,11 @@ impl Tab { } let mut new_pos_and_size_for_pane = pane.position_and_size(); new_pos_and_size_for_pane.columns += increase_by; - if !self.pos_and_size_is_within_expansion_boundary(new_pos_and_size_for_pane) { - return false; - } if let Some(panes_to_the_right) = self.pane_ids_directly_right_of(&pane_id) { return panes_to_the_right.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.columns() > increase_by - && p.columns() - increase_by >= p.min_width() + p.columns() > increase_by && p.columns() - increase_by >= p.min_width() }); } else { false @@ -1558,17 +1528,11 @@ impl Tab { } let mut new_pos_and_size_for_pane = pane.position_and_size(); new_pos_and_size_for_pane.x = new_pos_and_size_for_pane.x.saturating_sub(increase_by); - if !self.pos_and_size_is_within_expansion_boundary(new_pos_and_size_for_pane) { - return false; - } if let Some(panes_to_the_left) = self.pane_ids_directly_left_of(&pane_id) { return panes_to_the_left.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.columns() > increase_by - && p.columns() - increase_by >= p.min_width() + p.columns() > increase_by && p.columns() - increase_by >= p.min_width() }); } else { false @@ -1589,17 +1553,11 @@ impl Tab { } let mut new_pos_and_size_for_pane = pane.position_and_size(); new_pos_and_size_for_pane.rows += increase_by; - if !self.pos_and_size_is_within_expansion_boundary(new_pos_and_size_for_pane) { - return false; - } if let Some(panes_below) = self.pane_ids_directly_below(&pane_id) { return panes_below.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.rows() > increase_by - && p.rows() - increase_by >= p.min_height() + p.rows() > increase_by && p.rows() - increase_by >= p.min_height() }); } else { false @@ -1616,17 +1574,11 @@ impl Tab { } let mut new_pos_and_size_for_pane = pane.position_and_size(); new_pos_and_size_for_pane.y = new_pos_and_size_for_pane.y.saturating_sub(increase_by); - if !self.pos_and_size_is_within_expansion_boundary(new_pos_and_size_for_pane) { - return false; - } if let Some(panes_above) = self.pane_ids_directly_above(&pane_id) { return panes_above.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.rows() > increase_by - && p.rows() - increase_by >= p.min_height() + p.rows() > increase_by && p.rows() - increase_by >= p.min_height() }); } else { false @@ -1643,11 +1595,9 @@ impl Tab { if let Some(panes_to_the_left) = self.pane_ids_directly_left_of(&pane_id) { return panes_to_the_left.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.max_width() - .map(|max_width| p.columns() + reduce_by <= max_width) - .unwrap_or(true) // no max width, increase to your heart's content + p.max_width() + .map(|max_width| p.columns() + reduce_by <= max_width) + .unwrap_or(true) // no max width, increase to your heart's content }); } else { false @@ -1664,11 +1614,9 @@ impl Tab { if let Some(panes_to_the_right) = self.pane_ids_directly_right_of(&pane_id) { return panes_to_the_right.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.max_width() - .map(|max_width| p.columns() + reduce_by <= max_width) - .unwrap_or(true) // no max width, increase to your heart's content + p.max_width() + .map(|max_width| p.columns() + reduce_by <= max_width) + .unwrap_or(true) // no max width, increase to your heart's content }); } else { false @@ -1685,11 +1633,9 @@ impl Tab { if let Some(panes_above) = self.pane_ids_directly_above(&pane_id) { return panes_above.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.max_height() - .map(|max_height| p.rows() + reduce_by <= max_height) - .unwrap_or(true) // no max height, increase to your heart's content + p.max_height() + .map(|max_height| p.rows() + reduce_by <= max_height) + .unwrap_or(true) // no max height, increase to your heart's content }); } else { false @@ -1706,11 +1652,9 @@ impl Tab { if let Some(panes_below) = self.pane_ids_directly_below(&pane_id) { return panes_below.iter().all(|id| { let p = self.panes.get(id).unwrap(); - let position_and_size_for_pane = p.position_and_size(); - self.pos_and_size_is_within_expansion_boundary(position_and_size_for_pane) - && p.max_height() - .map(|max_height| p.rows() + reduce_by <= max_height) - .unwrap_or(true) // no max height, increase to your heart's content + p.max_height() + .map(|max_height| p.rows() + reduce_by <= max_height) + .unwrap_or(true) // no max height, increase to your heart's content }); } else { false @@ -1718,7 +1662,7 @@ impl Tab { } pub fn resize_whole_tab(&mut self, new_screen_size: PositionAndSize) { if self.fullscreen_is_active { - // this is not ideal but until we get rid of expansion_boundary, it's a necessity + // this is not ideal, we can improve this self.toggle_active_pane_fullscreen(); } if let Some((column_difference, row_difference)) = @@ -1726,13 +1670,6 @@ impl Tab { .resize(self.full_screen_ws, new_screen_size) { self.should_clear_display_before_rendering = true; - if let Some(expansion_boundary) = self.expansion_boundary.as_mut() { - // TODO: this is not always accurate - expansion_boundary.columns = - (expansion_boundary.columns as isize + column_difference) as usize; - expansion_boundary.rows = - (expansion_boundary.rows as isize + row_difference) as usize; - }; self.full_screen_ws.columns = (self.full_screen_ws.columns as isize + column_difference) as usize; self.full_screen_ws.rows = |
