Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6b3ac946
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b3ac946
编写于
3月 22, 2019
作者:
I
Ian Sanders
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove RGBColor and implement common classes
上级
a42a1ffd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
42 deletion
+14
-42
src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts
src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts
+14
-42
未找到文件。
src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts
浏览文件 @
6b3ac946
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
LinkDetector
}
from
'
vs/workbench/contrib/debug/browser/linkDetector
'
;
import
{
RGBA
,
Color
}
from
'
vs/base/common/color
'
;
/**
* @param text The content to stylize.
...
...
@@ -15,8 +16,8 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML
const
textLength
:
number
=
text
.
length
;
let
styleNames
:
string
[]
=
[];
let
customFgColor
:
RGB
Color
|
null
=
null
;
let
customBgColor
:
RGB
Color
|
null
=
null
;
let
customFgColor
:
RGB
A
|
null
=
null
;
let
customBgColor
:
RGB
A
|
null
=
null
;
let
currentPos
:
number
=
0
;
let
buffer
:
string
=
''
;
...
...
@@ -112,7 +113,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML
* @param customColor If provided, this custom color will be used instead of
* a class-defined color.
*/
function
changeColor
(
newClass
:
string
|
number
|
null
,
isForeground
:
boolean
,
customColor
?:
RGB
Color
|
null
):
void
{
function
changeColor
(
newClass
:
string
|
number
|
null
,
isForeground
:
boolean
,
customColor
?:
RGB
A
|
null
):
void
{
const
colorType
=
isForeground
?
'
foreground
'
:
'
background
'
;
styleNames
=
styleNames
.
filter
(
style
=>
!
style
.
match
(
new
RegExp
(
`^code-
${
colorType
}
-(\\d+|custom)$`
)));
if
(
newClass
)
{
...
...
@@ -170,7 +171,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML
styleCodes
[
2
]
>=
0
&&
styleCodes
[
2
]
<=
255
&&
styleCodes
[
3
]
>=
0
&&
styleCodes
[
3
]
<=
255
&&
styleCodes
[
4
]
>=
0
&&
styleCodes
[
4
]
<=
255
)
{
const
customColor
=
new
RGB
Color
(
styleCodes
[
2
],
styleCodes
[
3
],
styleCodes
[
4
]);
const
customColor
=
new
RGB
A
(
styleCodes
[
2
],
styleCodes
[
3
],
styleCodes
[
4
]);
changeColor
(
'
custom
'
,
isForeground
,
customColor
);
}
}
...
...
@@ -215,8 +216,8 @@ export function appendStylizedStringToContainer(
stringContent
:
string
,
cssClasses
:
string
[],
linkDetector
:
LinkDetector
,
customTextColor
?:
RGB
Color
|
null
,
customBackgroundColor
?:
RGB
Color
|
null
customTextColor
?:
RGB
A
|
null
,
customBackgroundColor
?:
RGB
A
|
null
):
void
{
if
(
!
root
||
!
stringContent
)
{
return
;
...
...
@@ -226,46 +227,17 @@ export function appendStylizedStringToContainer(
container
.
className
=
cssClasses
.
join
(
'
'
);
if
(
customTextColor
)
{
container
.
style
.
color
=
customTextColor
.
asCSSString
;
container
.
style
.
color
=
Color
.
Format
.
CSS
.
formatRGB
(
new
Color
(
customTextColor
));
}
if
(
customBackgroundColor
)
{
container
.
style
.
backgroundColor
=
customBackgroundColor
.
asCSSString
;
container
.
style
.
backgroundColor
=
Color
.
Format
.
CSS
.
formatRGB
(
new
Color
(
customBackgroundColor
));
}
root
.
appendChild
(
container
);
}
/**
* Class representing a color defined with RGB values.
*/
export
class
RGBColor
{
/** Red level from 0 to 255. */
r
:
number
;
/** Green level from 0 to 255. */
g
:
number
;
/** Blue level from 0 to 255. */
b
:
number
;
/**
* Construct a new RGBColor.
* @param r Red level from 0 to 255.
* @param g Green level from 0 to 255.
* @param b Blue level from 0 to 255.
*/
constructor
(
r
:
number
,
g
:
number
,
b
:
number
)
{
this
.
r
=
r
;
this
.
g
=
g
;
this
.
b
=
b
;
}
/**
* Get the color as a string for use in CSS rules.
*/
get
asCSSString
():
string
{
return
`rgb(
${
this
.
r
}
,
${
this
.
g
}
,
${
this
.
b
}
)`
;
}
}
/**
* Calculate the color from the color set defined in the ANSI 8-bit standard.
* Standard and high intensity colors are not defined in the standard as specific
...
...
@@ -274,7 +246,7 @@ export class RGBColor {
* @param colorNumber The number (ranging from 16 to 255) referring to the color
* desired.
*/
export
function
calcANSI8bitColor
(
colorNumber
:
number
):
RGB
Color
|
null
{
export
function
calcANSI8bitColor
(
colorNumber
:
number
):
RGB
A
|
null
{
if
(
colorNumber
%
1
!==
0
)
{
// Should be integer
return
null
;
...
...
@@ -294,12 +266,12 @@ export function calcANSI8bitColor(colorNumber: number): RGBColor | null {
green
=
Math
.
round
(
green
*
convFactor
);
red
=
Math
.
round
(
red
*
convFactor
);
return
new
RGB
Color
(
red
,
green
,
blue
);
return
new
RGB
A
(
red
,
green
,
blue
);
}
else
if
(
colorNumber
>=
232
&&
colorNumber
<=
255
)
{
// Converts to a grayscale value
colorNumber
-=
232
;
const
colorLevel
:
number
=
Math
.
round
(
colorNumber
/
23
*
255
);
return
new
RGB
Color
(
colorLevel
,
colorLevel
,
colorLevel
);
return
new
RGB
A
(
colorLevel
,
colorLevel
,
colorLevel
);
}
else
{
return
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录