mirror of https://github.com/bobwen-dev/hunter
add option to separate icon and file name with a space
This commit is contained in:
parent
edc2def611
commit
84d7773205
|
@ -88,6 +88,7 @@ pub struct Config {
|
|||
pub select_cmd: String,
|
||||
pub cd_cmd: String,
|
||||
pub icons: bool,
|
||||
pub icons_space: bool,
|
||||
pub media_autoplay: bool,
|
||||
pub media_mute: bool,
|
||||
pub media_previewer: String,
|
||||
|
@ -113,6 +114,7 @@ impl Config {
|
|||
select_cmd: "find -type f | fzf -m".to_string(),
|
||||
cd_cmd: "find -type d | fzf".to_string(),
|
||||
icons: false,
|
||||
icons_space: false,
|
||||
media_autoplay: false,
|
||||
media_mute: false,
|
||||
media_previewer: "hunter-media".to_string(),
|
||||
|
@ -146,6 +148,8 @@ impl Config {
|
|||
Ok(("show_hidden", "off")) => config.show_hidden = false,
|
||||
Ok(("icons", "on")) => config.icons = true,
|
||||
Ok(("icons", "off")) => config.icons = false,
|
||||
Ok(("icons_space", "on")) => config.icons_space = true,
|
||||
Ok(("icons_space", "off")) => config.icons_space = false,
|
||||
Ok(("select_cmd", cmd)) => {
|
||||
let cmd = cmd.to_string();
|
||||
config.select_cmd = cmd;
|
||||
|
|
|
@ -744,14 +744,17 @@ impl ListView<Files>
|
|||
use crate::files::FileError;
|
||||
|
||||
let xsize = self.get_coordinates().unwrap().xsize();
|
||||
let icons = self.core.config().icons;
|
||||
let config = self.core.config();
|
||||
let icons = config.icons;
|
||||
let icons_space = config.icons_space;
|
||||
|
||||
move |file| -> String {
|
||||
let mut line = String::with_capacity(500);
|
||||
|
||||
let icon = match icons {
|
||||
true => file.icon(),
|
||||
false => ""
|
||||
let (icon, icon_space) = match (icons, icons_space) {
|
||||
(true, true) => (file.icon(), " "),
|
||||
(true, false) => (file.icon(), ""),
|
||||
_ => ("", "")
|
||||
};
|
||||
|
||||
let name = &file.name;
|
||||
|
@ -805,27 +808,30 @@ impl ListView<Files>
|
|||
let padding = xsize - padding as u16;
|
||||
let padding = padding - tag_len;
|
||||
let padding = padding - icon.width() as u16;
|
||||
let padding = padding - icon_space.len() as u16;
|
||||
|
||||
write!(&mut line, "{}", termion::cursor::Save).unwrap();
|
||||
|
||||
match file.get_color() {
|
||||
Some(color) => write!(&mut line,
|
||||
"{}{}{}{}{}{:padding$}{}",
|
||||
"{}{}{}{}{}{}{:padding$}{}",
|
||||
tag,
|
||||
&color,
|
||||
selection_color,
|
||||
selection_gap,
|
||||
icon,
|
||||
icon_space,
|
||||
&sized_string,
|
||||
term::normal_color(),
|
||||
padding = padding as usize),
|
||||
_ => write!(&mut line,
|
||||
"{}{}{}{}{}{:padding$}{}",
|
||||
"{}{}{}{}{}{}{:padding$}{}",
|
||||
tag,
|
||||
term::normal_color(),
|
||||
selection_color,
|
||||
selection_gap,
|
||||
icon,
|
||||
icon_space ,
|
||||
&sized_string,
|
||||
term::normal_color(),
|
||||
padding = padding as usize),
|
||||
|
|
Loading…
Reference in New Issue