Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
29976b03
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
29976b03
编写于
3月 10, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add cursorStyle to TextEditorOptions
上级
1fb7eb9c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
84 addition
and
7 deletion
+84
-7
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+21
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+2
-0
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+5
-1
src/vs/workbench/api/node/mainThreadEditors.ts
src/vs/workbench/api/node/mainThreadEditors.ts
+56
-6
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
29976b03
...
...
@@ -520,6 +520,20 @@ declare namespace vscode {
viewColumn
:
ViewColumn
;
}
/**
* Rendering style of the cursor.
*/
export
enum
TextEditorCursorStyle
{
/**
* Render the cursor as a vertical line.
*/
Line
=
1
,
/**
* Render the cursor as a block.
*/
Block
=
2
}
/**
* Represents a [text editor](#TextEditor)'s [options](#TextEditor.options).
*/
...
...
@@ -540,6 +554,13 @@ declare namespace vscode {
* When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
*/
insertSpaces
?:
boolean
|
string
;
/**
* The rendering style of the cursor in this editor.
* When getting a text editor's options, this property will always be present.
* When setting a text editor's options, this property is optional.
*/
cursorStyle
?:
TextEditorCursorStyle
;
}
/**
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
29976b03
...
...
@@ -86,6 +86,7 @@ export class ExtHostAPIImplementation {
OverviewRulerLane
:
typeof
vscode
.
OverviewRulerLane
;
TextEditorRevealType
:
typeof
vscode
.
TextEditorRevealType
;
EndOfLine
:
typeof
vscode
.
EndOfLine
;
TextEditorCursorStyle
:
typeof
vscode
.
TextEditorCursorStyle
;
commands
:
typeof
vscode
.
commands
;
window
:
typeof
vscode
.
window
;
workspace
:
typeof
vscode
.
workspace
;
...
...
@@ -132,6 +133,7 @@ export class ExtHostAPIImplementation {
this
.
OverviewRulerLane
=
EditorCommon
.
OverviewRulerLane
;
this
.
TextEditorRevealType
=
TextEditorRevealType
;
this
.
EndOfLine
=
extHostTypes
.
EndOfLine
;
this
.
TextEditorCursorStyle
=
extHostTypes
.
TextEditorCursorStyle
;
errors
.
setUnexpectedErrorHandler
((
err
)
=>
{
this
.
_proxy
.
onUnexpectedExtHostError
(
errors
.
transformErrorForSerialization
(
err
));
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
29976b03
...
...
@@ -692,4 +692,8 @@ export enum StatusBarAlignment {
export
enum
EndOfLine
{
LF
=
1
,
CRLF
=
2
}
\ No newline at end of file
}
export
enum
TextEditorCursorStyle
{
Line
=
1
,
Block
=
2
}
src/vs/workbench/api/node/mainThreadEditors.ts
浏览文件 @
29976b03
...
...
@@ -13,15 +13,17 @@ import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
EndOfLine
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
EndOfLine
,
TextEditorCursorStyle
}
from
'
vs/workbench/api/node/extHostTypes
'
;
export
interface
ITextEditorConfigurationUpdate
{
tabSize
?:
number
|
string
;
insertSpaces
?:
boolean
|
string
;
cursorStyle
?:
TextEditorCursorStyle
;
}
export
interface
IResolvedTextEditorConfiguration
{
tabSize
:
number
;
insertSpaces
:
boolean
;
cursorStyle
:
TextEditorCursorStyle
;
}
function
configurationsEqual
(
a
:
IResolvedTextEditorConfiguration
,
b
:
IResolvedTextEditorConfiguration
)
{
...
...
@@ -86,10 +88,10 @@ export class MainThreadTextEditor {
this
.
_onConfigurationChanged
=
new
Emitter
<
IResolvedTextEditorConfiguration
>
();
this
.
_lastSelection
=
[
new
Selection
(
1
,
1
,
1
,
1
)
];
this
.
_setConfiguration
(
MainThreadTextEditor
.
_readConfiguration
(
this
.
_model
));
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
this
.
_modelListeners
=
[];
this
.
_modelListeners
.
push
(
this
.
_model
.
addListener2
(
EditorCommon
.
EventType
.
ModelOptionsChanged
,
(
e
)
=>
{
this
.
_setConfiguration
(
MainThreadTextEditor
.
_readConfiguration
(
this
.
_model
));
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
}));
this
.
setCodeEditor
(
codeEditor
);
...
...
@@ -138,6 +140,10 @@ export class MainThreadTextEditor {
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
EditorBlur
,
()
=>
{
this
.
_focusTracker
.
onLostFocus
();
}));
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
ConfigurationChanged
,
()
=>
{
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
}));
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
}
}
...
...
@@ -173,7 +179,7 @@ export class MainThreadTextEditor {
return
this
.
_configuration
;
}
p
ublic
se
tConfiguration
(
newConfiguration
:
ITextEditorConfigurationUpdate
):
void
{
p
rivate
_setInden
tConfiguration
(
newConfiguration
:
ITextEditorConfigurationUpdate
):
void
{
if
(
newConfiguration
.
tabSize
===
'
auto
'
||
newConfiguration
.
insertSpaces
===
'
auto
'
)
{
// one of the options was set to 'auto' => detect indentation
...
...
@@ -212,6 +218,23 @@ export class MainThreadTextEditor {
this
.
_model
.
updateOptions
(
newOpts
);
}
public
setConfiguration
(
newConfiguration
:
ITextEditorConfigurationUpdate
):
void
{
this
.
_setIndentConfiguration
(
newConfiguration
);
if
(
newConfiguration
.
cursorStyle
)
{
let
newCursorStyle
=
cursorStyleToString
(
newConfiguration
.
cursorStyle
);
if
(
!
this
.
_codeEditor
)
{
console
.
warn
(
'
setConfiguration on invisible editor
'
);
return
;
}
this
.
_codeEditor
.
updateOptions
({
cursorStyle
:
newCursorStyle
});
}
}
public
setDecorations
(
key
:
string
,
ranges
:
EditorCommon
.
IRangeWithMessage
[]):
void
{
if
(
!
this
.
_codeEditor
)
{
console
.
warn
(
'
setDecorations on invisible editor
'
);
...
...
@@ -236,11 +259,18 @@ export class MainThreadTextEditor {
}
}
private
static
_readConfiguration
(
model
:
EditorCommon
.
IModel
):
IResolvedTextEditorConfiguration
{
private
_readConfiguration
(
model
:
EditorCommon
.
IModel
,
codeEditor
:
EditorCommon
.
ICommonCodeEditor
):
IResolvedTextEditorConfiguration
{
let
cursorStyle
=
this
.
_configuration
?
this
.
_configuration
.
cursorStyle
:
TextEditorCursorStyle
.
Line
;
if
(
codeEditor
)
{
let
codeEditorOpts
=
codeEditor
.
getConfiguration
();
cursorStyle
=
cursorStyleFromString
(
codeEditorOpts
.
cursorStyle
);
}
let
indent
=
model
.
getOptions
();
return
{
insertSpaces
:
indent
.
insertSpaces
,
tabSize
:
indent
.
tabSize
tabSize
:
indent
.
tabSize
,
cursorStyle
:
cursorStyle
};
}
...
...
@@ -615,4 +645,24 @@ function strcmp(a:string, b:string): number {
return
1
;
}
return
0
;
}
function
cursorStyleToString
(
cursorStyle
:
TextEditorCursorStyle
):
string
{
if
(
cursorStyle
===
TextEditorCursorStyle
.
Line
)
{
return
'
line
'
;
}
else
if
(
cursorStyle
===
TextEditorCursorStyle
.
Block
)
{
return
'
block
'
;
}
else
{
throw
new
Error
(
'
cursorStyleToString: Unknown cursorStyle
'
);
}
}
function
cursorStyleFromString
(
cursorStyle
:
string
):
TextEditorCursorStyle
{
if
(
cursorStyle
===
'
line
'
)
{
return
TextEditorCursorStyle
.
Line
;
}
else
if
(
cursorStyle
===
'
block
'
)
{
return
TextEditorCursorStyle
.
Block
;
}
else
{
throw
new
Error
(
'
cursorStyleFromString: Unknown cursorStyle
'
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录