diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 10:44:23 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-06 10:44:23 +0800 |
commit | 98f850a1ccd30618620a7d78999899c24463238a (patch) | |
tree | a1fe3d9754d673c9fd90ab5e042da68879148e74 | |
parent | 4b59c36ca8c53e63dd74fc0b3179a4ed9de2f60d (diff) |
Use crosstermion to create a terminal with the corresponding backend
The only question left is how to conform colors.
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/main.rs | 17 |
3 files changed, 9 insertions, 14 deletions
@@ -232,7 +232,7 @@ dependencies = [ "structopt", "termion", "tui", - "tui-react 0.4.0", + "tui-react 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation", ] @@ -20,7 +20,7 @@ petgraph = "0.5" itertools = "0.9.0" open = "1.2.2" log = "0.4.6" -tui-react = { path = "./tui-react", version = "0.4" } +tui-react = { version = "0.4" } num_cpus = "1.10.0" unicode-segmentation = "1.3.0" filesize = "0.2.0" @@ -28,7 +28,7 @@ flume = {version = "0.7.1", default-features = false} anyhow = "1.0.31" [target.'cfg(windows)'.dependencies] -crosstermion = { version = "0.1.3", features = ["tui-react-crossterm", "input-thread-flume"]} +crosstermion = { version = "0.1.3", default-features = false, features = ["tui-react-crossterm", "input-thread-flume"]} [target.'cfg(unix)'.dependencies] crosstermion = { version = "0.1.3", default-features = false, features = ["tui-react-termion", "input-thread-flume"]} diff --git a/src/main.rs b/src/main.rs index ebc6f6b..8642963 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,10 @@ #![allow(clippy::match_bool)] use crate::interactive::{Interaction, TerminalApp}; use anyhow::{Context, Result}; +use crosstermion::terminal::{tui::new_terminal, AlternateRawScreen}; use dua::{ByteFormat, Color, TraversalSorting}; use std::{fs, io, io::Write, path::PathBuf, process}; use structopt::StructOpt; -use termion::{raw::IntoRawMode, screen::AlternateScreen}; -use tui::backend::TermionBackend; -use tui_react::Terminal; mod interactive; mod options; @@ -31,14 +29,11 @@ fn main() -> Result<()> { }; let res = match opt.command { Some(Interactive { input }) => { - let mut terminal = { - let stdout = io::stdout() - .into_raw_mode() - .with_context(|| "Interactive mode requires a connected terminal")?; - let stdout = AlternateScreen::from(stdout); - let backend = TermionBackend::new(stdout); - Terminal::new(backend)? - }; + let mut terminal = new_terminal( + AlternateRawScreen::try_from(io::stdout()) + .with_context(|| "Failed to initialize alternate raw screen")?, + ) + .with_context(|| "Could not instantiate terminal")?; let res = TerminalApp::initialize( &mut terminal, walk_options, |