diff options
author | Blaž Hrastnik | 2021-03-08 08:00:32 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-08 08:00:32 +0000 |
commit | 5ea610c41d58c8e63178200db7b723d016318f67 (patch) | |
tree | c76d8b76d5cda802ca9a0fc36137e5ddbed281b5 /helix-term/src/ui/text.rs | |
parent | 05aa0d6991820625189c7e367a6d033682ef4e4e (diff) |
ui: Move terminal into compositor, redo required_size hints.
Diffstat (limited to 'helix-term/src/ui/text.rs')
-rw-r--r-- | helix-term/src/ui/text.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/helix-term/src/ui/text.rs b/helix-term/src/ui/text.rs index 133cdd25..9db4d3bc 100644 --- a/helix-term/src/ui/text.rs +++ b/helix-term/src/ui/text.rs @@ -33,8 +33,10 @@ impl Component for Text { par.render(area, surface); } - fn size_hint(&self, area: Rect) -> Option<(usize, usize)> { + fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> { let contents = tui::text::Text::from(self.contents.clone()); - Some((contents.width(), contents.height())) + let width = std::cmp::min(contents.width() as u16, viewport.0); + let height = std::cmp::min(contents.height() as u16, viewport.1); + Some((width, height)) } } |