Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
ccf8d440
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,发现更多精彩内容 >>
提交
ccf8d440
编写于
5月 07, 2017
作者:
B
Benjamin Sago
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace the links boolean with an enum field
上级
88fecb7b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
18 deletion
+28
-18
src/output/details.rs
src/output/details.rs
+4
-4
src/output/file_name.rs
src/output/file_name.rs
+16
-8
src/output/grid.rs
src/output/grid.rs
+3
-3
src/output/grid_details.rs
src/output/grid_details.rs
+3
-1
src/output/lines.rs
src/output/lines.rs
+2
-2
未找到文件。
src/output/details.rs
浏览文件 @
ccf8d440
...
...
@@ -101,7 +101,7 @@ use output::colours::Colours;
use
output
::
column
::{
Alignment
,
Column
,
Columns
,
SizeFormat
};
use
output
::
cell
::{
TextCell
,
TextCellContents
,
DisplayWidth
};
use
output
::
tree
::
TreeTrunk
;
use
output
::
file_name
::
FileName
;
use
output
::
file_name
::
{
FileName
,
LinkStyle
}
;
/// With the **Details** view, the output gets formatted into columns, with
...
...
@@ -310,7 +310,7 @@ impl Details {
let
row
=
Row
{
depth
:
depth
,
cells
:
Some
(
egg
.cells
),
name
:
FileName
::
new
(
&
egg
.file
,
&
self
.colours
)
.paint
(
true
,
self
.classify
)
.promote
(),
name
:
FileName
::
new
(
&
egg
.file
,
LinkStyle
::
FullLinkPaths
,
&
self
.colours
)
.paint
(
self
.classify
)
.promote
(),
last
:
index
==
num_eggs
-
1
,
};
...
...
@@ -443,8 +443,8 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
self
.rows
.push
(
row
);
}
pub
fn
filename
(
&
self
,
file
:
File
,
links
:
bool
)
->
TextCellContents
{
FileName
::
new
(
&
file
,
&
self
.opts.colours
)
.paint
(
links
,
self
.opts.classify
)
pub
fn
filename
(
&
self
,
file
:
File
,
links
:
LinkStyle
)
->
TextCellContents
{
FileName
::
new
(
&
file
,
links
,
&
self
.opts.colours
)
.paint
(
self
.opts.classify
)
}
pub
fn
add_file_with_cells
(
&
mut
self
,
cells
:
Vec
<
TextCell
>
,
name_cell
:
TextCell
,
depth
:
usize
,
last
:
bool
)
{
...
...
src/output/file_name.rs
浏览文件 @
ccf8d440
...
...
@@ -8,24 +8,32 @@ use output::escape;
use
output
::
cell
::
TextCellContents
;
pub
enum
LinkStyle
{
JustFilenames
,
FullLinkPaths
,
}
pub
struct
FileName
<
'a
,
'dir
:
'a
>
{
file
:
&
'a
File
<
'dir
>
,
colours
:
&
'a
Colours
,
target
:
Option
<
FileTarget
<
'dir
>>
,
link_style
:
LinkStyle
,
}
impl
<
'a
,
'dir
>
FileName
<
'a
,
'dir
>
{
pub
fn
new
(
file
:
&
'a
File
<
'dir
>
,
colours
:
&
'a
Colours
)
->
FileName
<
'a
,
'dir
>
{
pub
fn
new
(
file
:
&
'a
File
<
'dir
>
,
link_style
:
LinkStyle
,
colours
:
&
'a
Colours
)
->
FileName
<
'a
,
'dir
>
{
let
target
=
if
file
.is_link
()
{
Some
(
file
.link_target
())
}
else
{
None
};
FileName
{
file
:
file
,
colours
:
colours
,
target
:
target
,
link_style
:
link_style
,
}
}
pub
fn
paint
(
&
self
,
links
:
bool
,
classify
:
bool
)
->
TextCellContents
{
pub
fn
paint
(
&
self
,
classify
:
bool
)
->
TextCellContents
{
let
mut
bits
=
Vec
::
new
();
if
self
.file.dir
.is_none
()
{
...
...
@@ -40,9 +48,9 @@ impl<'a, 'dir> FileName<'a, 'dir> {
}
}
if
l
inks
&&
self
.target
.is_some
(
)
{
match
self
.target
.as_ref
()
.unwrap
()
{
&
FileTarget
::
Ok
(
ref
target
)
=>
{
if
l
et
(
&
LinkStyle
::
FullLinkPaths
,
Some
(
ref
target
))
=
(
&
self
.link_style
,
self
.target
.as_ref
()
)
{
match
**
target
{
FileTarget
::
Ok
(
ref
target
)
=>
{
bits
.push
(
Style
::
default
()
.paint
(
" "
));
bits
.push
(
self
.colours.punctuation
.paint
(
"->"
));
bits
.push
(
Style
::
default
()
.paint
(
" "
));
...
...
@@ -52,21 +60,21 @@ impl<'a, 'dir> FileName<'a, 'dir> {
}
if
!
target
.name
.is_empty
()
{
let
target
=
FileName
::
new
(
&
target
,
self
.colours
);
let
target
=
FileName
::
new
(
&
target
,
LinkStyle
::
FullLinkPaths
,
self
.colours
);
for
bit
in
target
.coloured_file_name
()
{
bits
.push
(
bit
);
}
}
},
&
FileTarget
::
Broken
(
ref
broken_path
)
=>
{
FileTarget
::
Broken
(
ref
broken_path
)
=>
{
bits
.push
(
Style
::
default
()
.paint
(
" "
));
bits
.push
(
self
.colours.broken_arrow
.paint
(
"->"
));
bits
.push
(
Style
::
default
()
.paint
(
" "
));
escape
(
broken_path
.display
()
.to_string
(),
&
mut
bits
,
self
.colours.broken_filename
,
self
.colours.control_char
.underline
());
},
&
FileTarget
::
Err
(
_
)
=>
{
FileTarget
::
Err
(
_
)
=>
{
// Do nothing -- the error gets displayed on the next line
},
}
...
...
src/output/grid.rs
浏览文件 @
ccf8d440
...
...
@@ -4,7 +4,7 @@ use term_grid as grid;
use
fs
::
File
;
use
output
::
colours
::
Colours
;
use
output
::
file_name
::
FileName
;
use
output
::
file_name
::
{
FileName
,
LinkStyle
}
;
#[derive(PartialEq,
Debug,
Copy,
Clone)]
...
...
@@ -28,7 +28,7 @@ impl Grid {
grid
.reserve
(
files
.len
());
for
file
in
files
.iter
()
{
let
filename
=
FileName
::
new
(
file
,
&
self
.colours
)
.paint
(
false
,
self
.classify
);
let
filename
=
FileName
::
new
(
file
,
LinkStyle
::
JustFilenames
,
&
self
.colours
)
.paint
(
self
.classify
);
let
width
=
filename
.width
();
grid
.add
(
grid
::
Cell
{
...
...
@@ -43,7 +43,7 @@ impl Grid {
else
{
// File names too long for a grid - drop down to just listing them!
for
file
in
files
.iter
()
{
let
name_cell
=
FileName
::
new
(
file
,
&
self
.colours
)
.paint
(
false
,
self
.classify
);
let
name_cell
=
FileName
::
new
(
file
,
LinkStyle
::
JustFilenames
,
&
self
.colours
)
.paint
(
self
.classify
);
writeln!
(
w
,
"{}"
,
name_cell
.strings
())
?
;
}
Ok
(())
...
...
src/output/grid_details.rs
浏览文件 @
ccf8d440
...
...
@@ -12,6 +12,8 @@ use output::cell::TextCell;
use
output
::
column
::
Column
;
use
output
::
details
::{
Details
,
Table
,
Environment
};
use
output
::
grid
::
Grid
;
use
output
::
file_name
::
LinkStyle
;
#[derive(PartialEq,
Debug,
Clone)]
pub
struct
GridDetails
{
...
...
@@ -45,7 +47,7 @@ impl GridDetails {
.collect
::
<
Vec
<
_
>>
();
let
file_names
=
files
.into_iter
()
.map
(|
file
|
first_table
.filename
(
file
,
false
)
.promote
())
.map
(|
file
|
first_table
.filename
(
file
,
LinkStyle
::
JustFilenames
)
.promote
())
.collect
::
<
Vec
<
_
>>
();
(
cells
,
file_names
)
...
...
src/output/lines.rs
浏览文件 @
ccf8d440
...
...
@@ -4,7 +4,7 @@ use ansi_term::ANSIStrings;
use
fs
::
File
;
use
output
::
file_name
::
FileName
;
use
output
::
file_name
::
{
FileName
,
LinkStyle
}
;
use
super
::
colours
::
Colours
;
...
...
@@ -18,7 +18,7 @@ pub struct Lines {
impl
Lines
{
pub
fn
view
<
W
:
Write
>
(
&
self
,
files
:
Vec
<
File
>
,
w
:
&
mut
W
)
->
IOResult
<
()
>
{
for
file
in
files
{
let
name_cell
=
FileName
::
new
(
&
file
,
&
self
.colours
)
.paint
(
true
,
self
.classify
);
let
name_cell
=
FileName
::
new
(
&
file
,
LinkStyle
::
FullLinkPaths
,
&
self
.colours
)
.paint
(
self
.classify
);
writeln!
(
w
,
"{}"
,
ANSIStrings
(
&
name_cell
))
?
;
}
Ok
(())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录