Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Luterán Lajos <[email protected]>
  • Loading branch information
luteran42 committed Mar 14, 2024
2 parents e0cd3bf + 9339b90 commit 82d1bc1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 28 deletions.
5 changes: 1 addition & 4 deletions src/config/clean/theme/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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
}

Expand All @@ -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(),
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/config/raw/theme/style.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ lazy_static! {

static ref HOME_DIR: Option<PathBuf> = dirs_next::home_dir();

static ref USERNAME: String = whoami::fallible::realname().unwrap_or("No Username".to_string());
static ref USERNAME: String = whoami::fallible::username().unwrap_or("No Username".to_string());
static ref HOSTNAME: String = whoami::fallible::hostname().unwrap_or("No Hostname".to_string());

static ref TIMEZONE_STR: String = {
Expand Down
6 changes: 2 additions & 4 deletions src/ui/widgets/tui_dirlist_detailed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -118,7 +117,6 @@ impl<'a> Widget for TuiDirListDetailed<'a> {
self.tab_display_options.linemode,
drawing_width - 1,
&prefix,
prefix_width,
);
});
}
Expand All @@ -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 => "",
Expand Down Expand Up @@ -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;

Expand Down
24 changes: 9 additions & 15 deletions src/util/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,29 @@ 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_marked_cut() {
if let Some(cut_mark) = THEME_T.mark.get("cut") {
return (cut_mark.prefix.as_str(), cut_mark.prefix_width);
return &cut_mark.prefix;
}
}
if entry.is_marked_copy() {
if let Some(copy_mark) = THEME_T.mark.get("copy") {
return (copy_mark.prefix.as_str(), copy_mark.prefix_width);
return &copy_mark.prefix;
}
}
if entry.is_marked_sym() {
if let Some(sym_mark) = THEME_T.mark.get("symlink") {
return (sym_mark.prefix.as_str(), sym_mark.prefix_width);
return &sym_mark.prefix;
}
}
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(
Expand Down

0 comments on commit 82d1bc1

Please sign in to comment.