Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
05dd644c
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,发现更多精彩内容 >>
提交
05dd644c
编写于
11月 26, 2014
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upgrade to latest ansi_term
Yeah, I broke my own code again.
上级
6ade060e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
34 addition
and
24 deletion
+34
-24
.gitignore
.gitignore
+0
-1
Cargo.lock
Cargo.lock
+12
-0
src/exa.rs
src/exa.rs
+3
-3
src/file.rs
src/file.rs
+18
-19
src/filetype.rs
src/filetype.rs
+1
-1
未找到文件。
.gitignore
浏览文件 @
05dd644c
*~
*~
target
target
Cargo.lock
\ No newline at end of file
Cargo.lock
0 → 100644
浏览文件 @
05dd644c
[root]
name = "exa"
version = "0.1.0"
dependencies = [
"ansi_term 0.3.0 (git+https://github.com/ogham/rust-ansi-term.git)",
]
[[package]]
name = "ansi_term"
version = "0.3.0"
source = "git+https://github.com/ogham/rust-ansi-term.git#4b9ea6cf266053e1a771e75b935b4e54c586c139"
src/exa.rs
浏览文件 @
05dd644c
...
@@ -15,7 +15,7 @@ use column::Alignment::Left;
...
@@ -15,7 +15,7 @@ use column::Alignment::Left;
use
options
::{
Options
,
View
};
use
options
::{
Options
,
View
};
use
unix
::
Unix
;
use
unix
::
Unix
;
use
ansi_term
::{
P
aint
,
P
lain
,
strip_formatting
};
use
ansi_term
::{
Plain
,
strip_formatting
};
pub
mod
column
;
pub
mod
column
;
pub
mod
dir
;
pub
mod
dir
;
...
@@ -135,7 +135,7 @@ fn grid_view(across: bool, console_width: uint, files: Vec<File>) {
...
@@ -135,7 +135,7 @@ fn grid_view(across: bool, console_width: uint, files: Vec<File>) {
let
ref
file
=
files
[
num
];
let
ref
file
=
files
[
num
];
let
file_name
=
file
.name
.clone
();
let
file_name
=
file
.name
.clone
();
let
styled_name
=
file
.file_colour
()
.paint
(
file_name
.as_slice
());
let
styled_name
=
file
.file_colour
()
.paint
(
file_name
.as_slice
())
.to_string
()
;
if
x
==
num_columns
-
1
{
if
x
==
num_columns
-
1
{
print!
(
"{}"
,
styled_name
);
print!
(
"{}"
,
styled_name
);
}
}
...
@@ -161,7 +161,7 @@ fn details_view(options: &Options, columns: &Vec<Column>, files: Vec<File>) {
...
@@ -161,7 +161,7 @@ fn details_view(options: &Options, columns: &Vec<Column>, files: Vec<File>) {
.collect
();
.collect
();
if
options
.header
{
if
options
.header
{
table
.insert
(
0
,
columns
.iter
()
.map
(|
c
|
Plain
.underline
()
.paint
(
c
.header
()))
.collect
());
table
.insert
(
0
,
columns
.iter
()
.map
(|
c
|
Plain
.underline
()
.paint
(
c
.header
())
.to_string
()
)
.collect
());
}
}
// Each column needs to have its invisible colour-formatting
// Each column needs to have its invisible colour-formatting
...
...
src/file.rs
浏览文件 @
05dd644c
use
std
::
io
::{
fs
,
IoResult
};
use
std
::
io
::{
fs
,
IoResult
};
use
std
::
io
;
use
std
::
io
;
use
std
::
str
::
SendStr
;
use
ansi_term
::{
Paint
,
Colour
,
Plain
,
Style
,
Red
,
Green
,
Yellow
,
Blue
,
Purple
,
Cyan
,
Fixed
};
use
ansi_term
::{
ANSIString
,
Colour
,
Plain
,
Style
,
Red
,
Green
,
Yellow
,
Blue
,
Purple
,
Cyan
,
Fixed
};
use
column
::
Column
;
use
column
::
Column
;
use
column
::
Column
::
*
;
use
column
::
Column
::
*
;
...
@@ -121,19 +120,19 @@ impl<'a> File<'a> {
...
@@ -121,19 +120,19 @@ impl<'a> File<'a> {
// the time.
// the time.
HardLinks
=>
{
HardLinks
=>
{
let
style
=
if
self
.has_multiple_links
()
{
Red
.on
(
Yellow
)
}
else
{
Red
.normal
()
};
let
style
=
if
self
.has_multiple_links
()
{
Red
.on
(
Yellow
)
}
else
{
Red
.normal
()
};
style
.paint
(
self
.stat.unstable.nlink
.to_string
()
.as_slice
())
style
.paint
(
self
.stat.unstable.nlink
.to_string
()
.as_slice
())
.to_string
()
},
},
Inode
=>
{
Inode
=>
{
Purple
.paint
(
self
.stat.unstable.inode
.to_string
()
.as_slice
())
Purple
.paint
(
self
.stat.unstable.inode
.to_string
()
.as_slice
())
.to_string
()
},
},
Blocks
=>
{
Blocks
=>
{
if
self
.stat.kind
==
io
::
TypeFile
||
self
.stat.kind
==
io
::
TypeSymlink
{
if
self
.stat.kind
==
io
::
TypeFile
||
self
.stat.kind
==
io
::
TypeSymlink
{
Cyan
.paint
(
self
.stat.unstable.blocks
.to_string
()
.as_slice
())
Cyan
.paint
(
self
.stat.unstable.blocks
.to_string
()
.as_slice
())
.to_string
()
}
}
else
{
else
{
GREY
.paint
(
"-"
)
GREY
.paint
(
"-"
)
.to_string
()
}
}
},
},
...
@@ -144,7 +143,7 @@ impl<'a> File<'a> {
...
@@ -144,7 +143,7 @@ impl<'a> File<'a> {
unix
.load_user
(
uid
);
unix
.load_user
(
uid
);
let
user_name
=
unix
.get_user_name
(
uid
)
.unwrap_or
(
uid
.to_string
());
let
user_name
=
unix
.get_user_name
(
uid
)
.unwrap_or
(
uid
.to_string
());
let
style
=
if
unix
.uid
==
uid
{
Yellow
.bold
()
}
else
{
Plain
};
let
style
=
if
unix
.uid
==
uid
{
Yellow
.bold
()
}
else
{
Plain
};
style
.paint
(
user_name
.as_slice
())
style
.paint
(
user_name
.as_slice
())
.to_string
()
},
},
Group
=>
{
Group
=>
{
...
@@ -152,7 +151,7 @@ impl<'a> File<'a> {
...
@@ -152,7 +151,7 @@ impl<'a> File<'a> {
unix
.load_group
(
gid
);
unix
.load_group
(
gid
);
let
group_name
=
unix
.get_group_name
(
gid
)
.unwrap_or
(
gid
.to_string
());
let
group_name
=
unix
.get_group_name
(
gid
)
.unwrap_or
(
gid
.to_string
());
let
style
=
if
unix
.is_group_member
(
gid
)
{
Yellow
.normal
()
}
else
{
Plain
};
let
style
=
if
unix
.is_group_member
(
gid
)
{
Yellow
.normal
()
}
else
{
Plain
};
style
.paint
(
group_name
.as_slice
())
style
.paint
(
group_name
.as_slice
())
.to_string
()
},
},
}
}
}
}
...
@@ -169,11 +168,11 @@ impl<'a> File<'a> {
...
@@ -169,11 +168,11 @@ impl<'a> File<'a> {
};
};
format!
(
"{} {}"
,
displayed_name
,
self
.target_file_name_and_arrow
(
target_path
))
format!
(
"{} {}"
,
displayed_name
,
self
.target_file_name_and_arrow
(
target_path
))
}
}
Err
(
_
)
=>
displayed_name
,
Err
(
_
)
=>
displayed_name
.to_string
()
,
}
}
}
}
else
{
else
{
displayed_name
displayed_name
.to_string
()
}
}
}
}
...
@@ -212,7 +211,7 @@ impl<'a> File<'a> {
...
@@ -212,7 +211,7 @@ impl<'a> File<'a> {
// 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
{
GREY
.paint
(
"-"
)
GREY
.paint
(
"-"
)
.to_string
()
}
}
else
{
else
{
let
(
size
,
suffix
)
=
if
use_iec_prefixes
{
let
(
size
,
suffix
)
=
if
use_iec_prefixes
{
...
@@ -226,14 +225,14 @@ impl<'a> File<'a> {
...
@@ -226,14 +225,14 @@ impl<'a> File<'a> {
}
}
}
}
fn
type_char
(
&
self
)
->
SendStr
{
fn
type_char
(
&
self
)
->
ANSIString
{
return
match
self
.stat.kind
{
return
match
self
.stat.kind
{
io
::
TypeFile
=>
"."
.into_maybe_owned
(
),
io
::
TypeFile
=>
Plain
.paint
(
"."
),
io
::
TypeDirectory
=>
Blue
.paint
(
"d"
)
.into_maybe_owned
()
,
io
::
TypeDirectory
=>
Blue
.paint
(
"d"
),
io
::
TypeNamedPipe
=>
Yellow
.paint
(
"|"
)
.into_maybe_owned
()
,
io
::
TypeNamedPipe
=>
Yellow
.paint
(
"|"
),
io
::
TypeBlockSpecial
=>
Purple
.paint
(
"s"
)
.into_maybe_owned
()
,
io
::
TypeBlockSpecial
=>
Purple
.paint
(
"s"
),
io
::
TypeSymlink
=>
Cyan
.paint
(
"l"
)
.into_maybe_owned
()
,
io
::
TypeSymlink
=>
Cyan
.paint
(
"l"
),
io
::
TypeUnknown
=>
"?"
.into_maybe_owned
(
),
io
::
TypeUnknown
=>
Plain
.paint
(
"?"
),
}
}
}
}
...
@@ -264,7 +263,7 @@ impl<'a> File<'a> {
...
@@ -264,7 +263,7 @@ impl<'a> File<'a> {
);
);
}
}
fn
permission_bit
(
bits
:
io
::
FilePermission
,
bit
:
io
::
FilePermission
,
character
:
&
'static
str
,
style
:
Style
)
->
String
{
fn
permission_bit
(
bits
:
io
::
FilePermission
,
bit
:
io
::
FilePermission
,
character
:
&
'static
str
,
style
:
Style
)
->
ANSI
String
{
if
bits
.contains
(
bit
)
{
if
bits
.contains
(
bit
)
{
style
.paint
(
character
.as_slice
())
style
.paint
(
character
.as_slice
())
}
}
...
...
src/filetype.rs
浏览文件 @
05dd644c
...
@@ -4,7 +4,7 @@ use self::FileType::*;
...
@@ -4,7 +4,7 @@ use self::FileType::*;
use
std
::
io
;
use
std
::
io
;
use
std
::
ascii
::
AsciiExt
;
use
std
::
ascii
::
AsciiExt
;
use
ansi_term
::{
P
aint
,
P
lain
,
Style
,
Red
,
Green
,
Yellow
,
Blue
,
Cyan
,
Fixed
};
use
ansi_term
::{
Plain
,
Style
,
Red
,
Green
,
Yellow
,
Blue
,
Cyan
,
Fixed
};
pub
enum
FileType
{
pub
enum
FileType
{
Normal
,
Directory
,
Executable
,
Immediate
,
Compiled
,
Symlink
,
Special
,
Normal
,
Directory
,
Executable
,
Immediate
,
Compiled
,
Symlink
,
Special
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录