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 | |
parent | 4b2e72f0a89b9f0930a894ef9ebf3e4af94464a0 (diff) |
Update tui to 0.8
-rw-r--r-- | Cargo.lock | 24 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/interactive/widgets/help.rs | 20 | ||||
-rw-r--r-- | src/interactive/widgets/main.rs | 2 | ||||
-rw-r--r-- | tests/utilities.sh | 2 | ||||
-rw-r--r-- | tui-react/Cargo.toml | 2 |
6 files changed, 23 insertions, 29 deletions
@@ -200,7 +200,7 @@ dependencies = [ "pretty_assertions", "structopt", "termion", - "tui 0.7.0", + "tui", "tui-react", "unicode-segmentation", ] @@ -597,25 +597,9 @@ dependencies = [ [[package]] name = "tui" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b422ff4986065d33272b587907654f918a3fe8702786a8110bf68dede0d8ee" -dependencies = [ - "bitflags", - "cassowary", - "either", - "itertools", - "log", - "termion", - "unicode-segmentation", - "unicode-width", -] - -[[package]] -name = "tui" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0606ff286997171664d4f5ace6b130dd6ba1b867e6a27433077f618807aedc3b" +checksum = "6b871b61f4c4b81e630215cd12e0ec29953d4545898e21a9e023b7520a74a9f9" dependencies = [ "bitflags", "cassowary", @@ -632,7 +616,7 @@ name = "tui-react" version = "0.1.2" dependencies = [ "log", - "tui 0.6.2", + "tui", ] [[package]] @@ -17,7 +17,7 @@ jwalk = "0.4.0" byte-unit = "3" termion = "1.5.2" atty = "0.2.11" -tui = "0.6.0" +tui = "0.8.0" petgraph = "0.5" itertools = "0.8.0" open = "1.2.2" 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::*; diff --git a/tests/utilities.sh b/tests/utilities.sh index 86084cf..7eb6d90 100644 --- a/tests/utilities.sh +++ b/tests/utilities.sh @@ -157,4 +157,4 @@ function expect_run () { exit 1 fi set -e -} +}
\ No newline at end of file diff --git a/tui-react/Cargo.toml b/tui-react/Cargo.toml index 08c6ba6..ff58dc1 100644 --- a/tui-react/Cargo.toml +++ b/tui-react/Cargo.toml @@ -9,5 +9,5 @@ readme = "README.md" license = "MIT" [dependencies] -tui = "0.6.0" +tui = "0.8.0" log = "0.4.6" |