diff --git a/Cargo.lock b/Cargo.lock index f430961..67bb352 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,12 +367,6 @@ dependencies = [ "autocfg 1.0.0", ] -[[package]] -name = "numtoa" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" - [[package]] name = "object" version = "0.20.0" @@ -607,15 +601,6 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -dependencies = [ - "redox_syscall", -] - [[package]] name = "rustc-demangle" version = "0.1.16" @@ -778,23 +763,10 @@ dependencies = [ "serde_json", "shlex", "task-hookrs", - "termion", "tui", "unicode-width", ] -[[package]] -name = "termion" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" -dependencies = [ - "libc", - "numtoa", - "redox_syscall", - "redox_termios", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -823,7 +795,6 @@ dependencies = [ "bitflags", "cassowary", "crossterm", - "termion", "unicode-segmentation", "unicode-width", ] diff --git a/Cargo.toml b/Cargo.toml index 79be6aa..0d386ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ edition = "2018" [features] default = ["crossterm-backend"] crossterm-backend = ["tui/crossterm", "crossterm"] -termion-backend = ["tui/termion", "termion"] [dependencies] clap = "*" @@ -21,5 +20,4 @@ shlex = "0.1" chrono = "0.4" unicode-width = "0.1" tui = { version = "0.10", optional = true, default-features = false } -termion = { version = "1.5", optional = true, default-features = false } crossterm = { version = "0.17", optional = true, default-features = false } diff --git a/src/app.rs b/src/app.rs index 0ab5db3..c006a9d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -23,16 +23,6 @@ use tui::{ Terminal, }; -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -use tui::backend::TermionBackend; -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -use termion::{ - event, - input::{MouseTerminal, TermRead}, - raw::{IntoRawMode, RawTerminal}, - screen::AlternateScreen, -}; - pub fn cmp(t1: &Task, t2: &Task) -> Ordering { let urgency1 = match &t1.uda()["urgency"] { UDAValue::Str(_) => 0.0, diff --git a/src/util.rs b/src/util.rs index 7b5b302..2298c8d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -7,17 +7,6 @@ use crossterm::{ #[cfg(feature = "crossterm")] use tui::{backend::CrosstermBackend, Terminal}; -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -use termion::{ - event, - input::{MouseTerminal, TermRead}, - raw::{IntoRawMode, RawTerminal}, - screen::{AlternateScreen,ToMainScreen, ToAlternateScreen}, -}; -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -use tui::{backend::TermionBackend, Terminal}; - - use std::io::{self, Write}; use std::{sync::mpsc, thread, time::Duration}; use std::sync::{ @@ -74,22 +63,6 @@ pub fn destruct_terminal(mut terminal: Terminal>) { terminal.show_cursor().unwrap(); } -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -pub fn setup_terminal( -) -> Terminal>>>> { - let raw_stdout = io::stdout().into_raw_mode().unwrap(); - let stdout = MouseTerminal::from(raw_stdout); - let stdout = AlternateScreen::from(stdout); - let backend = TermionBackend::new(stdout); - Terminal::new(backend).unwrap() -} - -#[cfg(all(feature = "termion", not(feature = "crossterm")))] -pub fn destruct_terminal( - terminal: Terminal>>>>, -) { -} - pub struct Events { pub rx: mpsc::Receiver>, pub tx: mpsc::Sender>, @@ -153,83 +126,12 @@ impl Events { Events { rx, tx, pause_stdin } } - #[cfg(all(feature = "termion", not(feature = "crossterm")))] - pub fn with_config(config: EventConfig) -> Events { - use termion::event::Key::*; - let (tx, rx) = mpsc::channel(); - let pause_stdin = Arc::new(Mutex::new(false)); - let input_handle = { - let tx = tx.clone(); - let pause_stdin = pause_stdin.clone(); - thread::spawn(move || { - let stdin = io::stdin(); - for evt in stdin.keys() { - while *pause_stdin.lock().unwrap() { - thread::sleep(config.tick_rate); - } - if let Ok(key) = evt { - let key = match key { - Backspace => Key::Backspace, - Left => Key::Left, - Right => Key::Right, - Up => Key::Up, - Down => Key::Down, - Home => Key::Home, - End => Key::End, - PageUp => Key::PageUp, - PageDown => Key::PageDown, - BackTab => Key::BackTab, - Delete => Key::Delete, - Insert => Key::Insert, - F(c) => Key::F(c), - Char(c) => Key::Char(c), - Alt(c) => Key::Alt(c), - Ctrl(c) => Key::Ctrl(c), - Null => Key::Null, - Esc => Key::Esc, - _ => Key::Null, - }; - if let Err(err) = tx.send(Event::Input(key)) { - eprintln!("{}", err); - return; - } - } - } - }) - }; - let tick_handle = { - let tx = tx.clone(); - thread::spawn(move || loop { - if tx.send(Event::Tick).is_err() { - break; - } - thread::sleep(config.tick_rate); - }) - }; - Events { rx, tx, pause_stdin } - } - /// Attempts to read an event. /// This function will block the current thread. pub fn next(&self) -> Result, mpsc::RecvError> { self.rx.recv() } - #[cfg(all(feature = "termion", not(feature = "crossterm")))] - pub fn pause_event_loop(&self, terminal: & mut Terminal>>>>) { - *self.pause_stdin.lock().unwrap() = true; - std::thread::sleep(std::time::Duration::from_millis(50)); - write!(terminal.backend_mut(), "{}", ToMainScreen).unwrap(); - } - - #[cfg(all(feature = "termion", not(feature = "crossterm")))] - pub fn resume_event_loop(&self, terminal: & mut Terminal>>>>) { - write!(terminal.backend_mut(), "{}", ToAlternateScreen).unwrap(); - std::thread::sleep(std::time::Duration::from_millis(50)); - *self.pause_stdin.lock().unwrap() = false; - terminal.resize(terminal.size().unwrap()).unwrap(); - } - #[cfg(feature = "crossterm")] pub fn pause_event_loop(&self, terminal: & mut Terminal>) { *self.pause_stdin.lock().unwrap() = true;