summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2023-12-10 09:08:12 +0100
committerSebastian Thiel <sebastian.thiel@icloud.com>2023-12-10 09:08:12 +0100
commit81eadf8cdfcfa964401b5cf5d1e80cc21ec4441f (patch)
tree43925bf57048fdbebe076125894a50f5877b99be /src
parent2c69ea1faf40499431616e632e02351a22bac249 (diff)
refactor
Use a single version of the COUNT formatter.
Diffstat (limited to 'src')
-rw-r--r--src/interactive/widgets/entries.rs9
-rw-r--r--src/interactive/widgets/mark.rs9
-rw-r--r--src/interactive/widgets/mod.rs7
3 files changed, 9 insertions, 16 deletions
diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs
index 9357587..e50a0a1 100644
--- a/src/interactive/widgets/entries.rs
+++ b/src/interactive/widgets/entries.rs
@@ -1,3 +1,4 @@
+use crate::interactive::widgets::COUNT;
use crate::interactive::{
path_of,
widgets::{entry_color, EntryMarkMap},
@@ -5,9 +6,7 @@ use crate::interactive::{
};
use chrono::DateTime;
use dua::traverse::{EntryData, Tree, TreeIndex};
-use human_format;
use itertools::Itertools;
-use once_cell::sync::Lazy;
use std::time::SystemTime;
use std::{borrow::Borrow, path::Path};
use tui::{
@@ -24,12 +23,6 @@ use tui_react::{
List, ListProps,
};
-static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
- let mut formatter = human_format::Formatter::new();
- formatter.with_decimals(0).with_separator("");
- formatter
-});
-
pub struct EntriesProps<'a> {
pub tree: &'a Tree,
pub root: TreeIndex,
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index eac0c76..ffb5143 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -1,3 +1,4 @@
+use crate::interactive::widgets::COUNT;
use crate::interactive::{
fit_string_graphemes_with_ellipsis, path_of, widgets::entry_color, CursorDirection,
};
@@ -6,9 +7,7 @@ use dua::{
traverse::{Tree, TreeIndex},
ByteFormat,
};
-use human_format;
use itertools::Itertools;
-use once_cell::sync::Lazy;
use std::{
borrow::Borrow,
collections::{btree_map::Entry, BTreeMap},
@@ -28,12 +27,6 @@ use tui_react::{
};
use unicode_segmentation::UnicodeSegmentation;
-static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
- let mut formatter = human_format::Formatter::new();
- formatter.with_decimals(0).with_separator("");
- formatter
-});
-
pub enum MarkMode {
Delete,
#[cfg(feature = "trash-move")]
diff --git a/src/interactive/widgets/mod.rs b/src/interactive/widgets/mod.rs
index 2c11ff1..29d32aa 100644
--- a/src/interactive/widgets/mod.rs
+++ b/src/interactive/widgets/mod.rs
@@ -11,12 +11,19 @@ pub use header::*;
pub use help::*;
pub use main::*;
pub use mark::*;
+use once_cell::sync::Lazy;
use tui::style::Color;
pub const COLOR_MARKED: Color = Color::Yellow;
pub const COLOR_MARKED_DARK: Color = Color::Rgb(176, 126, 0);
+static COUNT: Lazy<human_format::Formatter> = Lazy::new(|| {
+ let mut formatter = human_format::Formatter::new();
+ formatter.with_decimals(0).with_separator("");
+ formatter
+});
+
fn entry_color(fg: Option<Color>, is_file: bool, is_marked: bool) -> Option<Color> {
match (is_file, is_marked) {
(true, false) => fg,