summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2022-09-12 09:47:21 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2022-09-12 09:47:21 +0800
commit20b76721939b77dc6c9a86d3c5f4c22cc7f1cf65 (patch)
treeed192e3b13c084afc1ab9a9ef08ddb369577714c
parent6bd433831850c2032674e440809ac86c0b8c6784 (diff)
parent28f5ac90cc1ba7d668ae8a83eb5cd899294a8301 (diff)
Merge branch 'dep-upgrade'
-rw-r--r--Cargo.lock61
-rw-r--r--Cargo.toml6
-rw-r--r--src/interactive/app/eventloop.rs30
-rw-r--r--src/interactive/app/tests/journeys_with_writes.rs8
-rw-r--r--src/interactive/app/tests/utils.rs8
-rw-r--r--src/main.rs2
6 files changed, 50 insertions, 65 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0a2c8af..83742eb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -188,9 +188,9 @@ dependencies = [
[[package]]
name = "crossterm"
-version = "0.22.1"
+version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c"
+checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
dependencies = [
"bitflags",
"crossterm_winapi",
@@ -213,9 +213,7 @@ dependencies = [
[[package]]
name = "crosstermion"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a05e035b986ed55343b748f978fd8d2508dbab8492ef228aa7896735b1d51931"
+version = "0.10.0"
dependencies = [
"crossterm",
"termion",
@@ -344,15 +342,6 @@ dependencies = [
]
[[package]]
-name = "instant"
-version = "0.1.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
-dependencies = [
- "cfg-if",
-]
-
-[[package]]
name = "itertools"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -428,24 +417,14 @@ dependencies = [
[[package]]
name = "mio"
-version = "0.7.14"
+version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
+checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [
"libc",
"log",
- "miow",
- "ntapi",
- "winapi",
-]
-
-[[package]]
-name = "miow"
-version = "0.3.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
-dependencies = [
- "winapi",
+ "wasi",
+ "windows-sys",
]
[[package]]
@@ -515,27 +494,25 @@ dependencies = [
[[package]]
name = "parking_lot"
-version = "0.11.2"
+version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
- "instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
-version = "0.8.5"
+version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
+checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [
"cfg-if",
- "instant",
"libc",
"redox_syscall",
"smallvec",
- "winapi",
+ "windows-sys",
]
[[package]]
@@ -788,9 +765,9 @@ dependencies = [
[[package]]
name = "tui"
-version = "0.17.0"
+version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23ed0a32c88b039b73f1b6c5acbd0554bfa5b6be94467375fd947c4de3a02271"
+checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
dependencies = [
"bitflags",
"cassowary",
@@ -802,9 +779,7 @@ dependencies = [
[[package]]
name = "tui-react"
-version = "0.17.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a0d3e9b9c7dfdad4919ee6fa65d3a13b742c7791f58e861f1d0b400648d43ed"
+version = "0.19.0"
dependencies = [
"log",
"tui",
@@ -870,6 +845,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
name = "wild"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 3f4b6a7..6ce8dda 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,9 +32,9 @@ trash = { version = "2.1.5", optional = true, default-features = false, features
# 'tui' related
unicode-segmentation = { version = "1.3.0", optional = true }
-crosstermion = { optional = true, version = "0.9.0", default-features = false }
-tui = { version = "0.17.0", optional = true, default-features = false }
-tui-react = { version = "0.17.0", optional = true }
+crosstermion = { optional = true, version = "0.10.0", default-features = false }
+tui = { version = "0.19.0", optional = true, default-features = false }
+tui-react = { version = "0.19.0", optional = true }
open = { version = "3.0", optional = true }
wild = "2.0.4"
diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs
index 6814dd2..77901ed 100644
--- a/src/interactive/app/eventloop.rs
+++ b/src/interactive/app/eventloop.rs
@@ -5,7 +5,7 @@ use crate::interactive::{
SortMode,
};
use anyhow::Result;
-use crosstermion::input::{key_input_channel, Key};
+use crosstermion::input::{input_channel, Event, Key};
use dua::{
traverse::{Traversal, TreeIndex},
WalkOptions, WalkResult,
@@ -69,7 +69,7 @@ impl AppState {
traversal: &mut Traversal,
display: &mut DisplayOptions,
terminal: &mut Terminal<B>,
- keys: impl Iterator<Item = Key>,
+ events: impl Iterator<Item = Event>,
) -> Result<ProcessingResult>
where
B: Backend,
@@ -77,8 +77,12 @@ impl AppState {
use crosstermion::input::Key::*;
use FocussedPane::*;
- self.draw(window, traversal, *display, terminal)?;
- for key in keys {
+ for event in events {
+ let key = match event {
+ Event::Key(key) => key,
+ Event::Resize(_, _) => Alt('\r'),
+ };
+
self.reset_message();
match key {
Char('?') => self.toggle_help_pane(window),
@@ -106,17 +110,15 @@ impl AppState {
}
match self.focussed {
- FocussedPane::Mark => {
- self.dispatch_to_mark_pane(key, window, traversal, *display, terminal)
- }
- FocussedPane::Help => {
+ Mark => self.dispatch_to_mark_pane(key, window, traversal, *display, terminal),
+ Help => {
window
.help_pane
.as_mut()
.expect("help pane")
.process_events(key);
}
- FocussedPane::Main => match key {
+ Main => match key {
Char('O') => self.open_that(traversal),
Char(' ') => self.mark_entry(
CursorMode::KeepPosition,
@@ -184,7 +186,7 @@ pub struct TerminalApp {
pub window: MainWindow,
}
-type KeyboardInputAndApp = (std::sync::mpsc::Receiver<Key>, TerminalApp);
+type KeyboardInputAndApp = (std::sync::mpsc::Receiver<Event>, TerminalApp);
impl TerminalApp {
pub fn refresh_view<B>(&mut self, terminal: &mut Terminal<B>)
@@ -198,14 +200,14 @@ impl TerminalApp {
&mut self.traversal,
&mut self.display,
terminal,
- std::iter::once(Key::Alt('\r')),
+ std::iter::once(Event::Key(Key::Alt('\r'))),
)
.ok();
}
pub fn process_events<B>(
&mut self,
terminal: &mut Terminal<B>,
- keys: impl Iterator<Item = Key>,
+ events: impl Iterator<Item = Event>,
) -> Result<WalkResult>
where
B: Backend,
@@ -215,7 +217,7 @@ impl TerminalApp {
&mut self.traversal,
&mut self.display,
terminal,
- keys,
+ events,
)? {
ProcessingResult::Finished(res) | ProcessingResult::ExitRequested(res) => Ok(res),
}
@@ -240,7 +242,7 @@ impl TerminalApp {
let (_, keys_rx) = std::sync::mpsc::channel();
keys_rx
}
- Interaction::Full => key_input_channel(),
+ Interaction::Full => input_channel(),
};
let fetch_buffered_key_events = || {
diff --git a/src/interactive/app/tests/journeys_with_writes.rs b/src/interactive/app/tests/journeys_with_writes.rs
index 6e411f3..4e990ee 100644
--- a/src/interactive/app/tests/journeys_with_writes.rs
+++ b/src/interactive/app/tests/journeys_with_writes.rs
@@ -2,6 +2,8 @@ use crate::interactive::app::tests::utils::{
initialized_app_and_terminal_from_paths, into_keys, WritableFixture,
};
use anyhow::Result;
+use crosstermion::input::Event;
+use crosstermion::input::Key;
use pretty_assertions::assert_eq;
#[test]
@@ -24,11 +26,7 @@ fn basic_user_journey_with_deletion() -> Result<()> {
// When selecting the marker window and pressing the combination to delete entries
app.process_events(
&mut terminal,
- vec![
- crosstermion::input::Key::Char('\t'),
- crosstermion::input::Key::Ctrl('r'),
- ]
- .into_iter(),
+ vec![Event::Key(Key::Char('\t')), Event::Key(Key::Ctrl('r'))].into_iter(),
)?;
assert!(
app.window.mark_pane.is_none(),
diff --git a/src/interactive/app/tests/utils.rs b/src/interactive/app/tests/utils.rs
index 0e1a8f0..2882f6d 100644
--- a/src/interactive/app/tests/utils.rs
+++ b/src/interactive/app/tests/utils.rs
@@ -21,8 +21,12 @@ use crate::interactive::{app::tests::FIXTURE_PATH, Interaction, TerminalApp};
pub fn into_keys<'a>(
bytes: impl Iterator<Item = &'a u8> + 'a,
-) -> impl Iterator<Item = crosstermion::input::Key> + 'a {
- bytes.map(|b| crosstermion::input::Key::Char(std::char::from_u32(*b as u32).unwrap()))
+) -> impl Iterator<Item = crosstermion::input::Event> + 'a {
+ bytes.map(|b| {
+ crosstermion::input::Event::Key(crosstermion::input::Key::Char(
+ std::char::from_u32(*b as u32).unwrap(),
+ ))
+ })
}
pub fn node_by_index(app: &TerminalApp, id: TreeIndex) -> &EntryData {
diff --git a/src/main.rs b/src/main.rs
index af7406c..c185d75 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,7 +38,7 @@ fn derive_default_threads(threads: usize) -> usize {
.processors()
.get(0)
.map_or(0, |p| match p.brand() {
- "Apple M1"|"Apple M1 Pro"|"Apple M1 Max" => 4,
+ "Apple M1"|"Apple M1 Pro"|"Apple M1 Max"|"Apple M2" => 4,
other => {
eprintln!(
"Couldn't auto-configure correct amount of threads for {}. Create an issue here: https://github.com/byron/dua-cli/issues",