Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3713e4de
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,发现更多精彩内容 >>
提交
3713e4de
编写于
7月 24, 2017
作者:
M
Michel Kaporin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added ColorMode to API.
上级
2c45d350
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
81 addition
and
41 deletion
+81
-41
src/vs/base/common/color.ts
src/vs/base/common/color.ts
+1
-1
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+7
-3
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+2
-3
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+9
-2
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
+4
-1
src/vs/editor/contrib/colorPicker/browser/colorPickerModel.ts
...vs/editor/contrib/colorPicker/browser/colorPickerModel.ts
+9
-14
src/vs/editor/contrib/colorPicker/common/colorPicker.ts
src/vs/editor/contrib/colorPicker/common/colorPicker.ts
+5
-1
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+13
-8
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+10
-3
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
...kbench/api/electron-browser/mainThreadLanguageFeatures.ts
+3
-2
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+2
-1
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+1
-0
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+14
-2
未找到文件。
src/vs/base/common/color.ts
浏览文件 @
3713e4de
...
...
@@ -509,4 +509,4 @@ export class Color {
public
static
readonly
cyan
=
new
Color
(
new
RGBA
(
0
,
255
,
255
,
255
));
public
static
readonly
lightgrey
=
new
Color
(
new
RGBA
(
211
,
211
,
211
,
255
));
public
static
readonly
transparent
=
new
Color
(
new
RGBA
(
0
,
0
,
0
,
0
));
}
\ No newline at end of file
}
src/vs/editor/common/editorCommon.ts
浏览文件 @
3713e4de
...
...
@@ -9,7 +9,7 @@ import { MarkedString } from 'vs/base/common/htmlContent';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
LanguageId
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageId
,
LanguageIdentifier
,
ColorMode
}
from
'
vs/editor/common/modes
'
;
import
{
LineTokens
}
from
'
vs/editor/common/core/lineTokens
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -62,6 +62,10 @@ export interface IModelDecorationOverviewRulerOptions {
position
:
OverviewRulerLane
;
}
export
interface
IColorInfo
{
color
:
Color
;
mode
:
ColorMode
;
}
/**
* Options for a model decoration.
*/
...
...
@@ -84,9 +88,9 @@ export interface IModelDecorationOptions {
*/
hoverMessage
?:
MarkedString
|
MarkedString
[];
/**
* Color to render in the color picker.
* Color
with mode
to render in the color picker.
*/
color
?:
Color
;
color
Info
?:
IColorInfo
;
/**
* Should the decoration expand to encompass a whole line.
*/
...
...
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
3713e4de
...
...
@@ -17,7 +17,6 @@ import { LanguageIdentifier } from 'vs/editor/common/modes';
import
{
ITextSource
,
IRawTextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
*
as
textModelEvents
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
ThemeColor
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Color
}
from
"
vs/base/common/color
"
;
export
const
ClassName
=
{
EditorWarningDecoration
:
'
greensquiggly
'
,
...
...
@@ -896,7 +895,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
readonly
stickiness
:
editorCommon
.
TrackedRangeStickiness
;
readonly
className
:
string
;
readonly
hoverMessage
:
MarkedString
|
MarkedString
[];
readonly
color
:
Color
;
readonly
color
Info
:
editorCommon
.
IColorInfo
;
readonly
glyphMarginHoverMessage
:
MarkedString
|
MarkedString
[];
readonly
isWholeLine
:
boolean
;
readonly
showIfCollapsed
:
boolean
;
...
...
@@ -913,7 +912,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
this
.
stickiness
=
options
.
stickiness
||
editorCommon
.
TrackedRangeStickiness
.
AlwaysGrowsWhenTypingAtEdges
;
this
.
className
=
options
.
className
?
cleanClassName
(
options
.
className
)
:
strings
.
empty
;
this
.
hoverMessage
=
options
.
hoverMessage
||
[];
this
.
color
=
options
.
color
||
undefined
;
this
.
color
Info
=
options
.
colorInfo
||
undefined
;
this
.
glyphMarginHoverMessage
=
options
.
glyphMarginHoverMessage
||
strings
.
empty
;
this
.
isWholeLine
=
options
.
isWholeLine
||
false
;
this
.
showIfCollapsed
=
options
.
showIfCollapsed
||
false
;
...
...
src/vs/editor/common/modes.ts
浏览文件 @
3713e4de
...
...
@@ -173,7 +173,7 @@ export interface MarkedStringHover {
// TODO@michel documentation
export
interface
ColorHover
{
color
:
Color
;
mode
:
ColorMode
;
/**
* The range to which this hover applies. When missing, the
* editor will use the range at the current position or the
...
...
@@ -678,12 +678,19 @@ export interface LinkProvider {
*/
export
interface
IColorInfo
{
color
:
Color
;
mode
:
ColorMode
;
range
:
IRange
;
}
export
enum
ColorMode
{
RGBA
=
0
,
Hex
=
1
,
HSLA
=
2
}
/**
* A provider of
link
s.
* A provider of
color
s.
*/
export
interface
ColorProvider
{
provideColors
(
model
:
editorCommon
.
IReadOnlyModel
,
token
:
CancellationToken
):
IColorInfo
[]
|
Thenable
<
IColorInfo
[]
>
;
}
...
...
src/vs/editor/contrib/colorPicker/browser/colorPicker.ts
浏览文件 @
3713e4de
...
...
@@ -112,7 +112,10 @@ export class ColorPicker implements IEditorContribution {
endColumn
:
c
.
range
.
endColumn
},
options
:
{
color
:
c
.
color
colorInfo
:
{
color
:
c
.
color
,
mode
:
c
.
mode
}
}
});
}
...
...
src/vs/editor/contrib/colorPicker/browser/colorPickerModel.ts
浏览文件 @
3713e4de
...
...
@@ -5,6 +5,7 @@
import
{
ColorPickerWidget
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerWidget
"
;
import
{
Color
,
RGBA
}
from
"
vs/base/common/color
"
;
import
{
ColorMode
}
from
"
vs/editor/common/modes
"
;
export
class
ColorPickerModel
{
...
...
@@ -17,7 +18,7 @@ export class ColorPickerModel {
private
_opacity
:
number
;
private
_hue
:
Color
;
private
_colorModel
:
ColorMode
l
;
private
_colorModel
:
ColorMode
;
private
_colorModelIndex
:
number
;
constructor
()
{
...
...
@@ -32,9 +33,9 @@ export class ColorPickerModel {
this
.
_hue
=
color
;
}
if
(
this
.
_colorModel
===
ColorMode
l
.
RGBA
)
{
if
(
this
.
_colorModel
===
ColorMode
.
RGBA
)
{
this
.
selectedColorString
=
color
.
toRGBA
().
toString
();
}
else
if
(
this
.
_colorModel
===
ColorMode
l
.
Hex
)
{
}
else
if
(
this
.
_colorModel
===
ColorMode
.
Hex
)
{
this
.
selectedColorString
=
color
.
toRGBHex
();
}
else
{
this
.
selectedColorString
=
color
.
toHSLA
().
toString
();
...
...
@@ -73,8 +74,8 @@ export class ColorPickerModel {
public
set
opacity
(
opacity
:
number
)
{
this
.
_opacity
=
opacity
;
if
(
this
.
_colorModel
===
ColorMode
l
.
Hex
)
{
this
.
colorModel
=
ColorMode
l
.
RGBA
;
if
(
this
.
_colorModel
===
ColorMode
.
Hex
)
{
this
.
colorModel
=
ColorMode
.
RGBA
;
}
const
rgba
=
this
.
_color
.
toRGBA
();
...
...
@@ -89,7 +90,7 @@ export class ColorPickerModel {
return
this
.
_opacity
;
}
public
set
colorModel
(
model
:
ColorMode
l
)
{
public
set
colorModel
(
model
:
ColorMode
)
{
this
.
_colorModel
=
model
;
this
.
_colorModelIndex
=
model
;
...
...
@@ -98,7 +99,7 @@ export class ColorPickerModel {
}
}
public
get
colorModel
():
ColorMode
l
{
public
get
colorModel
():
ColorMode
{
return
this
.
_colorModel
;
}
...
...
@@ -110,7 +111,7 @@ export class ColorPickerModel {
}
// Skip hex model if opacity is set
if
(
this
.
_colorModelIndex
===
ColorMode
l
.
Hex
&&
this
.
_opacity
!==
1
)
{
if
(
this
.
_colorModelIndex
===
ColorMode
.
Hex
&&
this
.
_opacity
!==
1
)
{
this
.
nextColorModel
();
return
;
}
...
...
@@ -122,10 +123,4 @@ export class ColorPickerModel {
export
class
ISaturationState
{
public
x
:
number
;
public
y
:
number
;
}
export
enum
ColorModel
{
RGBA
,
Hex
,
HSL
}
\ No newline at end of file
src/vs/editor/contrib/colorPicker/common/colorPicker.ts
浏览文件 @
3713e4de
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
import
{
ColorProviderRegistry
,
IColorInfo
}
from
"
vs/editor/common/modes
"
;
import
{
ColorProviderRegistry
,
IColorInfo
,
ColorProvider
}
from
"
vs/editor/common/modes
"
;
import
{
asWinJsPromise
}
from
"
vs/base/common/async
"
;
import
{
onUnexpectedExternalError
}
from
"
vs/base/common/errors
"
;
import
{
IReadOnlyModel
}
from
"
vs/editor/common/editorCommon
"
;
...
...
@@ -24,4 +24,8 @@ export function getColors(model: IReadOnlyModel): TPromise<IColorInfo[]> {
return
TPromise
.
join
(
promises
).
then
(()
=>
{
return
colors
;
});
}
export
function
changeMode
(
provider
:
ColorProvider
,
colorInfo
:
IColorInfo
):
TPromise
<
string
>
{
throw
new
Error
(
'
not implemented
'
);
}
\ No newline at end of file
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
3713e4de
...
...
@@ -22,9 +22,9 @@ import { HoverOperation, IHoverComputer } from './hoverOperation';
import
{
ContentHoverWidget
}
from
'
./hoverWidgets
'
;
import
{
textToMarkedString
,
MarkedString
}
from
'
vs/base/common/htmlContent
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModelWithDecorations
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
ColorPickerModel
,
ColorModel
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerModel
"
;
import
{
ColorPickerModel
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerModel
"
;
import
{
ColorPickerWidget
}
from
"
vs/editor/contrib/colorPicker/browser/colorPickerWidget
"
;
import
{
IColorInfo
}
from
'
vs/editor/common/editorCommon
'
;
class
ModesContentComputer
implements
IHoverComputer
<
Hover
[]
>
{
...
...
@@ -67,7 +67,7 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
return
[];
}
const
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[]
|
Color
)
=>
{
const
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[]
|
IColorInfo
)
=>
{
return
contents
&&
(
!
Array
.
isArray
(
contents
)
||
(
<
MarkedString
[]
>
contents
).
length
>
0
);
};
...
...
@@ -78,7 +78,7 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
if
(
startColumn
>
this
.
_range
.
startColumn
||
this
.
_range
.
endColumn
>
endColumn
||
(
!
hasHoverContent
(
d
.
options
.
hoverMessage
)
&&
!
hasHoverContent
(
d
.
options
.
color
)))
{
if
(
startColumn
>
this
.
_range
.
startColumn
||
this
.
_range
.
endColumn
>
endColumn
||
(
!
hasHoverContent
(
d
.
options
.
hoverMessage
)
&&
!
hasHoverContent
(
d
.
options
.
color
Info
)))
{
return
null
;
}
...
...
@@ -93,9 +93,14 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
}
}
const
color
=
d
.
options
.
color
;
if
(
color
)
{
return
{
color
,
range
};
const
colorInfo
=
d
.
options
.
colorInfo
;
if
(
colorInfo
)
{
return
{
color
:
colorInfo
.
color
,
mode
:
colorInfo
.
mode
,
range
:
range
};
}
return
{
contents
,
range
};
...
...
@@ -289,7 +294,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
const
widget
=
this
.
_register
(
new
ColorPickerWidget
(
model
,
this
.
_editor
));
model
.
widget
=
widget
;
model
.
originalColor
=
msg
.
color
.
toRGBA
().
toString
();
model
.
colorModel
=
ColorModel
.
RGBA
;
model
.
colorModel
=
msg
.
mode
;
model
.
color
=
msg
.
color
;
this
.
_colorPicker
=
widget
;
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
3713e4de
...
...
@@ -265,6 +265,12 @@ declare module 'vscode' {
static
fromHex
(
hex
:
string
):
Color
;
}
export
enum
ColorMode
{
RGBA
=
0
,
Hex
=
1
,
// should we account for 4-byte hex?
HSLA
=
2
}
// TODO@Michel
export
class
ColorInfo
{
/**
...
...
@@ -274,13 +280,14 @@ declare module 'vscode' {
color
:
Color
;
constructor
(
color
:
Color
,
range
:
Range
);
}
mode
:
ColorMode
;
constructor
(
range
:
Range
,
color
:
Color
,
mode
:
ColorMode
);
}
export
interface
DocumentColorProvider
{
provideDocumentColors
(
document
:
TextDocument
,
token
:
CancellationToken
):
ProviderResult
<
ColorInfo
[]
>
;
//
provideColorFormat(colorInfo: ColorInfo): ProviderResult<string>;
provideColorFormat
(
colorInfo
:
ColorInfo
):
ProviderResult
<
string
>
;
}
export
namespace
languages
{
...
...
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
浏览文件 @
3713e4de
...
...
@@ -272,10 +272,11 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
this
.
_registrations
[
handle
]
=
modes
.
ColorProviderRegistry
.
register
(
selector
,
<
modes
.
ColorProvider
>
{
provideColors
:
(
model
,
token
)
=>
{
return
wireCancellationToken
(
token
,
this
.
_proxy
.
$provideDocumentColors
(
handle
,
model
.
uri
))
.
then
((
colors
)
=>
{
return
colors
.
map
(
c
=>
{
.
then
((
color
Info
s
)
=>
{
return
color
Info
s
.
map
(
c
=>
{
return
{
color
:
Color
.
fromRGBA
(
new
RGBA
(
c
.
color
[
0
],
c
.
color
[
1
],
c
.
color
[
2
],
c
.
color
[
3
]
*
255
)),
mode
:
c
.
mode
,
range
:
c
.
range
};
});
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
3713e4de
...
...
@@ -492,6 +492,7 @@ export function createApiFactory(
CodeLens
:
extHostTypes
.
CodeLens
,
Color
:
extHostTypes
.
Color
,
ColorInfo
:
extHostTypes
.
ColorInfo
,
ColorMode
:
extHostTypes
.
ColorMode
,
EndOfLine
:
extHostTypes
.
EndOfLine
,
CompletionItem
:
extHostTypes
.
CompletionItem
,
CompletionItemKind
:
extHostTypes
.
CompletionItemKind
,
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
3713e4de
...
...
@@ -35,7 +35,7 @@ import { IConfigurationData } from 'vs/platform/configuration/common/configurati
import
{
IPickOpenEntry
,
IPickOptions
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
SaveReason
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TextEditorCursorStyle
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
EndOfLine
,
TextEditorLineNumbersStyle
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
EndOfLine
,
TextEditorLineNumbersStyle
,
ColorMode
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
TaskSet
}
from
'
vs/workbench/parts/tasks/common/tasks
'
;
...
...
@@ -456,6 +456,7 @@ export abstract class ExtHostHeapServiceShape {
export
interface
IColorInfo
{
color
:
[
number
,
number
,
number
,
number
|
undefined
];
mode
:
ColorMode
;
range
:
IRange
;
}
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
3713e4de
...
...
@@ -374,6 +374,7 @@ export namespace DocumentColor {
export
function
from
(
colorInfo
:
vscode
.
ColorInfo
):
IColorInfo
{
return
{
color
:
[
colorInfo
.
color
.
red
,
colorInfo
.
color
.
green
,
colorInfo
.
color
.
blue
,
colorInfo
.
color
.
alpha
],
mode
:
<
number
>
colorInfo
.
mode
,
range
:
fromRange
(
colorInfo
.
range
)
};
}
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
3713e4de
...
...
@@ -1043,20 +1043,32 @@ export class Color {
}
}
export
enum
ColorMode
{
RGBA
=
0
,
Hex
=
1
,
HSLA
=
2
}
export
class
ColorInfo
{
range
:
Range
;
color
:
Color
;
constructor
(
color
:
Color
,
range
:
Range
)
{
mode
:
ColorMode
;
constructor
(
range
:
Range
,
color
:
Color
,
mode
:
ColorMode
)
{
if
(
color
&&
!
(
color
instanceof
Color
))
{
throw
illegalArgument
(
'
target
'
);
throw
illegalArgument
(
'
color
'
);
}
if
(
mode
&&
!
(
mode
in
ColorMode
))
{
throw
illegalArgument
(
'
mode
'
);
}
if
(
!
Range
.
isRange
(
range
)
||
range
.
isEmpty
)
{
throw
illegalArgument
(
'
range
'
);
}
this
.
range
=
range
;
this
.
color
=
color
;
this
.
mode
=
mode
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录