Fixes #2524: Switch default theme to color +
This commit is contained in:
parent
e2a8c933c6
commit
6e4933c87c
|
@ -4,7 +4,7 @@
|
||||||
"description": "The default VS Code Light and Dark themes with a touch of color. We are considering adding these to the default themes in the January release. Please provide feedback in issue 1849.",
|
"description": "The default VS Code Light and Dark themes with a touch of color. We are considering adding these to the default themes in the January release. Please provide feedback in issue 1849.",
|
||||||
"categories": [ "Themes" ],
|
"categories": [ "Themes" ],
|
||||||
"version": "0.1.10",
|
"version": "0.1.10",
|
||||||
"publisher": "aeschli",
|
"publisher": "vscode",
|
||||||
"engines": { "vscode": "*" },
|
"engines": { "vscode": "*" },
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"themes": [
|
"themes": [
|
||||||
|
|
|
@ -12,8 +12,6 @@ export enum BaseTheme {
|
||||||
HIGH_CONTRAST
|
HIGH_CONTRAST
|
||||||
}
|
}
|
||||||
|
|
||||||
export var DEFAULT_THEME_ID = toId(BaseTheme.VS);
|
|
||||||
|
|
||||||
export function getBaseThemes(includeHighContrast: boolean): BaseTheme[] {
|
export function getBaseThemes(includeHighContrast: boolean): BaseTheme[] {
|
||||||
if (includeHighContrast) {
|
if (includeHighContrast) {
|
||||||
return [BaseTheme.VS, BaseTheme.VS_DARK, BaseTheme.HIGH_CONTRAST];
|
return [BaseTheme.VS, BaseTheme.VS_DARK, BaseTheme.HIGH_CONTRAST];
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {IEditorSelection, IEditor, EventType, IConfigurationChangedEvent, IModel
|
||||||
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||||
import {IFilesConfiguration} from 'vs/platform/files/common/files';
|
import {IFilesConfiguration} from 'vs/platform/files/common/files';
|
||||||
import {Position} from 'vs/platform/editor/common/editor';
|
import {Position} from 'vs/platform/editor/common/editor';
|
||||||
import {DEFAULT_THEME_ID} from 'vs/platform/theme/common/themes';
|
import {DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
import {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
|
import {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
|
||||||
import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';
|
import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';
|
||||||
import {IEventService} from 'vs/platform/event/common/event';
|
import {IEventService} from 'vs/platform/event/common/event';
|
||||||
|
|
|
@ -40,7 +40,7 @@ import {AbstractKeybindingService} from 'vs/platform/keybinding/browser/keybindi
|
||||||
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
|
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||||
import {WorkbenchEditorService} from 'vs/workbench/services/editor/browser/editorService';
|
import {WorkbenchEditorService} from 'vs/workbench/services/editor/browser/editorService';
|
||||||
import {Position, Parts, IPartService} from 'vs/workbench/services/part/common/partService';
|
import {Position, Parts, IPartService} from 'vs/workbench/services/part/common/partService';
|
||||||
import {DEFAULT_THEME_ID} from 'vs/platform/theme/common/themes';
|
import {DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
import {IWorkspaceContextService as IWorkbenchWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
import {IWorkspaceContextService as IWorkbenchWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||||
import {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
|
import {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
|
||||||
import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace';
|
import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace';
|
||||||
|
|
|
@ -93,7 +93,7 @@ import {MainThreadModeServiceImpl} from 'vs/editor/common/services/modeServiceIm
|
||||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||||
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
|
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||||
import {CrashReporter} from 'vs/workbench/electron-browser/crashReporter';
|
import {CrashReporter} from 'vs/workbench/electron-browser/crashReporter';
|
||||||
import {IThemeService, ThemeService} from 'vs/workbench/services/themes/node/themeService';
|
import {IThemeService, ThemeService, DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
import { IServiceCtor, isServiceEvent } from 'vs/base/common/service';
|
import { IServiceCtor, isServiceEvent } from 'vs/base/common/service';
|
||||||
import { connect, Client } from 'vs/base/node/service.net';
|
import { connect, Client } from 'vs/base/node/service.net';
|
||||||
import { IExtensionsService } from 'vs/workbench/parts/extensions/common/extensions';
|
import { IExtensionsService } from 'vs/workbench/parts/extensions/common/extensions';
|
||||||
|
@ -400,7 +400,7 @@ export class WorkbenchShell {
|
||||||
// Enable theme support
|
// Enable theme support
|
||||||
let themeId = this.storageService.get(Preferences.THEME, StorageScope.GLOBAL, null);
|
let themeId = this.storageService.get(Preferences.THEME, StorageScope.GLOBAL, null);
|
||||||
if (!themeId) {
|
if (!themeId) {
|
||||||
themeId = themes.toId(themes.BaseTheme.VS_DARK);
|
themeId = DEFAULT_THEME_ID;
|
||||||
this.storageService.store(Preferences.THEME, themeId, StorageScope.GLOBAL);
|
this.storageService.store(Preferences.THEME, themeId, StorageScope.GLOBAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,11 +432,10 @@ export class WorkbenchShell {
|
||||||
if (!themes.getSyntaxThemeId(themeId)) {
|
if (!themes.getSyntaxThemeId(themeId)) {
|
||||||
applyTheme();
|
applyTheme();
|
||||||
} else {
|
} else {
|
||||||
this.themeService.getTheme(themeId).then(theme => {
|
this.themeService.loadTheme(themeId).then(theme => {
|
||||||
if (theme) {
|
if (theme) {
|
||||||
this.themeService.loadThemeCSS(themeId);
|
this.themeService.applyThemeCSS(themeId);
|
||||||
applyTheme();
|
applyTheme();
|
||||||
|
|
||||||
}
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
errors.onUnexpectedError(error);
|
errors.onUnexpectedError(error);
|
||||||
|
|
|
@ -20,8 +20,8 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
|
||||||
import {ResourceEditorModel} from 'vs/workbench/common/editor/resourceEditorModel';
|
import {ResourceEditorModel} from 'vs/workbench/common/editor/resourceEditorModel';
|
||||||
import {Preferences} from 'vs/workbench/common/constants';
|
import {Preferences} from 'vs/workbench/common/constants';
|
||||||
import {HtmlInput} from 'vs/workbench/parts/html/common/htmlInput';
|
import {HtmlInput} from 'vs/workbench/parts/html/common/htmlInput';
|
||||||
import {DEFAULT_THEME_ID, isLightTheme} from 'vs/platform/theme/common/themes';
|
import {isLightTheme} from 'vs/platform/theme/common/themes';
|
||||||
|
import {DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
/**
|
/**
|
||||||
* An implementation of editor for showing HTML content in an IFrame by leveraging the IFrameEditorInput.
|
* An implementation of editor for showing HTML content in an IFrame by leveraging the IFrameEditorInput.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {Preferences} from 'vs/workbench/common/constants';
|
||||||
import {IModel} from 'vs/editor/common/editorCommon';
|
import {IModel} from 'vs/editor/common/editorCommon';
|
||||||
import {IEmitOutput} from 'vs/editor/common/modes';
|
import {IEmitOutput} from 'vs/editor/common/modes';
|
||||||
import themes = require('vs/platform/theme/common/themes');
|
import themes = require('vs/platform/theme/common/themes');
|
||||||
|
import {DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
import {MARKDOWN_MIME, MARKDOWN_MODE_ID} from 'vs/workbench/parts/markdown/common/markdown';
|
import {MARKDOWN_MIME, MARKDOWN_MODE_ID} from 'vs/workbench/parts/markdown/common/markdown';
|
||||||
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
||||||
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
|
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
|
||||||
|
@ -49,7 +50,7 @@ export class MarkdownEditorModel extends IFrameEditorModel {
|
||||||
// On Error: Show error to user as rendered HTML
|
// On Error: Show error to user as rendered HTML
|
||||||
let onError = (error: Error) => {
|
let onError = (error: Error) => {
|
||||||
try {
|
try {
|
||||||
let theme = this.storageService.get(Preferences.THEME, StorageScope.GLOBAL, themes.DEFAULT_THEME_ID);
|
let theme = this.storageService.get(Preferences.THEME, StorageScope.GLOBAL, DEFAULT_THEME_ID);
|
||||||
let usesLightTheme = themes.isLightTheme(theme);
|
let usesLightTheme = themes.isLightTheme(theme);
|
||||||
|
|
||||||
let markdownError = nls.localize('markdownError', "Unable to open '{0}' for Markdown rendering. Please make sure the file exists and that it is a valid Markdown file.", paths.basename(this.resource.fsPath));
|
let markdownError = nls.localize('markdownError', "Unable to open '{0}' for Markdown rendering. Please make sure the file exists and that it is a valid Markdown file.", paths.basename(this.resource.fsPath));
|
||||||
|
|
|
@ -17,7 +17,7 @@ import workbenchActionRegistry = require('vs/workbench/common/actionRegistry');
|
||||||
import Themes = require('vs/platform/theme/common/themes');
|
import Themes = require('vs/platform/theme/common/themes');
|
||||||
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||||
import {IThemeService, ITheme} from 'vs/workbench/services/themes/node/themeService';
|
import {IThemeService, IThemeData, DEFAULT_THEME_ID} from 'vs/workbench/services/themes/node/themeService';
|
||||||
|
|
||||||
import {ipcRenderer as ipc} from 'electron';
|
import {ipcRenderer as ipc} from 'electron';
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class SelectThemeAction extends actions.Action {
|
||||||
public run(): winjs.Promise {
|
public run(): winjs.Promise {
|
||||||
|
|
||||||
return this.themeService.getThemes().then(contributedThemes => {
|
return this.themeService.getThemes().then(contributedThemes => {
|
||||||
let currentTheme = this.storageService.get(Constants.Preferences.THEME, StorageScope.GLOBAL, Themes.DEFAULT_THEME_ID);
|
let currentTheme = this.storageService.get(Constants.Preferences.THEME, StorageScope.GLOBAL, DEFAULT_THEME_ID);
|
||||||
let selectedIndex = 0;
|
let selectedIndex = 0;
|
||||||
|
|
||||||
let picks: IPickOpenEntry[] = [];
|
let picks: IPickOpenEntry[] = [];
|
||||||
|
@ -49,7 +49,7 @@ class SelectThemeAction extends actions.Action {
|
||||||
picks.push({ label: Themes.toLabel(baseTheme), id: Themes.toId(baseTheme) });
|
picks.push({ label: Themes.toLabel(baseTheme), id: Themes.toId(baseTheme) });
|
||||||
});
|
});
|
||||||
|
|
||||||
let contributedThemesById : { [id:string]: ITheme } = {};
|
let contributedThemesById : { [id:string]: IThemeData } = {};
|
||||||
contributedThemes.forEach(theme => {
|
contributedThemes.forEach(theme => {
|
||||||
picks.push({ id: theme.id, label: theme.label, description: theme.description });
|
picks.push({ id: theme.id, label: theme.label, description: theme.description });
|
||||||
contributedThemes[theme.id] = theme;
|
contributedThemes[theme.id] = theme;
|
||||||
|
@ -72,7 +72,7 @@ class SelectThemeAction extends actions.Action {
|
||||||
ipc.send('vscode:changeTheme', themeId);
|
ipc.send('vscode:changeTheme', themeId);
|
||||||
} else {
|
} else {
|
||||||
// before applying, check that it can be loaded
|
// before applying, check that it can be loaded
|
||||||
return this.themeService.loadThemeCSS(themeId).then(_ => {
|
return this.themeService.applyThemeCSS(themeId).then(_ => {
|
||||||
ipc.send('vscode:changeTheme', themeId);
|
ipc.send('vscode:changeTheme', themeId);
|
||||||
}, error => {
|
}, error => {
|
||||||
this.messageService.show(Severity.Info, nls.localize('problemChangingTheme', "Problem loading theme: {0}", error.message));
|
this.messageService.show(Severity.Info, nls.localize('problemChangingTheme', "Problem loading theme: {0}", error.message));
|
||||||
|
|
|
@ -20,12 +20,12 @@ export let IThemeService = createDecorator<IThemeService>('themeService');
|
||||||
|
|
||||||
export interface IThemeService {
|
export interface IThemeService {
|
||||||
serviceId: ServiceIdentifier<any>;
|
serviceId: ServiceIdentifier<any>;
|
||||||
getTheme(themeId: string): TPromise<ITheme>;
|
loadTheme(themeId: string): TPromise<IThemeData>;
|
||||||
loadThemeCSS(themeId: string): TPromise<boolean>;
|
applyThemeCSS(themeId: string): TPromise<boolean>;
|
||||||
getThemes(): TPromise<ITheme[]>;
|
getThemes(): TPromise<IThemeData[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITheme {
|
export interface IThemeData {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
@ -33,6 +33,8 @@ export interface ITheme {
|
||||||
styleSheetContent?: string;
|
styleSheetContent?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_THEME_ID = 'vs-dark vscode-theme-colorful-defaults-themes-dark_plus-tmTheme';
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
let defaultBaseTheme = Themes.toId(Themes.BaseTheme.VS_DARK);
|
let defaultBaseTheme = Themes.toId(Themes.BaseTheme.VS_DARK);
|
||||||
|
@ -64,7 +66,7 @@ let themesExtPoint = PluginsRegistry.registerExtensionPoint<IThemeExtensionPoint
|
||||||
export class ThemeService implements IThemeService {
|
export class ThemeService implements IThemeService {
|
||||||
serviceId = IThemeService;
|
serviceId = IThemeService;
|
||||||
|
|
||||||
private knownThemes: ITheme[];
|
private knownThemes: IThemeData[];
|
||||||
|
|
||||||
constructor(private pluginService: IPluginService) {
|
constructor(private pluginService: IPluginService) {
|
||||||
this.knownThemes = [];
|
this.knownThemes = [];
|
||||||
|
@ -76,7 +78,7 @@ export class ThemeService implements IThemeService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTheme(themeId: string): TPromise<ITheme> {
|
public loadTheme(themeId: string): TPromise<IThemeData> {
|
||||||
return this.getThemes().then(allThemes => {
|
return this.getThemes().then(allThemes => {
|
||||||
let themes = allThemes.filter(t => t.id === themeId);
|
let themes = allThemes.filter(t => t.id === themeId);
|
||||||
if (themes.length > 0) {
|
if (themes.length > 0) {
|
||||||
|
@ -86,16 +88,16 @@ export class ThemeService implements IThemeService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadThemeCSS(themeId: string): TPromise<boolean> {
|
public applyThemeCSS(themeId: string): TPromise<boolean> {
|
||||||
return this.getTheme(themeId).then(theme => {
|
return this.loadTheme(themeId).then(theme => {
|
||||||
if (theme) {
|
if (theme) {
|
||||||
return loadTheme(theme);
|
return applyTheme(theme);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getThemes(): TPromise<ITheme[]> {
|
public getThemes(): TPromise<IThemeData[]> {
|
||||||
return this.pluginService.onReady().then(isReady => {
|
return this.pluginService.onReady().then(isReady => {
|
||||||
return this.knownThemes;
|
return this.knownThemes;
|
||||||
});
|
});
|
||||||
|
@ -141,7 +143,7 @@ function toCssSelector(str: string) {
|
||||||
return str.replace(/[^_\-a-zA-Z0-9]/g, '-');
|
return str.replace(/[^_\-a-zA-Z0-9]/g, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTheme(theme: ITheme): TPromise<boolean> {
|
function applyTheme(theme: IThemeData): TPromise<boolean> {
|
||||||
if (theme.styleSheetContent) {
|
if (theme.styleSheetContent) {
|
||||||
_applyRules(theme.styleSheetContent);
|
_applyRules(theme.styleSheetContent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue