mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 23:46:41 +02:00
Remove termion backend
This commit is contained in:
parent
299653e12c
commit
a7ddc2f39c
4 changed files with 0 additions and 139 deletions
29
Cargo.lock
generated
29
Cargo.lock
generated
|
@ -367,12 +367,6 @@ dependencies = [
|
||||||
"autocfg 1.0.0",
|
"autocfg 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "numtoa"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
|
@ -607,15 +601,6 @@ version = "0.1.57"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
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]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.16"
|
version = "0.1.16"
|
||||||
|
@ -778,23 +763,10 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"shlex",
|
"shlex",
|
||||||
"task-hookrs",
|
"task-hookrs",
|
||||||
"termion",
|
|
||||||
"tui",
|
"tui",
|
||||||
"unicode-width",
|
"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]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
@ -823,7 +795,6 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"termion",
|
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,7 +9,6 @@ edition = "2018"
|
||||||
[features]
|
[features]
|
||||||
default = ["crossterm-backend"]
|
default = ["crossterm-backend"]
|
||||||
crossterm-backend = ["tui/crossterm", "crossterm"]
|
crossterm-backend = ["tui/crossterm", "crossterm"]
|
||||||
termion-backend = ["tui/termion", "termion"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "*"
|
clap = "*"
|
||||||
|
@ -21,5 +20,4 @@ shlex = "0.1"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.1"
|
||||||
tui = { version = "0.10", optional = true, default-features = false }
|
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 }
|
crossterm = { version = "0.17", optional = true, default-features = false }
|
||||||
|
|
10
src/app.rs
10
src/app.rs
|
@ -23,16 +23,6 @@ use tui::{
|
||||||
Terminal,
|
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 {
|
pub fn cmp(t1: &Task, t2: &Task) -> Ordering {
|
||||||
let urgency1 = match &t1.uda()["urgency"] {
|
let urgency1 = match &t1.uda()["urgency"] {
|
||||||
UDAValue::Str(_) => 0.0,
|
UDAValue::Str(_) => 0.0,
|
||||||
|
|
98
src/util.rs
98
src/util.rs
|
@ -7,17 +7,6 @@ use crossterm::{
|
||||||
#[cfg(feature = "crossterm")]
|
#[cfg(feature = "crossterm")]
|
||||||
use tui::{backend::CrosstermBackend, Terminal};
|
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::io::{self, Write};
|
||||||
use std::{sync::mpsc, thread, time::Duration};
|
use std::{sync::mpsc, thread, time::Duration};
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
|
@ -74,22 +63,6 @@ pub fn destruct_terminal(mut terminal: Terminal<CrosstermBackend<io::Stdout>>) {
|
||||||
terminal.show_cursor().unwrap();
|
terminal.show_cursor().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
|
||||||
pub fn setup_terminal(
|
|
||||||
) -> Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>> {
|
|
||||||
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<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Events {
|
pub struct Events {
|
||||||
pub rx: mpsc::Receiver<Event<Key>>,
|
pub rx: mpsc::Receiver<Event<Key>>,
|
||||||
pub tx: mpsc::Sender<Event<Key>>,
|
pub tx: mpsc::Sender<Event<Key>>,
|
||||||
|
@ -153,83 +126,12 @@ impl Events {
|
||||||
Events { rx, tx, pause_stdin }
|
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.
|
/// Attempts to read an event.
|
||||||
/// This function will block the current thread.
|
/// This function will block the current thread.
|
||||||
pub fn next(&self) -> Result<Event<Key>, mpsc::RecvError> {
|
pub fn next(&self) -> Result<Event<Key>, mpsc::RecvError> {
|
||||||
self.rx.recv()
|
self.rx.recv()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "termion", not(feature = "crossterm")))]
|
|
||||||
pub fn pause_event_loop(&self, terminal: & mut Terminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>>) {
|
|
||||||
*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<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<io::Stdout>>>>>) {
|
|
||||||
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")]
|
#[cfg(feature = "crossterm")]
|
||||||
pub fn pause_event_loop(&self, terminal: & mut Terminal<CrosstermBackend<io::Stdout>>) {
|
pub fn pause_event_loop(&self, terminal: & mut Terminal<CrosstermBackend<io::Stdout>>) {
|
||||||
*self.pause_stdin.lock().unwrap() = true;
|
*self.pause_stdin.lock().unwrap() = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue