mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-12 16:51:40 +00:00
Split out function for --classify character
This commit is contained in:
parent
05a0a5e199
commit
7531b2617c
@ -76,23 +76,32 @@ impl<'a, 'dir> FileName<'a, 'dir> {
|
||||
// Do nothing -- the error gets displayed on the next line
|
||||
}
|
||||
}
|
||||
} else if classify {
|
||||
if self.file.is_executable_file() {
|
||||
bits.push(Style::default().paint("*"));
|
||||
} else if self.file.is_directory() {
|
||||
bits.push(Style::default().paint("/"));
|
||||
} else if self.file.is_pipe() {
|
||||
bits.push(Style::default().paint("|"));
|
||||
} else if self.file.is_link() {
|
||||
bits.push(Style::default().paint("@"));
|
||||
} else if self.file.is_socket() {
|
||||
bits.push(Style::default().paint("="));
|
||||
}
|
||||
else if classify {
|
||||
if let Some(class) = self.classify_char() {
|
||||
bits.push(Style::default().paint(class));
|
||||
}
|
||||
}
|
||||
|
||||
bits.into()
|
||||
}
|
||||
|
||||
fn classify_char(&self) -> Option<&'static str> {
|
||||
if self.file.is_executable_file() {
|
||||
Some("*")
|
||||
} else if self.file.is_directory() {
|
||||
Some("/")
|
||||
} else if self.file.is_pipe() {
|
||||
Some("|")
|
||||
} else if self.file.is_link() {
|
||||
Some("@")
|
||||
} else if self.file.is_socket() {
|
||||
Some("=")
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns at least one ANSI-highlighted string representing this file’s
|
||||
/// name using the given set of colours.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user