some icons
This commit is contained in:
@@ -4,11 +4,10 @@ use crate::utils::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn list(elements: Vec<Element>, recursive_limit: usize) {
|
pub fn list(elements: Vec<Element>, recursive_limit: usize) {
|
||||||
// elements.sort_unstable_by_key(|a: &Element| a.get_name());
|
|
||||||
let width = term_size::dimensions().unwrap().0;
|
|
||||||
// ╭──────────────╼ File name ╾──────────────┬─╼ Size ╾─┬──╼ Creation ╾──╮
|
// ╭──────────────╼ File name ╾──────────────┬─╼ Size ╾─┬──╼ Creation ╾──╮
|
||||||
// │ some_example_file │ 420.69 G │ 01-01-70 00:00 │
|
// │ some_example_file │ 420.69 G │ 01-01-70 00:00 │
|
||||||
// ╰─────────────────────────────────────────┴──────────┴────────────────╯
|
// ╰─────────────────────────────────────────┴──────────┴────────────────╯
|
||||||
|
let width = term_size::dimensions().unwrap().0;
|
||||||
|
|
||||||
let name_max_len = get_max_width(&elements, recursive_limit, 0);
|
let name_max_len = get_max_width(&elements, recursive_limit, 0);
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ fn print_elements(
|
|||||||
|
|
||||||
let num_splits =
|
let num_splits =
|
||||||
get_string_length(e.get_name().as_str()) / (name_length - (3 + 2 * current_depth));
|
get_string_length(e.get_name().as_str()) / (name_length - (3 + 2 * current_depth));
|
||||||
// println!("{}", num_splits + 1);
|
|
||||||
for j in 1..num_splits + 1 {
|
for j in 1..num_splits + 1 {
|
||||||
let mut e_name = String::from("│ ");
|
let mut e_name = String::from("│ ");
|
||||||
if current_depth > 0 {
|
if current_depth > 0 {
|
||||||
@@ -118,7 +117,6 @@ fn add_recursive_lines(e_string: &mut String, is_last_element: &[bool], is_last:
|
|||||||
if is_last {
|
if is_last {
|
||||||
e_string.push_str("╰─");
|
e_string.push_str("╰─");
|
||||||
} else {
|
} else {
|
||||||
// println!("yahooo");
|
|
||||||
e_string.push_str("├─");
|
e_string.push_str("├─");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +143,6 @@ fn add_recursive_lines_for_name_resize(
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_slice_of_string(e: &str, name_length: usize, i: usize, _current_depth: usize) -> String {
|
fn get_slice_of_string(e: &str, name_length: usize, i: usize, _current_depth: usize) -> String {
|
||||||
// println!("--{}--", e);
|
|
||||||
e.chars().collect::<Vec<char>>()[((name_length) * i).min(get_string_length(e))
|
e.chars().collect::<Vec<char>>()[((name_length) * i).min(get_string_length(e))
|
||||||
..((name_length) * (i + 1)).min(get_string_length(e))]
|
..((name_length) * (i + 1)).min(get_string_length(e))]
|
||||||
.iter()
|
.iter()
|
||||||
@@ -165,7 +162,6 @@ fn print_size_and_creation_date(e: &Element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn print_footer(num_elements: usize, name_length: usize) {
|
fn print_footer(num_elements: usize, name_length: usize) {
|
||||||
// let num_elements = elements.len();
|
|
||||||
let num_elements_len = (num_elements as f32).log10() as usize;
|
let num_elements_len = (num_elements as f32).log10() as usize;
|
||||||
let name_length_fixed = name_length - (num_elements_len + 13);
|
let name_length_fixed = name_length - (num_elements_len + 13);
|
||||||
print!("╰");
|
print!("╰");
|
||||||
|
|||||||
15
src/utils.rs
15
src/utils.rs
@@ -16,8 +16,6 @@ pub fn get_elements_from_path(path: String, all: bool) -> Vec<Element> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn pad_string(s: String, pad: usize, after: bool) -> String {
|
pub fn pad_string(s: String, pad: usize, after: bool) -> String {
|
||||||
// println!("{}", pad);
|
|
||||||
|
|
||||||
let mut s2 = String::new();
|
let mut s2 = String::new();
|
||||||
let s_length = get_string_length(&s);
|
let s_length = get_string_length(&s);
|
||||||
if after {
|
if after {
|
||||||
@@ -57,20 +55,25 @@ pub fn system_time_to_string(system_time: SystemTime) -> String {
|
|||||||
datetime.format("%d-%m-%y %H:%M").to_string()
|
datetime.format("%d-%m-%y %H:%M").to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ALL ICONS MUST BE FOLLOWED BY A SPACE
|
||||||
pub fn get_icon_file_type<'a>(filename: String) -> &'a str {
|
pub fn get_icon_file_type<'a>(filename: String) -> &'a str {
|
||||||
let extension = filename.split('.').collect::<Vec<&str>>()[1..].join(".");
|
let extension = filename.split('.').last().unwrap(); //.collect::<Vec<&str>>()[1..].join(".");
|
||||||
match extension.to_lowercase().as_str() {
|
match extension.to_lowercase().as_str() {
|
||||||
"jpg" | "jpeg" | "png" | "bmp" | "gif" | "webp" | "svg" => " ",
|
"jpg" | "jpeg" | "png" | "bmp" | "gif" | "webp" | "svg" => " ",
|
||||||
"zip" | "rar" | "7zip" | "tar" | "tar.gz" | "tgz" => " ",
|
"zip" | "rar" | "7zip" | "tar" | "gz" | "tgz" => " ",
|
||||||
"flv" | "avi" | "mp4" | "webm" | "mov" => " ",
|
"flv" | "avi" | "mp4" | "webm" | "mov" => " ",
|
||||||
"exe" | "ini" | "bat" => " ",
|
"config" | "toml" | "yaml" | "conf" => " ",
|
||||||
|
"exe" | "bat" | "dll" => " ",
|
||||||
"java" | "jar" => " ",
|
"java" | "jar" => " ",
|
||||||
"json" => " ",
|
"json" => " ",
|
||||||
"html" => " ",
|
"html" => " ",
|
||||||
"csv" => " ",
|
"csv" => " ",
|
||||||
"cpp" => " ",
|
"cpp" => " ",
|
||||||
"pdf" => " ",
|
"pdf" => " ",
|
||||||
"css" => " ",
|
"css" => " ",
|
||||||
|
"bin" => " ",
|
||||||
|
"asm" => " ",
|
||||||
|
"txt" => " ",
|
||||||
"rs" => " ",
|
"rs" => " ",
|
||||||
"py" => " ",
|
"py" => " ",
|
||||||
"js" => " ",
|
"js" => " ",
|
||||||
|
|||||||
Reference in New Issue
Block a user