mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-25 13:27:33 +00:00
Upgrade to latest Rust nightly
Replace ~strs with either &'static strs or .to_owned() strs where appropriate Fields now seem to be private by default - good!
This commit is contained in:
parent
e4cee37805
commit
d6e34723b9
@ -24,10 +24,10 @@ impl Style {
|
|||||||
StyleStruct { foreground, background, bold, underline } => {
|
StyleStruct { foreground, background, bold, underline } => {
|
||||||
let bg: ~str = match background {
|
let bg: ~str = match background {
|
||||||
Some(c) => format!("{};", c as int + 10),
|
Some(c) => format!("{};", c as int + 10),
|
||||||
None => ~"",
|
None => "".to_owned(),
|
||||||
};
|
};
|
||||||
let bo: ~str = if bold { ~"1;" } else { ~"" };
|
let bo = if bold { "1;" } else { "" };
|
||||||
let un: ~str = if underline { ~"4;" } else { ~"" };
|
let un = if underline { "4;" } else { "" };
|
||||||
format!("\x1B[{}{}{}{}m{}\x1B[0m", bo, un, bg, foreground as int, input)
|
format!("\x1B[{}{}{}{}m{}\x1B[0m", bo, un, bg, foreground as int, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
exa.rs
9
exa.rs
@ -30,7 +30,12 @@ fn main() {
|
|||||||
showInvisibles: matches.opt_present("all")
|
showInvisibles: matches.opt_present("all")
|
||||||
};
|
};
|
||||||
|
|
||||||
let strs = if matches.free.is_empty() {vec!(~"./")} else {matches.free.clone()};
|
let strs = if matches.free.is_empty() {
|
||||||
|
vec!("./".to_owned())
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
matches.free.clone()
|
||||||
|
};
|
||||||
|
|
||||||
for dir in strs.move_iter() {
|
for dir in strs.move_iter() {
|
||||||
list(opts, Path::new(dir))
|
list(opts, Path::new(dir))
|
||||||
@ -46,7 +51,7 @@ fn list(opts: Options, path: Path) {
|
|||||||
for subpath in files.iter() {
|
for subpath in files.iter() {
|
||||||
let file = File::from_path(subpath);
|
let file = File::from_path(subpath);
|
||||||
|
|
||||||
if file.name.starts_with(".") && !opts.showInvisibles {
|
if file.is_dotfile() && !opts.showInvisibles {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
file.rs
32
file.rs
@ -30,6 +30,10 @@ impl<'a> File<'a> {
|
|||||||
return File { path: path, stat: stat, name: filename };
|
return File { path: path, stat: stat, name: filename };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_dotfile(&self) -> bool {
|
||||||
|
self.name.starts_with(".")
|
||||||
|
}
|
||||||
|
|
||||||
pub fn display(&self, column: &Column) -> ~str {
|
pub fn display(&self, column: &Column) -> ~str {
|
||||||
match *column {
|
match *column {
|
||||||
Permissions => self.permissions(),
|
Permissions => self.permissions(),
|
||||||
@ -54,12 +58,12 @@ impl<'a> File<'a> {
|
|||||||
|
|
||||||
fn type_char(&self) -> ~str {
|
fn type_char(&self) -> ~str {
|
||||||
return match self.stat.kind {
|
return match self.stat.kind {
|
||||||
io::TypeFile => ~".",
|
io::TypeFile => ".".to_owned(),
|
||||||
io::TypeDirectory => Blue.paint("d"),
|
io::TypeDirectory => Blue.paint("d"),
|
||||||
io::TypeNamedPipe => Yellow.paint("|"),
|
io::TypeNamedPipe => Yellow.paint("|"),
|
||||||
io::TypeBlockSpecial => Purple.paint("s"),
|
io::TypeBlockSpecial => Purple.paint("s"),
|
||||||
io::TypeSymlink => Cyan.paint("l"),
|
io::TypeSymlink => Cyan.paint("l"),
|
||||||
_ => ~"?",
|
_ => "?".to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,23 +84,23 @@ impl<'a> File<'a> {
|
|||||||
let bits = self.stat.perm;
|
let bits = self.stat.perm;
|
||||||
return format!("{}{}{}{}{}{}{}{}{}{}",
|
return format!("{}{}{}{}{}{}{}{}{}{}",
|
||||||
self.type_char(),
|
self.type_char(),
|
||||||
bit(bits, io::UserRead, ~"r", Yellow.bold()),
|
bit(bits, io::UserRead, "r", Yellow.bold()),
|
||||||
bit(bits, io::UserWrite, ~"w", Red.bold()),
|
bit(bits, io::UserWrite, "w", Red.bold()),
|
||||||
bit(bits, io::UserExecute, ~"x", Green.bold().underline()),
|
bit(bits, io::UserExecute, "x", Green.bold().underline()),
|
||||||
bit(bits, io::GroupRead, ~"r", Yellow.normal()),
|
bit(bits, io::GroupRead, "r", Yellow.normal()),
|
||||||
bit(bits, io::GroupWrite, ~"w", Red.normal()),
|
bit(bits, io::GroupWrite, "w", Red.normal()),
|
||||||
bit(bits, io::GroupExecute, ~"x", Green.normal()),
|
bit(bits, io::GroupExecute, "x", Green.normal()),
|
||||||
bit(bits, io::OtherRead, ~"r", Yellow.normal()),
|
bit(bits, io::OtherRead, "r", Yellow.normal()),
|
||||||
bit(bits, io::OtherWrite, ~"w", Red.normal()),
|
bit(bits, io::OtherWrite, "w", Red.normal()),
|
||||||
bit(bits, io::OtherExecute, ~"x", Green.normal()),
|
bit(bits, io::OtherExecute, "x", Green.normal()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bit(bits: u32, bit: u32, other: ~str, style: Style) -> ~str {
|
fn bit(bits: u32, bit: u32, other: &'static str, style: Style) -> ~str {
|
||||||
if bits & bit == bit {
|
if bits & bit == bit {
|
||||||
style.paint(other)
|
style.paint(other.to_owned())
|
||||||
} else {
|
} else {
|
||||||
Black.bold().paint(~"-")
|
Black.bold().paint("-".to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user