Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a7caa978
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,发现更多精彩内容 >>
提交
a7caa978
编写于
10月 01, 2020
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OSColorScheme: Separate dark and hc
上级
7c20f505
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
41 addition
and
46 deletion
+41
-46
src/vs/code/electron-main/window.ts
src/vs/code/electron-main/window.ts
+4
-2
src/vs/platform/native/common/native.ts
src/vs/platform/native/common/native.ts
+2
-3
src/vs/platform/native/electron-main/nativeHostMainService.ts
...vs/platform/native/electron-main/nativeHostMainService.ts
+6
-13
src/vs/platform/windows/common/windows.ts
src/vs/platform/windows/common/windows.ts
+6
-2
src/vs/workbench/services/environment/browser/environmentService.ts
...kbench/services/environment/browser/environmentService.ts
+1
-2
src/vs/workbench/services/themes/browser/browserHostColorSchemeService.ts
.../services/themes/browser/browserHostColorSchemeService.ts
+12
-8
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
...orkbench/services/themes/browser/workbenchThemeService.ts
+2
-6
src/vs/workbench/services/themes/common/hostColorSchemeService.ts
...orkbench/services/themes/common/hostColorSchemeService.ts
+2
-2
src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts
...s/themes/electron-sandbox/nativeHostColorSchemeService.ts
+5
-6
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
.../workbench/test/electron-browser/workbenchTestServices.ts
+1
-2
未找到文件。
src/vs/code/electron-main/window.ts
浏览文件 @
a7caa978
...
...
@@ -35,7 +35,6 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec
import
{
IStorageMainService
}
from
'
vs/platform/storage/node/storageMainService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
FileAccess
,
Schemas
}
from
'
vs/base/common/network
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
export
interface
IWindowCreationOptions
{
state
:
IWindowState
;
...
...
@@ -784,7 +783,10 @@ export class CodeWindow extends Disposable implements ICodeWindow {
windowConfiguration
.
fullscreen
=
this
.
isFullScreen
;
// Set Accessibility Config
windowConfiguration
.
colorScheme
=
(
nativeTheme
.
shouldUseInvertedColorScheme
||
nativeTheme
.
shouldUseHighContrastColors
)
?
ColorScheme
.
HIGH_CONTRAST
:
nativeTheme
.
shouldUseDarkColors
?
ColorScheme
.
DARK
:
ColorScheme
.
LIGHT
;
windowConfiguration
.
colorScheme
=
{
dark
:
nativeTheme
.
shouldUseDarkColors
,
highContrast
:
nativeTheme
.
shouldUseInvertedColorScheme
||
nativeTheme
.
shouldUseHighContrastColors
};
windowConfiguration
.
autoDetectHighContrast
=
windowConfig
?.
autoDetectHighContrast
??
true
;
windowConfiguration
.
accessibilitySupport
=
app
.
accessibilitySupportEnabled
;
...
...
src/vs/platform/native/common/native.ts
浏览文件 @
a7caa978
...
...
@@ -5,10 +5,9 @@
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
MessageBoxOptions
,
MessageBoxReturnValue
,
OpenDevToolsOptions
,
SaveDialogOptions
,
OpenDialogOptions
,
OpenDialogReturnValue
,
SaveDialogReturnValue
,
MouseInputEvent
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
{
IOpenedWindow
,
IWindowOpenable
,
IOpenEmptyWindowOptions
,
IOpenWindowOptions
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IOpenedWindow
,
IWindowOpenable
,
IOpenEmptyWindowOptions
,
IOpenWindowOptions
,
IColorScheme
}
from
'
vs/platform/windows/common/windows
'
;
import
{
INativeOpenDialogOptions
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
ISerializableCommandAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
interface
ICPUProperties
{
...
...
@@ -48,7 +47,7 @@ export interface ICommonNativeHostService {
readonly
onOSResume
:
Event
<
unknown
>
;
readonly
onColorSchemeChange
:
Event
<
ColorScheme
>
;
readonly
onColorSchemeChange
:
Event
<
I
ColorScheme
>
;
// Window
getWindows
():
Promise
<
IOpenedWindow
[]
>
;
...
...
src/vs/platform/native/electron-main/nativeHostMainService.ts
浏览文件 @
a7caa978
...
...
@@ -8,7 +8,7 @@ import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-m
import
{
MessageBoxOptions
,
MessageBoxReturnValue
,
shell
,
OpenDevToolsOptions
,
SaveDialogOptions
,
SaveDialogReturnValue
,
OpenDialogOptions
,
OpenDialogReturnValue
,
Menu
,
BrowserWindow
,
app
,
clipboard
,
powerMonitor
,
nativeTheme
}
from
'
electron
'
;
import
{
OpenContext
}
from
'
vs/platform/windows/node/window
'
;
import
{
ILifecycleMainService
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMainService
'
;
import
{
IOpenedWindow
,
IOpenWindowOptions
,
IWindowOpenable
,
IOpenEmptyWindowOptions
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IOpenedWindow
,
IOpenWindowOptions
,
IWindowOpenable
,
IOpenEmptyWindowOptions
,
IColorScheme
}
from
'
vs/platform/windows/common/windows
'
;
import
{
INativeOpenDialogOptions
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
isMacintosh
,
isWindows
,
isRootUser
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
ICommonNativeHostService
,
IOSProperties
,
IOSStatistics
}
from
'
vs/platform/native/common/native
'
;
...
...
@@ -22,7 +22,6 @@ import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MouseInputEvent
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
{
arch
,
totalmem
,
release
,
platform
,
type
,
loadavg
,
freemem
,
cpus
}
from
'
os
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
virtualMachineHint
}
from
'
vs/base/node/id
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
dirname
,
join
}
from
'
vs/base/common/path
'
;
...
...
@@ -52,16 +51,10 @@ export class NativeHostMainService implements INativeHostMainService {
// Color Scheme changes
nativeTheme
.
on
(
'
updated
'
,
()
=>
{
let
colorScheme
:
ColorScheme
;
if
(
nativeTheme
.
shouldUseInvertedColorScheme
||
nativeTheme
.
shouldUseHighContrastColors
)
{
colorScheme
=
ColorScheme
.
HIGH_CONTRAST
;
}
else
if
(
nativeTheme
.
shouldUseDarkColors
)
{
colorScheme
=
ColorScheme
.
DARK
;
}
else
{
colorScheme
=
ColorScheme
.
LIGHT
;
}
this
.
_onColorSchemeChange
.
fire
(
colorScheme
);
this
.
_onColorSchemeChange
.
fire
({
highContrast
:
nativeTheme
.
shouldUseInvertedColorScheme
||
nativeTheme
.
shouldUseHighContrastColors
,
dark
:
nativeTheme
.
shouldUseDarkColors
});
});
}
...
...
@@ -87,7 +80,7 @@ export class NativeHostMainService implements INativeHostMainService {
readonly
onOSResume
=
Event
.
fromNodeEventEmitter
(
powerMonitor
,
'
resume
'
);
private
readonly
_onColorSchemeChange
=
new
Emitter
<
ColorScheme
>
();
private
readonly
_onColorSchemeChange
=
new
Emitter
<
I
ColorScheme
>
();
readonly
onColorSchemeChange
=
this
.
_onColorSchemeChange
.
event
;
//#endregion
...
...
src/vs/platform/windows/common/windows.ts
浏览文件 @
a7caa978
...
...
@@ -11,7 +11,6 @@ import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platf
import
{
NativeParsedArgs
}
from
'
vs/platform/environment/common/argv
'
;
import
{
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
ExportData
}
from
'
vs/base/common/performance
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
export
const
WindowMinimumSize
=
{
WIDTH
:
400
,
...
...
@@ -213,12 +212,17 @@ export interface INativeRunKeybindingInWindowRequest {
userSettingsLabel
:
string
;
}
export
interface
IColorScheme
{
dark
:
boolean
;
highContrast
:
boolean
;
}
export
interface
IWindowConfiguration
{
sessionId
:
string
;
remoteAuthority
?:
string
;
colorScheme
:
ColorScheme
;
colorScheme
:
I
ColorScheme
;
autoDetectHighContrast
?:
boolean
;
filesToOpenOrCreate
?:
IPath
[];
...
...
src/vs/workbench/services/environment/browser/environmentService.ts
浏览文件 @
a7caa978
...
...
@@ -15,7 +15,6 @@ import { IProductService } from 'vs/platform/product/common/productService';
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
parseLineAndColumnAware
}
from
'
vs/base/common/extpath
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
class
BrowserWorkbenchConfiguration
implements
IWindowConfiguration
{
...
...
@@ -72,7 +71,7 @@ class BrowserWorkbenchConfiguration implements IWindowConfiguration {
}
get
colorScheme
()
{
return
ColorScheme
.
LIGHT
;
return
{
dark
:
false
,
highContrast
:
false
}
;
}
}
...
...
src/vs/workbench/services/themes/browser/browserHostColorSchemeService.ts
浏览文件 @
a7caa978
...
...
@@ -8,7 +8,6 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IHostColorSchemeService
}
from
'
vs/workbench/services/themes/common/hostColorSchemeService
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
export
class
BrowserHostColorSchemeService
extends
Disposable
implements
IHostColorSchemeService
{
...
...
@@ -38,15 +37,20 @@ export class BrowserHostColorSchemeService extends Disposable implements IHostCo
return
this
.
_onDidSchemeChangeEvent
.
event
;
}
get
colorScheme
():
ColorScheme
{
if
(
window
.
matchMedia
(
`(forced-colors: active)`
).
matches
)
{
return
ColorScheme
.
HIGH_CONTRAST
;
}
else
if
(
window
.
matchMedia
(
`(prefers-color-scheme: light)`
).
matches
)
{
return
ColorScheme
.
LIGHT
;
get
dark
():
boolean
{
if
(
window
.
matchMedia
(
`(prefers-color-scheme: light)`
).
matches
)
{
return
false
;
}
else
if
(
window
.
matchMedia
(
`(prefers-color-scheme: dark)`
).
matches
)
{
return
ColorScheme
.
DARK
;
return
true
;
}
return
this
.
environmentService
.
configuration
.
colorScheme
.
dark
;
}
get
highContrast
():
boolean
{
if
(
window
.
matchMedia
(
`(forced-colors: active)`
).
matches
)
{
return
true
;
}
return
this
.
environmentService
.
configuration
.
colorScheme
;
return
this
.
environmentService
.
configuration
.
colorScheme
.
highContrast
;
}
}
...
...
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
浏览文件 @
a7caa978
...
...
@@ -363,15 +363,11 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
}
private
getPreferredColorScheme
():
ColorScheme
|
undefined
{
const
detectHCThemeSetting
=
this
.
configurationService
.
getValue
<
boolean
>
(
ThemeSettings
.
DETECT_HC
);
if
(
this
.
hostColorService
.
colorScheme
===
ColorScheme
.
HIGH_CONTRAST
&&
detectHCThemeSetting
)
{
if
(
this
.
configurationService
.
getValue
<
boolean
>
(
ThemeSettings
.
DETECT_HC
)
&&
this
.
hostColorService
.
highContrast
)
{
return
ColorScheme
.
HIGH_CONTRAST
;
}
if
(
this
.
configurationService
.
getValue
<
boolean
>
(
ThemeSettings
.
DETECT_COLOR_SCHEME
))
{
const
osScheme
=
this
.
hostColorService
.
colorScheme
;
if
(
osScheme
!==
ColorScheme
.
HIGH_CONTRAST
)
{
return
osScheme
;
}
return
this
.
hostColorService
.
dark
?
ColorScheme
.
DARK
:
ColorScheme
.
LIGHT
;
}
return
undefined
;
}
...
...
src/vs/workbench/services/themes/common/hostColorSchemeService.ts
浏览文件 @
a7caa978
...
...
@@ -5,7 +5,6 @@
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
export
const
IHostColorSchemeService
=
createDecorator
<
IHostColorSchemeService
>
(
'
hostColorSchemeService
'
);
...
...
@@ -13,7 +12,8 @@ export interface IHostColorSchemeService {
readonly
_serviceBrand
:
undefined
;
readonly
colorScheme
:
ColorScheme
;
readonly
dark
:
boolean
;
readonly
highContrast
:
boolean
;
readonly
onDidChangeColorScheme
:
Event
<
void
>
;
}
src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts
浏览文件 @
a7caa978
...
...
@@ -8,7 +8,6 @@ import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
IHostColorSchemeService
}
from
'
vs/workbench/services/themes/common/hostColorSchemeService
'
;
export
class
NativeHostColorSchemeService
extends
Disposable
implements
IHostColorSchemeService
{
...
...
@@ -27,9 +26,9 @@ export class NativeHostColorSchemeService extends Disposable implements IHostCol
private
registerListeners
():
void
{
// Color Scheme
this
.
_register
(
this
.
nativeHostService
.
onColorSchemeChange
(
scheme
=>
{
this
.
_colorScheme
=
scheme
;
this
.
_register
(
this
.
nativeHostService
.
onColorSchemeChange
(
({
highContrast
,
dark
})
=>
{
this
.
dark
=
dark
;
this
.
highContrast
=
highContrast
;
this
.
_onDidChangeColorScheme
.
fire
();
}));
}
...
...
@@ -37,8 +36,8 @@ export class NativeHostColorSchemeService extends Disposable implements IHostCol
private
readonly
_onDidChangeColorScheme
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeColorScheme
=
this
.
_onDidChangeColorScheme
.
event
;
p
rivate
_colorScheme
:
ColorScheme
=
this
.
environmentService
.
configuration
.
colorScheme
;
get
colorScheme
()
{
return
this
.
_colorScheme
;
}
p
ublic
dark
:
boolean
=
this
.
environmentService
.
configuration
.
colorScheme
.
dark
;
public
highContrast
:
boolean
=
this
.
environmentService
.
configuration
.
colorScheme
.
highContrast
;
}
...
...
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
浏览文件 @
a7caa978
...
...
@@ -40,7 +40,6 @@ import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/ur
import
{
MouseInputEvent
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IOSProperties
,
IOSStatistics
}
from
'
vs/platform/native/common/native
'
;
import
{
ColorScheme
}
from
'
vs/platform/theme/common/theme
'
;
import
{
homedir
}
from
'
os
'
;
export
const
TestWorkbenchConfiguration
:
INativeWorkbenchConfiguration
=
{
...
...
@@ -54,7 +53,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
userEnv
:
{},
execPath
:
process
.
execPath
,
perfEntries
:
[],
colorScheme
:
ColorScheme
.
DARK
,
colorScheme
:
{
dark
:
true
,
highContrast
:
false
}
,
...
parseArgs
(
process
.
argv
,
OPTIONS
)
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录