summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzad <49314270+Akmadan23@users.noreply.github.com>2024-03-14 16:32:32 +0100
committerGitHub <noreply@github.com>2024-03-14 11:32:32 -0400
commit9339b90cd4a8b26aaa57d63b90c633f427990745 (patch)
tree7a577bdf6658475cba797d4a7f857f0fc4aed661
parent80c967275cb08971589761134f2f0edcd4661ebc (diff)
fix: restore line numbers (#511)
* fix: restore line numbers * clippy
-rw-r--r--src/config/clean/theme/style.rs5
-rw-r--r--src/config/raw/theme/style.rs5
-rw-r--r--src/ui/widgets/tui_dirlist_detailed.rs6
-rw-r--r--src/util/style.rs18
4 files changed, 10 insertions, 24 deletions
diff --git a/src/config/clean/theme/style.rs b/src/config/clean/theme/style.rs
index 89f0919..67f95be 100644
--- a/src/config/clean/theme/style.rs
+++ b/src/config/clean/theme/style.rs
@@ -9,7 +9,6 @@ pub struct AppStyle {
pub fg: style::Color,
pub bg: style::Color,
pub prefix: String,
- pub prefix_width: usize,
pub modifier: style::Modifier,
}
@@ -22,9 +21,8 @@ impl AppStyle {
self.fg = fg;
self
}
- pub fn set_prefix(mut self, prefix: String, prefix_width: usize) -> Self {
+ pub fn set_prefix(mut self, prefix: String) -> Self {
self.prefix = prefix;
- self.prefix_width = prefix_width;
self
}
@@ -44,7 +42,6 @@ impl std::default::Default for AppStyle {
fg: default_color(),
bg: default_color(),
prefix: String::new(),
- prefix_width: 0,
modifier: style::Modifier::empty(),
}
}
diff --git a/src/config/raw/theme/style.rs b/src/config/raw/theme/style.rs
index fe4d6a8..9c5c144 100644
--- a/src/config/raw/theme/style.rs
+++ b/src/config/raw/theme/style.rs
@@ -1,7 +1,6 @@
use colors_transform::{Color, Rgb};
use ratatui::style::{self, Style};
use serde::Deserialize;
-use unicode_width::UnicodeWidthStr;
use crate::config::clean::theme::style::AppStyle;
@@ -111,8 +110,6 @@ impl AppStyleRaw {
pub fn to_style_theme(&self) -> AppStyle {
let bg = Self::str_to_color(self.bg.as_str());
let fg = Self::str_to_color(self.fg.as_str());
- let prefix = self.prefix.clone();
- let prefix_width = prefix.width();
let mut modifier = style::Modifier::empty();
if self.bold {
@@ -128,7 +125,7 @@ impl AppStyleRaw {
AppStyle::default()
.set_fg(fg)
.set_bg(bg)
- .set_prefix(prefix, prefix_width)
+ .set_prefix(self.prefix.clone())
.insert(modifier)
}
diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs
index 7b31300..0318a19 100644
--- a/src/ui/widgets/tui_dirlist_detailed.rs
+++ b/src/ui/widgets/tui_dirlist_detailed.rs
@@ -95,8 +95,7 @@ impl<'a> Widget for TuiDirListDetailed<'a> {
buf.set_string(x, y + i as u16, space_fill.as_str(), style);
- let (prefix, prefix_width) = style::entry_prefix(entry);
- let mut prefix = prefix.to_string();
+ let mut prefix = style::entry_prefix(entry).to_string();
let line_number_prefix = match line_num_style {
LineNumberStyle::None => "".to_string(),
_ if ix == curr_index => format!("{:<1$} ", curr_index + 1, max_index_length),
@@ -118,7 +117,6 @@ impl<'a> Widget for TuiDirListDetailed<'a> {
self.tab_display_options.linemode,
drawing_width - 1,
&prefix,
- prefix_width,
);
});
}
@@ -145,7 +143,6 @@ fn print_entry(
linemode: LineMode,
drawing_width: usize,
prefix: &str,
- prefix_width: usize,
) {
let symlink_string = match entry.metadata.link_type() {
LinkType::Normal => "",
@@ -185,6 +182,7 @@ fn print_entry(
);
// draw prefix first
+ let prefix_width = prefix.width();
buf.set_stringn(x, y, prefix, prefix_width, Style::default());
let x = x + prefix_width as u16;
diff --git a/src/util/style.rs b/src/util/style.rs
index 058a9a9..bf695a2 100644
--- a/src/util/style.rs
+++ b/src/util/style.rs
@@ -48,20 +48,14 @@ pub fn entry_style(config: &AppConfig, entry: &JoshutoDirEntry) -> Style {
}
}
-pub fn entry_prefix(entry: &JoshutoDirEntry) -> (&str, usize) {
+pub fn entry_prefix(entry: &JoshutoDirEntry) -> &str {
if entry.is_visual_mode_selected() {
- return (
- THEME_T.visual_mode_selection.prefix.as_str(),
- THEME_T.visual_mode_selection.prefix_width,
- );
- }
- if entry.is_permanent_selected() {
- return (
- THEME_T.selection.prefix.as_str(),
- THEME_T.selection.prefix_width,
- );
+ &THEME_T.visual_mode_selection.prefix
+ } else if entry.is_permanent_selected() {
+ &THEME_T.selection.prefix
+ } else {
+ ""
}
- ("", 0)
}
fn default_style(