summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-07-25 09:53:56 +0800
committerSebastian Thiel <sthiel@thoughtworks.com>2019-07-25 09:53:56 +0800
commitfa7daf1be9b67d70c3cde64cecdd4a76d2e8082b (patch)
treee5d57a85039180b3dc12f996bda4fe5fde38d711
parent3baf7f31b91c71ba0acb2be886a47ccbd2b295fb (diff)
Run rustfmt; use debug_assert; rename function
-rw-r--r--src/interactive/app/handlers.rs8
-rw-r--r--src/interactive/widgets/entries.rs10
-rw-r--r--src/interactive/widgets/header.rs4
-rw-r--r--src/interactive/widgets/mark.rs8
-rw-r--r--src/interactive/widgets/mod.rs4
5 files changed, 18 insertions, 16 deletions
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index 67a9b8e..843b186 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -161,7 +161,13 @@ impl TerminalApp {
pub fn mark_entry(&mut self, advance_cursor: bool) {
if let Some(index) = self.state.selected {
- let is_dir = self.state.entries.iter().find(|e| e.index == index).unwrap().is_dir;
+ let is_dir = self
+ .state
+ .entries
+ .iter()
+ .find(|e| e.index == index)
+ .unwrap()
+ .is_dir;
if let Some(pane) = self.window.mark_pane.take() {
self.window.mark_pane = pane.toggle_index(index, &self.traversal.tree, is_dir);
} else {
diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs
index b4274f2..2fbccc7 100644
--- a/src/interactive/widgets/entries.rs
+++ b/src/interactive/widgets/entries.rs
@@ -1,8 +1,6 @@
use crate::interactive::{
path_of,
- widgets::{
- get_name_color, EntryMarkMap,
- },
+ widgets::{entry_color, EntryMarkMap},
DisplayOptions, EntryDataBundle,
};
use dua::traverse::{Tree, TreeIndex};
@@ -11,7 +9,7 @@ use std::{borrow::Borrow, path::Path};
use tui::{
buffer::Buffer,
layout::Rect,
- style::{Color, Style, Modifier},
+ style::{Color, Modifier, Style},
widgets::{Block, Borders, Text},
};
use tui_react::{fill_background_to_right, List, ListProps};
@@ -147,10 +145,10 @@ impl Entries {
// non-existing - always red!
Color::Red
} else {
- get_name_color(style.fg, !is_dir, is_marked)
+ entry_color(style.fg, !is_dir, is_marked)
};
Style { fg, ..style }
- }
+ },
);
vec![bytes, percentage, name]
},
diff --git a/src/interactive/widgets/header.rs b/src/interactive/widgets/header.rs
index fca6f8f..75f72a4 100644
--- a/src/interactive/widgets/header.rs
+++ b/src/interactive/widgets/header.rs
@@ -9,12 +9,12 @@ pub struct Header;
impl Header {
pub fn render(&self, bg_color: Color, area: Rect, buf: &mut Buffer) {
- let standard = Style{
+ let standard = Style {
fg: Color::Black,
bg: bg_color,
..Default::default()
};
- assert_ne!(standard.bg, standard.fg);
+ debug_assert_ne!(standard.bg, standard.fg);
let modified = |text: &'static str, modifier| {
Text::Styled(
text.into(),
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index 702c187..8f8ef7c 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -1,7 +1,5 @@
use crate::interactive::{
- fit_string_graphemes_with_ellipsis, path_of,
- widgets::get_name_color,
- CursorDirection,
+ fit_string_graphemes_with_ellipsis, path_of, widgets::entry_color, CursorDirection,
};
use dua::{
traverse::{Tree, TreeIndex},
@@ -234,7 +232,7 @@ impl MarkPane {
modifier,
..Default::default()
}
- },
+ }
_ => Style::default(),
};
let (path, path_len) = {
@@ -260,7 +258,7 @@ impl MarkPane {
_ => (path, num_path_graphemes),
}
};
- let fg_path = get_name_color(Color::Reset, !v.is_dir, true);
+ let fg_path = entry_color(Color::Reset, !v.is_dir, true);
let path = Text::Styled(
path.into(),
Style {
diff --git a/src/interactive/widgets/mod.rs b/src/interactive/widgets/mod.rs
index b9c72f5..5e37423 100644
--- a/src/interactive/widgets/mod.rs
+++ b/src/interactive/widgets/mod.rs
@@ -17,8 +17,8 @@ use tui::style::Color;
pub const COLOR_MARKED: Color = Color::Yellow;
pub const COLOR_MARKED_DARK: Color = Color::Rgb(176, 126, 0);
-fn get_name_color(fg: Color, is_file: bool, is_marked: bool) -> Color {
- match (is_file, is_marked) {
+fn entry_color(fg: Color, is_file: bool, is_marked: bool) -> Color {
+ match (is_file, is_marked) {
(true, false) => Color::DarkGray,
(true, true) => COLOR_MARKED_DARK,
(false, true) => COLOR_MARKED,