diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-02-01 13:41:31 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-02-01 13:42:29 +0800 |
commit | d871bc044028edf6e1cdb4cdcb1c59176648c129 (patch) | |
tree | 70883ce5039b8b8c5045f8948dab49bd90654a4f /src/interactive/widgets | |
parent | 4b2e72f0a89b9f0930a894ef9ebf3e4af94464a0 (diff) |
Update tui to 0.8
Diffstat (limited to 'src/interactive/widgets')
-rw-r--r-- | src/interactive/widgets/help.rs | 20 | ||||
-rw-r--r-- | src/interactive/widgets/main.rs | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 88966be..f758386 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -1,8 +1,9 @@ use crate::interactive::CursorDirection; -use std::borrow::Borrow; -use std::cell::{Cell, RefCell}; -use termion::event::Key; -use termion::event::Key::*; +use std::{ + borrow::Borrow, + cell::{Cell, RefCell}, +}; +use termion::{event::Key, event::Key::*}; use tui::{ buffer::Buffer, layout::Rect, @@ -20,6 +21,15 @@ pub struct HelpPaneProps { pub border_style: Style, } +fn margin(r: Rect, margin: u16) -> Rect { + Rect { + x: r.x + margin, + y: r.y + margin, + width: r.width - 2 * margin, + height: r.height - 2 * margin, + } +} + impl HelpPane { pub fn key(&mut self, key: Key) { match key { @@ -172,7 +182,7 @@ impl HelpPane { .borders(Borders::ALL); block.draw(area, buf); - let area = block.inner(area).inner(1); + let area = margin(block.inner(area), 1); self.scroll = self.scroll.min(num_lines.saturating_sub(area.height)); Paragraph::new(texts.iter()) .scroll(self.scroll) diff --git a/src/interactive/widgets/main.rs b/src/interactive/widgets/main.rs index 51dfaf8..8a43a01 100644 --- a/src/interactive/widgets/main.rs +++ b/src/interactive/widgets/main.rs @@ -7,11 +7,11 @@ use crate::interactive::{ }; use dua::traverse::Traversal; use std::borrow::Borrow; -use tui::style::{Color, Style}; use tui::{ buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, style::Modifier, + style::{Color, Style}, }; use Constraint::*; use FocussedPane::*; |