Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d1076741
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,体验更适合开发者的 AI 搜索 >>
提交
d1076741
编写于
3月 14, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move show hide logic into HideableElement
上级
7da5d304
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
85 deletion
+86
-85
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+86
-85
未找到文件。
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
d1076741
...
...
@@ -244,29 +244,38 @@ const nlsTabFocusMode = nls.localize('tabFocusModeEnabled', "Tab Moves Focus");
const
nlsScreenReaderDetected
=
nls
.
localize
(
'
screenReaderDetected
'
,
"
Screen Reader Optimized
"
);
const
nlsScreenReaderDetectedTitle
=
nls
.
localize
(
'
screenReaderDetectedExtra
'
,
"
If you are not using a Screen Reader, please change the setting `editor.accessibilitySupport` to
\"
off
\"
.
"
);
function
setDisplay
(
el
:
HTMLElement
,
desiredValue
:
string
):
void
{
if
(
el
.
style
.
display
!==
desiredValue
)
{
el
.
style
.
display
=
desiredValue
;
class
HideableElement
{
private
_showing
=
true
;
constructor
(
public
readonly
element
:
HTMLElement
)
{
}
public
show
():
void
{
this
.
toggle
(
true
);
}
public
hide
():
void
{
this
.
toggle
(
false
);
}
public
toggle
(
shouldShow
:
boolean
):
void
{
if
(
shouldShow
!==
this
.
_showing
)
{
this
.
_showing
=
shouldShow
;
this
.
element
.
style
.
display
=
shouldShow
?
''
:
'
none
'
;
}
}
}
function
show
(
el
:
HTMLElement
):
void
{
setDisplay
(
el
,
''
);
}
function
hide
(
el
:
HTMLElement
):
void
{
setDisplay
(
el
,
'
none
'
);
}
export
class
EditorStatus
implements
IStatusbarItem
{
private
state
:
State
;
private
element
:
HTMLElement
;
private
tabFocusModeElement
:
H
TML
Element
;
private
screenRedearModeElement
:
H
TML
Element
;
private
indentationElement
:
H
TML
Element
;
private
selectionElement
:
H
TML
Element
;
private
encodingElement
:
H
TML
Element
;
private
eolElement
:
H
TML
Element
;
private
modeElement
:
H
TML
Element
;
private
metadataElement
:
H
TML
Element
;
private
tabFocusModeElement
:
H
ideable
Element
;
private
screenRedearModeElement
:
H
ideable
Element
;
private
indentationElement
:
H
ideable
Element
;
private
selectionElement
:
H
ideable
Element
;
private
encodingElement
:
H
ideable
Element
;
private
eolElement
:
H
ideable
Element
;
private
modeElement
:
H
ideable
Element
;
private
metadataElement
:
H
ideable
Element
;
private
toDispose
:
IDisposable
[];
private
activeEditorListeners
:
IDisposable
[];
private
delayedRender
:
IDisposable
|
null
;
...
...
@@ -292,46 +301,46 @@ export class EditorStatus implements IStatusbarItem {
render
(
container
:
HTMLElement
):
IDisposable
{
this
.
element
=
append
(
container
,
$
(
'
.editor-statusbar-item
'
));
this
.
tabFocusModeElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-tabfocusmode.status-bar-info
'
));
this
.
tabFocusModeElement
.
title
=
nls
.
localize
(
'
disableTabMode
'
,
"
Disable Accessibility Mode
"
);
this
.
tabFocusModeElement
.
onclick
=
()
=>
this
.
onTabFocusModeClick
();
this
.
tabFocusModeElement
.
textContent
=
nlsTabFocusMode
;
hide
(
this
.
tabFocusModeElement
);
this
.
screenRedearModeElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-screenreadermode.status-bar-info
'
));
this
.
screenRedearModeElement
.
textContent
=
nlsScreenReaderDetected
;
this
.
screenRedearModeElement
.
title
=
nlsScreenReaderDetectedTitle
;
this
.
screenRedearModeElement
.
onclick
=
()
=>
this
.
onScreenReaderModeClick
();
hide
(
this
.
screenRedearModeElement
);
this
.
selectionElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-selection
'
));
this
.
selectionElement
.
title
=
nls
.
localize
(
'
gotoLine
'
,
"
Go to Line
"
);
this
.
selectionElement
.
onclick
=
()
=>
this
.
onSelectionClick
();
hide
(
this
.
selectionElement
);
this
.
indentationElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-indentation
'
));
this
.
indentationElement
.
title
=
nls
.
localize
(
'
selectIndentation
'
,
"
Select Indentation
"
);
this
.
indentationElement
.
onclick
=
()
=>
this
.
onIndentationClick
();
hide
(
this
.
indentationElement
);
this
.
encodingElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-encoding
'
));
this
.
encodingElement
.
title
=
nls
.
localize
(
'
selectEncoding
'
,
"
Select Encoding
"
);
this
.
encodingElement
.
onclick
=
()
=>
this
.
onEncodingClick
();
hide
(
this
.
encodingElement
);
this
.
eolElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-eol
'
));
this
.
eolElement
.
title
=
nls
.
localize
(
'
selectEOL
'
,
"
Select End of Line Sequence
"
);
this
.
eolElement
.
onclick
=
()
=>
this
.
onEOLClick
();
hide
(
this
.
eolElement
);
this
.
modeElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-mode
'
));
this
.
modeElement
.
title
=
nls
.
localize
(
'
selectLanguageMode
'
,
"
Select Language Mode
"
);
this
.
modeElement
.
onclick
=
()
=>
this
.
onModeClick
();
hide
(
this
.
modeElement
);
this
.
metadataElement
=
append
(
this
.
element
,
$
(
'
span.editor-status-metadata
'
));
this
.
metadataElement
.
title
=
nls
.
localize
(
'
fileInfo
'
,
"
File Information
"
);
hide
(
this
.
metadataElement
);
this
.
tabFocusModeElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-tabfocusmode.status-bar-info
'
)
));
this
.
tabFocusModeElement
.
element
.
title
=
nls
.
localize
(
'
disableTabMode
'
,
"
Disable Accessibility Mode
"
);
this
.
tabFocusModeElement
.
element
.
onclick
=
()
=>
this
.
onTabFocusModeClick
();
this
.
tabFocusModeElement
.
element
.
textContent
=
nlsTabFocusMode
;
this
.
tabFocusModeElement
.
hide
(
);
this
.
screenRedearModeElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-screenreadermode.status-bar-info
'
)
));
this
.
screenRedearModeElement
.
element
.
textContent
=
nlsScreenReaderDetected
;
this
.
screenRedearModeElement
.
element
.
title
=
nlsScreenReaderDetectedTitle
;
this
.
screenRedearModeElement
.
element
.
onclick
=
()
=>
this
.
onScreenReaderModeClick
();
this
.
screenRedearModeElement
.
hide
(
);
this
.
selectionElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-selection
'
)
));
this
.
selectionElement
.
element
.
title
=
nls
.
localize
(
'
gotoLine
'
,
"
Go to Line
"
);
this
.
selectionElement
.
element
.
onclick
=
()
=>
this
.
onSelectionClick
();
this
.
selectionElement
.
hide
(
);
this
.
indentationElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-indentation
'
)
));
this
.
indentationElement
.
element
.
title
=
nls
.
localize
(
'
selectIndentation
'
,
"
Select Indentation
"
);
this
.
indentationElement
.
element
.
onclick
=
()
=>
this
.
onIndentationClick
();
this
.
indentationElement
.
hide
(
);
this
.
encodingElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-encoding
'
)
));
this
.
encodingElement
.
element
.
title
=
nls
.
localize
(
'
selectEncoding
'
,
"
Select Encoding
"
);
this
.
encodingElement
.
element
.
onclick
=
()
=>
this
.
onEncodingClick
();
this
.
encodingElement
.
hide
(
);
this
.
eolElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-eol
'
)
));
this
.
eolElement
.
element
.
title
=
nls
.
localize
(
'
selectEOL
'
,
"
Select End of Line Sequence
"
);
this
.
eolElement
.
element
.
onclick
=
()
=>
this
.
onEOLClick
();
this
.
eolElement
.
hide
(
);
this
.
modeElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
a.editor-status-mode
'
)
));
this
.
modeElement
.
element
.
title
=
nls
.
localize
(
'
selectLanguageMode
'
,
"
Select Language Mode
"
);
this
.
modeElement
.
element
.
onclick
=
()
=>
this
.
onModeClick
();
this
.
modeElement
.
hide
(
);
this
.
metadataElement
=
new
HideableElement
(
append
(
this
.
element
,
$
(
'
span.editor-status-metadata
'
)
));
this
.
metadataElement
.
element
.
title
=
nls
.
localize
(
'
fileInfo
'
,
"
File Information
"
);
this
.
metadataElement
.
hide
(
);
this
.
delayedRender
=
null
;
this
.
toRender
=
null
;
...
...
@@ -378,72 +387,64 @@ export class EditorStatus implements IStatusbarItem {
private
_renderNow
(
changed
:
StateChange
):
void
{
if
(
changed
.
tabFocusMode
)
{
if
(
this
.
state
.
tabFocusMode
&&
this
.
state
.
tabFocusMode
===
true
)
{
show
(
this
.
tabFocusModeElement
);
}
else
{
hide
(
this
.
tabFocusModeElement
);
}
this
.
tabFocusModeElement
.
toggle
(
!!
this
.
state
.
tabFocusMode
);
}
if
(
changed
.
screenReaderMode
)
{
if
(
this
.
state
.
screenReaderMode
&&
this
.
state
.
screenReaderMode
===
true
)
{
show
(
this
.
screenRedearModeElement
);
}
else
{
hide
(
this
.
screenRedearModeElement
);
}
this
.
screenRedearModeElement
.
toggle
(
!!
this
.
state
.
screenReaderMode
);
}
if
(
changed
.
indentation
)
{
if
(
this
.
state
.
indentation
)
{
this
.
indentationElement
.
textContent
=
this
.
state
.
indentation
;
show
(
this
.
indentationElement
);
this
.
indentationElement
.
element
.
textContent
=
this
.
state
.
indentation
;
this
.
indentationElement
.
show
(
);
}
else
{
hide
(
this
.
indentationElement
);
this
.
indentationElement
.
hide
(
);
}
}
if
(
changed
.
selectionStatus
)
{
if
(
this
.
state
.
selectionStatus
&&
!
this
.
state
.
screenReaderMode
)
{
this
.
selectionElement
.
textContent
=
this
.
state
.
selectionStatus
;
show
(
this
.
selectionElement
);
this
.
selectionElement
.
element
.
textContent
=
this
.
state
.
selectionStatus
;
this
.
selectionElement
.
show
(
);
}
else
{
hide
(
this
.
selectionElement
);
this
.
selectionElement
.
hide
(
);
}
}
if
(
changed
.
encoding
)
{
if
(
this
.
state
.
encoding
)
{
this
.
encodingElement
.
textContent
=
this
.
state
.
encoding
;
show
(
this
.
encodingElement
);
this
.
encodingElement
.
element
.
textContent
=
this
.
state
.
encoding
;
this
.
encodingElement
.
show
(
);
}
else
{
hide
(
this
.
encodingElement
);
this
.
encodingElement
.
hide
(
);
}
}
if
(
changed
.
EOL
)
{
if
(
this
.
state
.
EOL
)
{
this
.
eolElement
.
textContent
=
this
.
state
.
EOL
===
'
\r\n
'
?
nlsEOLCRLF
:
nlsEOLLF
;
show
(
this
.
eolElement
);
this
.
eolElement
.
element
.
textContent
=
this
.
state
.
EOL
===
'
\r\n
'
?
nlsEOLCRLF
:
nlsEOLLF
;
this
.
eolElement
.
show
(
);
}
else
{
hide
(
this
.
eolElement
);
this
.
eolElement
.
hide
(
);
}
}
if
(
changed
.
mode
)
{
if
(
this
.
state
.
mode
)
{
this
.
modeElement
.
textContent
=
this
.
state
.
mode
;
show
(
this
.
modeElement
);
this
.
modeElement
.
element
.
textContent
=
this
.
state
.
mode
;
this
.
modeElement
.
show
(
);
}
else
{
hide
(
this
.
modeElement
);
this
.
modeElement
.
hide
(
);
}
}
if
(
changed
.
metadata
)
{
if
(
this
.
state
.
metadata
)
{
this
.
metadataElement
.
textContent
=
this
.
state
.
metadata
;
show
(
this
.
metadataElement
);
this
.
metadataElement
.
element
.
textContent
=
this
.
state
.
metadata
;
this
.
metadataElement
.
show
(
);
}
else
{
hide
(
this
.
metadataElement
);
this
.
metadataElement
.
hide
(
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录