@@ -1,8 +1,8 @@
1use crate::compositor::{Component, Context};
1use crate::compositor::{Component, Context};
2−use helix_view::graphics::Rect;
2+use helix_view::graphics::{Margin, Rect};
3use helix_view::info::Info;
3use helix_view::info::Info;
4use tui::buffer::Buffer as Surface;
4use tui::buffer::Buffer as Surface;
5−use tui::widgets::{Block, Borders, Widget};
5+use tui::widgets::{Block, Borders, Paragraph, Widget};
7impl Component for Info {
7impl Component for Info {
8 fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
8 fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
@@ -11,10 +11,11 @@ impl Component for Info {
11 // Calculate the area of the terminal to modify. Because we want to
11 // Calculate the area of the terminal to modify. Because we want to
12 // render at the bottom right, we use the viewport's width and height
12 // render at the bottom right, we use the viewport's width and height
13 // which evaluate to the most bottom right coordinate.
13 // 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
15 let area = viewport.intersection(Rect::new(
16 let area = viewport.intersection(Rect::new(
16 viewport.width.saturating_sub(width),
17 viewport.width.saturating_sub(width),
17− viewport.height.saturating_sub(height + 2),
18+ viewport.height.saturating_sub(height + 2), // +2 for statusline
@@ -24,15 +25,14 @@ impl Component for Info {
24 .title(self.title.as_str())
25 .title(self.title.as_str())
25 .borders(Borders::ALL)
26 .borders(Borders::ALL)
26 .border_style(style);
27 .border_style(style);
29+ let margin = Margin {
27− let inner = block.inner(area);
33+ let inner = block.inner(area).inner(&margin);
28 block.render(area, surface);
34 block.render(area, surface);
30− // Only write as many lines as there are rows available.
36+ Paragraph::new(self.text.as_str()).render(inner, surface);
31− for (y, line) in (inner.y..)
32− .zip(self.text.lines())
33− .take(inner.height as usize)
35− surface.set_string(inner.x, y, line, style);