Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ce593d7a
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,发现更多精彩内容 >>
提交
ce593d7a
编写于
4月 30, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only certain dom nodes get editor font settings (#5972)
上级
03a0c93a
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
254 addition
and
202 deletion
+254
-202
src/vs/base/browser/styleMutator.ts
src/vs/base/browser/styleMutator.ts
+10
-0
src/vs/editor/browser/config/configuration.ts
src/vs/editor/browser/config/configuration.ts
+41
-32
src/vs/editor/browser/controller/keyboardHandler.ts
src/vs/editor/browser/controller/keyboardHandler.ts
+5
-2
src/vs/editor/browser/controller/mouseTarget.ts
src/vs/editor/browser/controller/mouseTarget.ts
+1
-1
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+5
-0
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+3
-6
src/vs/editor/browser/view/viewOverlays.ts
src/vs/editor/browser/view/viewOverlays.ts
+11
-0
src/vs/editor/browser/viewParts/lines/viewLine.ts
src/vs/editor/browser/viewParts/lines/viewLine.ts
+3
-3
src/vs/editor/browser/viewParts/lines/viewLines.ts
src/vs/editor/browser/viewParts/lines/viewLines.ts
+5
-0
src/vs/editor/browser/viewParts/rulers/rulers.ts
src/vs/editor/browser/viewParts/rulers/rulers.ts
+3
-3
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
+30
-25
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+4
-0
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+1
-1
src/vs/editor/browser/widget/media/default-theme.css
src/vs/editor/browser/widget/media/default-theme.css
+0
-9
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+1
-1
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+29
-53
src/vs/editor/common/config/defaultConfig.ts
src/vs/editor/common/config/defaultConfig.ts
+11
-2
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+39
-31
src/vs/editor/common/viewModel/viewModel.ts
src/vs/editor/common/viewModel/viewModel.ts
+1
-1
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
+34
-20
src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts
...or/contrib/parameterHints/browser/parameterHintsWidget.ts
+8
-1
src/vs/editor/contrib/suggest/browser/suggest.css
src/vs/editor/contrib/suggest/browser/suggest.css
+4
-0
src/vs/editor/test/common/mocks/mockConfiguration.ts
src/vs/editor/test/common/mocks/mockConfiguration.ts
+4
-10
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
...editor/test/common/viewModel/splitLinesCollection.test.ts
+1
-1
未找到文件。
src/vs/base/browser/styleMutator.ts
浏览文件 @
ce593d7a
...
...
@@ -16,6 +16,7 @@ export abstract class FastDomNode {
private
_left
:
number
;
private
_bottom
:
number
;
private
_right
:
number
;
private
_fontFamily
:
string
;
private
_fontSize
:
number
;
private
_lineHeight
:
number
;
private
_className
:
string
;
...
...
@@ -38,6 +39,7 @@ export abstract class FastDomNode {
this
.
_left
=
-
1
;
this
.
_bottom
=
-
1
;
this
.
_right
=
-
1
;
this
.
_fontFamily
=
''
;
this
.
_fontSize
=
-
1
;
this
.
_lineHeight
=
-
1
;
this
.
_className
=
''
;
...
...
@@ -104,6 +106,14 @@ export abstract class FastDomNode {
this
.
_domNode
.
style
.
right
=
this
.
_right
+
'
px
'
;
}
public
setFontFamily
(
fontFamily
:
string
):
void
{
if
(
this
.
_fontFamily
===
fontFamily
)
{
return
;
}
this
.
_fontFamily
=
fontFamily
;
this
.
_domNode
.
style
.
fontFamily
=
this
.
_fontFamily
;
}
public
setFontSize
(
fontSize
:
number
):
void
{
if
(
this
.
_fontSize
===
fontSize
)
{
return
;
...
...
src/vs/editor/browser/config/configuration.ts
浏览文件 @
ce593d7a
...
...
@@ -8,34 +8,35 @@ import Event, {Emitter} from 'vs/base/common/event';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
browser
from
'
vs/base/browser/browser
'
;
import
{
CommonEditorConfiguration
,
ICSSConfig
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
IDimension
,
EditorStyling
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
IDimension
,
FontInfo
,
BareFontInfo
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ElementSizeObserver
}
from
'
vs/editor/browser/config/elementSizeObserver
'
;
import
{
FastDomNode
}
from
'
vs/base/browser/styleMutator
'
;
class
CSSBasedConfigurationCache
{
private
_keys
:
{
[
key
:
string
]:
EditorStyling
;
};
private
_values
:
{
[
key
:
string
]:
ICSSConfig
;
};
private
_keys
:
{
[
key
:
string
]:
BareFontInfo
;
};
private
_values
:
{
[
key
:
string
]:
FontInfo
;
};
constructor
()
{
this
.
_keys
=
Object
.
create
(
null
);
this
.
_values
=
Object
.
create
(
null
);
}
public
has
(
item
:
EditorStyling
):
boolean
{
public
has
(
item
:
BareFontInfo
):
boolean
{
return
!!
this
.
_values
[
item
.
getId
()];
}
public
get
(
item
:
EditorStyling
):
ICSSConfig
{
public
get
(
item
:
BareFontInfo
):
FontInfo
{
return
this
.
_values
[
item
.
getId
()];
}
public
put
(
item
:
EditorStyling
,
value
:
ICSSConfig
):
void
{
public
put
(
item
:
BareFontInfo
,
value
:
FontInfo
):
void
{
this
.
_keys
[
item
.
getId
()]
=
item
;
this
.
_values
[
item
.
getId
()]
=
value
;
}
public
getKeys
():
EditorStyling
[]
{
public
getKeys
():
BareFontInfo
[]
{
return
Object
.
keys
(
this
.
_keys
).
map
(
id
=>
this
.
_keys
[
id
]);
}
}
...
...
@@ -99,9 +100,9 @@ class CSSBasedConfiguration extends Disposable {
super
.
dispose
();
}
public
readConfiguration
(
styling
:
EditorStyling
):
ICSSConfig
{
if
(
!
this
.
_cache
.
has
(
styling
))
{
let
readConfig
=
CSSBasedConfiguration
.
_actualReadConfiguration
(
styling
);
public
readConfiguration
(
bareFontInfo
:
BareFontInfo
):
FontInfo
{
if
(
!
this
.
_cache
.
has
(
bareFontInfo
))
{
let
readConfig
=
CSSBasedConfiguration
.
_actualReadConfiguration
(
bareFontInfo
);
if
(
readConfig
.
typicalHalfwidthCharacterWidth
<=
2
||
readConfig
.
typicalFullwidthCharacterWidth
<=
2
||
readConfig
.
spaceWidth
<=
2
||
readConfig
.
maxDigitWidth
<=
2
)
{
// Hey, it's Bug 14341 ... we couldn't read
...
...
@@ -112,9 +113,9 @@ class CSSBasedConfiguration extends Disposable {
this
.
_installChangeMonitor
();
}
this
.
_cache
.
put
(
styling
,
readConfig
);
this
.
_cache
.
put
(
bareFontInfo
,
readConfig
);
}
return
this
.
_cache
.
get
(
styling
);
return
this
.
_cache
.
get
(
bareFontInfo
);
}
private
_installChangeMonitor
():
void
{
...
...
@@ -151,9 +152,9 @@ class CSSBasedConfiguration extends Disposable {
return
'
editorSizeProvider
'
+
index
;
}
private
static
_createTestElements
(
styling
:
EditorStyling
,
readers
:
CharWidthReader
[]):
HTMLElement
{
private
static
_createTestElements
(
bareFontInfo
:
BareFontInfo
,
readers
:
CharWidthReader
[]):
HTMLElement
{
let
container
=
document
.
createElement
(
'
div
'
);
Configuration
.
apply
EditorStyling
(
container
,
styling
);
Configuration
.
apply
FontInfoSlow
(
container
,
bareFontInfo
);
container
.
style
.
position
=
'
absolute
'
;
container
.
style
.
top
=
'
-50000px
'
;
container
.
style
.
width
=
'
50000px
'
;
...
...
@@ -179,9 +180,9 @@ class CSSBasedConfiguration extends Disposable {
}
}
private
static
_runReaders
(
styling
:
EditorStyling
,
readers
:
CharWidthReader
[]):
void
{
private
static
_runReaders
(
bareFontInfo
:
BareFontInfo
,
readers
:
CharWidthReader
[]):
void
{
// Create a test container with all these test elements
let
testContainer
=
this
.
_createTestElements
(
styling
,
readers
);
let
testContainer
=
this
.
_createTestElements
(
bareFontInfo
,
readers
);
// Add the container to the DOM
document
.
body
.
appendChild
(
testContainer
);
...
...
@@ -193,35 +194,43 @@ class CSSBasedConfiguration extends Disposable {
document
.
body
.
removeChild
(
testContainer
);
}
private
static
_actualReadConfiguration
(
styling
:
EditorStyling
):
ICSSConfig
{
private
static
_actualReadConfiguration
(
bareFontInfo
:
BareFontInfo
):
FontInfo
{
let
typicalHalfwidthCharacter
=
new
CharWidthReader
(
'
n
'
);
let
typicalFullwidthCharacter
=
new
CharWidthReader
(
'
\
uff4d
'
);
let
space
=
new
CharWidthReader
(
'
'
);
let
digits
=
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
].
map
(
chr
=>
new
CharWidthReader
(
chr
));
this
.
_runReaders
(
styling
,
digits
.
concat
([
typicalHalfwidthCharacter
,
typicalFullwidthCharacter
,
space
]));
this
.
_runReaders
(
bareFontInfo
,
digits
.
concat
([
typicalHalfwidthCharacter
,
typicalFullwidthCharacter
,
space
]));
let
maxDigitWidth
=
0
;
for
(
let
i
=
0
,
len
=
digits
.
length
;
i
<
len
;
i
++
)
{
maxDigitWidth
=
Math
.
max
(
maxDigitWidth
,
digits
[
i
].
width
);
}
return
{
typicalHalfwidthCharacterWidth
:
typicalHalfwidthCharacter
.
width
,
typicalFullwidthCharacterWidth
:
typicalFullwidthCharacter
.
width
,
spaceWidth
:
space
.
width
,
maxDigitWidth
:
maxDigitWidth
};
return
new
FontInfo
(
bareFontInfo
.
fontFamily
,
bareFontInfo
.
fontSize
,
bareFontInfo
.
lineHeight
,
typicalHalfwidthCharacter
.
width
,
typicalFullwidthCharacter
.
width
,
space
.
width
,
maxDigitWidth
);
}
}
export
class
Configuration
extends
CommonEditorConfiguration
{
public
static
applyEditorStyling
(
domNode
:
HTMLElement
,
styling
:
EditorStyling
):
void
{
domNode
.
className
=
styling
.
editorClassName
;
domNode
.
style
.
fontFamily
=
styling
.
fontFamily
;
domNode
.
style
.
fontSize
=
styling
.
fontSize
+
'
px
'
;
domNode
.
style
.
lineHeight
=
styling
.
lineHeight
+
'
px
'
;
public
static
applyFontInfoSlow
(
domNode
:
HTMLElement
,
fontInfo
:
BareFontInfo
):
void
{
domNode
.
style
.
fontFamily
=
fontInfo
.
fontFamily
;
domNode
.
style
.
fontSize
=
fontInfo
.
fontSize
+
'
px
'
;
domNode
.
style
.
lineHeight
=
fontInfo
.
lineHeight
+
'
px
'
;
}
public
static
applyFontInfo
(
domNode
:
FastDomNode
,
fontInfo
:
BareFontInfo
):
void
{
domNode
.
setFontFamily
(
fontInfo
.
fontFamily
);
domNode
.
setFontSize
(
fontInfo
.
fontSize
);
domNode
.
setLineHeight
(
fontInfo
.
lineHeight
);
}
constructor
(
options
:
any
,
referenceDomElement
:
HTMLElement
=
null
)
{
...
...
@@ -278,7 +287,7 @@ export class Configuration extends CommonEditorConfiguration {
return
this
.
_elementSizeObserver
.
getHeight
();
}
protected
readConfiguration
(
styling
:
EditorStyling
):
ICSSConfig
{
return
CSSBasedConfiguration
.
INSTANCE
.
readConfiguration
(
styling
);
protected
readConfiguration
(
bareFontInfo
:
BareFontInfo
):
FontInfo
{
return
CSSBasedConfiguration
.
INSTANCE
.
readConfiguration
(
bareFontInfo
);
}
}
src/vs/editor/browser/controller/keyboardHandler.ts
浏览文件 @
ce593d7a
...
...
@@ -17,6 +17,7 @@ import {Range} from 'vs/editor/common/core/range';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
IKeyboardHandlerHelper
,
IViewContext
,
IViewController
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
class
ClipboardEventWrapper
implements
IClipboardEvent
{
...
...
@@ -209,6 +210,7 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
this
.
context
=
context
;
this
.
viewController
=
viewController
;
this
.
textArea
=
new
TextAreaWrapper
(
viewHelper
.
textArea
);
Configuration
.
applyFontInfoSlow
(
this
.
textArea
.
actual
,
this
.
context
.
configuration
.
editor
.
fontInfo
);
this
.
viewHelper
=
viewHelper
;
this
.
contentLeft
=
0
;
...
...
@@ -294,8 +296,9 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
public
onConfigurationChanged
(
e
:
editorCommon
.
IConfigurationChangedEvent
):
boolean
{
// Give textarea same font size & line height as editor, for the IME case (when the textarea is visible)
StyleMutator
.
setFontSize
(
this
.
textArea
.
actual
,
this
.
context
.
configuration
.
editor
.
fontSize
);
StyleMutator
.
setLineHeight
(
this
.
textArea
.
actual
,
this
.
context
.
configuration
.
editor
.
lineHeight
);
if
(
e
.
fontInfo
)
{
Configuration
.
applyFontInfoSlow
(
this
.
textArea
.
actual
,
this
.
context
.
configuration
.
editor
.
fontInfo
);
}
if
(
e
.
experimentalScreenReader
)
{
this
.
textAreaHandler
.
setStrategy
(
this
.
_getStrategy
());
}
...
...
src/vs/editor/browser/controller/mouseTarget.ts
浏览文件 @
ce593d7a
...
...
@@ -601,7 +601,7 @@ export class MouseTargetFactory {
if
(
mouseContentHorizontalOffset
<
0
)
{
return
1
;
}
let
charWidth
=
this
.
context
.
configuration
.
editor
.
typicalHalfwidthCharacterWidth
;
let
charWidth
=
this
.
context
.
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
;
let
chars
=
Math
.
round
(
mouseContentHorizontalOffset
/
charWidth
);
return
(
chars
+
1
);
}
...
...
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
ce593d7a
...
...
@@ -687,6 +687,11 @@ export interface ICodeEditor extends editorCommon.ICommonCodeEditor {
setHiddenAreas
(
ranges
:
editorCommon
.
IRange
[]):
void
;
setAriaActiveDescendant
(
id
:
string
):
void
;
/**
* Apply the same font settings as the editor to `target`.
*/
applyFontInfo
(
target
:
HTMLElement
):
void
;
}
/**
...
...
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
ce593d7a
...
...
@@ -103,7 +103,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this
.
linesContent
=
document
.
createElement
(
'
div
'
);
this
.
linesContent
.
className
=
editorBrowser
.
ClassNames
.
LINES_CONTENT
+
'
monaco-editor-background
'
;
this
.
domNode
=
document
.
createElement
(
'
div
'
);
Configuration
.
applyEditorStyling
(
this
.
domNode
,
configuration
.
editor
.
stylingInfo
)
;
this
.
domNode
.
className
=
configuration
.
editor
.
editorClassName
;
this
.
overflowGuardContainer
=
document
.
createElement
(
'
div
'
);
this
.
overflowGuardContainer
.
className
=
editorBrowser
.
ClassNames
.
OVERFLOW_GUARD
;
...
...
@@ -177,9 +177,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
StyleMutator
.
setTop
(
this
.
textArea
,
0
);
StyleMutator
.
setLeft
(
this
.
textArea
,
0
);
// Give textarea same font size & line height as editor, for the IME case (when the textarea is visible)
StyleMutator
.
setFontSize
(
this
.
textArea
,
this
.
context
.
configuration
.
editor
.
fontSize
);
StyleMutator
.
setLineHeight
(
this
.
textArea
,
this
.
context
.
configuration
.
editor
.
lineHeight
);
this
.
listenersToDispose
.
push
(
dom
.
addDisposableListener
(
this
.
textArea
,
'
focus
'
,
()
=>
this
.
_setHasFocus
(
true
)));
this
.
listenersToDispose
.
push
(
dom
.
addDisposableListener
(
this
.
textArea
,
'
blur
'
,
()
=>
this
.
_setHasFocus
(
false
)));
...
...
@@ -443,8 +440,8 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
return
false
;
}
public
onConfigurationChanged
(
e
:
editorCommon
.
IConfigurationChangedEvent
):
boolean
{
if
(
e
.
stylingInfo
)
{
Configuration
.
applyEditorStyling
(
this
.
domNode
,
this
.
context
.
configuration
.
editor
.
stylingInfo
)
;
if
(
e
.
editorClassName
)
{
this
.
domNode
.
className
=
this
.
context
.
configuration
.
editor
.
editorClassName
;
}
if
(
e
.
ariaLabel
)
{
this
.
textArea
.
setAttribute
(
'
aria-label
'
,
this
.
context
.
configuration
.
editor
.
ariaLabel
);
...
...
src/vs/editor/browser/view/viewOverlays.ts
浏览文件 @
ce593d7a
...
...
@@ -10,6 +10,7 @@ import {IScrollEvent, IConfigurationChangedEvent, IEditorLayoutInfo, IModelDecor
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IVisibleLineData
,
ViewLayer
}
from
'
vs/editor/browser/view/viewLayer
'
;
import
{
DynamicViewOverlay
}
from
'
vs/editor/browser/view/dynamicViewOverlay
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
export
class
ViewOverlays
extends
ViewLayer
{
...
...
@@ -231,6 +232,8 @@ export class MarginViewOverlays extends ViewOverlays {
this
.
domNode
.
setClassName
(
editorBrowser
.
ClassNames
.
MARGIN_VIEW_OVERLAYS
+
'
monaco-editor-background
'
);
this
.
domNode
.
setWidth
(
1
);
Configuration
.
applyFontInfo
(
this
.
domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
}
protected
_extraDomNodeHTML
():
string
{
...
...
@@ -264,6 +267,14 @@ export class MarginViewOverlays extends ViewOverlays {
return
super
.
onLayoutChanged
(
layoutInfo
)
||
true
;
}
public
onConfigurationChanged
(
e
:
IConfigurationChangedEvent
):
boolean
{
if
(
e
.
fontInfo
)
{
Configuration
.
applyFontInfo
(
this
.
domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
}
return
super
.
onConfigurationChanged
(
e
);
}
_viewOverlaysRender
(
ctx
:
editorBrowser
.
IRestrictedRenderingContext
):
void
{
super
.
_viewOverlaysRender
(
ctx
);
if
(
browser
.
canUseTranslate3d
)
{
...
...
src/vs/editor/browser/viewParts/lines/viewLine.ts
浏览文件 @
ce593d7a
...
...
@@ -38,7 +38,7 @@ export class ViewLine implements IVisibleLineData {
this
.
_context
=
context
;
this
.
_renderWhitespace
=
this
.
_context
.
configuration
.
editor
.
renderWhitespace
;
this
.
_indentGuides
=
this
.
_context
.
configuration
.
editor
.
indentGuides
;
this
.
_spaceWidth
=
this
.
_context
.
configuration
.
editor
.
spaceWidth
;
this
.
_spaceWidth
=
this
.
_context
.
configuration
.
editor
.
fontInfo
.
spaceWidth
;
this
.
_lineHeight
=
this
.
_context
.
configuration
.
editor
.
lineHeight
;
this
.
_stopRenderingLineAfter
=
this
.
_context
.
configuration
.
editor
.
stopRenderingLineAfter
;
this
.
_fontLigatures
=
this
.
_context
.
configuration
.
editor
.
fontLigatures
;
...
...
@@ -88,8 +88,8 @@ export class ViewLine implements IVisibleLineData {
if
(
e
.
indentGuides
)
{
this
.
_indentGuides
=
this
.
_context
.
configuration
.
editor
.
indentGuides
;
}
if
(
e
.
spaceWidth
)
{
this
.
_spaceWidth
=
this
.
_context
.
configuration
.
editor
.
spaceWidth
;
if
(
e
.
fontInfo
)
{
this
.
_spaceWidth
=
this
.
_context
.
configuration
.
editor
.
fontInfo
.
spaceWidth
;
}
if
(
e
.
lineHeight
)
{
this
.
_lineHeight
=
this
.
_context
.
configuration
.
editor
.
lineHeight
;
...
...
src/vs/editor/browser/viewParts/lines/viewLines.ts
浏览文件 @
ce593d7a
...
...
@@ -12,6 +12,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
ClassNames
,
ILayoutProvider
,
IViewContext
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IVisibleLineData
,
ViewLayer
}
from
'
vs/editor/browser/view/viewLayer
'
;
import
{
ViewLine
,
createLine
}
from
'
vs/editor/browser/viewParts/lines/viewLine
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
class
LastRenderedData
{
...
...
@@ -74,6 +75,7 @@ export class ViewLines extends ViewLayer {
this
.
_revealHorizontalRightPadding
=
this
.
_context
.
configuration
.
editor
.
revealHorizontalRightPadding
;
this
.
_layoutProvider
=
layoutProvider
;
this
.
domNode
.
setClassName
(
ClassNames
.
VIEW_LINES
);
Configuration
.
applyFontInfo
(
this
.
domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
// --- width & height
this
.
_maxLineWidth
=
0
;
...
...
@@ -115,6 +117,9 @@ export class ViewLines extends ViewLayer {
if
(
e
.
revealHorizontalRightPadding
)
{
this
.
_revealHorizontalRightPadding
=
this
.
_context
.
configuration
.
editor
.
revealHorizontalRightPadding
;
}
if
(
e
.
fontInfo
)
{
Configuration
.
applyFontInfo
(
this
.
domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
}
return
shouldRender
;
}
...
...
src/vs/editor/browser/viewParts/rulers/rulers.ts
浏览文件 @
ce593d7a
...
...
@@ -26,7 +26,7 @@ export class Rulers extends ViewPart {
this
.
domNode
.
className
=
'
view-rulers
'
;
this
.
_rulers
=
this
.
_context
.
configuration
.
editor
.
rulers
;
this
.
_height
=
this
.
_context
.
configuration
.
editor
.
layoutInfo
.
contentHeight
;
this
.
_typicalHalfwidthCharacterWidth
=
this
.
_context
.
configuration
.
editor
.
typicalHalfwidthCharacterWidth
;
this
.
_typicalHalfwidthCharacterWidth
=
this
.
_context
.
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
;
}
public
dispose
():
void
{
...
...
@@ -36,10 +36,10 @@ export class Rulers extends ViewPart {
// --- begin event handlers
public
onConfigurationChanged
(
e
:
editorCommon
.
IConfigurationChangedEvent
):
boolean
{
if
(
e
.
rulers
||
e
.
layoutInfo
||
e
.
typicalHalfwidthCharacterWidth
)
{
if
(
e
.
rulers
||
e
.
layoutInfo
||
e
.
fontInfo
)
{
this
.
_rulers
=
this
.
_context
.
configuration
.
editor
.
rulers
;
this
.
_height
=
this
.
_context
.
configuration
.
editor
.
layoutInfo
.
contentHeight
;
this
.
_typicalHalfwidthCharacterWidth
=
this
.
_context
.
configuration
.
editor
.
typicalHalfwidthCharacterWidth
;
this
.
_typicalHalfwidthCharacterWidth
=
this
.
_context
.
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
;
return
true
;
}
return
false
;
...
...
src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
浏览文件 @
ce593d7a
...
...
@@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
StyleMutator
}
from
'
vs/base/browser/styleMutator
'
;
import
{
FastDomNode
,
createFastDomNode
}
from
'
vs/base/browser/styleMutator
'
;
import
{
IConfigurationChangedEvent
,
IPosition
,
TextEditorCursorStyle
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IRenderingContext
,
IRestrictedRenderingContext
,
IViewContext
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
export
class
ViewCursor
{
private
_context
:
IViewContext
;
private
_position
:
IPosition
;
private
_domNode
:
HTMLElement
;
private
_domNode
:
FastDomNode
;
private
_positionTop
:
number
;
private
_positionLeft
:
number
;
private
_isInEditableRange
:
boolean
;
...
...
@@ -30,30 +31,32 @@ export class ViewCursor {
this
.
_isInEditableRange
=
true
;
this
.
_domNode
=
this
.
_createCursorDomNode
(
isSecondary
);
Configuration
.
applyFontInfo
(
this
.
_domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
this
.
_isVisible
=
true
;
StyleMutator
.
setDisplay
(
this
.
_domNode
,
'
none
'
);
this
.
_domNode
.
setDisplay
(
'
none
'
);
this
.
updatePosition
({
lineNumber
:
1
,
column
:
1
});
}
private
_createCursorDomNode
(
isSecondary
:
boolean
):
HTMLElement
{
var
domNode
=
document
.
createElement
(
'
div
'
);
domNode
.
className
=
'
cursor
'
;
private
_createCursorDomNode
(
isSecondary
:
boolean
):
FastDomNode
{
let
domNode
=
createFastDomNode
(
document
.
createElement
(
'
div
'
));
if
(
isSecondary
)
{
domNode
.
className
+=
'
secondary
'
;
domNode
.
setClassName
(
'
cursor secondary
'
);
}
else
{
domNode
.
setClassName
(
'
cursor
'
);
}
StyleMutator
.
setHeight
(
domNode
,
this
.
_lineHeight
);
StyleMutator
.
setTop
(
domNode
,
0
);
StyleMutator
.
setLeft
(
domNode
,
0
);
domNode
.
setAttribute
(
'
role
'
,
'
presentation
'
);
domNode
.
setAttribute
(
'
aria-hidden
'
,
'
true
'
);
domNode
.
setHeight
(
this
.
_lineHeight
);
domNode
.
setTop
(
0
);
domNode
.
setLeft
(
0
);
domNode
.
domNode
.
setAttribute
(
'
role
'
,
'
presentation
'
);
domNode
.
domNode
.
setAttribute
(
'
aria-hidden
'
,
'
true
'
);
return
domNode
;
}
public
getDomNode
():
HTMLElement
{
return
this
.
_domNode
;
return
this
.
_domNode
.
domNode
;
}
public
getIsInEditableRange
():
boolean
{
...
...
@@ -70,14 +73,14 @@ export class ViewCursor {
public
show
():
void
{
if
(
!
this
.
_isVisible
)
{
StyleMutator
.
setVisibility
(
this
.
_domNode
,
'
inherit
'
);
this
.
_domNode
.
setVisibility
(
'
inherit
'
);
this
.
_isVisible
=
true
;
}
}
public
hide
():
void
{
if
(
this
.
_isVisible
)
{
StyleMutator
.
setVisibility
(
this
.
_domNode
,
'
hidden
'
);
this
.
_domNode
.
setVisibility
(
'
hidden
'
);
this
.
_isVisible
=
false
;
}
}
...
...
@@ -100,11 +103,13 @@ export class ViewCursor {
public
onConfigurationChanged
(
e
:
IConfigurationChangedEvent
):
boolean
{
if
(
e
.
lineHeight
)
{
this
.
_lineHeight
=
this
.
_context
.
configuration
.
editor
.
lineHeight
;
}
if
(
e
.
cursorStyle
)
{
this
.
_cursorStyle
=
this
.
_context
.
configuration
.
editor
.
cursorStyle
;
}
if
(
e
.
fontInfo
)
{
Configuration
.
applyFontInfo
(
this
.
_domNode
,
this
.
_context
.
configuration
.
editor
.
fontInfo
);
}
return
true
;
}
...
...
@@ -132,23 +137,23 @@ export class ViewCursor {
let
renderContent
=
this
.
_getRenderedContent
();
if
(
this
.
_lastRenderedContent
!==
renderContent
)
{
this
.
_lastRenderedContent
=
renderContent
;
this
.
_domNode
.
textContent
=
this
.
_lastRenderedContent
;
this
.
_domNode
.
domNode
.
textContent
=
this
.
_lastRenderedContent
;
}
StyleMutator
.
setDisplay
(
this
.
_domNode
,
'
block
'
);
StyleMutator
.
setLeft
(
this
.
_domNode
,
this
.
_positionLeft
);
StyleMutator
.
setTop
(
this
.
_domNode
,
this
.
_positionTop
+
ctx
.
viewportTop
-
ctx
.
bigNumbersDelta
);
StyleMutator
.
setLineHeight
(
this
.
_domNode
,
this
.
_lineHeight
);
StyleMutator
.
setHeight
(
this
.
_domNode
,
this
.
_lineHeight
);
this
.
_domNode
.
setDisplay
(
'
block
'
);
this
.
_domNode
.
setLeft
(
this
.
_positionLeft
);
this
.
_domNode
.
setTop
(
this
.
_positionTop
+
ctx
.
viewportTop
-
ctx
.
bigNumbersDelta
);
this
.
_domNode
.
setLineHeight
(
this
.
_lineHeight
);
this
.
_domNode
.
setHeight
(
this
.
_lineHeight
);
}
else
{
StyleMutator
.
setDisplay
(
this
.
_domNode
,
'
none
'
);
this
.
_domNode
.
setDisplay
(
'
none
'
);
}
}
private
updatePosition
(
newPosition
:
IPosition
):
void
{
this
.
_position
=
newPosition
;
this
.
_domNode
.
setAttribute
(
'
lineNumber
'
,
this
.
_position
.
lineNumber
.
toString
());
this
.
_domNode
.
setAttribute
(
'
column
'
,
this
.
_position
.
column
.
toString
());
this
.
_domNode
.
domNode
.
setAttribute
(
'
lineNumber
'
,
this
.
_position
.
lineNumber
.
toString
());
this
.
_domNode
.
domNode
.
setAttribute
(
'
column
'
,
this
.
_position
.
column
.
toString
());
this
.
_isInViewport
=
false
;
}
}
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
ce593d7a
...
...
@@ -411,6 +411,10 @@ export class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.
this
.
_view
.
setAriaActiveDescendant
(
id
);
}
public
applyFontInfo
(
target
:
HTMLElement
):
void
{
Configuration
.
applyFontInfoSlow
(
target
,
this
.
_configuration
.
editor
.
fontInfo
);
}
_attachModel
(
model
:
editorCommon
.
IModel
):
void
{
this
.
_view
=
null
;
...
...
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
ce593d7a
...
...
@@ -1784,7 +1784,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
let
r
=
renderLine
(
new
RenderLineInput
(
lineContent
,
tabSize
,
config
.
spaceWidth
,
config
.
fontInfo
.
spaceWidth
,
config
.
stopRenderingLineAfter
,
config
.
renderWhitespace
,
parts
.
getParts
()
...
...
src/vs/editor/browser/widget/media/default-theme.css
浏览文件 @
ce593d7a
...
...
@@ -4,9 +4,6 @@
*--------------------------------------------------------------------------------------------*/
/* The editor */
.monaco-editor
,
.monaco-editor
.inputarea
{
font-family
:
Menlo
,
Monaco
,
Consolas
,
"Droid Sans Mono"
,
"Courier New"
,
monospace
,
"Droid Sans Fallback"
;
font-size
:
14px
;
line-height
:
19px
;
color
:
#333
;
/*
* WORKAROUND:
...
...
@@ -16,12 +13,6 @@
background
:
#fffffe
;
}
/* Editor on Mac */
.monaco-editor.mac
{
font-size
:
12px
;
line-height
:
18px
;
}
/* Background */
.monaco-editor-background
{
background
:
#fffffe
;
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
ce593d7a
...
...
@@ -692,7 +692,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
hardWrappingLineMapperFactory
,
this
.
model
.
getOptions
().
tabSize
,
this
.
_configuration
.
editor
.
wrappingInfo
.
wrappingColumn
,
this
.
_configuration
.
editor
.
typicalFullwidthCharacterWidth
/
this
.
_configuration
.
editor
.
typicalHalfwidthCharacterWidth
,
this
.
_configuration
.
editor
.
fontInfo
.
typicalFullwidthCharacterWidth
/
this
.
_configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
editorCommon
.
wrappingIndentFromString
(
this
.
_configuration
.
editor
.
wrappingIndent
)
);
...
...
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
ce593d7a
...
...
@@ -109,16 +109,13 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
renderWhitespace
:
boolean
;
indentGuides
:
boolean
;
layoutInfo
:
editorCommon
.
IEditorLayoutInfo
;
stylingInfo
:
editorCommon
.
EditorStyling
;
fontInfo
:
editorCommon
.
FontInfo
;
editorClassName
:
string
;
wrappingInfo
:
editorCommon
.
IEditorWrappingInfo
;
observedOuterWidth
:
number
;
observedOuterHeight
:
number
;
lineHeight
:
number
;
pageSize
:
number
;
typicalHalfwidthCharacterWidth
:
number
;
typicalFullwidthCharacterWidth
:
number
;
spaceWidth
:
number
;
fontSize
:
number
;
constructor
(
input
:
editorCommon
.
IInternalEditorOptions
)
{
this
.
experimentalScreenReader
=
Boolean
(
input
.
experimentalScreenReader
);
...
...
@@ -201,12 +198,16 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
right
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
right
)
|
0
,
}
};
this
.
stylingInfo
=
new
editorCommon
.
EditorStyling
(
input
.
stylingInfo
.
editorClassName
,
input
.
stylingInfo
.
fontFamily
,
input
.
stylingInfo
.
fontSize
,
input
.
stylingInfo
.
lineHeight
this
.
fontInfo
=
new
editorCommon
.
FontInfo
(
input
.
fontInfo
.
fontFamily
,
input
.
fontInfo
.
fontSize
,
input
.
fontInfo
.
lineHeight
,
input
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
input
.
fontInfo
.
typicalFullwidthCharacterWidth
,
input
.
fontInfo
.
spaceWidth
,
input
.
fontInfo
.
maxDigitWidth
);
this
.
editorClassName
=
input
.
editorClassName
;
this
.
wrappingInfo
=
{
isViewportWrapping
:
Boolean
(
input
.
wrappingInfo
.
isViewportWrapping
),
wrappingColumn
:
Number
(
input
.
wrappingInfo
.
wrappingColumn
)
|
0
,
...
...
@@ -215,10 +216,6 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this
.
observedOuterHeight
=
Number
(
input
.
observedOuterHeight
)
|
0
;
this
.
lineHeight
=
Number
(
input
.
lineHeight
)
|
0
;
this
.
pageSize
=
Number
(
input
.
pageSize
)
|
0
;
this
.
typicalHalfwidthCharacterWidth
=
Number
(
input
.
typicalHalfwidthCharacterWidth
);
this
.
typicalFullwidthCharacterWidth
=
Number
(
input
.
typicalFullwidthCharacterWidth
);
this
.
spaceWidth
=
Number
(
input
.
spaceWidth
);
this
.
fontSize
=
Number
(
input
.
fontSize
)
|
0
;
}
}
...
...
@@ -230,8 +227,8 @@ class InternalEditorOptionsHelper {
public
static
createInternalEditorOptions
(
outerWidth
:
number
,
outerHeight
:
number
,
opts
:
editorCommon
.
IEditorOptions
,
styling
:
editorCommon
.
EditorStyling
,
cssOpts
:
ICSSConfi
g
,
fontInfo
:
editorCommon
.
FontInfo
,
editorClassName
:
strin
g
,
isDominatedByLongLines
:
boolean
,
lineCount
:
number
):
editorCommon
.
IInternalEditorOptions
{
...
...
@@ -270,11 +267,11 @@ class InternalEditorOptionsHelper {
outerWidth
:
outerWidth
,
outerHeight
:
outerHeight
,
showGlyphMargin
:
glyphMargin
,
lineHeight
:
styling
.
lineHeight
,
lineHeight
:
fontInfo
.
lineHeight
,
showLineNumbers
:
!!
lineNumbers
,
lineNumbersMinChars
:
lineNumbersMinChars
,
lineDecorationsWidth
:
lineDecorationsWidth
,
maxDigitWidth
:
cssOpts
.
maxDigitWidth
,
maxDigitWidth
:
fontInfo
.
maxDigitWidth
,
lineCount
:
lineCount
,
verticalScrollbarWidth
:
scrollbar
.
verticalScrollbarSize
,
horizontalScrollbarHeight
:
scrollbar
.
horizontalScrollbarSize
,
...
...
@@ -282,7 +279,7 @@ class InternalEditorOptionsHelper {
verticalScrollbarHasArrows
:
scrollbar
.
verticalHasArrows
});
let
pageSize
=
Math
.
floor
(
layoutInfo
.
height
/
styling
.
lineHeight
)
-
2
;
let
pageSize
=
Math
.
floor
(
layoutInfo
.
height
/
fontInfo
.
lineHeight
)
-
2
;
if
(
isDominatedByLongLines
&&
wrappingColumn
>
0
)
{
// Force viewport width wrapping if model is dominated by long lines
...
...
@@ -295,7 +292,7 @@ class InternalEditorOptionsHelper {
// If viewport width wrapping is enabled
wrappingInfo
=
{
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
max
(
1
,
Math
.
floor
((
layoutInfo
.
contentWidth
-
layoutInfo
.
verticalScrollbarWidth
)
/
cssOpts
.
typicalHalfwidthCharacterWidth
))
wrappingColumn
:
Math
.
max
(
1
,
Math
.
floor
((
layoutInfo
.
contentWidth
-
layoutInfo
.
verticalScrollbarWidth
)
/
fontInfo
.
typicalHalfwidthCharacterWidth
))
};
}
else
if
(
wrappingColumn
>
0
)
{
// Wrapping is enabled
...
...
@@ -365,20 +362,15 @@ class InternalEditorOptionsHelper {
indentGuides
:
toBoolean
(
opts
.
indentGuides
),
layoutInfo
:
layoutInfo
,
stylingInfo
:
styling
,
fontInfo
:
fontInfo
,
editorClassName
:
editorClassName
,
wrappingInfo
:
wrappingInfo
,
observedOuterWidth
:
outerWidth
,
observedOuterHeight
:
outerHeight
,
lineHeight
:
styling
.
lineHeight
,
// todo -> duplicated in styling
fontSize
:
styling
.
fontSize
,
// todo -> duplicated in styling
lineHeight
:
fontInfo
.
lineHeight
,
// todo -> duplicated in styling
pageSize
:
pageSize
,
typicalHalfwidthCharacterWidth
:
cssOpts
.
typicalHalfwidthCharacterWidth
,
typicalFullwidthCharacterWidth
:
cssOpts
.
typicalFullwidthCharacterWidth
,
spaceWidth
:
cssOpts
.
spaceWidth
,
};
}
...
...
@@ -454,16 +446,13 @@ class InternalEditorOptionsHelper {
indentGuides
:
(
prevOpts
.
indentGuides
!==
newOpts
.
indentGuides
),
layoutInfo
:
(
!
EditorLayoutProvider
.
layoutEqual
(
prevOpts
.
layoutInfo
,
newOpts
.
layoutInfo
)),
stylingInfo
:
(
!
prevOpts
.
stylingInfo
.
equals
(
newOpts
.
stylingInfo
)),
fontInfo
:
(
!
prevOpts
.
fontInfo
.
equals
(
newOpts
.
fontInfo
)),
editorClassName
:
(
prevOpts
.
editorClassName
!==
newOpts
.
editorClassName
),
wrappingInfo
:
(
!
this
.
_wrappingInfoEqual
(
prevOpts
.
wrappingInfo
,
newOpts
.
wrappingInfo
)),
observedOuterWidth
:
(
prevOpts
.
observedOuterWidth
!==
newOpts
.
observedOuterWidth
),
observedOuterHeight
:
(
prevOpts
.
observedOuterHeight
!==
newOpts
.
observedOuterHeight
),
lineHeight
:
(
prevOpts
.
lineHeight
!==
newOpts
.
lineHeight
),
pageSize
:
(
prevOpts
.
pageSize
!==
newOpts
.
pageSize
),
typicalHalfwidthCharacterWidth
:
(
prevOpts
.
typicalHalfwidthCharacterWidth
!==
newOpts
.
typicalHalfwidthCharacterWidth
),
typicalFullwidthCharacterWidth
:
(
prevOpts
.
typicalFullwidthCharacterWidth
!==
newOpts
.
typicalFullwidthCharacterWidth
),
spaceWidth
:
(
prevOpts
.
spaceWidth
!==
newOpts
.
spaceWidth
),
fontSize
:
(
prevOpts
.
fontSize
!==
newOpts
.
fontSize
)
};
}
...
...
@@ -504,16 +493,6 @@ class InternalEditorOptionsHelper {
}
}
export
interface
ICSSConfig
{
typicalHalfwidthCharacterWidth
:
number
;
typicalFullwidthCharacterWidth
:
number
;
spaceWidth
:
number
;
maxDigitWidth
:
number
;
// lineHeight:number;
// font:string;
// fontSize:number;
}
function
toBoolean
(
value
:
any
):
boolean
{
return
value
===
'
false
'
?
false
:
Boolean
(
value
);
}
...
...
@@ -658,19 +637,16 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
lineHeight
=
Math
.
round
(
1.3
*
fontSize
);
}
let
styling
=
new
editorCommon
.
EditorStyling
(
editorClassName
,
fontFamily
,
fontSize
,
lineHeight
);
let
result
=
InternalEditorOptionsHelper
.
createInternalEditorOptions
(
this
.
getOuterWidth
(),
this
.
getOuterHeight
(),
opts
,
styling
,
this
.
readConfiguration
(
styling
),
this
.
readConfiguration
(
new
editorCommon
.
BareFontInfo
(
fontFamily
,
fontSize
,
lineHeight
)),
editorClassName
,
this
.
_isDominatedByLongLines
,
this
.
_lineCount
);
...
...
@@ -699,7 +675,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
protected
abstract
getOuterHeight
():
number
;
protected
abstract
readConfiguration
(
styling
:
editorCommon
.
EditorStyling
):
ICSSConfig
;
protected
abstract
readConfiguration
(
styling
:
editorCommon
.
BareFontInfo
):
editorCommon
.
FontInfo
;
}
/**
...
...
src/vs/editor/common/config/defaultConfig.ts
浏览文件 @
ce593d7a
...
...
@@ -6,6 +6,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
export
interface
IConfiguration
{
editor
:
IEditorOptions
;
...
...
@@ -18,6 +19,10 @@ export const DEFAULT_INDENTATION = {
detectIndentation
:
true
};
const
DEFAULT_WINDOWS_FONT_FAMILY
=
'
Consolas,
\'
Courier New
\'
, monospace
'
;
const
DEFAULT_MAC_FONT_FAMILY
=
'
Menlo, Monaco,
\'
Courier New
\'
, monospace
'
;
const
DEFAULT_LINUX_FONT_FAMILY
=
'
\'
Droid Sans Mono
\'
,
\'
Courier New
\'
, monospace,
\'
Droid Sans Fallback
\'
'
;
class
ConfigClass
implements
IConfiguration
{
public
editor
:
IEditorOptions
;
...
...
@@ -81,8 +86,12 @@ class ConfigClass implements IConfiguration {
renderWhitespace
:
false
,
indentGuides
:
false
,
fontFamily
:
'
Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback"
'
,
fontSize
:
14
,
fontFamily
:
(
platform
.
isMacintosh
?
DEFAULT_MAC_FONT_FAMILY
:
(
platform
.
isLinux
?
DEFAULT_LINUX_FONT_FAMILY
:
DEFAULT_WINDOWS_FONT_FAMILY
)
),
fontSize
:
(
platform
.
isMacintosh
?
12
:
14
),
lineHeight
:
0
};
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
ce593d7a
...
...
@@ -654,7 +654,8 @@ export interface IInternalEditorOptions {
layoutInfo
:
IEditorLayoutInfo
;
stylingInfo
:
EditorStyling
;
fontInfo
:
FontInfo
;
editorClassName
:
string
;
wrappingInfo
:
IEditorWrappingInfo
;
...
...
@@ -674,22 +675,6 @@ export interface IInternalEditorOptions {
* Computed page size (deduced from editor size) in lines.
*/
pageSize
:
number
;
/**
* Computed width of 'm' (deduced from theme and CSS) in px.
*/
typicalHalfwidthCharacterWidth
:
number
;
/**
* Computed width of fullwidth 'm' (U+FF4D)
*/
typicalFullwidthCharacterWidth
:
number
;
/**
* Computed width of non breaking space
*/
spaceWidth
:
number
;
/**
* Computed font size.
*/
fontSize
:
number
;
}
/**
...
...
@@ -745,16 +730,13 @@ export interface IConfigurationChangedEvent {
// ---- Options that are computed
layoutInfo
:
boolean
;
stylingInfo
:
boolean
;
fontInfo
:
boolean
;
editorClassName
:
boolean
;
wrappingInfo
:
boolean
;
observedOuterWidth
:
boolean
;
observedOuterHeight
:
boolean
;
lineHeight
:
boolean
;
pageSize
:
boolean
;
typicalHalfwidthCharacterWidth
:
boolean
;
typicalFullwidthCharacterWidth
:
boolean
;
spaceWidth
:
boolean
;
fontSize
:
boolean
;
}
/**
...
...
@@ -2572,31 +2554,57 @@ export interface IHandlerDispatcher {
trigger
(
source
:
string
,
handlerId
:
string
,
payload
:
any
):
boolean
;
}
export
class
EditorStyling
{
_
editorStyling
Trait
:
void
;
export
class
BareFontInfo
{
_
bareFontInfo
Trait
:
void
;
editorClassName
:
string
;
fontFamily
:
string
;
fontSize
:
number
;
lineHeight
:
number
;
constructor
(
editorClassName
:
string
,
fontFamily
:
string
,
fontSize
:
number
,
lineHeight
:
number
)
{
this
.
editorClassName
=
String
(
editorClassName
);
constructor
(
fontFamily
:
string
,
fontSize
:
number
,
lineHeight
:
number
)
{
this
.
fontFamily
=
String
(
fontFamily
);
this
.
fontSize
=
fontSize
|
0
;
this
.
lineHeight
=
lineHeight
|
0
;
}
public
getId
():
string
{
return
this
.
editorClassName
+
'
-
'
+
this
.
fontFamily
+
'
-
'
+
this
.
fontSize
+
'
-
'
+
this
.
lineHeight
;
return
this
.
fontFamily
+
'
-
'
+
this
.
fontSize
+
'
-
'
+
this
.
lineHeight
;
}
}
export
class
FontInfo
extends
BareFontInfo
{
_editorStylingTrait
:
void
;
typicalHalfwidthCharacterWidth
:
number
;
typicalFullwidthCharacterWidth
:
number
;
spaceWidth
:
number
;
maxDigitWidth
:
number
;
constructor
(
fontFamily
:
string
,
fontSize
:
number
,
lineHeight
:
number
,
typicalHalfwidthCharacterWidth
:
number
,
typicalFullwidthCharacterWidth
:
number
,
spaceWidth
:
number
,
maxDigitWidth
:
number
)
{
super
(
fontFamily
,
fontSize
,
lineHeight
);
this
.
typicalHalfwidthCharacterWidth
=
typicalHalfwidthCharacterWidth
;
this
.
typicalFullwidthCharacterWidth
=
typicalFullwidthCharacterWidth
;
this
.
spaceWidth
=
spaceWidth
;
this
.
maxDigitWidth
=
maxDigitWidth
;
}
public
equals
(
other
:
EditorStyling
):
boolean
{
public
equals
(
other
:
FontInfo
):
boolean
{
return
(
this
.
editorClassName
===
other
.
editorClassName
&&
this
.
fontFamily
===
other
.
fontFamily
this
.
fontFamily
===
other
.
fontFamily
&&
this
.
fontSize
===
other
.
fontSize
&&
this
.
lineHeight
===
other
.
lineHeight
&&
this
.
typicalHalfwidthCharacterWidth
===
other
.
typicalHalfwidthCharacterWidth
&&
this
.
typicalFullwidthCharacterWidth
===
other
.
typicalFullwidthCharacterWidth
&&
this
.
spaceWidth
===
other
.
spaceWidth
&&
this
.
maxDigitWidth
===
other
.
maxDigitWidth
);
}
}
...
...
src/vs/editor/common/viewModel/viewModel.ts
浏览文件 @
ce593d7a
...
...
@@ -262,7 +262,7 @@ export class ViewModel extends EventEmitter implements editorCommon.IViewModel {
case
editorCommon
.
EventType
.
ConfigurationChanged
:
revealPreviousCenteredModelRange
=
this
.
_onWrappingIndentChange
(
this
.
configuration
.
editor
.
wrappingIndent
)
||
revealPreviousCenteredModelRange
;
revealPreviousCenteredModelRange
=
this
.
_onWrappingColumnChange
(
this
.
configuration
.
editor
.
wrappingInfo
.
wrappingColumn
,
this
.
configuration
.
editor
.
typicalFullwidthCharacterWidth
/
this
.
configuration
.
editor
.
typicalHalfwidthCharacterWidth
)
||
revealPreviousCenteredModelRange
;
revealPreviousCenteredModelRange
=
this
.
_onWrappingColumnChange
(
this
.
configuration
.
editor
.
wrappingInfo
.
wrappingColumn
,
this
.
configuration
.
editor
.
fontInfo
.
typicalFullwidthCharacterWidth
/
this
.
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
)
||
revealPreviousCenteredModelRange
;
if
((
<
editorCommon
.
IConfigurationChangedEvent
>
data
).
readOnly
)
{
// Must read again all decorations due to readOnly filtering
this
.
decorations
.
reset
(
this
.
model
);
...
...
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
浏览文件 @
ce593d7a
...
...
@@ -5,29 +5,28 @@
'
use strict
'
;
import
{
CommonKeybindings
}
from
'
vs/base/common/keyCodes
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
StyleMutator
}
from
'
vs/base/browser/styleMutator
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IEditorPosition
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorPosition
,
IPosition
,
EventType
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
export
class
ContentHoverWidget
implements
editorBrowser
.
IContentWidget
{
export
class
ContentHoverWidget
extends
Widget
implements
editorBrowser
.
IContentWidget
{
private
_id
:
string
;
_editor
:
editorBrowser
.
ICodeEditor
;
_isVisible
:
boolean
;
protected
_editor
:
editorBrowser
.
ICodeEditor
;
protected
_isVisible
:
boolean
;
private
_containerDomNode
:
HTMLElement
;
_domNode
:
HTMLElement
;
_showAtPosition
:
IEditorPosition
;
protected
_domNode
:
HTMLElement
;
protected
_showAtPosition
:
IEditorPosition
;
private
_stoleFocus
:
boolean
;
private
_toDispose
:
IDisposable
[];
// Editor.IContentWidget.allowEditorOverflow
public
allowEditorOverflow
=
true
;
constructor
(
id
:
string
,
editor
:
editorBrowser
.
ICodeEditor
)
{
super
();
this
.
_id
=
id
;
this
.
_editor
=
editor
;
this
.
_isVisible
=
false
;
...
...
@@ -39,11 +38,17 @@ export class ContentHoverWidget implements editorBrowser.IContentWidget {
this
.
_domNode
.
style
.
display
=
'
inline-block
'
;
this
.
_containerDomNode
.
appendChild
(
this
.
_domNode
);
this
.
_containerDomNode
.
tabIndex
=
0
;
this
.
_toDispose
=
[];
this
.
_toDispose
.
push
(
dom
.
addStandardDisposableListener
(
this
.
_containerDomNode
,
'
keydown
'
,
(
e
:
IKeyboardEvent
)
=>
{
this
.
onkeydown
(
this
.
_containerDomNode
,
(
e
:
IKeyboardEvent
)
=>
{
if
(
e
.
equals
(
CommonKeybindings
.
ESCAPE
))
{
this
.
hide
();
}
});
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
_register
(
this
.
_editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
}
}));
this
.
_editor
.
addContentWidget
(
this
);
...
...
@@ -111,21 +116,21 @@ export class ContentHoverWidget implements editorBrowser.IContentWidget {
}
public
dispose
():
void
{
this
.
hide
(
);
this
.
_toDispose
=
dispose
(
this
.
_toDispose
);
this
.
_editor
.
removeContentWidget
(
this
);
super
.
dispose
(
);
}
}
export
class
GlyphHoverWidget
implements
editorBrowser
.
IOverlayWidget
{
export
class
GlyphHoverWidget
extends
Widget
implements
editorBrowser
.
IOverlayWidget
{
private
_id
:
string
;
_editor
:
editorBrowser
.
ICodeEditor
;
_isVisible
:
boolean
;
_domNode
:
HTMLElement
;
_showAtLineNumber
:
number
;
protected
_editor
:
editorBrowser
.
ICodeEditor
;
protected
_isVisible
:
boolean
;
protected
_domNode
:
HTMLElement
;
protected
_showAtLineNumber
:
number
;
constructor
(
id
:
string
,
editor
:
editorBrowser
.
ICodeEditor
)
{
super
();
this
.
_id
=
id
;
this
.
_editor
=
editor
;
this
.
_isVisible
=
false
;
...
...
@@ -137,6 +142,14 @@ export class GlyphHoverWidget implements editorBrowser.IOverlayWidget {
this
.
_domNode
.
setAttribute
(
'
role
'
,
'
presentation
'
);
this
.
_showAtLineNumber
=
-
1
;
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
_register
(
this
.
_editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
}
}));
this
.
_editor
.
addOverlayWidget
(
this
);
}
...
...
@@ -177,6 +190,7 @@ export class GlyphHoverWidget implements editorBrowser.IOverlayWidget {
}
public
dispose
():
void
{
this
.
hide
();
this
.
_editor
.
removeOverlayWidget
(
this
);
super
.
dispose
();
}
}
src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts
浏览文件 @
ce593d7a
...
...
@@ -11,7 +11,7 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
aria
=
require
(
'
vs/base/browser/ui/aria/aria
'
);
import
{
EventType
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EventType
,
ICursorSelectionChangedEvent
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IParameterHints
,
ISignature
}
from
'
vs/editor/common/modes
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IHintEvent
,
ParameterHintsModel
}
from
'
./parameterHintsModel
'
;
...
...
@@ -105,6 +105,13 @@ export class ParameterHintsWidget implements IContentWidget {
this
.
editor
.
layoutContentWidget
(
this
);
}
}));
this
.
editor
.
applyFontInfo
(
this
.
getDomNode
());
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
editor
.
applyFontInfo
(
this
.
getDomNode
());
}
}));
}
private
show
():
void
{
...
...
src/vs/editor/contrib/suggest/browser/suggest.css
浏览文件 @
ce593d7a
...
...
@@ -36,6 +36,10 @@
width
:
100%
;
}
.monaco-editor
.suggest-widget
>
.tree
{
font-family
:
Menlo
,
Monaco
,
Consolas
,
"Droid Sans Mono"
,
"Courier New"
,
monospace
,
"Droid Sans Fallback"
;
}
.monaco-editor
.suggest-widget
.monaco-list
.monaco-list-row
{
-mox-box-sizing
:
border-box
;
box-sizing
:
border-box
;
...
...
src/vs/editor/test/common/mocks/mockConfiguration.ts
浏览文件 @
ce593d7a
...
...
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
CommonEditorConfiguration
,
ICSSConfig
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
IEditorOptions
,
EditorStyling
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
IEditorOptions
,
FontInfo
,
BareFontInfo
}
from
'
vs/editor/common/editorCommon
'
;
export
class
MockConfiguration
extends
CommonEditorConfiguration
{
...
...
@@ -25,13 +25,7 @@ export class MockConfiguration extends CommonEditorConfiguration {
return
100
;
}
protected
readConfiguration
(
styling
:
EditorStyling
):
ICSSConfig
{
// Doesn't really matter
return
{
typicalHalfwidthCharacterWidth
:
10
,
typicalFullwidthCharacterWidth
:
20
,
spaceWidth
:
10
,
maxDigitWidth
:
10
};
protected
readConfiguration
(
styling
:
BareFontInfo
):
FontInfo
{
return
new
FontInfo
(
'
mockFont
'
,
14
,
19
,
10
,
20
,
10
,
10
);
}
}
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
浏览文件 @
ce593d7a
...
...
@@ -103,7 +103,7 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
hardWrappingLineMapperFactory
,
model
.
getOptions
().
tabSize
,
config
.
editor
.
wrappingInfo
.
wrappingColumn
,
config
.
editor
.
typicalFullwidthCharacterWidth
/
config
.
editor
.
typicalHalfwidthCharacterWidth
,
config
.
editor
.
fontInfo
.
typicalFullwidthCharacterWidth
/
config
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
editorCommon
.
wrappingIndentFromString
(
config
.
editor
.
wrappingIndent
)
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录