Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
ff1f6d00
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,发现更多精彩内容 >>
提交
ff1f6d00
编写于
2月 26, 2015
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add --group-directories-first option
Closes #27.
上级
98235200
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
3 deletion
+16
-3
src/file.rs
src/file.rs
+8
-3
src/options.rs
src/options.rs
+8
-0
未找到文件。
src/file.rs
浏览文件 @
ff1f6d00
...
...
@@ -91,6 +91,11 @@ impl<'a> File<'a> {
name
.ends_with
(
"~"
)
||
(
name
.starts_with
(
"#"
)
&&
name
.ends_with
(
"#"
))
}
/// Whether this file is a directory or not.
pub
fn
is_directory
(
&
self
)
->
bool
{
self
.stat.kind
==
io
::
FileType
::
Directory
}
/// Get the data for a column, formatted as a coloured string.
pub
fn
display
<
U
:
Users
>
(
&
self
,
column
:
&
Column
,
users_cache
:
&
mut
U
,
locale
:
&
UserLocale
)
->
Cell
{
match
*
column
{
...
...
@@ -300,7 +305,7 @@ impl<'a> File<'a> {
/// any information from it, so by emitting "-" instead, the table is less
/// cluttered with numbers.
fn
file_size
(
&
self
,
size_format
:
SizeFormat
,
locale
:
&
locale
::
Numeric
)
->
Cell
{
if
self
.
stat.kind
==
io
::
FileType
::
Directory
{
if
self
.
is_directory
()
{
Cell
{
text
:
GREY
.paint
(
"-"
)
.to_string
(),
length
:
1
}
}
else
{
...
...
@@ -363,7 +368,7 @@ impl<'a> File<'a> {
/// Marker indicating that the file contains extended attributes
///
/// Returns “@” or “ ” depending on wheter the file contains an extented
/// Returns “@” or “ ” depending on wheter the file contains an extented
/// attribute or not. Also returns “ ” in case the attributes cannot be read
/// for some reason.
fn
attribute_marker
(
&
self
)
->
ANSIString
{
...
...
@@ -447,7 +452,7 @@ impl<'a> File<'a> {
fn
git_status
(
&
self
)
->
Cell
{
let
status
=
match
self
.dir
{
Some
(
d
)
=>
d
.git_status
(
&
current_dir
()
.unwrap_or
(
Path
::
new
(
"."
))
.join
(
&
self
.path
),
self
.
stat.kind
==
io
::
FileType
::
Directory
),
self
.
is_directory
()
),
None
=>
GREY
.paint
(
"--"
)
.to_string
(),
};
...
...
src/options.rs
浏览文件 @
ff1f6d00
...
...
@@ -28,6 +28,7 @@ pub struct Options {
#[derive(PartialEq,
Debug,
Copy)]
pub
struct
FileFilter
{
list_dirs_first
:
bool
,
reverse
:
bool
,
show_invisibles
:
bool
,
sort_field
:
SortField
,
...
...
@@ -51,6 +52,7 @@ impl Options {
opts
.optflag
(
"B"
,
"bytes"
,
"list file sizes in bytes, without prefixes"
);
opts
.optflag
(
"d"
,
"list-dirs"
,
"list directories as regular files"
);
opts
.optflag
(
"g"
,
"group"
,
"show group as well as user"
);
opts
.optflag
(
""
,
"group-directories-first"
,
"list directories before other files"
);
opts
.optflag
(
"h"
,
"header"
,
"show a header row at the top"
);
opts
.optflag
(
"H"
,
"links"
,
"show number of hard links"
);
opts
.optflag
(
"i"
,
"inode"
,
"show each file's inode number"
);
...
...
@@ -87,6 +89,7 @@ impl Options {
};
let
filter
=
FileFilter
{
list_dirs_first
:
matches
.opt_present
(
"group-directories-first"
),
reverse
:
matches
.opt_present
(
"reverse"
),
show_invisibles
:
matches
.opt_present
(
"all"
),
sort_field
:
sort_field
,
...
...
@@ -139,6 +142,11 @@ impl FileFilter {
if
self
.reverse
{
files
.reverse
();
}
if
self
.list_dirs_first
{
// This relies on the fact that sort_by is stable.
files
.sort_by
(|
a
,
b
|
b
.is_directory
()
.cmp
(
&
a
.is_directory
()));
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录