mirror of
https://github.com/bobwen-dev/hunter
synced 2025-04-12 00:55:41 +02:00
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 select_cmd: String,
|
||||||
pub cd_cmd: String,
|
pub cd_cmd: String,
|
||||||
pub icons: bool,
|
pub icons: bool,
|
||||||
|
pub icons_space: bool,
|
||||||
pub media_autoplay: bool,
|
pub media_autoplay: bool,
|
||||||
pub media_mute: bool,
|
pub media_mute: bool,
|
||||||
pub media_previewer: String,
|
pub media_previewer: String,
|
||||||
@ -113,6 +114,7 @@ impl Config {
|
|||||||
select_cmd: "find -type f | fzf -m".to_string(),
|
select_cmd: "find -type f | fzf -m".to_string(),
|
||||||
cd_cmd: "find -type d | fzf".to_string(),
|
cd_cmd: "find -type d | fzf".to_string(),
|
||||||
icons: false,
|
icons: false,
|
||||||
|
icons_space: false,
|
||||||
media_autoplay: false,
|
media_autoplay: false,
|
||||||
media_mute: false,
|
media_mute: false,
|
||||||
media_previewer: "hunter-media".to_string(),
|
media_previewer: "hunter-media".to_string(),
|
||||||
@ -146,6 +148,8 @@ impl Config {
|
|||||||
Ok(("show_hidden", "off")) => config.show_hidden = false,
|
Ok(("show_hidden", "off")) => config.show_hidden = false,
|
||||||
Ok(("icons", "on")) => config.icons = true,
|
Ok(("icons", "on")) => config.icons = true,
|
||||||
Ok(("icons", "off")) => config.icons = false,
|
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)) => {
|
Ok(("select_cmd", cmd)) => {
|
||||||
let cmd = cmd.to_string();
|
let cmd = cmd.to_string();
|
||||||
config.select_cmd = cmd;
|
config.select_cmd = cmd;
|
||||||
|
@ -744,14 +744,17 @@ impl ListView<Files>
|
|||||||
use crate::files::FileError;
|
use crate::files::FileError;
|
||||||
|
|
||||||
let xsize = self.get_coordinates().unwrap().xsize();
|
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 {
|
move |file| -> String {
|
||||||
let mut line = String::with_capacity(500);
|
let mut line = String::with_capacity(500);
|
||||||
|
|
||||||
let icon = match icons {
|
let (icon, icon_space) = match (icons, icons_space) {
|
||||||
true => file.icon(),
|
(true, true) => (file.icon(), " "),
|
||||||
false => ""
|
(true, false) => (file.icon(), ""),
|
||||||
|
_ => ("", "")
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = &file.name;
|
let name = &file.name;
|
||||||
@ -805,27 +808,30 @@ impl ListView<Files>
|
|||||||
let padding = xsize - padding as u16;
|
let padding = xsize - padding as u16;
|
||||||
let padding = padding - tag_len;
|
let padding = padding - tag_len;
|
||||||
let padding = padding - icon.width() as u16;
|
let padding = padding - icon.width() as u16;
|
||||||
|
let padding = padding - icon_space.len() as u16;
|
||||||
|
|
||||||
write!(&mut line, "{}", termion::cursor::Save).unwrap();
|
write!(&mut line, "{}", termion::cursor::Save).unwrap();
|
||||||
|
|
||||||
match file.get_color() {
|
match file.get_color() {
|
||||||
Some(color) => write!(&mut line,
|
Some(color) => write!(&mut line,
|
||||||
"{}{}{}{}{}{:padding$}{}",
|
"{}{}{}{}{}{}{:padding$}{}",
|
||||||
tag,
|
tag,
|
||||||
&color,
|
&color,
|
||||||
selection_color,
|
selection_color,
|
||||||
selection_gap,
|
selection_gap,
|
||||||
icon,
|
icon,
|
||||||
|
icon_space,
|
||||||
&sized_string,
|
&sized_string,
|
||||||
term::normal_color(),
|
term::normal_color(),
|
||||||
padding = padding as usize),
|
padding = padding as usize),
|
||||||
_ => write!(&mut line,
|
_ => write!(&mut line,
|
||||||
"{}{}{}{}{}{:padding$}{}",
|
"{}{}{}{}{}{}{:padding$}{}",
|
||||||
tag,
|
tag,
|
||||||
term::normal_color(),
|
term::normal_color(),
|
||||||
selection_color,
|
selection_color,
|
||||||
selection_gap,
|
selection_gap,
|
||||||
icon,
|
icon,
|
||||||
|
icon_space ,
|
||||||
&sized_string,
|
&sized_string,
|
||||||
term::normal_color(),
|
term::normal_color(),
|
||||||
padding = padding as usize),
|
padding = padding as usize),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user