Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
2d8a9b49
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,发现更多精彩内容 >>
提交
2d8a9b49
编写于
6月 08, 2015
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various unimportant style changes
上级
549f5909
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
110 addition
and
79 deletion
+110
-79
src/colours.rs
src/colours.rs
+0
-1
src/column.rs
src/column.rs
+1
-2
src/dir.rs
src/dir.rs
+4
-3
src/feature/git.rs
src/feature/git.rs
+1
-0
src/feature/mod.rs
src/feature/mod.rs
+3
-1
src/feature/xattr_darwin.rs
src/feature/xattr_darwin.rs
+6
-1
src/feature/xattr_linux.rs
src/feature/xattr_linux.rs
+4
-0
src/file.rs
src/file.rs
+1
-0
src/filetype.rs
src/filetype.rs
+3
-0
src/main.rs
src/main.rs
+4
-2
src/options.rs
src/options.rs
+56
-51
src/output/details.rs
src/output/details.rs
+13
-10
src/output/grid.rs
src/output/grid.rs
+4
-2
src/output/lines.rs
src/output/lines.rs
+2
-0
src/output/mod.rs
src/output/mod.rs
+7
-5
src/term.rs
src/term.rs
+1
-1
未找到文件。
src/colours.rs
浏览文件 @
2d8a9b49
use
ansi_term
::
Style
;
use
ansi_term
::
Colour
::{
Red
,
Green
,
Yellow
,
Blue
,
Cyan
,
Purple
,
Fixed
};
use
std
::
default
::
Default
;
#[derive(Clone,
Copy,
Debug,
Default,
PartialEq)]
pub
struct
Colours
{
...
...
src/column.rs
浏览文件 @
2d8a9b49
use
std
::
iter
::
repeat
;
use
options
::{
SizeFormat
,
TimeType
};
use
ansi_term
::
Style
;
use
unicode_width
::
UnicodeWidthStr
;
use
options
::{
SizeFormat
,
TimeType
};
#[derive(PartialEq,
Debug,
Copy,
Clone)]
...
...
src/dir.rs
浏览文件 @
2d8a9b49
use
feature
::
Git
;
use
file
::{
File
,
fields
};
use
std
::
io
;
use
std
::
fs
;
use
std
::
path
::{
Path
,
PathBuf
};
use
feature
::
Git
;
use
file
::{
File
,
fields
};
/// A **Dir** provides a cached list of the file paths in a directory that's
/// being listed.
///
...
...
src/feature/git.rs
浏览文件 @
2d8a9b49
...
...
@@ -4,6 +4,7 @@ use git2;
use
file
::
fields
;
/// Container of Git statuses for all the files in this folder's Git repository.
pub
struct
Git
{
statuses
:
Vec
<
(
PathBuf
,
git2
::
Status
)
>
,
...
...
src/feature/mod.rs
浏览文件 @
2d8a9b49
...
...
@@ -8,6 +8,8 @@
#[cfg(not(any(target_os
=
"macos"
,
target_os
=
"linux"
)))]
use
std
::
old_io
as
io
;
#[cfg(not(any(target_os
=
"macos"
,
target_os
=
"linux"
)))]
#[derive(Clone)]
pub
struct
Attribute
;
...
...
@@ -38,7 +40,6 @@ impl Attribute {
}
// Git support
#[cfg(feature=
"git"
)]
mod
git
;
...
...
@@ -47,6 +48,7 @@ impl Attribute {
#[cfg(not(feature=
"git"
))]
pub
struct
Git
;
#[cfg(not(feature=
"git"
))]
use
std
::
path
::
Path
;
#[cfg(not(feature=
"git"
))]
use
file
::
fields
;
#[cfg(not(feature=
"git"
))]
impl
Git
{
pub
fn
scan
(
_
:
&
Path
)
->
Result
<
Git
,
()
>
{
...
...
src/feature/xattr_darwin.rs
浏览文件 @
2d8a9b49
...
...
@@ -2,17 +2,20 @@
extern
crate
libc
;
use
std
::
io
;
use
std
::
mem
;
use
std
::
path
::
Path
;
use
std
::
ptr
;
use
std
::
mem
;
use
self
::
libc
::{
c_int
,
size_t
,
ssize_t
,
c_char
,
c_void
,
uint32_t
};
/// Don't follow symbolic links
const
XATTR_NOFOLLOW
:
c_int
=
0x0001
;
/// Expose HFS Compression extended attributes
const
XATTR_SHOWCOMPRESSION
:
c_int
=
0x0020
;
extern
"C"
{
fn
listxattr
(
path
:
*
const
c_char
,
namebuf
:
*
mut
c_char
,
size
:
size_t
,
options
:
c_int
)
->
ssize_t
;
...
...
@@ -21,6 +24,7 @@ extern "C" {
options
:
c_int
)
->
ssize_t
;
}
/// Attributes which can be passed to `Attribute::list_with_flags`
#[derive(Copy,
Clone)]
pub
enum
ListFlags
{
...
...
@@ -30,6 +34,7 @@ pub enum ListFlags {
ShowCompression
=
XATTR_SHOWCOMPRESSION
as
isize
}
/// Extended attribute
#[derive(Debug,
Clone)]
pub
struct
Attribute
{
...
...
src/feature/xattr_linux.rs
浏览文件 @
2d8a9b49
...
...
@@ -5,8 +5,10 @@ use std::ffi::CString;
use
std
::
io
;
use
std
::
path
::
Path
;
use
std
::
ptr
;
use
self
::
libc
::{
size_t
,
ssize_t
,
c_char
,
c_void
};
extern
"C"
{
fn
listxattr
(
path
:
*
const
c_char
,
list
:
*
mut
c_char
,
size
:
size_t
)
->
ssize_t
;
fn
llistxattr
(
path
:
*
const
c_char
,
list
:
*
mut
c_char
,
size
:
size_t
)
->
ssize_t
;
...
...
@@ -18,6 +20,7 @@ extern "C" {
)
->
ssize_t
;
}
/// Attributes which can be passed to `Attribute::list_with_flags`
#[derive(Copy,
Clone)]
pub
enum
FollowSymlinks
{
...
...
@@ -25,6 +28,7 @@ pub enum FollowSymlinks {
No
}
/// Extended attribute
#[derive(Debug,
Clone)]
pub
struct
Attribute
{
...
...
src/file.rs
浏览文件 @
2d8a9b49
...
...
@@ -423,6 +423,7 @@ fn ext(name: &str) -> Option<String> {
name
.rfind
(
'.'
)
.map
(|
p
|
name
[
p
+
1
..
]
.to_ascii_lowercase
())
}
/// Wrapper types for the values returned from `File` objects.
///
/// The methods of `File` don't return formatted strings; neither do they
...
...
src/filetype.rs
浏览文件 @
2d8a9b49
...
...
@@ -3,6 +3,7 @@ use ansi_term::Style;
use
file
::
File
;
use
colours
::
Colours
;
pub
fn
file_colour
(
colours
:
&
Colours
,
file
:
&
File
)
->
Style
{
match
file
{
f
if
f
.is_directory
()
=>
colours
.filetypes.directory
,
...
...
@@ -23,6 +24,7 @@ pub fn file_colour(colours: &Colours, file: &File) -> Style {
}
}
trait
FileTypes
{
fn
is_immediate
(
&
self
)
->
bool
;
fn
is_image
(
&
self
)
->
bool
;
...
...
@@ -114,6 +116,7 @@ impl<'_> FileTypes for File<'_> {
}
}
#[cfg(broken_test)]
mod
test
{
use
super
::
*
;
...
...
src/main.rs
浏览文件 @
2d8a9b49
...
...
@@ -11,18 +11,19 @@ extern crate num_cpus;
extern
crate
number_prefix
;
extern
crate
pad
;
extern
crate
threadpool
;
extern
crate
users
;
extern
crate
unicode_width
;
extern
crate
users
;
#[cfg(feature=
"git"
)]
extern
crate
git2
;
use
std
::
env
;
use
std
::
fs
;
use
std
::
path
::{
Component
,
Path
,
PathBuf
};
use
std
::
sync
::
mpsc
::
channel
;
use
threadpool
::
ThreadPool
;
use
std
::
sync
::
mpsc
::
channel
;
use
dir
::
Dir
;
use
file
::
File
;
...
...
@@ -183,6 +184,7 @@ impl<'dir> Exa<'dir> {
}
}
#[cfg(not(test))]
fn
main
()
{
let
args
:
Vec
<
String
>
=
env
::
args
()
.collect
();
...
...
src/options.rs
浏览文件 @
2d8a9b49
use
colours
::
Colours
;
use
dir
::
Dir
;
use
file
::
File
;
use
column
::
Column
;
use
column
::
Column
::
*
;
use
feature
::
Attribute
;
use
output
::{
Grid
,
Details
,
Lines
};
use
term
::
dimensions
;
use
std
::
cmp
::
Ordering
;
use
std
::
cmp
;
use
std
::
default
;
use
std
::
fmt
;
use
std
::
num
::
ParseIntError
;
use
std
::
os
::
unix
::
fs
::
MetadataExt
;
...
...
@@ -15,7 +7,15 @@ use std::os::unix::fs::MetadataExt;
use
getopts
;
use
natord
;
use
self
::
Misfire
::
*
;
use
colours
::
Colours
;
use
column
::
Column
;
use
column
::
Column
::
*
;
use
dir
::
Dir
;
use
feature
::
Attribute
;
use
file
::
File
;
use
output
::{
Grid
,
Details
,
Lines
};
use
term
::
dimensions
;
/// The *Options* struct represents a parsed version of the user's
/// command-line options.
...
...
@@ -26,21 +26,6 @@ pub struct Options {
pub
view
:
View
,
}
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
struct
FileFilter
{
list_dirs_first
:
bool
,
reverse
:
bool
,
show_invisibles
:
bool
,
sort_field
:
SortField
,
}
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
enum
View
{
Details
(
Details
),
Lines
(
Lines
),
Grid
(
Grid
),
}
impl
Options
{
/// Call getopts on the given slice of command-line strings.
...
...
@@ -126,6 +111,15 @@ impl Options {
}
}
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
struct
FileFilter
{
list_dirs_first
:
bool
,
reverse
:
bool
,
show_invisibles
:
bool
,
sort_field
:
SortField
,
}
impl
FileFilter
{
/// Transform the files (sorting, reversing, filtering) before listing them.
pub
fn
transform_files
(
&
self
,
files
:
&
mut
Vec
<
File
>
)
{
...
...
@@ -143,8 +137,8 @@ impl FileFilter {
SortField
::
AccessedDate
=>
files
.sort_by
(|
a
,
b
|
a
.metadata
.as_raw
()
.atime
()
.cmp
(
&
b
.metadata
.as_raw
()
.atime
())),
SortField
::
CreatedDate
=>
files
.sort_by
(|
a
,
b
|
a
.metadata
.as_raw
()
.ctime
()
.cmp
(
&
b
.metadata
.as_raw
()
.ctime
())),
SortField
::
Extension
=>
files
.sort_by
(|
a
,
b
|
match
a
.ext
.cmp
(
&
b
.ext
)
{
Ordering
::
Equal
=>
natord
::
compare
(
&*
a
.name
,
&*
b
.name
),
order
=>
order
,
cmp
::
Ordering
::
Equal
=>
natord
::
compare
(
&*
a
.name
,
&*
b
.name
),
order
=>
order
,
}),
}
...
...
@@ -166,7 +160,7 @@ pub enum SortField {
ModifiedDate
,
AccessedDate
,
CreatedDate
,
}
impl
Default
for
SortField
{
impl
default
::
Default
for
SortField
{
fn
default
()
->
SortField
{
SortField
::
Name
}
...
...
@@ -195,6 +189,7 @@ impl SortField {
}
}
/// One of these things could happen instead of listing files.
#[derive(PartialEq,
Debug)]
pub
enum
Misfire
{
...
...
@@ -227,13 +222,15 @@ pub enum Misfire {
impl
Misfire
{
/// The OS return code this misfire should signify.
pub
fn
error_code
(
&
self
)
->
i32
{
if
let
Help
(
_
)
=
*
self
{
2
}
else
{
3
}
if
let
Misfire
::
Help
(
_
)
=
*
self
{
2
}
else
{
3
}
}
}
impl
fmt
::
Display
for
Misfire
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
use
self
::
Misfire
::
*
;
match
*
self
{
InvalidOptions
(
ref
e
)
=>
write!
(
f
,
"{}"
,
e
),
Help
(
ref
text
)
=>
write!
(
f
,
"{}"
,
text
),
...
...
@@ -247,14 +244,24 @@ impl fmt::Display for Misfire {
}
}
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
enum
View
{
Details
(
Details
),
Lines
(
Lines
),
Grid
(
Grid
),
}
impl
View
{
pub
fn
deduce
(
matches
:
&
getopts
::
Matches
,
filter
:
FileFilter
,
dir_action
:
DirAction
)
->
Result
<
View
,
Misfire
>
{
use
self
::
Misfire
::
*
;
if
matches
.opt_present
(
"long"
)
{
if
matches
.opt_present
(
"across"
)
{
Err
(
Misfire
::
Useless
(
"across"
,
true
,
"long"
))
Err
(
Useless
(
"across"
,
true
,
"long"
))
}
else
if
matches
.opt_present
(
"oneline"
)
{
Err
(
Misfire
::
Useless
(
"oneline"
,
true
,
"long"
))
Err
(
Useless
(
"oneline"
,
true
,
"long"
))
}
else
{
let
details
=
Details
{
...
...
@@ -269,45 +276,45 @@ impl View {
}
}
else
if
matches
.opt_present
(
"binary"
)
{
Err
(
Misfire
::
Useless
(
"binary"
,
false
,
"long"
))
Err
(
Useless
(
"binary"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"bytes"
)
{
Err
(
Misfire
::
Useless
(
"bytes"
,
false
,
"long"
))
Err
(
Useless
(
"bytes"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"inode"
)
{
Err
(
Misfire
::
Useless
(
"inode"
,
false
,
"long"
))
Err
(
Useless
(
"inode"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"links"
)
{
Err
(
Misfire
::
Useless
(
"links"
,
false
,
"long"
))
Err
(
Useless
(
"links"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"header"
)
{
Err
(
Misfire
::
Useless
(
"header"
,
false
,
"long"
))
Err
(
Useless
(
"header"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"blocks"
)
{
Err
(
Misfire
::
Useless
(
"blocks"
,
false
,
"long"
))
Err
(
Useless
(
"blocks"
,
false
,
"long"
))
}
else
if
cfg!
(
feature
=
"git"
)
&&
matches
.opt_present
(
"git"
)
{
Err
(
Misfire
::
Useless
(
"git"
,
false
,
"long"
))
Err
(
Useless
(
"git"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"time"
)
{
Err
(
Misfire
::
Useless
(
"time"
,
false
,
"long"
))
Err
(
Useless
(
"time"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"tree"
)
{
Err
(
Misfire
::
Useless
(
"tree"
,
false
,
"long"
))
Err
(
Useless
(
"tree"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"group"
)
{
Err
(
Misfire
::
Useless
(
"group"
,
false
,
"long"
))
Err
(
Useless
(
"group"
,
false
,
"long"
))
}
else
if
matches
.opt_present
(
"level"
)
&&
!
matches
.opt_present
(
"recurse"
)
{
Err
(
Misfire
::
Useless2
(
"level"
,
"recurse"
,
"tree"
))
Err
(
Useless2
(
"level"
,
"recurse"
,
"tree"
))
}
else
if
Attribute
::
feature_implemented
()
&&
matches
.opt_present
(
"extended"
)
{
Err
(
Misfire
::
Useless
(
"extended"
,
false
,
"long"
))
Err
(
Useless
(
"extended"
,
false
,
"long"
))
}
else
if
let
Some
((
width
,
_
))
=
dimensions
()
{
if
matches
.opt_present
(
"oneline"
)
{
if
matches
.opt_present
(
"across"
)
{
Err
(
Misfire
::
Useless
(
"across"
,
true
,
"oneline"
))
Err
(
Useless
(
"across"
,
true
,
"oneline"
))
}
else
{
let
lines
=
Lines
{
...
...
@@ -341,7 +348,6 @@ impl View {
}
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
enum
SizeFormat
{
DecimalBytes
,
...
...
@@ -349,7 +355,7 @@ pub enum SizeFormat {
JustBytes
,
}
impl
Default
for
SizeFormat
{
impl
default
::
Default
for
SizeFormat
{
fn
default
()
->
SizeFormat
{
SizeFormat
::
DecimalBytes
}
...
...
@@ -393,7 +399,7 @@ pub struct TimeTypes {
created
:
bool
,
}
impl
Default
for
TimeTypes
{
impl
default
::
Default
for
TimeTypes
{
fn
default
()
->
TimeTypes
{
TimeTypes
{
accessed
:
false
,
modified
:
true
,
created
:
false
}
}
...
...
@@ -599,12 +605,11 @@ impl Columns {
mod
test
{
use
super
::
Options
;
use
super
::
Misfire
;
use
super
::
Misfire
::
*
;
use
feature
::
Attribute
;
fn
is_helpful
<
T
>
(
misfire
:
Result
<
T
,
Misfire
>
)
->
bool
{
match
misfire
{
Err
(
Help
(
_
))
=>
true
,
Misfire
::
Err
(
Help
(
_
))
=>
true
,
_
=>
false
,
}
}
...
...
src/output/details.rs
浏览文件 @
2d8a9b49
use
colours
::
Colours
;
use
column
::{
Alignment
,
Column
,
Cell
};
use
feature
::
Attribute
;
use
dir
::
Dir
;
use
f
ile
::
Fil
e
;
use
f
eature
::
Attribut
e
;
use
file
::
fields
as
f
;
use
file
::
File
;
use
options
::{
Columns
,
FileFilter
,
RecurseOptions
,
SizeFormat
};
use
users
::{
OSUsers
,
Users
};
use
users
::
mock
::
MockUsers
;
use
super
::
filename
;
use
ansi_term
::{
ANSIString
,
ANSIStrings
,
Style
};
use
datetime
::
local
::{
LocalDateTime
,
DatePiece
};
use
datetime
::
format
::{
DateFormat
};
use
datetime
::
zoned
::{
VariableOffset
,
TimeZone
};
use
locale
;
use
number_prefix
::{
binary_prefix
,
decimal_prefix
,
Prefixed
,
Standalone
,
PrefixNames
};
use
datetime
::
local
::{
LocalDateTime
,
DatePiece
};
use
datetime
::
format
::{
DateFormat
};
use
datetime
::
zoned
::{
VariableOffset
,
TimeZone
};
use
users
::{
OSUsers
,
Users
};
use
users
::
mock
::
MockUsers
;
use
super
::
filename
;
/// With the **Details** view, the output gets formatted into columns, with
...
...
@@ -97,6 +97,7 @@ impl Details {
}
}
struct
Row
{
/// Vector of cells to display.
...
...
@@ -122,6 +123,7 @@ struct Row {
children
:
bool
,
}
/// A **Table** object gets built up by the view as it lists files and
/// directories.
pub
struct
Table
<
U
>
{
...
...
@@ -427,6 +429,7 @@ impl<U> Table<U> where U: Users {
}
}
#[derive(PartialEq,
Debug,
Clone)]
enum
TreePart
{
...
...
src/output/grid.rs
浏览文件 @
2d8a9b49
use
std
::
cmp
::
max
;
use
std
::
iter
::
repeat
;
use
colours
::
Colours
;
use
column
::
Alignment
::
Left
;
use
file
::
File
;
use
filetype
::
file_colour
;
use
super
::
lines
::
Lines
;
use
std
::
cmp
::
max
;
use
std
::
iter
::
repeat
;
#[derive(PartialEq,
Debug,
Copy,
Clone)]
pub
struct
Grid
{
...
...
src/output/lines.rs
浏览文件 @
2d8a9b49
use
colours
::
Colours
;
use
file
::
File
;
use
super
::
filename
;
#[derive(Clone,
Copy,
Debug,
PartialEq)]
pub
struct
Lines
{
pub
colours
:
Colours
,
...
...
src/output/mod.rs
浏览文件 @
2d8a9b49
mod
grid
;
pub
mod
details
;
mod
lines
;
use
ansi_term
::
ANSIStrings
;
use
colours
::
Colours
;
use
file
::
File
;
use
filetype
::
file_colour
;
use
ansi_term
::
ANSIStrings
;
pub
use
self
::
grid
::
Grid
;
pub
use
self
::
details
::
Details
;
pub
use
self
::
grid
::
Grid
;
pub
use
self
::
lines
::
Lines
;
mod
grid
;
pub
mod
details
;
mod
lines
;
pub
fn
filename
(
file
:
&
File
,
colours
:
&
Colours
)
->
String
{
if
file
.is_link
()
{
symlink_filename
(
file
,
colours
)
...
...
src/term.rs
浏览文件 @
2d8a9b49
mod
c
{
pub
use
libc
::{
c_int
,
c_ushort
,
c_ulong
,
STDOUT_FILENO
};
use
std
::
mem
::
zeroed
;
use
libc
::{
c_int
,
c_ushort
,
c_ulong
,
STDOUT_FILENO
};
// Getting the terminal size is done using an ioctl command that
// takes the file handle to the terminal (which in our case is
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录