Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
19816a1c
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,发现更多精彩内容 >>
提交
19816a1c
编写于
4月 18, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strong typing for ViewOutgoingEvents
上级
30f83907
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
91 addition
and
97 deletion
+91
-97
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+2
-2
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+5
-8
src/vs/editor/browser/view/viewOutgoingEvents.ts
src/vs/editor/browser/view/viewOutgoingEvents.ts
+46
-38
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+38
-49
未找到文件。
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
19816a1c
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
...
...
@@ -13,6 +12,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
FastDomNode
}
from
'
vs/base/browser/fastDomNode
'
;
import
{
ViewOutgoingEvents
}
from
'
vs/editor/browser/view/viewOutgoingEvents
'
;
/**
* @internal
...
...
@@ -56,7 +56,7 @@ export interface ICodeEditorHelper {
export
interface
IView
extends
IDisposable
{
domNode
:
FastDomNode
<
HTMLElement
>
;
getInternalEventBus
():
IEventEmitter
;
getInternalEventBus
():
ViewOutgoingEvents
;
createOverviewRuler
(
cssClassName
:
string
,
minimumHeight
:
number
,
maximumHeight
:
number
):
IOverviewRuler
;
getCodeEditorHelper
():
ICodeEditorHelper
;
...
...
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
19816a1c
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
browser
from
'
vs/base/browser/browser
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
...
...
@@ -669,11 +668,11 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
return
this
.
codeEditorHelper
;
}
public
getInternalEventBus
():
IEventEmitter
{
public
getInternalEventBus
():
ViewOutgoingEvents
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
ViewImpl.getInternalEventBus: View is disposed
'
);
}
return
this
.
outgoingEvents
.
getInternalEventBus
()
;
return
this
.
outgoingEvents
;
}
public
saveState
():
editorCommon
.
IViewState
{
...
...
@@ -851,11 +850,9 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
ViewImpl._renderOnce: View is disposed
'
);
}
return
this
.
outgoingEvents
.
deferredEmit
(()
=>
{
let
r
=
safeInvokeNoArg
(
callback
);
this
.
_scheduleRender
();
return
r
;
});
let
r
=
safeInvokeNoArg
(
callback
);
this
.
_scheduleRender
();
return
r
;
}
private
_scheduleRender
():
void
{
...
...
src/vs/editor/browser/view/viewOutgoingEvents.ts
浏览文件 @
19816a1c
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
EventEmitter
,
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -14,90 +13,99 @@ import { IScrollEvent, MouseTargetType } from 'vs/editor/common/editorCommon';
import
{
IEditorMouseEvent
,
IMouseTarget
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
MouseTarget
}
from
'
vs/editor/browser/controller/mouseTarget
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
export
c
onst
ViewEventType
=
{
export
c
lass
ViewOutgoingEvents
extends
Disposable
{
EditorScroll
:
'
scroll
'
,
private
readonly
_onDidScroll
:
Emitter
<
IScrollEvent
>
=
this
.
_register
(
new
Emitter
<
IScrollEvent
>
());
public
readonly
onDidScroll
:
Event
<
IScrollEvent
>
=
this
.
_onDidScroll
.
event
;
ViewFocusGained
:
'
focusGained
'
,
ViewFocusLost
:
'
focusLost
'
,
private
readonly
_onDidGainFocus
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidGainFocus
:
Event
<
void
>
=
this
.
_onDidGainFocus
.
event
;
ContextMenu
:
'
contextMenu
'
,
MouseDown
:
'
mousedown
'
,
MouseUp
:
'
mouseup
'
,
MouseMove
:
'
mousemove
'
,
MouseLeave
:
'
mouseleave
'
,
MouseDrag
:
'
mousedrag
'
,
MouseDrop
:
'
mousedrop
'
,
KeyDown
:
'
keydown
'
,
KeyUp
:
'
keyup
'
,
};
private
readonly
_onDidLoseFocus
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidLoseFocus
:
Event
<
void
>
=
this
.
_onDidLoseFocus
.
event
;
export
class
ViewOutgoingEvents
extends
Disposable
{
private
readonly
_onKeyDown
:
Emitter
<
IKeyboardEvent
>
=
this
.
_register
(
new
Emitter
<
IKeyboardEvent
>
());
public
readonly
onKeyDown
:
Event
<
IKeyboardEvent
>
=
this
.
_onKeyDown
.
event
;
private
readonly
_onKeyUp
:
Emitter
<
IKeyboardEvent
>
=
this
.
_register
(
new
Emitter
<
IKeyboardEvent
>
());
public
readonly
onKeyUp
:
Event
<
IKeyboardEvent
>
=
this
.
_onKeyUp
.
event
;
private
readonly
_onContextMenu
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onContextMenu
:
Event
<
IEditorMouseEvent
>
=
this
.
_onContextMenu
.
event
;
private
readonly
_onMouseMove
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseMove
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseMove
.
event
;
private
readonly
_onMouseLeave
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseLeave
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseLeave
.
event
;
private
readonly
_onMouseUp
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseUp
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseUp
.
event
;
private
readonly
_onMouseDown
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseDown
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseDown
.
event
;
private
readonly
_onMouseDrag
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseDrag
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseDrag
.
event
;
private
readonly
_onMouseDrop
:
Emitter
<
IEditorMouseEvent
>
=
this
.
_register
(
new
Emitter
<
IEditorMouseEvent
>
());
public
readonly
onMouseDrop
:
Event
<
IEditorMouseEvent
>
=
this
.
_onMouseDrop
.
event
;
private
_viewModel
:
IViewModel
;
private
_actual
:
EventEmitter
;
constructor
(
viewModel
:
IViewModel
)
{
super
();
this
.
_viewModel
=
viewModel
;
this
.
_actual
=
this
.
_register
(
new
EventEmitter
());
}
public
getInternalEventBus
():
IEventEmitter
{
return
this
.
_actual
;
}
public
deferredEmit
<
T
>
(
callback
:
()
=>
T
):
T
{
return
this
.
_actual
.
deferredEmit
(
callback
);
}
public
emitScrollChanged
(
e
:
viewEvents
.
ViewScrollChangedEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
EditorScroll
,
<
IScrollEvent
>
e
);
this
.
_
onDidScroll
.
fire
(
e
);
}
public
emitViewFocusGained
():
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
ViewFocusGained
,
{}
);
this
.
_
onDidGainFocus
.
fire
(
);
}
public
emitViewFocusLost
():
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
ViewFocusLost
,
{}
);
this
.
_
onDidLoseFocus
.
fire
(
);
}
public
emitKeyDown
(
e
:
IKeyboardEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
KeyDown
,
e
);
this
.
_
onKeyDown
.
fire
(
e
);
}
public
emitKeyUp
(
e
:
IKeyboardEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
KeyUp
,
e
);
this
.
_
onKeyUp
.
fire
(
e
);
}
public
emitContextMenu
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
ContextMenu
,
this
.
_convertViewToModelMouseEvent
(
e
)
);
this
.
_
onContextMenu
.
fire
(
e
);
}
public
emitMouseMove
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseMove
,
this
.
_convertViewToModelMouseEvent
(
e
)
);
this
.
_
onMouseMove
.
fire
(
e
);
}
public
emitMouseLeave
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseLeave
,
this
.
_convertViewToModelMouseEvent
(
e
)
);
this
.
_
onMouseLeave
.
fire
(
e
);
}
public
emitMouseUp
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseUp
,
this
.
_convertViewToModelMouseEvent
(
e
)
);
this
.
_
onMouseUp
.
fire
(
e
);
}
public
emitMouseDown
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseDown
,
this
.
_convertViewToModelMouseEvent
(
e
));
this
.
_
onMouseDown
.
fire
(
this
.
_convertViewToModelMouseEvent
(
e
));
}
public
emitMouseDrag
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseDrag
,
this
.
_convertViewToModelMouseEvent
(
e
));
this
.
_
onMouseDrag
.
fire
(
this
.
_convertViewToModelMouseEvent
(
e
));
}
public
emitMouseDrop
(
e
:
IEditorMouseEvent
):
void
{
this
.
_
actual
.
emit
(
ViewEventType
.
MouseDrop
,
this
.
_convertViewToModelMouseEvent
(
e
));
this
.
_
onMouseDrop
.
fire
(
this
.
_convertViewToModelMouseEvent
(
e
));
}
private
_convertViewToModelMouseEvent
(
e
:
IEditorMouseEvent
):
IEditorMouseEvent
{
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
19816a1c
...
...
@@ -29,7 +29,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
InternalEditorAction
}
from
'
vs/editor/common/editorAction
'
;
import
{
ViewEventType
}
from
'
vs/editor/browser/view/viewOutgoingEvents
'
;
export
abstract
class
CodeEditorWidget
extends
CommonCodeEditor
implements
editorBrowser
.
ICodeEditor
{
...
...
@@ -544,66 +543,56 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
}
);
this
.
listenersToRemove
.
push
(
this
.
_view
.
getInternalEventBus
().
addBulkListener
((
events
)
=>
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
eventType
=
events
[
i
].
type
;
let
e
=
events
[
i
].
data
;
const
viewEventBus
=
this
.
_view
.
getInternalEventBus
();
switch
(
eventType
)
{
case
ViewEventType
.
ViewFocusGained
:
this
.
_onDidFocusEditorText
.
fire
();
// In IE, the focus is not synchronous, so we give it a little help
this
.
_onDidFocusEditor
.
fire
();
break
;
case
ViewEventType
.
EditorScroll
:
this
.
_onDidScrollChange
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onDidGainFocus
(()
=>
{
this
.
_onDidFocusEditorText
.
fire
();
// In IE, the focus is not synchronous, so we give it a little help
this
.
_onDidFocusEditor
.
fire
();
}));
case
ViewEventType
.
ViewFocusLost
:
this
.
_onDidBlurEditorText
.
fire
(
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onDidScroll
((
e
)
=>
{
this
.
_onDidScrollChange
.
fire
(
e
);
}))
;
case
ViewEventType
.
ContextMenu
:
this
.
_onContextMenu
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onDidLoseFocus
(()
=>
{
this
.
_onDidBlurEditorText
.
fire
(
);
}))
;
case
ViewEventType
.
MouseDown
:
this
.
_onMouseDown
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onContextMenu
((
e
)
=>
{
this
.
_onContextMenu
.
fire
(
e
);
}))
;
case
ViewEventType
.
MouseUp
:
this
.
_onMouseUp
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseDown
((
e
)
=>
{
this
.
_onMouseDown
.
fire
(
e
);
}))
;
case
ViewEventType
.
MouseDrag
:
this
.
_onMouseDrag
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseUp
((
e
)
=>
{
this
.
_onMouseUp
.
fire
(
e
);
}))
;
case
ViewEventType
.
MouseDrop
:
this
.
_onMouseDrop
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseDrag
((
e
)
=>
{
this
.
_onMouseDrag
.
fire
(
e
);
}))
;
case
ViewEventType
.
KeyUp
:
this
.
_onKeyU
p
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseDrop
((
e
)
=>
{
this
.
_onMouseDro
p
.
fire
(
e
);
}))
;
case
ViewEventType
.
MouseMove
:
this
.
_onMouseMove
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onKeyUp
((
e
)
=>
{
this
.
_onKeyUp
.
fire
(
e
);
}))
;
case
ViewEventType
.
MouseLeave
:
this
.
_onMouseLea
ve
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseMove
((
e
)
=>
{
this
.
_onMouseMo
ve
.
fire
(
e
);
}))
;
case
ViewEventType
.
KeyDown
:
this
.
_onKeyDown
.
fire
(
e
);
break
;
this
.
listenersToRemove
.
push
(
viewEventBus
.
onMouseLeave
((
e
)
=>
{
this
.
_onMouseLeave
.
fire
(
e
);
}))
;
default
:
// console.warn("Unhandled view event: ", e);
}
}
this
.
listenersToRemove
.
push
(
viewEventBus
.
onKeyDown
((
e
)
=>
{
this
.
_onKeyDown
.
fire
(
e
);
}));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录