Add high contrast light theme on monaco editor (#149165)
* Register light HC theme * Do not always use black HC theme Co-authored-by: Loïc Mangeonjean <loic@codingame.com>pull/149173/head
parent
b44e3caa96
commit
8fb2dc9c2a
|
@ -16,7 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||
import { asCssVariableName, ColorIdentifier, Extensions, IColorRegistry } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Extensions as ThemingExtensions, ICssStyleCollector, IFileIconTheme, IProductIconTheme, IThemingRegistry, ITokenStyle } from 'vs/platform/theme/common/themeService';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { ColorScheme, isDark } from 'vs/platform/theme/common/theme';
|
||||
import { getIconsStyleSheet, UnthemedProductIconTheme } from 'vs/platform/theme/browser/iconsStyleSheet';
|
||||
|
||||
const VS_THEME_NAME = 'vs';
|
||||
|
@ -242,6 +242,7 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe
|
|||
this._knownThemes.set(VS_THEME_NAME, newBuiltInTheme(VS_THEME_NAME));
|
||||
this._knownThemes.set(VS_DARK_THEME_NAME, newBuiltInTheme(VS_DARK_THEME_NAME));
|
||||
this._knownThemes.set(HC_BLACK_THEME_NAME, newBuiltInTheme(HC_BLACK_THEME_NAME));
|
||||
this._knownThemes.set(HC_LIGHT_THEME_NAME, newBuiltInTheme(HC_LIGHT_THEME_NAME));
|
||||
|
||||
const iconsStyleSheet = getIconsStyleSheet(this);
|
||||
|
||||
|
@ -339,10 +340,18 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe
|
|||
this._updateActualTheme();
|
||||
}
|
||||
|
||||
private getHighContrastTheme() {
|
||||
if (isDark(this._desiredTheme.type)) {
|
||||
return HC_BLACK_THEME_NAME;
|
||||
} else {
|
||||
return HC_LIGHT_THEME_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
private _updateActualTheme(): void {
|
||||
const theme = (
|
||||
this._autoDetectHighContrast && window.matchMedia(`(forced-colors: active)`).matches
|
||||
? this._knownThemes.get(HC_BLACK_THEME_NAME)!
|
||||
? this._knownThemes.get(this.getHighContrastTheme())!
|
||||
: this._desiredTheme
|
||||
);
|
||||
if (this._theme === theme) {
|
||||
|
|
|
@ -16,3 +16,7 @@ export enum ColorScheme {
|
|||
export function isHighContrast(scheme: ColorScheme): boolean {
|
||||
return scheme === ColorScheme.HIGH_CONTRAST_DARK || scheme === ColorScheme.HIGH_CONTRAST_LIGHT;
|
||||
}
|
||||
|
||||
export function isDark(scheme: ColorScheme): boolean {
|
||||
return scheme === ColorScheme.DARK || scheme === ColorScheme.HIGH_CONTRAST_DARK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue