Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f9e371fb
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,发现更多精彩内容 >>
提交
f9e371fb
编写于
1月 25, 2017
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add scroll actions (fixes #18922)
上级
fc11a4c1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
159 addition
and
4 deletion
+159
-4
src/vs/workbench/parts/walkThrough/electron-browser/walkThrough.contribution.ts
.../walkThrough/electron-browser/walkThrough.contribution.ts
+17
-1
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughActions.ts
.../parts/walkThrough/electron-browser/walkThroughActions.ts
+99
-0
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts
...nch/parts/walkThrough/electron-browser/walkThroughPart.ts
+43
-3
未找到文件。
src/vs/workbench/parts/walkThrough/electron-browser/walkThrough.contribution.ts
浏览文件 @
f9e371fb
...
...
@@ -6,7 +6,8 @@
import
{
localize
}
from
'
vs/nls
'
;
import
{
WalkThroughInput
}
from
'
vs/workbench/parts/walkThrough/node/walkThroughInput
'
;
import
{
WalkThroughPart
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughPart
'
;
import
{
WalkThroughPart
,
WALK_THROUGH_FOCUS
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughPart
'
;
import
{
WalkThroughArrowUpAction
,
WalkThroughArrowDownAction
,
WalkThroughPageUpAction
,
WalkThroughPageDownAction
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughActions
'
;
import
{
WalkThroughContentProvider
,
WalkThroughSnippetContentProvider
}
from
'
vs/workbench/parts/walkThrough/node/walkThroughContentProvider
'
;
import
{
EditorWalkThroughAction
}
from
'
vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
...
...
@@ -16,6 +17,9 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
IWorkbenchActionRegistry
,
Extensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
Registry
.
as
<
IEditorRegistry
>
(
EditorExtensions
.
Editors
)
.
registerEditor
(
new
EditorDescriptor
(
WalkThroughPart
.
ID
,
...
...
@@ -34,3 +38,15 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
.
registerWorkbenchContribution
(
WalkThroughSnippetContentProvider
);
Registry
.
as
<
IWorkbenchActionRegistry
>
(
Extensions
.
WorkbenchActions
)
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
WalkThroughArrowUpAction
,
WalkThroughArrowUpAction
.
ID
,
WalkThroughArrowUpAction
.
LABEL
,
{
primary
:
KeyCode
.
UpArrow
},
ContextKeyExpr
.
and
(
WALK_THROUGH_FOCUS
,
EditorContextKeys
.
TextFocus
.
toNegated
())),
'
Interactive Playground: Scroll Up (Line)
'
,
localize
(
'
interactivePlayground
'
,
"
Interactive Playground
"
));
Registry
.
as
<
IWorkbenchActionRegistry
>
(
Extensions
.
WorkbenchActions
)
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
WalkThroughArrowDownAction
,
WalkThroughArrowDownAction
.
ID
,
WalkThroughArrowDownAction
.
LABEL
,
{
primary
:
KeyCode
.
DownArrow
},
ContextKeyExpr
.
and
(
WALK_THROUGH_FOCUS
,
EditorContextKeys
.
TextFocus
.
toNegated
())),
'
Interactive Playground: Scroll Down (Line)
'
,
localize
(
'
interactivePlayground
'
,
"
Interactive Playground
"
));
Registry
.
as
<
IWorkbenchActionRegistry
>
(
Extensions
.
WorkbenchActions
)
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
WalkThroughPageUpAction
,
WalkThroughPageUpAction
.
ID
,
WalkThroughPageUpAction
.
LABEL
,
{
primary
:
KeyCode
.
PageUp
},
ContextKeyExpr
.
and
(
WALK_THROUGH_FOCUS
,
EditorContextKeys
.
TextFocus
.
toNegated
())),
'
Interactive Playground: Scroll Up (Page)
'
,
localize
(
'
interactivePlayground
'
,
"
Interactive Playground
"
));
Registry
.
as
<
IWorkbenchActionRegistry
>
(
Extensions
.
WorkbenchActions
)
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
WalkThroughPageDownAction
,
WalkThroughPageDownAction
.
ID
,
WalkThroughPageDownAction
.
LABEL
,
{
primary
:
KeyCode
.
PageDown
},
ContextKeyExpr
.
and
(
WALK_THROUGH_FOCUS
,
EditorContextKeys
.
TextFocus
.
toNegated
())),
'
Interactive Playground: Scroll Down (Page)
'
,
localize
(
'
interactivePlayground
'
,
"
Interactive Playground
"
));
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughActions.ts
0 → 100644
浏览文件 @
f9e371fb
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
WalkThroughPart
}
from
'
vs/workbench/parts/walkThrough/electron-browser/walkThroughPart
'
;
export
class
WalkThroughArrowUpAction
extends
Action
{
public
static
ID
=
'
workbench.action.interactivePlayground.arrowUp
'
;
public
static
LABEL
=
localize
(
'
editorWalkThrough.arrowUp
'
,
"
Scroll Up (Line)
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
void
>
{
const
editor
=
this
.
editorService
.
getActiveEditor
();
if
(
editor
instanceof
WalkThroughPart
)
{
editor
.
arrowUp
();
}
return
null
;
}
}
export
class
WalkThroughArrowDownAction
extends
Action
{
public
static
ID
=
'
workbench.action.interactivePlayground.arrowDown
'
;
public
static
LABEL
=
localize
(
'
editorWalkThrough.arrowDown
'
,
"
Scroll Down (Line)
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
void
>
{
const
editor
=
this
.
editorService
.
getActiveEditor
();
if
(
editor
instanceof
WalkThroughPart
)
{
editor
.
arrowDown
();
}
return
null
;
}
}
export
class
WalkThroughPageUpAction
extends
Action
{
public
static
ID
=
'
workbench.action.interactivePlayground.pageUp
'
;
public
static
LABEL
=
localize
(
'
editorWalkThrough.pageUp
'
,
"
Scroll Up (Page)
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
void
>
{
const
editor
=
this
.
editorService
.
getActiveEditor
();
if
(
editor
instanceof
WalkThroughPart
)
{
editor
.
pageUp
();
}
return
null
;
}
}
export
class
WalkThroughPageDownAction
extends
Action
{
public
static
ID
=
'
workbench.action.interactivePlayground.pageDown
'
;
public
static
LABEL
=
localize
(
'
editorWalkThrough.pageDown
'
,
"
Scroll Down (Page)
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
void
>
{
const
editor
=
this
.
editorService
.
getActiveEditor
();
if
(
editor
instanceof
WalkThroughPart
)
{
editor
.
pageDown
();
}
return
null
;
}
}
\ No newline at end of file
src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts
浏览文件 @
f9e371fb
...
...
@@ -31,6 +31,10 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
localize
}
from
'
vs/nls
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
RawContextKey
,
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
export
const
WALK_THROUGH_FOCUS
=
new
RawContextKey
<
boolean
>
(
'
interactivePlaygroundFocus
'
,
false
);
const
UNBOUND_COMMAND
=
localize
(
'
walkThrough.unboundCommand
'
,
"
unbound
"
);
const
WALK_THROUGH_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
walkThroughEditorViewState
'
;
...
...
@@ -58,6 +62,7 @@ export class WalkThroughPart extends BaseEditor {
private
contentDisposables
:
IDisposable
[]
=
[];
private
content
:
HTMLDivElement
;
private
scrollbar
:
DomScrollableElement
;
private
editorFocus
:
IContextKey
<
boolean
>
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
...
...
@@ -68,9 +73,12 @@ export class WalkThroughPart extends BaseEditor {
@
IModelService
protected
modelService
:
IModelService
,
@
IKeybindingService
private
keybindingService
:
IKeybindingService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IModeService
private
modeService
:
IModeService
)
{
super
(
WalkThroughPart
.
ID
,
telemetryService
);
this
.
editorFocus
=
WALK_THROUGH_FOCUS
.
bindTo
(
this
.
contextKeyService
);
}
createEditor
(
parent
:
Builder
):
void
{
...
...
@@ -82,6 +90,12 @@ export class WalkThroughPart extends BaseEditor {
this
.
content
.
addEventListener
(
'
mousedown
'
,
e
=>
{
this
.
focus
();
});
this
.
content
.
addEventListener
(
'
focus
'
,
e
=>
{
this
.
editorFocus
.
set
(
true
);
});
this
.
content
.
addEventListener
(
'
blur
'
,
e
=>
{
this
.
editorFocus
.
reset
();
});
this
.
scrollbar
=
new
DomScrollableElement
(
this
.
content
,
{
canUseTranslate3d
:
false
,
...
...
@@ -171,6 +185,31 @@ export class WalkThroughPart extends BaseEditor {
if
(
!
active
)
{
this
.
content
.
focus
();
}
this
.
editorFocus
.
set
(
true
);
}
arrowUp
()
{
this
.
scrollbar
.
updateState
({
scrollTop
:
this
.
scrollbar
.
getScrollTop
()
-
this
.
getArrowScrollHeight
()
});
}
arrowDown
()
{
this
.
scrollbar
.
updateState
({
scrollTop
:
this
.
scrollbar
.
getScrollTop
()
+
this
.
getArrowScrollHeight
()
});
}
private
getArrowScrollHeight
()
{
let
fontSize
=
this
.
configurationService
.
lookup
<
number
>
(
'
editor.fontSize
'
).
value
;
if
(
typeof
fontSize
!==
'
number
'
||
fontSize
<
1
)
{
fontSize
=
12
;
}
return
3
*
fontSize
;
}
pageUp
()
{
this
.
scrollbar
.
updateState
({
scrollTop
:
this
.
scrollbar
.
getScrollTop
()
-
this
.
scrollbar
.
getHeight
()
});
}
pageDown
()
{
this
.
scrollbar
.
updateState
({
scrollTop
:
this
.
scrollbar
.
getScrollTop
()
+
this
.
scrollbar
.
getHeight
()
});
}
setInput
(
input
:
WalkThroughInput
,
options
:
EditorOptions
):
TPromise
<
void
>
{
...
...
@@ -246,9 +285,9 @@ export class WalkThroughPart extends BaseEditor {
this
.
contentDisposables
.
push
(
this
.
themeService
.
onDidColorThemeChange
(
theme
=>
editor
.
updateOptions
({
theme
:
theme
.
id
})));
if
(
i
===
0
)
{
editor
.
focus
();
}
//
if (i === 0) {
//
editor.focus();
//
}
});
if
(
input
.
onReady
)
{
input
.
onReady
(
innerContent
);
...
...
@@ -340,6 +379,7 @@ export class WalkThroughPart extends BaseEditor {
}
dispose
():
void
{
this
.
editorFocus
.
reset
();
this
.
contentDisposables
=
dispose
(
this
.
contentDisposables
);
this
.
disposables
=
dispose
(
this
.
disposables
);
super
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录