Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
a8d73d1c
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,发现更多精彩内容 >>
提交
a8d73d1c
编写于
6月 27, 2014
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add colour tests
And fix bugs found by these tests...
上级
03bf728a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
108 addition
and
7 deletion
+108
-7
colours.rs
colours.rs
+108
-7
未找到文件。
colours.rs
浏览文件 @
a8d73d1c
...
...
@@ -93,23 +93,23 @@ impl Style {
match
*
self
{
Plain
=>
Style
(
StyleStruct
{
foreground
:
White
,
background
:
None
,
bold
:
true
,
underline
:
false
}),
Foreground
(
c
)
=>
Style
(
StyleStruct
{
foreground
:
c
,
background
:
None
,
bold
:
true
,
underline
:
false
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
st
.background
,
bold
:
true
,
underline
:
fals
e
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
st
.background
,
bold
:
true
,
underline
:
st
.underlin
e
}),
}
}
pub
fn
underline
(
&
self
)
->
Style
{
match
*
self
{
Plain
=>
Style
(
StyleStruct
{
foreground
:
White
,
background
:
None
,
bold
:
false
,
underline
:
true
}),
Foreground
(
c
)
=>
Style
(
StyleStruct
{
foreground
:
c
,
background
:
None
,
bold
:
false
,
underline
:
true
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
st
.background
,
bold
:
false
,
underline
:
true
}),
Plain
=>
Style
(
StyleStruct
{
foreground
:
White
,
background
:
None
,
bold
:
false
,
underline
:
true
}),
Foreground
(
c
)
=>
Style
(
StyleStruct
{
foreground
:
c
,
background
:
None
,
bold
:
false
,
underline
:
true
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
st
.background
,
bold
:
st
.bold
,
underline
:
true
}),
}
}
pub
fn
on
(
&
self
,
background
:
Colour
)
->
Style
{
match
*
self
{
Plain
=>
Style
(
StyleStruct
{
foreground
:
White
,
background
:
Some
(
background
),
bold
:
false
,
underline
:
false
}),
Foreground
(
c
)
=>
Style
(
StyleStruct
{
foreground
:
c
,
background
:
Some
(
background
),
bold
:
false
,
underline
:
false
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
Some
(
background
),
bold
:
false
,
underline
:
fals
e
}),
Plain
=>
Style
(
StyleStruct
{
foreground
:
White
,
background
:
Some
(
background
),
bold
:
false
,
underline
:
false
}),
Foreground
(
c
)
=>
Style
(
StyleStruct
{
foreground
:
c
,
background
:
Some
(
background
),
bold
:
false
,
underline
:
false
}),
Style
(
st
)
=>
Style
(
StyleStruct
{
foreground
:
st
.foreground
,
background
:
Some
(
background
),
bold
:
st
.bold
,
underline
:
st
.underlin
e
}),
}
}
}
...
...
@@ -146,3 +146,104 @@ pub fn strip_formatting(input: &String) -> String {
let
re
=
regex!
(
"
\x1B\\
[.+?m"
);
re
.replace_all
(
input
.as_slice
(),
""
)
.to_string
()
}
#[test]
fn
test_red
()
{
let
hi
=
Red
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[31mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_black
()
{
let
hi
=
Black
.normal
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[30mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_yellow_bold
()
{
let
hi
=
Yellow
.bold
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;33mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_yellow_bold_2
()
{
let
hi
=
Yellow
.normal
()
.bold
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;33mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_blue_underline
()
{
let
hi
=
Blue
.underline
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[4;34mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_green_bold_underline
()
{
let
hi
=
Green
.bold
()
.underline
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;4;32mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_green_bold_underline_2
()
{
let
hi
=
Green
.underline
()
.bold
()
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;4;32mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_purple_on_white
()
{
let
hi
=
Purple
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[47;35mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_purple_on_white_2
()
{
let
hi
=
Purple
.normal
()
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[47;35mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_cyan_bold_on_white
()
{
let
hi
=
Cyan
.bold
()
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;47;36mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_cyan_underline_on_white
()
{
let
hi
=
Cyan
.underline
()
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[4;47;36mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_cyan_bold_underline_on_white
()
{
let
hi
=
Cyan
.bold
()
.underline
()
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;4;47;36mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_cyan_underline_bold_on_white
()
{
let
hi
=
Cyan
.underline
()
.bold
()
.on
(
White
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[1;4;47;36mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_fixed
()
{
let
hi
=
Fixed
(
100
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[38;5;100mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_fixed_on_purple
()
{
let
hi
=
Fixed
(
100
)
.on
(
Purple
)
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[45;38;5;100mhi
\x1B
[0m"
.to_string
());
}
#[test]
fn
test_fixed_on_fixed
()
{
let
hi
=
Fixed
(
100
)
.on
(
Fixed
(
200
))
.paint
(
"hi"
);
assert
!
(
hi
==
"
\x1B
[48;5;200;38;5;100mhi
\x1B
[0m"
.to_string
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录