@@ -1,8 +1,8 @@
11use crate::compositor::{Component, Context};
2−use helix_view::graphics::Rect;
2+use helix_view::graphics::{Margin, Rect};
33use helix_view::info::Info;
44use tui::buffer::Buffer as Surface;
5−use tui::widgets::{Block, Borders, Widget};
5+use tui::widgets::{Block, Borders, Paragraph, Widget};
66
77impl Component for Info {
88 fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
@@ -11,10 +11,11 @@ impl Component for Info {
1111 // Calculate the area of the terminal to modify. Because we want to
1212 // render at the bottom right, we use the viewport's width and height
1313 // which evaluate to the most bottom right coordinate.
14− let (width, height) = (self.width + 2, self.height + 2);
14+ let width = self.width + 2 + 2; // +2 for border, +2 for margin
15+ let height = self.height + 2; // +2 for border
1516 let area = viewport.intersection(Rect::new(
1617 viewport.width.saturating_sub(width),
17− viewport.height.saturating_sub(height + 2),
18+ viewport.height.saturating_sub(height + 2), // +2 for statusline
1819 width,
1920 height,
2021 ));
@@ -24,15 +25,14 @@ impl Component for Info {
2425 .title(self.title.as_str())
2526 .borders(Borders::ALL)
2627 .border_style(style);
27− let inner = block.inner(area);
28+
29+ let margin = Margin {
30+ vertical: 0,
31+ horizontal: 1,
32+ };
33+ let inner = block.inner(area).inner(&margin);
2834 block.render(area, surface);
2935
30− // Only write as many lines as there are rows available.
31− for (y, line) in (inner.y..)
32− .zip(self.text.lines())
33− .take(inner.height as usize)
34− {
35− surface.set_string(inner.x, y, line, style);
36− }
36+ Paragraph::new(self.text.as_str()).render(inner, surface);
3737 }
3838}