Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
67bd6f03
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,发现更多精彩内容 >>
提交
67bd6f03
编写于
1月 12, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Towards simplifying MouseTargetFactory
上级
eac9adad
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
300 addition
and
208 deletion
+300
-208
src/vs/editor/browser/controller/mouseHandler.ts
src/vs/editor/browser/controller/mouseHandler.ts
+7
-7
src/vs/editor/browser/controller/mouseTarget.ts
src/vs/editor/browser/controller/mouseTarget.ts
+230
-192
src/vs/editor/browser/editorDom.ts
src/vs/editor/browser/editorDom.ts
+63
-9
未找到文件。
src/vs/editor/browser/controller/mouseHandler.ts
浏览文件 @
67bd6f03
...
@@ -453,23 +453,23 @@ class MouseDownOperation extends Disposable {
...
@@ -453,23 +453,23 @@ class MouseDownOperation extends Disposable {
let
mouseColumn
=
this
.
_getMouseColumn
(
e
);
let
mouseColumn
=
this
.
_getMouseColumn
(
e
);
if
(
e
.
posy
<
editorContent
.
top
)
{
if
(
e
.
posy
<
editorContent
.
y
)
{
let
aboveLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
Math
.
max
(
this
.
_viewHelper
.
getScrollTop
()
-
(
editorContent
.
top
-
e
.
posy
),
0
));
let
aboveLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
Math
.
max
(
this
.
_viewHelper
.
getScrollTop
()
-
(
editorContent
.
y
-
e
.
posy
),
0
));
return
new
MousePosition
(
new
Position
(
aboveLineNumber
,
1
),
mouseColumn
);
return
new
MousePosition
(
new
Position
(
aboveLineNumber
,
1
),
mouseColumn
);
}
}
if
(
e
.
posy
>
editorContent
.
top
+
editorContent
.
height
)
{
if
(
e
.
posy
>
editorContent
.
y
+
editorContent
.
height
)
{
let
belowLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
this
.
_viewHelper
.
getScrollTop
()
+
(
e
.
posy
-
editorContent
.
top
));
let
belowLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
this
.
_viewHelper
.
getScrollTop
()
+
(
e
.
posy
-
editorContent
.
y
));
return
new
MousePosition
(
new
Position
(
belowLineNumber
,
this
.
_context
.
model
.
getLineMaxColumn
(
belowLineNumber
)),
mouseColumn
);
return
new
MousePosition
(
new
Position
(
belowLineNumber
,
this
.
_context
.
model
.
getLineMaxColumn
(
belowLineNumber
)),
mouseColumn
);
}
}
let
possibleLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
this
.
_viewHelper
.
getScrollTop
()
+
(
e
.
posy
-
editorContent
.
top
));
let
possibleLineNumber
=
this
.
_viewHelper
.
getLineNumberAtVerticalOffset
(
this
.
_viewHelper
.
getScrollTop
()
+
(
e
.
posy
-
editorContent
.
y
));
if
(
e
.
posx
<
editorContent
.
left
)
{
if
(
e
.
posx
<
editorContent
.
x
)
{
return
new
MousePosition
(
new
Position
(
possibleLineNumber
,
1
),
mouseColumn
);
return
new
MousePosition
(
new
Position
(
possibleLineNumber
,
1
),
mouseColumn
);
}
}
if
(
e
.
posx
>
editorContent
.
left
+
editorContent
.
width
)
{
if
(
e
.
posx
>
editorContent
.
x
+
editorContent
.
width
)
{
return
new
MousePosition
(
new
Position
(
possibleLineNumber
,
this
.
_context
.
model
.
getLineMaxColumn
(
possibleLineNumber
)),
mouseColumn
);
return
new
MousePosition
(
new
Position
(
possibleLineNumber
,
this
.
_context
.
model
.
getLineMaxColumn
(
possibleLineNumber
)),
mouseColumn
);
}
}
...
...
src/vs/editor/browser/controller/mouseTarget.ts
浏览文件 @
67bd6f03
此差异已折叠。
点击以展开。
src/vs/editor/browser/editorDom.ts
浏览文件 @
67bd6f03
...
@@ -9,27 +9,81 @@ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
...
@@ -9,27 +9,81 @@ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
GlobalMouseMoveMonitor
}
from
'
vs/base/browser/globalMouseMoveMonitor
'
;
import
{
GlobalMouseMoveMonitor
}
from
'
vs/base/browser/globalMouseMoveMonitor
'
;
/**
* Coordinates relative to the whole document (e.g. mouse event's pageX and pageY)
*/
export
class
PageCoordinates
{
_pageCoordinatesBrand
:
void
;
public
readonly
x
:
number
;
public
readonly
y
:
number
;
constructor
(
x
:
number
,
y
:
number
)
{
this
.
x
=
x
;
this
.
y
=
y
;
}
public
toClientCoordinates
():
ClientCoordinates
{
return
new
ClientCoordinates
(
this
.
x
-
dom
.
StandardWindow
.
scrollX
,
this
.
y
-
dom
.
StandardWindow
.
scrollY
);
}
}
/**
* Coordinates within the application's client area (i.e. origin is document's scroll position).
*
* For example, clicking in the top-left corner of the client area will
* always result in a mouse event with a client.x value of 0, regardless
* of whether the page is scrolled horizontally.
*/
export
class
ClientCoordinates
{
_clientCoordinatesBrand
:
void
;
public
readonly
clientX
:
number
;
public
readonly
clientY
:
number
;
constructor
(
clientX
:
number
,
clientY
:
number
)
{
this
.
clientX
=
clientX
;
this
.
clientY
=
clientY
;
}
}
/**
* The position of the editor in the page.
*/
export
class
EditorPagePosition
{
_editorPagePositionBrand
:
void
;
public
readonly
x
:
number
;
public
readonly
y
:
number
;
public
readonly
width
:
number
;
public
readonly
height
:
number
;
constructor
(
x
:
number
,
y
:
number
,
width
:
number
,
height
:
number
)
{
this
.
x
=
x
;
this
.
y
=
y
;
this
.
width
=
width
;
this
.
height
=
height
;
}
}
export
class
EditorMouseEvent
extends
StandardMouseEvent
{
export
class
EditorMouseEvent
extends
StandardMouseEvent
{
_editorMouseEventBrand
:
void
;
_editorMouseEventBrand
:
void
;
editorPos
:
dom
.
IDomNodePagePosition
;
/**
/**
*
The horizontal position of the cursor relative to the viewport (i.e. scrolled)
.
*
Coordinates relative to the whole document
.
*/
*/
viewportx
:
number
;
public
readonly
page
:
PageCoordinates
;
/**
/**
*
The vertical position of the cursor relative to the viewport (i.e. scrolled)
.
*
Editor's coordinates relative to the whole document
.
*/
*/
viewporty
:
number
;
public
readonly
editorPos
:
EditorPagePosition
;
constructor
(
e
:
MouseEvent
,
editorViewDomNode
:
HTMLElement
)
{
constructor
(
e
:
MouseEvent
,
editorViewDomNode
:
HTMLElement
)
{
super
(
e
);
super
(
e
);
this
.
editorPos
=
dom
.
getDomNodePagePosition
(
editorViewDomNode
);
this
.
page
=
new
PageCoordinates
(
this
.
posx
,
this
.
posy
);
this
.
viewportx
=
this
.
posx
-
dom
.
StandardWindow
.
scrollX
;
let
editorPos
=
dom
.
getDomNodePagePosition
(
editorViewDomNode
)
;
this
.
viewporty
=
this
.
posy
-
dom
.
StandardWindow
.
scrollY
;
this
.
editorPos
=
new
EditorPagePosition
(
editorPos
.
left
,
editorPos
.
top
,
editorPos
.
width
,
editorPos
.
height
)
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录