Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
006361a6
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,发现更多精彩内容 >>
提交
006361a6
编写于
9月 20, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
share one kind of label class
上级
84168a6e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
157 addition
and
84 deletion
+157
-84
src/vs/workbench/browser/labels.ts
src/vs/workbench/browser/labels.ts
+152
-0
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+1
-1
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+1
-1
src/vs/workbench/parts/files/browser/files.ts
src/vs/workbench/parts/files/browser/files.ts
+0
-79
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+1
-1
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
.../workbench/parts/files/browser/views/openEditorsViewer.ts
+2
-2
未找到文件。
src/vs/workbench/browser/
parts/editor/editorLabel
.ts
→
src/vs/workbench/browser/
labels
.ts
浏览文件 @
006361a6
...
...
@@ -6,12 +6,14 @@
'
use strict
'
;
import
uri
from
'
vs/base/common/uri
'
;
import
{
getFileIconClasses
}
from
'
vs/base/browser/ui/fileLabel/fileLabel
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
)
;
import
{
IconLabel
,
IIconLabelOptions
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
getResource
}
from
'
vs/workbench/common/editor
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
export
interface
IEditorLabel
{
name
:
string
;
...
...
@@ -19,13 +21,18 @@ export interface IEditorLabel {
resource
?:
uri
;
}
export
class
EditorLabel
extends
IconLabel
{
export
interface
IResourceLabelOptions
extends
IIconLabelOptions
{
isFolder
?:
boolean
;
}
export
class
ResourceLabel
extends
IconLabel
{
private
label
:
IEditorLabel
;
private
options
:
I
Icon
LabelOptions
;
private
options
:
I
Resource
LabelOptions
;
constructor
(
container
:
HTMLElement
,
@
IExtensionService
private
extensionService
:
IExtensionService
,
@
IWorkspaceContextService
protected
contextService
:
IWorkspaceContextService
,
@
IModeService
private
modeService
:
IModeService
)
{
super
(
container
);
...
...
@@ -35,15 +42,7 @@ export class EditorLabel extends IconLabel {
});
}
public
setInput
(
input
:
IEditorInput
,
options
?:
IIconLabelOptions
):
void
{
this
.
setLabel
({
resource
:
getResource
(
input
),
name
:
input
.
getName
(),
description
:
input
.
getDescription
()
},
options
);
}
public
setLabel
(
label
:
IEditorLabel
,
options
?:
IIconLabelOptions
):
void
{
public
setLabel
(
label
:
IEditorLabel
,
options
?:
IResourceLabelOptions
):
void
{
this
.
label
=
label
;
this
.
options
=
options
;
...
...
@@ -71,7 +70,7 @@ export class EditorLabel extends IconLabel {
title
=
resource
.
fsPath
;
}
const
extraClasses
=
getFileIconClasses
(
resource
,
path
=>
this
.
modeService
.
getModeIdByFilenameOrFirstLine
(
path
)
);
const
extraClasses
=
this
.
getIconClasses
(
resource
);
if
(
this
.
options
&&
this
.
options
.
extraClasses
)
{
extraClasses
.
push
(...
this
.
options
.
extraClasses
);
}
...
...
@@ -85,4 +84,69 @@ export class EditorLabel extends IconLabel {
this
.
label
=
void
0
;
this
.
options
=
void
0
;
}
protected
getIconClasses
(
arg1
?:
uri
|
string
):
string
[]
{
let
path
:
string
;
if
(
typeof
arg1
===
'
string
'
)
{
path
=
arg1
;
}
else
if
(
arg1
)
{
path
=
arg1
.
fsPath
;
}
const
classes
=
(
this
.
options
&&
this
.
options
.
isFolder
)
?
[
'
folder-icon
'
]
:
[
'
file-icon
'
];
if
(
path
)
{
const
basename
=
paths
.
basename
(
path
);
const
dotSegments
=
basename
.
split
(
'
.
'
);
const
name
=
dotSegments
[
0
];
// file.txt => "file", .dockerfile => "", file.some.txt => "file"
if
(
name
)
{
classes
.
push
(
`
${
this
.
cssEscape
(
name
.
toLowerCase
())}
-name-file-icon`
);
}
const
extensions
=
dotSegments
.
splice
(
1
);
if
(
extensions
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
extensions
.
length
;
i
++
)
{
classes
.
push
(
`
${
this
.
cssEscape
(
extensions
.
slice
(
i
).
join
(
'
.
'
).
toLowerCase
())}
-ext-file-icon`
);
// add each combination of all found extensions if more than one
}
}
const
langId
=
this
.
modeService
.
getModeIdByFilenameOrFirstLine
(
path
);
if
(
langId
)
{
classes
.
push
(
`
${
this
.
cssEscape
(
langId
)}
-lang-file-icon`
);
}
}
return
classes
;
}
private
cssEscape
(
val
:
string
):
string
{
return
val
.
replace
(
/
\s
/g
,
'
\\
$&
'
);
// make sure to not introduce CSS classes from files that contain whitespace
}
}
export
class
EditorLabel
extends
ResourceLabel
{
public
setEditor
(
editor
:
IEditorInput
,
options
?:
IResourceLabelOptions
):
void
{
this
.
setLabel
({
resource
:
getResource
(
editor
),
name
:
editor
.
getName
(),
description
:
editor
.
getDescription
()
},
options
);
}
}
export
interface
IFileLabelOptions
extends
IResourceLabelOptions
{
hidePath
?:
boolean
;
}
export
class
FileLabel
extends
ResourceLabel
{
public
setFile
(
resource
:
uri
,
options
:
IFileLabelOptions
=
Object
.
create
(
null
)):
void
{
this
.
setLabel
({
resource
,
name
:
paths
.
basename
(
resource
.
fsPath
),
description
:
!
options
.
hidePath
?
getPathLabel
(
paths
.
dirname
(
resource
.
fsPath
),
this
.
contextService
)
:
void
0
},
options
);
}
}
\ No newline at end of file
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
006361a6
...
...
@@ -10,7 +10,7 @@ import errors = require('vs/base/common/errors');
import
{
IEditorGroup
,
getResource
}
from
'
vs/workbench/common/editor
'
;
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
TitleControl
}
from
'
vs/workbench/browser/parts/editor/titleControl
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
parts/editor/editorLabel
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
labels
'
;
export
class
NoTabsTitleControl
extends
TitleControl
{
private
titleContainer
:
HTMLElement
;
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
006361a6
...
...
@@ -15,7 +15,7 @@ import {Position, IEditorInput} from 'vs/platform/editor/common/editor';
import
{
IEditorGroup
,
IEditorIdentifier
,
asFileEditorInput
,
getResource
}
from
'
vs/workbench/common/editor
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
parts/editor/editorLabel
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
labels
'
;
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
src/vs/workbench/parts/files/browser/files.ts
浏览文件 @
006361a6
...
...
@@ -4,16 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
uri
from
'
vs/base/common/uri
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
EditorDescriptor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
IFileEditorDescriptor
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
getFileIconClasses
}
from
'
vs/base/browser/ui/fileLabel/fileLabel
'
;
import
{
IconLabel
,
IIconLabelOptions
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
/**
* A lightweight descriptor of an editor for files. Optionally allows to specify a list of mime types the editor
...
...
@@ -32,75 +24,4 @@ export class FileEditorDescriptor extends EditorDescriptor implements IFileEdito
public
getMimeTypes
():
string
[]
{
return
this
.
mimetypes
;
}
}
export
interface
IFileIconLabelOptions
extends
IIconLabelOptions
{
hidePath
?:
boolean
;
isFolder
?:
boolean
;
}
export
class
FileLabel
extends
IconLabel
{
private
file
:
uri
;
private
options
:
IFileIconLabelOptions
;
constructor
(
container
:
HTMLElement
,
@
IExtensionService
private
extensionService
:
IExtensionService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IModeService
private
modeService
:
IModeService
)
{
super
(
container
);
this
.
extensionService
.
onReady
().
then
(()
=>
{
this
.
render
();
// there can be additional modes once the extension host is ready so we need to render again
});
}
public
setFile
(
resource
:
uri
,
options
?:
IFileIconLabelOptions
):
void
{
this
.
file
=
resource
;
this
.
options
=
options
;
this
.
render
();
}
public
clear
():
void
{
this
.
file
=
void
0
;
this
.
options
=
void
0
;
this
.
setValue
();
}
private
render
():
void
{
if
(
!
this
.
file
)
{
return
;
}
const
label
=
paths
.
basename
(
this
.
file
.
fsPath
);
let
description
:
string
;
if
(
!
this
.
options
||
!
this
.
options
.
hidePath
)
{
description
=
getPathLabel
(
paths
.
dirname
(
this
.
file
.
fsPath
),
this
.
contextService
);
}
let
title
=
''
;
if
(
this
.
options
&&
this
.
options
.
title
)
{
title
=
this
.
options
.
title
;
}
else
if
(
this
.
file
)
{
title
=
this
.
file
.
fsPath
;
}
const
extraClasses
=
getFileIconClasses
(
this
.
file
,
path
=>
this
.
modeService
.
getModeIdByFilenameOrFirstLine
(
path
),
this
.
options
&&
this
.
options
.
isFolder
);
if
(
this
.
options
&&
this
.
options
.
extraClasses
)
{
extraClasses
.
push
(...
this
.
options
.
extraClasses
);
}
const
italic
=
this
.
options
&&
this
.
options
.
italic
;
this
.
setValue
(
label
,
description
,
{
title
,
extraClasses
,
italic
});
}
public
dispose
():
void
{
this
.
file
=
void
0
;
this
.
options
=
void
0
;
}
}
\ No newline at end of file
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
006361a6
...
...
@@ -21,7 +21,7 @@ import {InputBox} from 'vs/base/browser/ui/inputbox/inputBox';
import
{
$
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
);
import
glob
=
require
(
'
vs/base/common/glob
'
);
import
{
FileLabel
}
from
'
vs/workbench/
parts/files/browser/file
s
'
;
import
{
FileLabel
}
from
'
vs/workbench/
browser/label
s
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
LocalFileChangeEvent
,
IFilesConfiguration
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
...
...
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
浏览文件 @
006361a6
...
...
@@ -8,7 +8,7 @@ import uri from 'vs/base/common/uri';
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
parts/editor/editorLabel
'
;
import
{
EditorLabel
}
from
'
vs/workbench/browser/
labels
'
;
import
treedefaults
=
require
(
'
vs/base/parts/tree/browser/treeDefaults
'
);
import
{
IDataSource
,
ITree
,
IAccessibilityProvider
,
IDragAndDropData
,
IDragOverReaction
,
DRAG_OVER_ACCEPT
,
DRAG_OVER_REJECT
,
ContextMenuEvent
,
IRenderer
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ExternalElementsDragAndDropData
,
ElementsDragAndDropData
,
DesktopDragAndDropData
}
from
'
vs/base/parts/tree/browser/treeDnd
'
;
...
...
@@ -178,7 +178,7 @@ export class Renderer implements IRenderer {
private
renderOpenEditor
(
tree
:
ITree
,
editor
:
OpenEditor
,
templateData
:
IOpenEditorTemplateData
):
void
{
editor
.
isDirty
()
?
dom
.
addClass
(
templateData
.
container
,
'
dirty
'
)
:
dom
.
removeClass
(
templateData
.
container
,
'
dirty
'
);
templateData
.
root
.
set
Input
(
editor
.
editorInput
,
{
italic
:
editor
.
isPreview
(),
extraClasses
:
[
'
open-editor
'
]
});
templateData
.
root
.
set
Editor
(
editor
.
editorInput
,
{
italic
:
editor
.
isPreview
(),
extraClasses
:
[
'
open-editor
'
]
});
templateData
.
actionBar
.
context
=
{
group
:
editor
.
editorGroup
,
editor
:
editor
.
editorInput
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录