Skip to content

update all dependencies #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
984 changes: 546 additions & 438 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ license = "MIT"
edition = "2018"

[dependencies]
tui = {version="0.11", default-features = false, features = ['crossterm'] }
crossterm = "0.17"
tui = { package = "ratatui", version = "0.26", default-features = false, features = ['crossterm'] }
crossterm = "0.27"
failure = "0.1"
jwalk = "0.5"
structopt = "0.3"
jwalk = "0.8"
clap = { version = "4", features = ["derive" ] }
filesize = "0.2.0"
unicode-width = "0.1.7"
nix = "0.17.0"
unicode-width = "0.2"
nix = { version = "0.29.0", features = ["user"] }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["securitybaseapi","debugapi"] }

[dev-dependencies]
insta = "0.16.0"
insta = "1"
4 changes: 4 additions & 0 deletions src/input/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@ macro_rules! key {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::NONE,
..
})
};
(shift $x:expr) => {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::SHIFT,
..
})
};
(ctrl $x:expr) => {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::CONTROL,
..
})
};
($x:ident) => {
Event::Key(KeyEvent {
code: KeyCode::$x,
modifiers: KeyModifiers::NONE,
..
})
};
}
Expand Down
19 changes: 11 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use ::std::sync::mpsc::{Receiver, SyncSender};
use ::std::sync::Arc;
use ::std::thread::park_timeout;
use ::std::{thread, time};
use ::structopt::StructOpt;
use ::clap::Parser;

use ::tui::backend::Backend;
use crossterm::event::KeyModifiers;
Expand All @@ -46,16 +46,16 @@ const SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS: bool = true;
#[cfg(test)]
const SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS: bool = false;

#[derive(StructOpt, Debug)]
#[structopt(name = "diskonaut")]
#[derive(Debug, Parser)]
#[clap(name = "diskonaut")]
pub struct Opt {
#[structopt(name = "folder", parse(from_os_str))]
#[clap(name = "folder")]
/// The folder to scan
folder: Option<PathBuf>,
#[structopt(short, long)]
#[clap(short, long)]
/// Show file sizes rather than their block usage on disk
apparent_size: bool,
#[structopt(short, long)]
#[clap(short, long)]
/// Don't ask for confirmation before deleting
disable_delete_confirmation: bool,
}
Expand All @@ -71,7 +71,7 @@ fn get_stdout() -> io::Result<io::Stdout> {
}

fn try_main() -> Result<(), failure::Error> {
let opts = Opt::from_args();
let opts = Opt::parse();

match get_stdout() {
Ok(stdout) => {
Expand Down Expand Up @@ -149,14 +149,17 @@ pub fn start<B>(
if let BackEvent::Key(KeyEvent {
code: KeyCode::Char('y'),
modifiers: KeyModifiers::NONE,
..
})
| BackEvent::Key(KeyEvent {
code: KeyCode::Char('q'),
modifiers: KeyModifiers::NONE,
..
})
| BackEvent::Key(KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
..
}) = evt
{
// not ideal, but works in a pinch
Expand Down Expand Up @@ -189,7 +192,7 @@ pub fn start<B>(
move || {
'scanning: for entry in WalkDir::new(&path)
.parallelism(if SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS {
RayonDefaultPool
RayonDefaultPool { busy_timeout: std::time::Duration::from_secs(1) }
} else {
Serial
})
Expand Down
8 changes: 7 additions & 1 deletion src/tests/cases/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ::std::iter;
use ::std::sync::{Arc, Mutex};
use crossterm::event::KeyModifiers;
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyEventState};

use crate::tests::fakes::{TerminalEvent, TerminalEvents, TestBackend};

Expand All @@ -10,18 +10,24 @@ macro_rules! key {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
(ctrl $x:expr) => {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
($x:ident) => {
Event::Key(KeyEvent {
code: KeyCode::$x,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
}
Expand Down
8 changes: 7 additions & 1 deletion src/tests/cases/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ::std::path::{Path, PathBuf};

use ::insta::assert_snapshot;
use crossterm::event::KeyModifiers;
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyEventState};

use crate::start;
use crate::tests::cases::test_utils::*;
Expand All @@ -18,18 +18,24 @@ macro_rules! key {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
(ctrl $x:expr) => {
Event::Key(KeyEvent {
code: KeyCode::Char($x),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
($x:ident) => {
Event::Key(KeyEvent {
code: KeyCode::$x,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
state: KeyEventState::empty(),
})
};
}
Expand Down
19 changes: 16 additions & 3 deletions src/tests/fakes/fake_output.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use ::std::collections::HashMap;
use ::std::io;
use ::std::sync::{Arc, Mutex};
use ::tui::backend::Backend;
use ::tui::backend::{Backend, WindowSize};
use ::tui::buffer::Cell;
use ::tui::layout::Rect;
use ::tui::layout::{Rect, Size};

#[derive(Hash, Debug, PartialEq)]
pub enum TerminalEvent {
Expand Down Expand Up @@ -87,7 +87,7 @@ impl Backend for TestBackend {
Some(cell) => {
// this will contain no style information at all
// should be good enough for testing
string.push_str(&cell.symbol);
string.push_str(cell.symbol());
}
None => {
string.push_str(" ");
Expand All @@ -111,4 +111,17 @@ impl Backend for TestBackend {
self.events.lock().unwrap().push(TerminalEvent::Flush);
Ok(())
}

fn window_size(&mut self) -> io::Result<WindowSize> {
Ok(WindowSize {
columns_rows: Size {
width: 80,
height: 24,
},
pixels: Size {
width: 0,
height: 0,
}
})
}
}
3 changes: 2 additions & 1 deletion src/ui/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ where
]
.as_ref(),
)
.split(full_screen);
.split(full_screen)
.to_vec();

// -1 cos we draw starting at offset 1 in both x and y directions

Expand Down
2 changes: 1 addition & 1 deletion src/ui/grid/draw_next_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn find_next_symbol(first_symbol: &str, second_symbol: &str) -> Option<&'static
}

pub fn draw_next_symbol(buf: &mut Buffer, x: u16, y: u16, symbol: &str) {
if let Some(next_symbol) = find_next_symbol(&buf.get(x, y).symbol, symbol) {
if let Some(next_symbol) = find_next_symbol(buf.get(x, y).symbol(), symbol) {
buf.get_mut(x, y).set_symbol(next_symbol);
} else {
buf.get_mut(x, y).set_symbol(symbol);
Expand Down