Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ include = [
[features]
default = ["tui-crossplatform", "trash-move"]
tui-crossplatform = [
"crosstermion/tui-crossterm",
"crossterm",
"tui",
"tui-react",
"open",
"unicode-segmentation",
"unicode-width",
Expand All @@ -46,9 +45,10 @@ chrono = { version = "0.4.31", default-features = false, features = ["std"] }
# 'tui' related
unicode-segmentation = { version = "1.3.0", optional = true }
unicode-width = { version = "0.2.0", optional = true }
crosstermion = { version = "0.14.0", default-features = false, optional = true }
tui = { package = "ratatui", version = "0.26.1", optional = true, default-features = false }
tui-react = { version = "0.23.2", optional = true }
crossterm = { version = "0.27.0", optional = true }
tui = { package = "ratatui", version = "0.26.1", optional = true, default-features = false, features = [
"crossterm",
] }
open = { version = "5.0", optional = true }
wild = "2.0.4"
owo-colors = "4.0.0"
Expand Down
5 changes: 2 additions & 3 deletions src/interactive/app/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::interactive::{
};
use anyhow::Result;
use crossbeam::channel::Receiver;
use crosstermion::crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use crosstermion::input::Event;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use dua::{
WalkResult,
traverse::{BackgroundTraversal, EntryData, Traversal, TreeIndex},
Expand Down Expand Up @@ -233,7 +232,7 @@ impl AppState {
B: Backend,
{
use FocussedPane::*;
use crosstermion::crossterm::event::KeyCode::*;
use crossterm::event::KeyCode::*;

let key = match event {
Event::Key(key) if key.kind != KeyEventKind::Release => {
Expand Down
4 changes: 2 additions & 2 deletions src/interactive/app/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::interactive::{
app::tree_view::TreeView,
widgets::{Column, GlobPane, HelpPane, MainWindow, MarkMode, MarkPane},
};
use crosstermion::input::Key;
use crossterm::event::KeyEvent;
use dua::traverse::TreeIndex;
use std::{fs, io, path::PathBuf};
use tui::{Terminal, backend::Backend};
Expand Down Expand Up @@ -232,7 +232,7 @@ impl AppState {

pub fn dispatch_to_mark_pane<B>(
&mut self,
key: Key,
key: KeyEvent,
window: &mut MainWindow,
tree_view: &mut TreeView<'_>,
display: DisplayOptions,
Expand Down
4 changes: 2 additions & 2 deletions src/interactive/app/input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crossbeam::channel::Receiver;
pub use crosstermion::crossterm::event::Event;
pub use crossterm::event::Event;

enum Action<T> {
Continue,
Expand All @@ -18,7 +18,7 @@ pub fn input_channel() -> Receiver<Event> {
let (key_send, key_receive) = crossbeam::channel::bounded(0);
std::thread::spawn(move || -> Result<(), std::io::Error> {
loop {
let event = match continue_on_interrupt(crosstermion::crossterm::event::read()) {
let event = match continue_on_interrupt(crossterm::event::read()) {
Action::Continue => continue,
Action::Result(res) => res?,
};
Expand Down
2 changes: 1 addition & 1 deletion src/interactive/app/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use crate::interactive::EntryCheck;
use anyhow::Result;
use crossbeam::channel::Receiver;
use crosstermion::input::Event;
use crossterm::event::Event;
#[cfg(test)]
use dua::traverse::TraversalStats;
use dua::{ByteFormat, WalkOptions, WalkResult, traverse::Traversal};
Expand Down
3 changes: 1 addition & 2 deletions src/interactive/app/tests/journeys_readonly.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::Result;
use crosstermion::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use crosstermion::input::Event;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use pretty_assertions::assert_eq;
use std::ffi::OsString;

Expand Down
3 changes: 1 addition & 2 deletions src/interactive/app/tests/journeys_with_writes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::interactive::app::tests::utils::{
WritableFixture, initialized_app_and_terminal_from_paths, into_codes,

Check warning on line 2 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused imports: `WritableFixture`, `initialized_app_and_terminal_from_paths`, and `into_codes`

Check warning on line 2 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused imports: `WritableFixture`, `initialized_app_and_terminal_from_paths`, and `into_codes`
};
use anyhow::Result;

Check warning on line 4 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused import: `anyhow::Result`

Check warning on line 4 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused import: `anyhow::Result`
use crosstermion::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use crosstermion::input::Event;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};

Check warning on line 5 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused imports: `Event`, `KeyCode`, `KeyEvent`, and `KeyModifiers`

Check warning on line 5 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused imports: `Event`, `KeyCode`, `KeyEvent`, and `KeyModifiers`
use pretty_assertions::assert_eq;

Check warning on line 6 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused import: `pretty_assertions::assert_eq`

Check warning on line 6 in src/interactive/app/tests/journeys_with_writes.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

unused import: `pretty_assertions::assert_eq`

#[test]
#[cfg(not(target_os = "windows"))] // it stopped working here, don't know if it's truly broken or if it's the test. Let's wait for windows users to report.
Expand Down
8 changes: 2 additions & 6 deletions src/interactive/app/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{Context, Error, Result};
use crossbeam::channel::Receiver;
use crosstermion::{crossterm::event::KeyCode, input::Event};
use crossterm::event::{Event, KeyCode};
use dua::{
ByteFormat, TraversalSorting, WalkOptions,
traverse::{EntryData, Tree, TreeIndex},
Expand Down Expand Up @@ -31,11 +31,7 @@
}

pub fn into_keys<'a>(codes: impl IntoIterator<Item = KeyCode> + 'a) -> Receiver<Event> {
into_events(
codes
.into_iter()
.map(|code| crosstermion::input::Event::Key(code.into())),
)
into_events(codes.into_iter().map(|code| Event::Key(code.into())))
}

pub fn into_codes(input: &str) -> Receiver<Event> {
Expand Down Expand Up @@ -80,7 +76,7 @@
index_by_name_and_size(app, name, None)
}

pub struct WritableFixture {

Check warning on line 79 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

struct `WritableFixture` is never constructed

Check warning on line 79 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

struct `WritableFixture` is never constructed
pub root: PathBuf,
}

Expand All @@ -90,7 +86,7 @@
}
}

fn delete_recursive(path: impl AsRef<Path>) -> Result<()> {

Check warning on line 89 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `delete_recursive` is never used

Check warning on line 89 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `delete_recursive` is never used
let mut files: Vec<_> = Vec::new();
let mut dirs: Vec<_> = Vec::new();

Expand Down Expand Up @@ -120,7 +116,7 @@
.collect::<Result<_, _>>()
}

fn copy_recursive(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<(), Error> {

Check warning on line 119 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `copy_recursive` is never used

Check warning on line 119 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `copy_recursive` is never used
for entry in WalkDir::new(&src)
.parallelism(jwalk::Parallelism::Serial)
.into_iter()
Expand Down Expand Up @@ -212,7 +208,7 @@
Terminal::new(TestBackend::new(40, 20))
}

pub fn initialized_app_and_terminal_from_paths(

Check warning on line 211 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `initialized_app_and_terminal_from_paths` is never used

Check warning on line 211 in src/interactive/app/tests/utils.rs

View workflow job for this annotation

GitHub Actions / Windows (nightly)

function `initialized_app_and_terminal_from_paths` is never used
fixture_paths: &[PathBuf],
) -> Result<(Terminal<TestBackend>, TerminalApp), Error> {
fn to_path_buf(p: &Path) -> PathBuf {
Expand Down
10 changes: 5 additions & 5 deletions src/interactive/widgets/entries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use crate::interactive::widgets::COUNT;
use crate::interactive::widgets::tui_ext::util::rect::line_bound;
use crate::interactive::widgets::tui_ext::{
List, ListProps, draw_text_nowrap_fn,
util::{block_width, rect},
};
use crate::interactive::{
DisplayOptions, EntryDataBundle, SortMode,
widgets::{EntryMarkMap, entry_color},
Expand All @@ -16,11 +21,6 @@ use tui::{
text::Span,
widgets::{Block, Borders, Scrollbar, ScrollbarOrientation, ScrollbarState, StatefulWidget},
};
use tui_react::util::rect::line_bound;
use tui_react::{
List, ListProps, draw_text_nowrap_fn,
util::{block_width, rect},
};
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;

Expand Down
23 changes: 11 additions & 12 deletions src/interactive/widgets/glob.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::interactive::widgets::tui_ext::{
draw_text_nowrap_fn,
util::{block_width, rect},
};
use anyhow::{Context, Result, anyhow};
use bstr::BString;
use crosstermion::crossterm::event::KeyEventKind;
use crosstermion::input::Key;
use crossterm::event::{KeyEvent, KeyEventKind};
use dua::traverse::{Tree, TreeIndex};
use gix_glob::pattern::Case;
use petgraph::Direction;
Expand All @@ -13,10 +16,6 @@ use tui::{
text::{Line, Span, Text},
widgets::{Block, Borders, Paragraph, Widget},
};
use tui_react::{
draw_text_nowrap_fn,
util::{block_width, rect},
};
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;

Expand Down Expand Up @@ -48,9 +47,9 @@ impl Default for GlobPane {
}

impl GlobPane {
pub fn process_events(&mut self, key: Key) {
use crosstermion::crossterm::event::KeyCode::*;
use crosstermion::crossterm::event::KeyModifiers;
pub fn process_events(&mut self, key: KeyEvent) {
use crossterm::event::KeyCode::*;
use crossterm::event::KeyModifiers;
if key.kind == KeyEventKind::Release {
return;
}
Expand Down Expand Up @@ -245,19 +244,19 @@ pub fn glob_search(
#[cfg(test)]
mod tests {
use super::*;
use crosstermion::crossterm::event::{KeyCode, KeyEventKind, KeyModifiers};
use crossterm::event::{KeyCode, KeyEventKind, KeyEventState, KeyModifiers};

#[test]
fn ctrl_f_key_types_into_input() {
let mut glob_pane = GlobPane::default();
assert_eq!(glob_pane.input, "");
assert_eq!(glob_pane.case, Case::Fold); // default is case-insensitive

let ctrl_f = Key {
let ctrl_f = KeyEvent {
code: KeyCode::Char('f'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
state: crosstermion::crossterm::event::KeyEventState::empty(),
state: KeyEventState::empty(),
};
glob_pane.process_events(ctrl_f);
assert_eq!(glob_pane.case, Case::Sensitive);
Expand Down
15 changes: 7 additions & 8 deletions src/interactive/widgets/help.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::interactive::CursorDirection;
pub use crosstermion::crossterm::event::KeyCode::*;
use crosstermion::crossterm::event::{KeyEventKind, KeyModifiers};
use crosstermion::input::Key;
use crate::interactive::widgets::tui_ext::{
draw_text_nowrap_fn,
util::{block_width, rect},
};
pub use crossterm::event::KeyCode::*;
use crossterm::event::{KeyEvent, KeyEventKind, KeyModifiers};
use std::{borrow::Borrow, cell::RefCell};
use tui::{
buffer::Buffer,
Expand All @@ -10,10 +13,6 @@ use tui::{
text::{Line, Span, Text},
widgets::{Block, Borders, Paragraph, Widget},
};
use tui_react::{
draw_text_nowrap_fn,
util::{block_width, rect},
};

#[derive(Default, Clone)]
pub struct HelpPane {
Expand All @@ -35,7 +34,7 @@ fn margin(r: Rect, margin: u16) -> Rect {
}

impl HelpPane {
pub fn process_events(&mut self, key: Key) {
pub fn process_events(&mut self, key: KeyEvent) {
if key.kind == KeyEventKind::Release {
return;
}
Expand Down
15 changes: 7 additions & 8 deletions src/interactive/widgets/mark.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use crate::interactive::widgets::COUNT;
use crate::interactive::widgets::tui_ext::{
List, ListProps, draw_text_nowrap_fn,
util::{block_width, rect, rect::line_bound},
};
use crate::interactive::{
CursorDirection, app::tree_view::TreeView, fit_string_graphemes_with_ellipsis,
widgets::entry_color,
};
use crosstermion::crossterm::event::{KeyEventKind, KeyModifiers};
use crosstermion::input::Key;
use crossterm::event::{KeyEvent, KeyEventKind, KeyModifiers};
use dua::{ByteFormat, traverse::TreeIndex};
use itertools::Itertools;
use std::{
Expand All @@ -22,10 +25,6 @@ use tui::{
Widget,
},
};
use tui_react::{
List, ListProps, draw_text_nowrap_fn,
util::{block_width, rect, rect::line_bound},
};
use unicode_segmentation::UnicodeSegmentation;

pub enum MarkMode {
Expand Down Expand Up @@ -116,8 +115,8 @@ impl MarkPane {
pub fn into_paths(self) -> impl Iterator<Item = PathBuf> {
self.marked.into_values().map(|v| v.path)
}
pub fn process_events(mut self, key: Key) -> Option<(Self, Option<MarkMode>)> {
use crosstermion::crossterm::event::KeyCode::*;
pub fn process_events(mut self, key: KeyEvent) -> Option<(Self, Option<MarkMode>)> {
use crossterm::event::KeyCode::*;
let action = None;
if key.kind == KeyEventKind::Release {
return Some((self, action));
Expand Down
1 change: 1 addition & 0 deletions src/interactive/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod header;
mod help;
mod main;
mod mark;
mod tui_ext;

pub use entries::*;
pub use footer::*;
Expand Down
Loading
Loading