Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d569aba4
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,发现更多精彩内容 >>
提交
d569aba4
编写于
2月 27, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use xterm's to calc terminal char dimensions if available
Fixes #44608
上级
d2d760ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
14 deletion
+22
-14
src/typings/vscode-xterm.d.ts
src/typings/vscode-xterm.d.ts
+1
-0
src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts
...h/parts/terminal/electron-browser/terminalConfigHelper.ts
+17
-10
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+4
-4
未找到文件。
src/typings/vscode-xterm.d.ts
浏览文件 @
d569aba4
...
@@ -606,5 +606,6 @@ declare module 'vscode-xterm' {
...
@@ -606,5 +606,6 @@ declare module 'vscode-xterm' {
webLinksInit
(
handler
?:
(
event
:
MouseEvent
,
uri
:
string
)
=>
void
,
options
?:
ILinkMatcherOptions
):
void
;
webLinksInit
(
handler
?:
(
event
:
MouseEvent
,
uri
:
string
)
=>
void
,
options
?:
ILinkMatcherOptions
):
void
;
winptyCompatInit
():
void
;
winptyCompatInit
():
void
;
charMeasure
?:
{
height
:
number
,
width
:
number
}
}
}
}
}
\ No newline at end of file
src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts
浏览文件 @
d569aba4
...
@@ -14,6 +14,7 @@ import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLau
...
@@ -14,6 +14,7 @@ import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLau
import
Severity
from
'
vs/base/common/severity
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
isFedora
}
from
'
vs/workbench/parts/terminal/electron-browser/terminal
'
;
import
{
isFedora
}
from
'
vs/workbench/parts/terminal/electron-browser/terminal
'
;
import
{
IChoiceService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IChoiceService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
Terminal
as
XTermTerminal
}
from
'
vscode-xterm
'
;
const
DEFAULT_LINE_HEIGHT
=
1.0
;
const
DEFAULT_LINE_HEIGHT
=
1.0
;
...
@@ -50,20 +51,12 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
...
@@ -50,20 +51,12 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
}
}
private
_measureFont
(
fontFamily
:
string
,
fontSize
:
number
,
lineHeight
:
number
):
ITerminalFont
{
private
_measureFont
(
fontFamily
:
string
,
fontSize
:
number
,
lineHeight
:
number
):
ITerminalFont
{
// Return cached font if no config changed
if
(
this
.
_lastFontMeasurement
&&
this
.
_lastFontMeasurement
.
fontFamily
===
fontFamily
&&
this
.
_lastFontMeasurement
.
fontSize
===
fontSize
&&
this
.
_lastFontMeasurement
.
lineHeight
===
lineHeight
)
{
return
this
.
_lastFontMeasurement
;
}
// Create charMeasureElement if it hasn't been created or if it was orphaned by its parent
// Create charMeasureElement if it hasn't been created or if it was orphaned by its parent
if
(
!
this
.
_charMeasureElement
||
!
this
.
_charMeasureElement
.
parentElement
)
{
if
(
!
this
.
_charMeasureElement
||
!
this
.
_charMeasureElement
.
parentElement
)
{
this
.
_charMeasureElement
=
document
.
createElement
(
'
div
'
);
this
.
_charMeasureElement
=
document
.
createElement
(
'
div
'
);
this
.
panelContainer
.
appendChild
(
this
.
_charMeasureElement
);
this
.
panelContainer
.
appendChild
(
this
.
_charMeasureElement
);
}
}
// TODO: This should leverage CharMeasure
const
style
=
this
.
_charMeasureElement
.
style
;
const
style
=
this
.
_charMeasureElement
.
style
;
style
.
display
=
'
block
'
;
style
.
display
=
'
block
'
;
style
.
fontFamily
=
fontFamily
;
style
.
fontFamily
=
fontFamily
;
...
@@ -92,7 +85,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
...
@@ -92,7 +85,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
* Gets the font information based on the terminal.integrated.fontFamily
* Gets the font information based on the terminal.integrated.fontFamily
* terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties
* terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties
*/
*/
public
getFont
(
excludeDimensions
?:
boolean
):
ITerminalFont
{
public
getFont
(
xterm
?:
XTermTerminal
,
excludeDimensions
?:
boolean
):
ITerminalFont
{
const
editorConfig
=
this
.
_configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
);
const
editorConfig
=
this
.
_configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
);
let
fontFamily
=
this
.
config
.
fontFamily
||
editorConfig
.
fontFamily
;
let
fontFamily
=
this
.
config
.
fontFamily
||
editorConfig
.
fontFamily
;
...
@@ -115,6 +108,20 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
...
@@ -115,6 +108,20 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
};
};
}
}
// Get the character dimensions from xterm if it's available
if
(
xterm
)
{
if
(
xterm
.
charMeasure
&&
xterm
.
charMeasure
.
width
&&
xterm
.
charMeasure
.
height
)
{
return
{
fontFamily
,
fontSize
,
lineHeight
,
charHeight
:
xterm
.
charMeasure
.
height
,
charWidth
:
xterm
.
charMeasure
.
width
};
}
}
// Fall back to measuring the font ourselves
return
this
.
_measureFont
(
fontFamily
,
fontSize
,
lineHeight
);
return
this
.
_measureFont
(
fontFamily
,
fontSize
,
lineHeight
);
}
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
d569aba4
...
@@ -223,7 +223,7 @@ export class TerminalInstance implements ITerminalInstance {
...
@@ -223,7 +223,7 @@ export class TerminalInstance implements ITerminalInstance {
return
null
;
return
null
;
}
}
const
font
=
this
.
_configHelper
.
getFont
();
const
font
=
this
.
_configHelper
.
getFont
(
this
.
_xterm
);
// Because xterm.js converts from CSS pixels to actual pixels through
// Because xterm.js converts from CSS pixels to actual pixels through
// the use of canvas, window.devicePixelRatio needs to be used here in
// the use of canvas, window.devicePixelRatio needs to be used here in
...
@@ -243,7 +243,7 @@ export class TerminalInstance implements ITerminalInstance {
...
@@ -243,7 +243,7 @@ export class TerminalInstance implements ITerminalInstance {
private
_getDimension
(
width
:
number
,
height
:
number
):
Dimension
{
private
_getDimension
(
width
:
number
,
height
:
number
):
Dimension
{
// The font needs to have been initialized
// The font needs to have been initialized
const
font
=
this
.
_configHelper
.
getFont
();
const
font
=
this
.
_configHelper
.
getFont
(
this
.
_xterm
);
if
(
!
font
||
!
font
.
charWidth
||
!
font
.
charHeight
)
{
if
(
!
font
||
!
font
.
charWidth
||
!
font
.
charHeight
)
{
return
null
;
return
null
;
}
}
...
@@ -285,7 +285,7 @@ export class TerminalInstance implements ITerminalInstance {
...
@@ -285,7 +285,7 @@ export class TerminalInstance implements ITerminalInstance {
Terminal
.
strings
.
tooMuchOutput
=
nls
.
localize
(
'
terminal.integrated.a11yTooMuchOutput
'
,
'
Too much output to announce, navigate to rows manually to read
'
);
Terminal
.
strings
.
tooMuchOutput
=
nls
.
localize
(
'
terminal.integrated.a11yTooMuchOutput
'
,
'
Too much output to announce, navigate to rows manually to read
'
);
}
}
const
accessibilitySupport
=
this
.
_configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
).
accessibilitySupport
;
const
accessibilitySupport
=
this
.
_configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
).
accessibilitySupport
;
const
font
=
this
.
_configHelper
.
getFont
(
true
);
const
font
=
this
.
_configHelper
.
getFont
(
undefined
,
true
);
this
.
_xterm
=
new
Terminal
({
this
.
_xterm
=
new
Terminal
({
scrollback
:
this
.
_configHelper
.
config
.
scrollback
,
scrollback
:
this
.
_configHelper
.
config
.
scrollback
,
theme
:
this
.
_getXtermTheme
(),
theme
:
this
.
_getXtermTheme
(),
...
@@ -1096,7 +1096,7 @@ export class TerminalInstance implements ITerminalInstance {
...
@@ -1096,7 +1096,7 @@ export class TerminalInstance implements ITerminalInstance {
}
}
if
(
this
.
_xterm
)
{
if
(
this
.
_xterm
)
{
const
font
=
this
.
_configHelper
.
getFont
();
const
font
=
this
.
_configHelper
.
getFont
(
this
.
_xterm
);
// Only apply these settings when the terminal is visible so that
// Only apply these settings when the terminal is visible so that
// the characters are measured correctly.
// the characters are measured correctly.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录