diff options
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/editor.rs | 5 | ||||
-rw-r--r-- | helix-view/src/tree.rs | 26 | ||||
-rw-r--r-- | helix-view/src/view.rs | 2 |
3 files changed, 30 insertions, 3 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 2942507d..6b5b285d 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -15,10 +15,13 @@ pub struct Editor { } impl Editor { - pub fn new(area: tui::layout::Rect) -> Self { + pub fn new(mut area: tui::layout::Rect) -> Self { let theme = Theme::default(); let language_servers = helix_lsp::Registry::new(); + // HAXX: offset the render area height by 1 to account for prompt/commandline + area.height -= 1; + Self { tree: Tree::new(area), should_close: false, diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index a5b59a79..dd07d76d 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -156,7 +156,31 @@ impl Tree { container.area = area; match container.layout { - Layout::Vertical => unimplemented!(), + Layout::Vertical => { + let len = container.children.len(); + + let height = area.height / len as u16; + + let mut child_y = area.y; + + for (i, child) in container.children.iter().enumerate() { + let mut area = Rect::new( + container.area.x, + child_y, + container.area.width, + height, + ); + child_y += height; + + // last child takes the remaining width because we can get uneven + // space from rounding + if i == len - 1 { + area.height = container.area.y + container.area.height - area.y; + } + + self.stack.push((*child, area)); + } + } Layout::Horizontal => { let len = container.children.len(); diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index 02eda72f..f1959ee3 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -51,7 +51,7 @@ impl View { /// Calculates the last visible line on screen #[inline] pub fn last_line(&self) -> usize { - let viewport = Rect::new(6, 0, self.area.width, self.area.height - 2); // - 2 for statusline and prompt + let viewport = Rect::new(6, 0, self.area.width, self.area.height - 1); // - 1 for statusline std::cmp::min( self.first_line + (viewport.height as usize), self.doc.text().len_lines() - 1, |