mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-18 14:41:46 +03:00
fix(ui): offset content after viewport construction
This commit is contained in:
parent
a51f500c17
commit
152315f110
@ -385,6 +385,7 @@ impl Tab {
|
|||||||
for geom in boundary_geom {
|
for geom in boundary_geom {
|
||||||
self.offset_viewport(&geom)
|
self.offset_viewport(&geom)
|
||||||
}
|
}
|
||||||
|
self.set_pane_frames(self.draw_pane_frames);
|
||||||
// This is the end of the nasty viewport hack...
|
// This is the end of the nasty viewport hack...
|
||||||
// FIXME: Active / new / current terminal, should be pane
|
// FIXME: Active / new / current terminal, should be pane
|
||||||
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
|
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
|
||||||
@ -1642,7 +1643,7 @@ impl Tab {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn relayout_tab(&mut self, direction: Direction) {
|
pub fn relayout_tab(&mut self, direction: Direction) {
|
||||||
let mut resizer = PaneResizer::new(&mut self.panes.iter_mut(), &mut self.os_api);
|
let mut resizer = PaneResizer::new(self.panes.iter_mut());
|
||||||
let result = match direction {
|
let result = match direction {
|
||||||
Direction::Horizontal => resizer.layout(direction, self.display_area.cols),
|
Direction::Horizontal => resizer.layout(direction, self.display_area.cols),
|
||||||
Direction::Vertical => resizer.layout(direction, self.display_area.rows),
|
Direction::Vertical => resizer.layout(direction, self.display_area.rows),
|
||||||
@ -1662,7 +1663,7 @@ impl Tab {
|
|||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|(pid, _)| !temp_panes_to_hide.contains(pid));
|
.filter(|(pid, _)| !temp_panes_to_hide.contains(pid));
|
||||||
let Size { rows, cols } = new_screen_size;
|
let Size { rows, cols } = new_screen_size;
|
||||||
let mut resizer = PaneResizer::new(panes, &mut self.os_api);
|
let mut resizer = PaneResizer::new(panes);
|
||||||
if resizer.layout(Direction::Horizontal, cols).is_ok() {
|
if resizer.layout(Direction::Horizontal, cols).is_ok() {
|
||||||
let column_difference = cols as isize - self.display_area.cols as isize;
|
let column_difference = cols as isize - self.display_area.cols as isize;
|
||||||
// FIXME: Should the viewport be an Offset?
|
// FIXME: Should the viewport be an Offset?
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{os_input_output::ServerOsApi, panes::PaneId, tab::Pane};
|
use crate::{panes::PaneId, tab::Pane};
|
||||||
use cassowary::{
|
use cassowary::{
|
||||||
strength::{REQUIRED, STRONG},
|
strength::{REQUIRED, STRONG},
|
||||||
Expression, Solver, Variable,
|
Expression, Solver, Variable,
|
||||||
@ -12,7 +12,6 @@ use zellij_utils::{
|
|||||||
|
|
||||||
pub struct PaneResizer<'a> {
|
pub struct PaneResizer<'a> {
|
||||||
panes: HashMap<&'a PaneId, &'a mut Box<dyn Pane>>,
|
panes: HashMap<&'a PaneId, &'a mut Box<dyn Pane>>,
|
||||||
os_api: &'a mut Box<dyn ServerOsApi>,
|
|
||||||
vars: HashMap<PaneId, Variable>,
|
vars: HashMap<PaneId, Variable>,
|
||||||
solver: Solver,
|
solver: Solver,
|
||||||
}
|
}
|
||||||
@ -31,10 +30,7 @@ struct Span {
|
|||||||
type Grid = Vec<Vec<Span>>;
|
type Grid = Vec<Vec<Span>>;
|
||||||
|
|
||||||
impl<'a> PaneResizer<'a> {
|
impl<'a> PaneResizer<'a> {
|
||||||
pub fn new(
|
pub fn new(panes: impl Iterator<Item = (&'a PaneId, &'a mut Box<dyn Pane>)>) -> Self {
|
||||||
panes: impl Iterator<Item = (&'a PaneId, &'a mut Box<dyn Pane>)>,
|
|
||||||
os_api: &'a mut Box<dyn ServerOsApi>,
|
|
||||||
) -> Self {
|
|
||||||
let panes: HashMap<_, _> = panes.collect();
|
let panes: HashMap<_, _> = panes.collect();
|
||||||
let mut vars = HashMap::new();
|
let mut vars = HashMap::new();
|
||||||
for &&k in panes.keys() {
|
for &&k in panes.keys() {
|
||||||
@ -42,7 +38,6 @@ impl<'a> PaneResizer<'a> {
|
|||||||
}
|
}
|
||||||
PaneResizer {
|
PaneResizer {
|
||||||
panes,
|
panes,
|
||||||
os_api,
|
|
||||||
vars,
|
vars,
|
||||||
solver: Solver::new(),
|
solver: Solver::new(),
|
||||||
}
|
}
|
||||||
@ -146,13 +141,6 @@ impl<'a> PaneResizer<'a> {
|
|||||||
} else {
|
} else {
|
||||||
pane.set_geom(new_geom);
|
pane.set_geom(new_geom);
|
||||||
}
|
}
|
||||||
if let PaneId::Terminal(pid) = pane.pid() {
|
|
||||||
self.os_api.set_terminal_size_using_fd(
|
|
||||||
pid,
|
|
||||||
pane.get_content_columns() as u16,
|
|
||||||
pane.get_content_rows() as u16,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user