Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
05b2d541
E
Exa
项目概览
vnotepad
/
Exa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Exa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05b2d541
编写于
5月 26, 2014
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
s/StrBuf/String/g
上级
566ed0bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
17 deletion
+17
-17
colours.rs
colours.rs
+3
-3
exa.rs
exa.rs
+1
-1
file.rs
file.rs
+5
-5
format.rs
format.rs
+3
-3
options.rs
options.rs
+3
-3
unix.rs
unix.rs
+2
-2
未找到文件。
colours.rs
浏览文件 @
05b2d541
...
...
@@ -16,7 +16,7 @@ pub struct StyleStruct {
}
impl
Style
{
pub
fn
paint
(
&
self
,
input
:
&
str
)
->
Str
Buf
{
pub
fn
paint
(
&
self
,
input
:
&
str
)
->
Str
ing
{
match
*
self
{
Plain
=>
input
.to_strbuf
(),
Foreground
(
c
)
=>
c
.paint
(
input
),
...
...
@@ -63,7 +63,7 @@ impl Style {
}
impl
Colour
{
pub
fn
paint
(
&
self
,
input
:
&
str
)
->
Str
Buf
{
pub
fn
paint
(
&
self
,
input
:
&
str
)
->
Str
ing
{
let
re
=
format!
(
"
\x1B
[{}m{}
\x1B
[0m"
,
*
self
as
int
,
input
);
return
re
.to_owned
();
}
...
...
@@ -85,7 +85,7 @@ impl Colour {
}
}
pub
fn
strip_formatting
(
input
:
&
Str
Buf
)
->
StrBuf
{
pub
fn
strip_formatting
(
input
:
&
Str
ing
)
->
String
{
let
re
=
regex!
(
"
\x1B\\
[.+?m"
);
re
.replace_all
(
input
.as_slice
(),
""
)
.to_owned
()
}
exa.rs
浏览文件 @
05b2d541
...
...
@@ -51,7 +51,7 @@ fn exa(options: &Options, path: Path) {
let
columns
=
options
.columns
();
let
table
:
Vec
<
Vec
<
Str
Buf
>>
=
files
.iter
()
let
table
:
Vec
<
Vec
<
Str
ing
>>
=
files
.iter
()
.filter
(|
&
f
|
options
.show
(
f
))
.map
(|
f
|
columns
.iter
()
.map
(|
c
|
f
.display
(
c
))
.collect
())
.collect
();
...
...
file.rs
浏览文件 @
05b2d541
...
...
@@ -55,7 +55,7 @@ impl<'a> File<'a> {
self
.name
.starts_with
(
"."
)
}
pub
fn
display
(
&
self
,
column
:
&
Column
)
->
Str
Buf
{
pub
fn
display
(
&
self
,
column
:
&
Column
)
->
Str
ing
{
match
*
column
{
Permissions
=>
self
.permissions
(),
FileName
=>
self
.file_colour
()
.paint
(
self
.name
.as_slice
()),
...
...
@@ -65,7 +65,7 @@ impl<'a> File<'a> {
}
}
fn
file_size
(
&
self
,
si
:
bool
)
->
Str
Buf
{
fn
file_size
(
&
self
,
si
:
bool
)
->
Str
ing
{
// Don't report file sizes for directories. I've never looked
// at one of those numbers and gained any information from it.
if
self
.stat.kind
==
io
::
TypeDirectory
{
...
...
@@ -81,7 +81,7 @@ impl<'a> File<'a> {
}
}
fn
type_char
(
&
self
)
->
Str
Buf
{
fn
type_char
(
&
self
)
->
Str
ing
{
return
match
self
.stat.kind
{
io
::
TypeFile
=>
"."
.to_strbuf
(),
io
::
TypeDirectory
=>
Blue
.paint
(
"d"
),
...
...
@@ -116,7 +116,7 @@ impl<'a> File<'a> {
}
}
fn
permissions
(
&
self
)
->
Str
Buf
{
fn
permissions
(
&
self
)
->
Str
ing
{
let
bits
=
self
.stat.perm
;
return
format!
(
"{}{}{}{}{}{}{}{}{}{}"
,
self
.type_char
(),
...
...
@@ -133,7 +133,7 @@ impl<'a> File<'a> {
}
}
fn
bit
(
bits
:
io
::
FilePermission
,
bit
:
io
::
FilePermission
,
other
:
&
'static
str
,
style
:
Style
)
->
Str
Buf
{
fn
bit
(
bits
:
io
::
FilePermission
,
bit
:
io
::
FilePermission
,
other
:
&
'static
str
,
style
:
Style
)
->
Str
ing
{
if
bits
.contains
(
bit
)
{
style
.paint
(
other
.as_slice
())
}
else
{
...
...
format.rs
浏览文件 @
05b2d541
...
...
@@ -6,7 +6,7 @@ static IEC_PREFIXES: &'static [&'static str] = &[
""
,
"Ki"
,
"Mi"
,
"Gi"
,
"Ti"
,
"Pi"
,
"Ei"
,
"Zi"
,
"Yi"
];
fn
formatBytes
(
mut
amount
:
u64
,
kilo
:
u64
,
prefixes
:
&
[
&
str
])
->
Str
Buf
{
fn
formatBytes
(
mut
amount
:
u64
,
kilo
:
u64
,
prefixes
:
&
[
&
str
])
->
Str
ing
{
let
mut
prefix
=
0
;
while
amount
>
kilo
{
amount
/=
kilo
;
...
...
@@ -15,10 +15,10 @@ fn formatBytes(mut amount: u64, kilo: u64, prefixes: &[&str]) -> StrBuf {
format!
(
"{}{}"
,
amount
,
prefixes
[
prefix
])
}
pub
fn
formatBinaryBytes
(
amount
:
u64
)
->
Str
Buf
{
pub
fn
formatBinaryBytes
(
amount
:
u64
)
->
Str
ing
{
formatBytes
(
amount
,
1024
,
IEC_PREFIXES
)
}
pub
fn
formatDecimalBytes
(
amount
:
u64
)
->
Str
Buf
{
pub
fn
formatDecimalBytes
(
amount
:
u64
)
->
Str
ing
{
formatBytes
(
amount
,
1000
,
METRIC_PREFIXES
)
}
options.rs
浏览文件 @
05b2d541
...
...
@@ -12,11 +12,11 @@ pub struct Options {
pub
showInvisibles
:
bool
,
pub
sortField
:
SortField
,
pub
reverse
:
bool
,
pub
dirs
:
Vec
<
Str
Buf
>
,
pub
dirs
:
Vec
<
Str
ing
>
,
}
impl
SortField
{
pub
fn
from_word
(
word
:
Str
Buf
)
->
SortField
{
pub
fn
from_word
(
word
:
Str
ing
)
->
SortField
{
match
word
.as_slice
()
{
"name"
=>
Name
,
"size"
=>
Size
,
...
...
@@ -39,7 +39,7 @@ impl SortField {
}
impl
Options
{
pub
fn
getopts
(
args
:
Vec
<
Str
Buf
>
)
->
Result
<
Options
,
getopts
::
Fail_
>
{
pub
fn
getopts
(
args
:
Vec
<
Str
ing
>
)
->
Result
<
Options
,
getopts
::
Fail_
>
{
let
opts
=
~
[
getopts
::
optflag
(
"a"
,
"all"
,
"show dot-files"
),
getopts
::
optflag
(
"r"
,
"reverse"
,
"reverse order of files"
),
...
...
unix.rs
浏览文件 @
05b2d541
...
...
@@ -34,7 +34,7 @@ mod c {
}
}
pub
fn
get_user_name
(
uid
:
i32
)
->
Option
<
Str
Buf
>
{
pub
fn
get_user_name
(
uid
:
i32
)
->
Option
<
Str
ing
>
{
let
pw
=
unsafe
{
c
::
getpwuid
(
uid
)
};
if
pw
.is_not_null
()
{
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
<
Str
Buf
>
{
pub
fn
get_group_name
(
gid
:
u32
)
->
Option
<
Str
ing
>
{
let
gr
=
unsafe
{
c
::
getgrgid
(
gid
)
};
if
gr
.is_not_null
()
{
return
unsafe
{
Some
(
from_c_str
(
read
(
gr
)
.gr_name
))
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录