mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-04-08 08:21:50 +00:00
s/StrBuf/String/g
This commit is contained in:
parent
566ed0bba8
commit
05b2d541ac
@ -16,7 +16,7 @@ pub struct StyleStruct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Style {
|
impl Style {
|
||||||
pub fn paint(&self, input: &str) -> StrBuf {
|
pub fn paint(&self, input: &str) -> String {
|
||||||
match *self {
|
match *self {
|
||||||
Plain => input.to_strbuf(),
|
Plain => input.to_strbuf(),
|
||||||
Foreground(c) => c.paint(input),
|
Foreground(c) => c.paint(input),
|
||||||
@ -63,7 +63,7 @@ impl Style {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Colour {
|
impl Colour {
|
||||||
pub fn paint(&self, input: &str) -> StrBuf {
|
pub fn paint(&self, input: &str) -> String {
|
||||||
let re = format!("\x1B[{}m{}\x1B[0m", *self as int, input);
|
let re = format!("\x1B[{}m{}\x1B[0m", *self as int, input);
|
||||||
return re.to_owned();
|
return re.to_owned();
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ impl Colour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn strip_formatting(input: &StrBuf) -> StrBuf {
|
pub fn strip_formatting(input: &String) -> String {
|
||||||
let re = regex!("\x1B\\[.+?m");
|
let re = regex!("\x1B\\[.+?m");
|
||||||
re.replace_all(input.as_slice(), "").to_owned()
|
re.replace_all(input.as_slice(), "").to_owned()
|
||||||
}
|
}
|
||||||
|
2
exa.rs
2
exa.rs
@ -51,7 +51,7 @@ fn exa(options: &Options, path: Path) {
|
|||||||
|
|
||||||
let columns = options.columns();
|
let columns = options.columns();
|
||||||
|
|
||||||
let table: Vec<Vec<StrBuf>> = files.iter()
|
let table: Vec<Vec<String>> = files.iter()
|
||||||
.filter(|&f| options.show(f))
|
.filter(|&f| options.show(f))
|
||||||
.map(|f| columns.iter().map(|c| f.display(c)).collect())
|
.map(|f| columns.iter().map(|c| f.display(c)).collect())
|
||||||
.collect();
|
.collect();
|
||||||
|
10
file.rs
10
file.rs
@ -55,7 +55,7 @@ impl<'a> File<'a> {
|
|||||||
self.name.starts_with(".")
|
self.name.starts_with(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display(&self, column: &Column) -> StrBuf {
|
pub fn display(&self, column: &Column) -> String {
|
||||||
match *column {
|
match *column {
|
||||||
Permissions => self.permissions(),
|
Permissions => self.permissions(),
|
||||||
FileName => self.file_colour().paint(self.name.as_slice()),
|
FileName => self.file_colour().paint(self.name.as_slice()),
|
||||||
@ -65,7 +65,7 @@ impl<'a> File<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_size(&self, si: bool) -> StrBuf {
|
fn file_size(&self, si: bool) -> String {
|
||||||
// Don't report file sizes for directories. I've never looked
|
// Don't report file sizes for directories. I've never looked
|
||||||
// at one of those numbers and gained any information from it.
|
// at one of those numbers and gained any information from it.
|
||||||
if self.stat.kind == io::TypeDirectory {
|
if self.stat.kind == io::TypeDirectory {
|
||||||
@ -81,7 +81,7 @@ impl<'a> File<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_char(&self) -> StrBuf {
|
fn type_char(&self) -> String {
|
||||||
return match self.stat.kind {
|
return match self.stat.kind {
|
||||||
io::TypeFile => ".".to_strbuf(),
|
io::TypeFile => ".".to_strbuf(),
|
||||||
io::TypeDirectory => Blue.paint("d"),
|
io::TypeDirectory => Blue.paint("d"),
|
||||||
@ -116,7 +116,7 @@ impl<'a> File<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn permissions(&self) -> StrBuf {
|
fn permissions(&self) -> String {
|
||||||
let bits = self.stat.perm;
|
let bits = self.stat.perm;
|
||||||
return format!("{}{}{}{}{}{}{}{}{}{}",
|
return format!("{}{}{}{}{}{}{}{}{}{}",
|
||||||
self.type_char(),
|
self.type_char(),
|
||||||
@ -133,7 +133,7 @@ impl<'a> File<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bit(bits: io::FilePermission, bit: io::FilePermission, other: &'static str, style: Style) -> StrBuf {
|
fn bit(bits: io::FilePermission, bit: io::FilePermission, other: &'static str, style: Style) -> String {
|
||||||
if bits.contains(bit) {
|
if bits.contains(bit) {
|
||||||
style.paint(other.as_slice())
|
style.paint(other.as_slice())
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,7 @@ static IEC_PREFIXES: &'static [&'static str] = &[
|
|||||||
"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"
|
"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"
|
||||||
];
|
];
|
||||||
|
|
||||||
fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> StrBuf {
|
fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> String {
|
||||||
let mut prefix = 0;
|
let mut prefix = 0;
|
||||||
while amount > kilo {
|
while amount > kilo {
|
||||||
amount /= kilo;
|
amount /= kilo;
|
||||||
@ -15,10 +15,10 @@ fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> StrBuf {
|
|||||||
format!("{}{}", amount, prefixes[prefix])
|
format!("{}{}", amount, prefixes[prefix])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn formatBinaryBytes(amount: u64) -> StrBuf {
|
pub fn formatBinaryBytes(amount: u64) -> String {
|
||||||
formatBytes(amount, 1024, IEC_PREFIXES)
|
formatBytes(amount, 1024, IEC_PREFIXES)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn formatDecimalBytes(amount: u64) -> StrBuf {
|
pub fn formatDecimalBytes(amount: u64) -> String {
|
||||||
formatBytes(amount, 1000, METRIC_PREFIXES)
|
formatBytes(amount, 1000, METRIC_PREFIXES)
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@ pub struct Options {
|
|||||||
pub showInvisibles: bool,
|
pub showInvisibles: bool,
|
||||||
pub sortField: SortField,
|
pub sortField: SortField,
|
||||||
pub reverse: bool,
|
pub reverse: bool,
|
||||||
pub dirs: Vec<StrBuf>,
|
pub dirs: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SortField {
|
impl SortField {
|
||||||
pub fn from_word(word: StrBuf) -> SortField {
|
pub fn from_word(word: String) -> SortField {
|
||||||
match word.as_slice() {
|
match word.as_slice() {
|
||||||
"name" => Name,
|
"name" => Name,
|
||||||
"size" => Size,
|
"size" => Size,
|
||||||
@ -39,7 +39,7 @@ impl SortField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
pub fn getopts(args: Vec<StrBuf>) -> Result<Options, getopts::Fail_> {
|
pub fn getopts(args: Vec<String>) -> Result<Options, getopts::Fail_> {
|
||||||
let opts = ~[
|
let opts = ~[
|
||||||
getopts::optflag("a", "all", "show dot-files"),
|
getopts::optflag("a", "all", "show dot-files"),
|
||||||
getopts::optflag("r", "reverse", "reverse order of files"),
|
getopts::optflag("r", "reverse", "reverse order of files"),
|
||||||
|
4
unix.rs
4
unix.rs
@ -34,7 +34,7 @@ mod c {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_user_name(uid: i32) -> Option<StrBuf> {
|
pub fn get_user_name(uid: i32) -> Option<String> {
|
||||||
let pw = unsafe { c::getpwuid(uid) };
|
let pw = unsafe { c::getpwuid(uid) };
|
||||||
if pw.is_not_null() {
|
if pw.is_not_null() {
|
||||||
return unsafe { Some(from_c_str(read(pw).pw_name)) };
|
return unsafe { Some(from_c_str(read(pw).pw_name)) };
|
||||||
@ -44,7 +44,7 @@ pub fn get_user_name(uid: i32) -> Option<StrBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_group_name(gid: u32) -> Option<StrBuf> {
|
pub fn get_group_name(gid: u32) -> Option<String> {
|
||||||
let gr = unsafe { c::getgrgid(gid) };
|
let gr = unsafe { c::getgrgid(gid) };
|
||||||
if gr.is_not_null() {
|
if gr.is_not_null() {
|
||||||
return unsafe { Some(from_c_str(read(gr).gr_name)) };
|
return unsafe { Some(from_c_str(read(gr).gr_name)) };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user