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