deps: Update tui to 0.19.0 and crossterm to 0.25.0 (#878)

* deps: update tui to 0.19 and crossterm to 0.25

* fix error

* handle breaking changes
This commit is contained in:
Clement Tsang 2022-11-08 00:56:39 -05:00 committed by GitHub
parent e1be318177
commit 8101e6fa56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 126 additions and 66 deletions

135
Cargo.lock generated
View file

@ -134,7 +134,7 @@ dependencies = [
"futures-lite", "futures-lite",
"libc", "libc",
"once_cell", "once_cell",
"signal-hook 0.3.13", "signal-hook",
"winapi", "winapi",
] ]
@ -436,25 +436,25 @@ dependencies = [
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.18.2" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e86d73f2a0b407b5768d10a8c720cf5d2df49a9efc10ca09176d201ead4b7fb" checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"crossterm_winapi", "crossterm_winapi",
"lazy_static",
"libc", "libc",
"mio", "mio",
"parking_lot", "parking_lot",
"signal-hook 0.1.17", "signal-hook",
"signal-hook-mio",
"winapi", "winapi",
] ]
[[package]] [[package]]
name = "crossterm_winapi" name = "crossterm_winapi"
version = "0.6.2" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db" checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c"
dependencies = [ dependencies = [
"winapi", "winapi",
] ]
@ -708,7 +708,7 @@ checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi", "wasi 0.10.2+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@ -1013,24 +1013,14 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.7.14" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"miow", "wasi 0.11.0+wasi-snapshot-preview1",
"ntapi 0.3.7", "windows-sys",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
] ]
[[package]] [[package]]
@ -1194,27 +1184,25 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.11.2" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [ dependencies = [
"instant",
"lock_api", "lock_api",
"parking_lot_core", "parking_lot_core",
] ]
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.8.5" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"instant",
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
"winapi", "windows-sys",
] ]
[[package]] [[package]]
@ -1434,17 +1422,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "signal-hook"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729"
dependencies = [
"libc",
"mio",
"signal-hook-registry",
]
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.13" version = "0.3.13"
@ -1455,6 +1432,17 @@ dependencies = [
"signal-hook-registry", "signal-hook-registry",
] ]
[[package]]
name = "signal-hook-mio"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.0" version = "1.4.0"
@ -1661,9 +1649,9 @@ dependencies = [
[[package]] [[package]]
name = "tui" name = "tui"
version = "0.14.0" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ced152a8e9295a5b168adc254074525c17ac4a83c90b2716274cc38118bddc9" checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cassowary", "cassowary",
@ -1750,6 +1738,12 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wepoll-ffi" name = "wepoll-ffi"
version = "0.1.2" version = "0.1.2"
@ -1796,6 +1790,63 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
[[package]] [[package]]
name = "wrapcenum-derive" name = "wrapcenum-derive"
version = "0.4.0" version = "0.4.0"

View file

@ -65,7 +65,7 @@ backtrace = "0.3.65"
cfg-if = "1.0.0" cfg-if = "1.0.0"
clap = { version = "3.1.12", features = ["default", "cargo", "wrap_help"] } clap = { version = "3.1.12", features = ["default", "cargo", "wrap_help"] }
concat-string = "1.0.1" concat-string = "1.0.1"
crossterm = "0.18.2" crossterm = "0.25.0"
ctrlc = { version = "3.1.9", features = ["termination"] } ctrlc = { version = "3.1.9", features = ["termination"] }
dirs = "4.0.0" dirs = "4.0.0"
fern = { version = "0.6.1", optional = true } fern = { version = "0.6.1", optional = true }
@ -85,7 +85,7 @@ sysinfo = "0.26.7"
thiserror = "1.0.30" thiserror = "1.0.30"
time = { version = "0.3.9", features = ["formatting", "macros"] } time = { version = "0.3.9", features = ["formatting", "macros"] }
toml = "0.5.9" toml = "0.5.9"
tui = { version = "0.14.0", features = ["crossterm"], default-features = false } tui = "0.19.0"
typed-builder = "0.10.0" typed-builder = "0.10.0"
unicode-segmentation = "1.9.0" unicode-segmentation = "1.9.0"
unicode-width = "0.1.9" unicode-width = "0.1.9"

View file

@ -14,7 +14,7 @@ use bottom::{
use std::{ use std::{
boxed::Box, boxed::Box,
io::{stdout, Write}, io::stdout,
panic, panic,
sync::{ sync::{
atomic::{AtomicBool, Ordering}, atomic::{AtomicBool, Ordering},

View file

@ -27,7 +27,10 @@ use std::{
}; };
use crossterm::{ use crossterm::{
event::{poll, read, DisableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent}, event::{
poll, read, DisableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent,
MouseEventKind,
},
execute, execute,
style::Print, style::Print,
terminal::{disable_raw_mode, LeaveAlternateScreen}, terminal::{disable_raw_mode, LeaveAlternateScreen},
@ -81,10 +84,11 @@ pub enum ThreadControlEvent {
} }
pub fn handle_mouse_event(event: MouseEvent, app: &mut App) { pub fn handle_mouse_event(event: MouseEvent, app: &mut App) {
match event { match event.kind {
MouseEvent::ScrollUp(_x, _y, _modifiers) => app.handle_scroll_up(), MouseEventKind::ScrollUp => app.handle_scroll_up(),
MouseEvent::ScrollDown(_x, _y, _modifiers) => app.handle_scroll_down(), MouseEventKind::ScrollDown => app.handle_scroll_down(),
MouseEvent::Down(button, x, y, _modifiers) => { MouseEventKind::Down(button) => {
let (x, y) = (event.column, event.row);
if !app.app_config_fields.disable_click { if !app.app_config_fields.disable_click {
match button { match button {
crossterm::event::MouseButton::Left => { crossterm::event::MouseButton::Left => {
@ -419,20 +423,31 @@ pub fn create_input_thread(
if let Ok(poll) = poll(Duration::from_millis(20)) { if let Ok(poll) = poll(Duration::from_millis(20)) {
if poll { if poll {
if let Ok(event) = read() { if let Ok(event) = read() {
if let Event::Key(key) = event { // FIXME: Handle all other event cases.
if Instant::now().duration_since(keyboard_timer).as_millis() >= 20 { match event {
if sender.send(BottomEvent::KeyInput(key)).is_err() { Event::Key(key) => {
break; if Instant::now().duration_since(keyboard_timer).as_millis() >= 20 {
if sender.send(BottomEvent::KeyInput(key)).is_err() {
break;
}
keyboard_timer = Instant::now();
} }
keyboard_timer = Instant::now();
} }
} else if let Event::Mouse(mouse) = event { Event::Mouse(mouse) => {
if Instant::now().duration_since(mouse_timer).as_millis() >= 20 { if Instant::now().duration_since(mouse_timer).as_millis() >= 20 {
if sender.send(BottomEvent::MouseInput(mouse)).is_err() { match mouse.kind {
break; MouseEventKind::Moved => {}
_ => {
if sender.send(BottomEvent::MouseInput(mouse)).is_err()
{
break;
}
mouse_timer = Instant::now();
}
}
} }
mouse_timer = Instant::now();
} }
_ => (),
} }
} }
} }

View file

@ -56,12 +56,6 @@ impl From<heim::Error> for BottomError {
} }
} }
impl From<crossterm::ErrorKind> for BottomError {
fn from(err: crossterm::ErrorKind) -> Self {
BottomError::CrosstermError(err.to_string())
}
}
impl From<std::num::ParseIntError> for BottomError { impl From<std::num::ParseIntError> for BottomError {
fn from(err: std::num::ParseIntError) -> Self { fn from(err: std::num::ParseIntError) -> Self {
BottomError::ConfigError(err.to_string()) BottomError::ConfigError(err.to_string())