Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0f5272af
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,发现更多精彩内容 >>
提交
0f5272af
编写于
8月 11, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
color api: docs
上级
43160efc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
14 deletion
+125
-14
extensions/css/client/src/colorDecorators.ts
extensions/css/client/src/colorDecorators.ts
+3
-3
extensions/json/client/src/colorDecorators.ts
extensions/json/client/src/colorDecorators.ts
+3
-3
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+117
-6
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+1
-1
未找到文件。
extensions/css/client/src/colorDecorators.ts
浏览文件 @
0f5272af
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
*
as
parse
from
'
parse-color
'
;
import
{
window
,
workspace
,
DecorationOptions
,
DecorationRenderOptions
,
Disposable
,
Range
,
TextDocument
,
DocumentColorProvider
,
Color
,
ColorFormat
,
Color
Info
}
from
'
vscode
'
;
import
{
window
,
workspace
,
DecorationOptions
,
DecorationRenderOptions
,
Disposable
,
Range
,
TextDocument
,
DocumentColorProvider
,
Color
,
ColorFormat
,
Color
Range
}
from
'
vscode
'
;
const
MAX_DECORATORS
=
500
;
...
...
@@ -158,7 +158,7 @@ export class ColorProvider implements DocumentColorProvider {
constructor
(
private
decoratorProvider
:
(
uri
:
string
)
=>
Thenable
<
Range
[]
>
)
{
}
async
provideDocumentColors
(
document
:
TextDocument
):
Promise
<
Color
Info
[]
>
{
async
provideDocumentColors
(
document
:
TextDocument
):
Promise
<
Color
Range
[]
>
{
const
ranges
=
await
this
.
decoratorProvider
(
document
.
uri
.
toString
());
const
result
=
[];
for
(
let
range
of
ranges
)
{
...
...
@@ -175,7 +175,7 @@ export class ColorProvider implements DocumentColorProvider {
}
if
(
color
)
{
const
format
=
detectFormat
(
value
);
result
.
push
(
new
Color
Info
(
range
,
color
,
format
,
[
CSSColorFormats
.
Hex
,
CSSColorFormats
.
RGB
,
CSSColorFormats
.
HSL
]));
result
.
push
(
new
Color
Range
(
range
,
color
,
format
,
[
CSSColorFormats
.
Hex
,
CSSColorFormats
.
RGB
,
CSSColorFormats
.
HSL
]));
}
}
return
result
;
...
...
extensions/json/client/src/colorDecorators.ts
浏览文件 @
0f5272af
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
window
,
workspace
,
DecorationOptions
,
DecorationRenderOptions
,
Disposable
,
Range
,
TextDocument
,
DocumentColorProvider
,
Color
,
Color
Info
}
from
'
vscode
'
;
import
{
window
,
workspace
,
DecorationOptions
,
DecorationRenderOptions
,
Disposable
,
Range
,
TextDocument
,
DocumentColorProvider
,
Color
,
Color
Range
}
from
'
vscode
'
;
const
MAX_DECORATORS
=
500
;
...
...
@@ -140,7 +140,7 @@ export class ColorProvider implements DocumentColorProvider {
constructor
(
private
decoratorProvider
:
(
uri
:
string
)
=>
Thenable
<
Range
[]
>
)
{
}
async
provideDocumentColors
(
document
:
TextDocument
):
Promise
<
Color
Info
[]
>
{
async
provideDocumentColors
(
document
:
TextDocument
):
Promise
<
Color
Range
[]
>
{
const
ranges
=
await
this
.
decoratorProvider
(
document
.
uri
.
toString
());
const
result
=
[];
for
(
let
range
of
ranges
)
{
...
...
@@ -149,7 +149,7 @@ export class ColorProvider implements DocumentColorProvider {
let
color
=
Color
.
fromHex
(
value
);
if
(
color
)
{
let
r
=
new
Range
(
range
.
start
.
line
,
range
.
start
.
character
+
1
,
range
.
end
.
line
,
range
.
end
.
character
-
1
);
result
.
push
(
new
Color
Info
(
r
,
color
,
ColorFormat_HEX
,
[
ColorFormat_HEX
]));
result
.
push
(
new
Color
Range
(
r
,
color
,
ColorFormat_HEX
,
[
ColorFormat_HEX
]));
}
}
return
result
;
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
0f5272af
...
...
@@ -89,35 +89,146 @@ declare module 'vscode' {
export
function
deleteSecret
(
service
:
string
,
account
:
string
):
Thenable
<
boolean
>
;
}
/**
* Represents a color in RGBA space.
*/
export
class
Color
{
/**
* The red component of this color in the range [0-1].
*/
readonly
red
:
number
;
/**
* The green component of this color in the range [0-1].
*/
readonly
green
:
number
;
/**
* The blue component of this color in the range [0-1].
*/
readonly
blue
:
number
;
readonly
alpha
?:
number
;
constructor
(
red
:
number
,
green
:
number
,
blue
:
number
,
alpha
?:
number
);
/**
* The alpha component of this color in the range [0-1].
*/
readonly
alpha
:
number
;
constructor
(
red
:
number
,
green
:
number
,
blue
:
number
,
alpha
:
number
);
/**
* Creates a color from the HSLA space.
*
* @param hue The hue component in the range [0-1].
* @param saturation The saturation component in the range [0-1].
* @param luminance The luminance component in the range [0-1].
* @param alpha The alpha component in the range [0-1].
*/
static
fromHSLA
(
hue
:
number
,
saturation
:
number
,
luminance
:
number
,
alpha
:
number
):
Color
;
static
fromHSLA
(
hue
:
number
,
saturation
:
number
,
luminosity
:
number
,
alpha
?:
number
):
Color
;
// TODO: this isn't needed. this is a parsing util. remove
static
fromHex
(
hex
:
string
):
Color
;
}
/**
* A color format is either a single format or a combination of two
* formats: an opaque one and a transparent one. The format itself
* is a string representation of how the color can be formatted. It
* supports the use of placeholders, similar to how snippets work.
* Each placeholder, surrounded by curly braces `{}`, requires a
* variable name and can optionally specify a number format and range
* for that variable's value.
*
* Supported variables:
* - `red`
* - `green`
* - `blue`
* - `hue`
* - `saturation`
* - `luminosity`
* - `alpha`
*
* Supported number formats:
* - `f`, float with 2 decimal points. This is the default format. Default range is `[0-1]`.
* - `Xf`, float with `X` decimal points. Default range is `[0-1]`.
* - `d`, decimal. Default range is `[0-255]`.
* - `h`, `H`, hexadecimal. Default range is `[00-FF]`.
*
* The default number format is float. The default number range is `[0-1]`.
*
* As an example, take the color `Color(1, 0.5, 0, 1)`. Here's how
* different formats would format it:
*
* - CSS RGB
* - Format: `rgb({red:d[0-255]}, {green:d[0-255]}, {blue:d[0-255]})`
* - Output: `rgb(255, 127, 0)`
*
* - CSS RGBA
* - Format: `rgba({red:d[0-255]}, {green:d[0-255]}, {blue:d[0-255]}, {alpha})`
* - Output: `rgba(255, 127, 0, 1)`
*
* - CSS Hexadecimal
* - Format: `#{red:X}{green:X}{blue:X}`
* - Output: `#FF7F00`
*
* - CSS HSLA
* - Format: `hsla({hue:d[0-360]}, {saturation:d[0-100]}%, {luminosity:d[0-100]}%, {alpha})`
* - Output: `hsla(30, 100%, 50%, 1)`
*/
export
type
ColorFormat
=
string
|
{
opaque
:
string
,
transparent
:
string
};
// TODO@Michel
export
class
ColorInfo
{
/**
* Represents a color range from a document.
*/
export
class
ColorRange
{
/**
* The range in the document where this color appers.
*/
range
:
Range
;
/**
* The actual color value for this color range.
*/
color
:
Color
;
/**
* The format in which this color is currently formatted.
*/
// TODO can we remove this?
format
:
ColorFormat
;
/**
* The other formats this color range supports the color to be formatted in.
*/
availableFormats
:
ColorFormat
[];
/**
* Creates a new color range.
*
* @param range The range the color appears in. Must not be empty.
* @param color The value of the color.
* @param format The format in which this color is currently formatted.
* @param availableFormats The other formats this color range supports the color to be formatted in.
*/
constructor
(
range
:
Range
,
color
:
Color
,
format
:
ColorFormat
,
availableFormats
:
ColorFormat
[]);
}
/**
* The document color provider defines the contract between extensions and feature of
* picking and modifying colors in the editor.
*/
export
interface
DocumentColorProvider
{
provideDocumentColors
(
document
:
TextDocument
,
token
:
CancellationToken
):
ProviderResult
<
ColorInfo
[]
>
;
/**
* Provide colors for the given document.
*
* @param document The document in which the command was invoked.
* @param token A cancellation token.
* @return An array of [color ranges](#ColorRange) or a thenable that resolves to such. The lack of a result
* can be signaled by returning `undefined`, `null`, or an empty array.
*/
provideDocumentColors
(
document
:
TextDocument
,
token
:
CancellationToken
):
ProviderResult
<
ColorRange
[]
>
;
}
export
namespace
languages
{
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
0f5272af
...
...
@@ -528,7 +528,7 @@ export function createApiFactory(
CancellationTokenSource
:
CancellationTokenSource
,
CodeLens
:
extHostTypes
.
CodeLens
,
Color
:
extHostTypes
.
Color
,
Color
Info
:
extHostTypes
.
ColorInfo
,
Color
Range
:
extHostTypes
.
ColorRange
,
EndOfLine
:
extHostTypes
.
EndOfLine
,
CompletionItem
:
extHostTypes
.
CompletionItem
,
CompletionItemKind
:
extHostTypes
.
CompletionItemKind
,
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
0f5272af
...
...
@@ -1040,7 +1040,7 @@ export class Color {
export
type
IColorFormat
=
string
|
{
opaque
:
string
,
transparent
:
string
};
export
class
Color
Info
{
export
class
Color
Range
{
range
:
Range
;
color
:
Color
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录