summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2020-07-06 10:44:23 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-07-06 10:44:23 +0800
commit98f850a1ccd30618620a7d78999899c24463238a (patch)
treea1fe3d9754d673c9fd90ab5e042da68879148e74 /src/main.rs
parent4b59c36ca8c53e63dd74fc0b3179a4ed9de2f60d (diff)
Use crosstermion to create a terminal with the corresponding backend
The only question left is how to conform colors.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 6 insertions, 11 deletions
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,