mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-12 23:46:30 +00:00
I like aligning things
This commit is contained in:
parent
d72be30c30
commit
5b7124bb71
@ -30,13 +30,13 @@ impl Column {
|
||||
pub fn header(&self) -> &'static str {
|
||||
match *self {
|
||||
Column::Permissions => "Permissions",
|
||||
Column::FileName => "Name",
|
||||
Column::FileName => "Name",
|
||||
Column::FileSize(_) => "Size",
|
||||
Column::Blocks => "Blocks",
|
||||
Column::User => "User",
|
||||
Column::Group => "Group",
|
||||
Column::HardLinks => "Links",
|
||||
Column::Inode => "inode",
|
||||
Column::Blocks => "Blocks",
|
||||
Column::User => "User",
|
||||
Column::Group => "Group",
|
||||
Column::HardLinks => "Links",
|
||||
Column::Inode => "inode",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ impl Column {
|
||||
impl Alignment {
|
||||
pub fn pad_string(&self, string: &String, padding: uint) -> String {
|
||||
match *self {
|
||||
Alignment::Left => string.clone() + " ".repeat(padding).as_slice(),
|
||||
Alignment::Left => string.clone() + " ".repeat(padding).as_slice(),
|
||||
Alignment::Right => " ".repeat(padding) + string.as_slice(),
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,8 @@ impl<'a> Dir<'a> {
|
||||
|
||||
for path in self.contents.iter() {
|
||||
match File::from_path(path, self) {
|
||||
Ok(file) => {
|
||||
files.push(file);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}: {}", path.display(), e);
|
||||
}
|
||||
Ok(file) => files.push(file),
|
||||
Err(e) => println!("{}: {}", path.display(), e),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl Options {
|
||||
getopts::optflag("l", "long", "display extended details and attributes"),
|
||||
getopts::optflag("i", "inode", "show each file's inode number"),
|
||||
getopts::optflag("r", "reverse", "reverse order of files"),
|
||||
getopts::optopt("s", "sort", "field to sort by", "WORD"),
|
||||
getopts::optopt ("s", "sort", "field to sort by", "WORD"),
|
||||
getopts::optflag("S", "blocks", "show number of file system blocks"),
|
||||
getopts::optflag("x", "across", "sort multi-column view entries across"),
|
||||
];
|
||||
@ -61,11 +61,11 @@ impl Options {
|
||||
Err(f) => Err(f),
|
||||
Ok(ref matches) => Ok(Options {
|
||||
show_invisibles: matches.opt_present("all"),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
header: matches.opt_present("header"),
|
||||
sort_field: matches.opt_str("sort").map(|word| SortField::from_word(word)).unwrap_or(SortField::Name),
|
||||
dirs: if matches.free.is_empty() { vec![ ".".to_string() ] } else { matches.free.clone() },
|
||||
view: Options::view(matches),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
header: matches.opt_present("header"),
|
||||
sort_field: matches.opt_str("sort").map(|word| SortField::from_word(word)).unwrap_or(SortField::Name),
|
||||
dirs: if matches.free.is_empty() { vec![ ".".to_string() ] } else { matches.free.clone() },
|
||||
view: Options::view(matches),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,8 @@ impl Options {
|
||||
fn should_display(&self, f: &File) -> bool {
|
||||
if self.show_invisibles {
|
||||
true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
!f.name.as_slice().starts_with(".")
|
||||
}
|
||||
}
|
||||
@ -134,7 +135,7 @@ impl Options {
|
||||
SortField::Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)),
|
||||
SortField::FileInode => files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)),
|
||||
SortField::Extension => files.sort_by(|a, b| {
|
||||
let exts = a.ext.clone().map(|e| e.to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.to_ascii_lower()));
|
||||
let exts = a.ext.clone().map(|e| e.to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.to_ascii_lower()));
|
||||
let names = a.name.to_ascii_lower().cmp(&b.name.to_ascii_lower());
|
||||
exts.cmp(&names)
|
||||
}),
|
||||
|
@ -22,7 +22,7 @@ impl SortPart {
|
||||
// numbers too big for a u64 fall back into strings.
|
||||
match from_str::<u64>(slice) {
|
||||
Some(num) => SortPart::Numeric(num),
|
||||
None => SortPart::Stringular(slice.to_string()),
|
||||
None => SortPart::Stringular(slice.to_string()),
|
||||
}
|
||||
} else {
|
||||
SortPart::Stringular(slice.to_ascii_lower())
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
mod c {
|
||||
#![allow(non_camel_case_types)]
|
||||
extern crate libc;
|
||||
@ -21,11 +20,10 @@ mod c {
|
||||
|
||||
// Unfortunately the actual command is not standardised...
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
static TIOCGWINSZ: c_ulong = 0x5413;
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
static TIOCGWINSZ: c_ulong = 0x40087468;
|
||||
|
||||
extern {
|
||||
|
@ -116,7 +116,7 @@ impl Unix {
|
||||
if username == ptr::null() {
|
||||
return false;
|
||||
}
|
||||
if unsafe { from_buf(username as *const u8) } == *uname {
|
||||
else if unsafe { from_buf(username as *const u8) } == *uname {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user