提交 14681a4d 编写于 作者: A Alex Dima

Add `ToggleHighContrast` that toggles the use of the high contrast theme to the standalone editor

上级 ce15df0f
......@@ -11,6 +11,7 @@ import 'vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard';
import 'vs/editor/standalone/browser/quickOpen/quickOutline';
import 'vs/editor/standalone/browser/quickOpen/gotoLine';
import 'vs/editor/standalone/browser/quickOpen/quickCommand';
import 'vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast';
import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase';
import { createMonacoEditorAPI } from 'vs/editor/standalone/browser/standaloneEditor';
......
......@@ -23,9 +23,10 @@ const colorRegistry = <IColorRegistry>Registry.as(Extensions.ColorContribution);
const themingRegistry = Registry.as<IThemingRegistry>(ThemingExtensions.ThemingContribution);
class StandaloneTheme implements IStandaloneTheme {
id: string;
public readonly id: string;
public readonly themeName: string;
private rules: ITokenThemeRule[];
base: string;
public readonly base: string;
private colors: { [colorId: string]: Color };
private defaultColors: { [colorId: string]: Color };
private _tokenTheme: TokenTheme;
......@@ -33,8 +34,10 @@ class StandaloneTheme implements IStandaloneTheme {
constructor(base: string, name: string, colors: IColors, rules: ITokenThemeRule[]) {
if (name.length > 0) {
this.id = base + ' ' + name;
this.themeName = name;
} else {
this.id = base;
this.themeName = base;
}
this.base = base;
this.rules = rules;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vs/nls';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { editorAction, EditorAction, ServicesAccessor } from 'vs/editor/common/editorCommonExtensions';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
@editorAction
class ToggleHighContrast extends EditorAction {
private _originalThemeName: string;
constructor() {
super({
id: 'editor.action.toggleHighContrast',
label: nls.localize('toggleHighContrast', "Toggle High Contrast Theme"),
alias: 'Toggle High Contrast Theme',
precondition: null
});
this._originalThemeName = null;
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
const standaloneThemeService = accessor.get(IStandaloneThemeService);
if (this._originalThemeName) {
// We must toggle back to the integrator's theme
standaloneThemeService.setTheme(this._originalThemeName);
this._originalThemeName = null;
} else {
this._originalThemeName = standaloneThemeService.getTheme().themeName;
standaloneThemeService.setTheme('hc-black');
}
}
}
......@@ -22,6 +22,7 @@ export interface IStandaloneThemeData {
export interface IStandaloneTheme extends ITheme {
tokenTheme: TokenTheme;
themeName: string;
}
export interface IStandaloneThemeService extends IThemeService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册