summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/panes/tiled_panes/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'zellij-server/src/panes/tiled_panes/mod.rs')
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs121
1 files changed, 118 insertions, 3 deletions
diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs
index 5a23f8870..82928b68d 100644
--- a/zellij-server/src/panes/tiled_panes/mod.rs
+++ b/zellij-server/src/panes/tiled_panes/mod.rs
@@ -20,7 +20,7 @@ use zellij_utils::{
data::{ModeInfo, ResizeStrategy, Style},
errors::prelude::*,
input::{command::RunCommand, layout::SplitDirection},
- pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport},
+ pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport, Dimension},
};
use std::{
@@ -292,6 +292,9 @@ impl TiledPanes {
if let Some(active_pane_id) = &self.active_panes.get(&client_id) {
if let Some(active_pane) = self.panes.get_mut(active_pane_id) {
let full_pane_size = active_pane.position_and_size();
+ if full_pane_size.is_stacked {
+ return false
+ }
if full_pane_size.rows.as_usize() < MIN_TERMINAL_HEIGHT * 2 {
return false;
} else {
@@ -305,6 +308,9 @@ impl TiledPanes {
if let Some(active_pane_id) = &self.active_panes.get(&client_id) {
if let Some(active_pane) = self.panes.get_mut(active_pane_id) {
let full_pane_size = active_pane.position_and_size();
+ if full_pane_size.is_stacked {
+ return false
+ }
if full_pane_size.cols.as_usize() < MIN_TERMINAL_WIDTH * 2 {
return false;
}
@@ -320,6 +326,9 @@ impl TiledPanes {
if full_pane_size.rows.is_fixed() {
return false;
}
+ if full_pane_size.is_stacked {
+ return false
+ }
if split(SplitDirection::Horizontal, &full_pane_size).is_some() {
true
} else {
@@ -351,6 +360,9 @@ impl TiledPanes {
if full_pane_size.cols.is_fixed() {
return false;
}
+ if full_pane_size.is_stacked {
+ return false
+ }
if split(SplitDirection::Vertical, &full_pane_size).is_some() {
true
} else {
@@ -774,13 +786,61 @@ impl TiledPanes {
true
},
- None => false,
+ None => {
+ log::info!("can has none");
+ match pane_grid.stacked_pane_id_below(&active_pane_id) {
+ Some(p) => {
+ log::info!("can has stacked_pane_id_below");
+ let source_pane = self
+ .panes
+ .get_mut(self.active_panes.get(&client_id).unwrap())
+ .unwrap();
+
+ // TODO:
+ // * set the y of the source_pane to be the y + rows of
+ // itself
+ // * set its rows size to be fixed 1
+ // * reduce the y of the current pane by 1
+
+ let mut source_pane_geom = source_pane.position_and_size();
+ let mut destination_pane_geom = source_pane_geom.clone();
+ destination_pane_geom.y = source_pane_geom.y + 1;
+ source_pane_geom.rows = Dimension::fixed(1);
+ source_pane.set_geom(source_pane_geom);
+
+ // render previously active pane so that its frame does not remain actively
+ // colored
+ source_pane.set_should_render(true);
+ // we render the full viewport to remove any ui elements that might have been
+ // there before (eg. another user's cursor)
+ source_pane.render_full_viewport();
+
+ let destination_pane = self.panes.get_mut(&p).unwrap();
+ destination_pane.set_geom(destination_pane_geom);
+
+ destination_pane.set_should_render(true);
+ // we render the full viewport to remove any ui elements that might have been
+ // there before (eg. another user's cursor)
+ destination_pane.render_full_viewport();
+
+ self.focus_pane(p, client_id);
+ self.set_pane_active_at(p);
+ self.set_pane_frames(self.draw_pane_frames); // TODO: do we need
+ // this?
+
+ true
+ },
+ None => false
+ }
+ }
+ // None => false,
}
},
None => false,
}
}
pub fn move_focus_up(&mut self, client_id: ClientId) -> bool {
+ log::info!("initial panes: {:#?}", self.panes.iter().map(|(_, p)| p.position_and_size()).collect::<Vec<_>>());
match self.get_active_pane_id(client_id) {
Some(active_pane_id) => {
let pane_grid = TiledPaneGrid::new(
@@ -815,7 +875,60 @@ impl TiledPanes {
true
},
- None => false,
+ None => {
+ match pane_grid.stacked_pane_id_above(&active_pane_id) {
+ Some(p) => {
+ let source_pane = self
+ .panes
+ .get_mut(self.active_panes.get(&client_id).unwrap())
+ .unwrap();
+
+ // TODO:
+ // * set the y of the source_pane to be the y + rows of
+ // itself
+ // * set its rows size to be fixed 1
+ // * reduce the y of the current pane by 1
+
+ let source_before = source_pane.position_and_size();
+
+ let mut source_pane_geom = source_pane.position_and_size();
+ let mut destination_pane_geom = source_pane_geom.clone();
+ let destination_before = destination_pane_geom.clone();
+ source_pane_geom.y = (source_pane_geom.y + source_pane_geom.rows.as_usize()) - 1; // -1 because we want to be at the last line of the source pane, not the next line over
+ source_pane_geom.rows = Dimension::fixed(1);
+ source_pane.set_geom(source_pane_geom);
+ destination_pane_geom.y -= 1;
+
+ log::info!("source after: {:?}", source_pane_geom);
+ log::info!("destination after: {:?}", destination_pane_geom);
+
+ // render previously active pane so that its frame does not remain actively
+ // colored
+ source_pane.set_should_render(true);
+ // we render the full viewport to remove any ui elements that might have been
+ // there before (eg. another user's cursor)
+ source_pane.render_full_viewport();
+
+ let destination_pane = self.panes.get_mut(&p).unwrap();
+ destination_pane.set_geom(destination_pane_geom);
+
+ destination_pane.set_should_render(true);
+ // we render the full viewport to remove any ui elements that might have been
+ // there before (eg. another user's cursor)
+ destination_pane.render_full_viewport();
+
+ self.focus_pane(p, client_id);
+ self.set_pane_active_at(p);
+ self.set_pane_frames(self.draw_pane_frames); // TODO: do we need
+ // this?
+
+ true
+ },
+ None => false
+ }
+
+ }
+ // None => false,
}
},
None => false,
@@ -1075,6 +1188,7 @@ impl TiledPanes {
self.panes.remove(&pane_id)
}
pub fn remove_pane(&mut self, pane_id: PaneId) -> Option<Box<dyn Pane>> {
+ log::info!("remove pane");
let mut pane_grid = TiledPaneGrid::new(
&mut self.panes,
&self.panes_to_hide,
@@ -1082,6 +1196,7 @@ impl TiledPanes {
*self.viewport.borrow(),
);
if pane_grid.fill_space_over_pane(pane_id) {
+ log::info!("successfully fill_space_over_pane");
// successfully filled space over pane
let closed_pane = self.panes.remove(&pane_id);
self.move_clients_out_of_pane(pane_id);