Fixes #2524: Switch default theme to color +

This commit is contained in:
Martin Aeschlimann 2016-01-29 11:14:34 +01:00
parent e2a8c933c6
commit 6e4933c87c
9 changed files with 28 additions and 28 deletions

View file

@ -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.",
"categories": [ "Themes" ],
"version": "0.1.10",
"publisher": "aeschli",
"publisher": "vscode",
"engines": { "vscode": "*" },
"contributes": {
"themes": [

View file

@ -12,8 +12,6 @@ export enum BaseTheme {
HIGH_CONTRAST
}
export var DEFAULT_THEME_ID = toId(BaseTheme.VS);
export function getBaseThemes(includeHighContrast: boolean): BaseTheme[] {
if (includeHighContrast) {
return [BaseTheme.VS, BaseTheme.VS_DARK, BaseTheme.HIGH_CONTRAST];

View file

@ -21,7 +21,7 @@ import {IEditorSelection, IEditor, EventType, IConfigurationChangedEvent, IModel
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IFilesConfiguration} from 'vs/platform/files/common/files';
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 {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';
import {IEventService} from 'vs/platform/event/common/event';

View file

@ -40,7 +40,7 @@ import {AbstractKeybindingService} from 'vs/platform/keybinding/browser/keybindi
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
import {WorkbenchEditorService} from 'vs/workbench/services/editor/browser/editorService';
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 {IStorageService, StorageScope, StorageEvent, StorageEventType} from 'vs/platform/storage/common/storage';
import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace';

View file

@ -93,7 +93,7 @@ import {MainThreadModeServiceImpl} from 'vs/editor/common/services/modeServiceIm
import {IModeService} from 'vs/editor/common/services/modeService';
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
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 { connect, Client } from 'vs/base/node/service.net';
import { IExtensionsService } from 'vs/workbench/parts/extensions/common/extensions';
@ -400,7 +400,7 @@ export class WorkbenchShell {
// Enable theme support
let themeId = this.storageService.get(Preferences.THEME, StorageScope.GLOBAL, null);
if (!themeId) {
themeId = themes.toId(themes.BaseTheme.VS_DARK);
themeId = DEFAULT_THEME_ID;
this.storageService.store(Preferences.THEME, themeId, StorageScope.GLOBAL);
}
@ -432,11 +432,10 @@ export class WorkbenchShell {
if (!themes.getSyntaxThemeId(themeId)) {
applyTheme();
} else {
this.themeService.getTheme(themeId).then(theme => {
this.themeService.loadTheme(themeId).then(theme => {
if (theme) {
this.themeService.loadThemeCSS(themeId);
this.themeService.applyThemeCSS(themeId);
applyTheme();
}
}, error => {
errors.onUnexpectedError(error);

View file

@ -20,8 +20,8 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
import {ResourceEditorModel} from 'vs/workbench/common/editor/resourceEditorModel';
import {Preferences} from 'vs/workbench/common/constants';
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.
*/

View file

@ -14,6 +14,7 @@ import {Preferences} from 'vs/workbench/common/constants';
import {IModel} from 'vs/editor/common/editorCommon';
import {IEmitOutput} from 'vs/editor/common/modes';
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 {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
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
let onError = (error: Error) => {
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 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));

View file

@ -17,7 +17,7 @@ import workbenchActionRegistry = require('vs/workbench/common/actionRegistry');
import Themes = require('vs/platform/theme/common/themes');
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
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';
@ -41,7 +41,7 @@ class SelectThemeAction extends actions.Action {
public run(): winjs.Promise {
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 picks: IPickOpenEntry[] = [];
@ -49,7 +49,7 @@ class SelectThemeAction extends actions.Action {
picks.push({ label: Themes.toLabel(baseTheme), id: Themes.toId(baseTheme) });
});
let contributedThemesById : { [id:string]: ITheme } = {};
let contributedThemesById : { [id:string]: IThemeData } = {};
contributedThemes.forEach(theme => {
picks.push({ id: theme.id, label: theme.label, description: theme.description });
contributedThemes[theme.id] = theme;
@ -72,7 +72,7 @@ class SelectThemeAction extends actions.Action {
ipc.send('vscode:changeTheme', themeId);
} else {
// 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);
}, error => {
this.messageService.show(Severity.Info, nls.localize('problemChangingTheme', "Problem loading theme: {0}", error.message));

View file

@ -20,12 +20,12 @@ export let IThemeService = createDecorator<IThemeService>('themeService');
export interface IThemeService {
serviceId: ServiceIdentifier<any>;
getTheme(themeId: string): TPromise<ITheme>;
loadThemeCSS(themeId: string): TPromise<boolean>;
getThemes(): TPromise<ITheme[]>;
loadTheme(themeId: string): TPromise<IThemeData>;
applyThemeCSS(themeId: string): TPromise<boolean>;
getThemes(): TPromise<IThemeData[]>;
}
export interface ITheme {
export interface IThemeData {
id: string;
label: string;
description?: string;
@ -33,6 +33,8 @@ export interface ITheme {
styleSheetContent?: string;
}
export const DEFAULT_THEME_ID = 'vs-dark vscode-theme-colorful-defaults-themes-dark_plus-tmTheme';
// implementation
let defaultBaseTheme = Themes.toId(Themes.BaseTheme.VS_DARK);
@ -64,7 +66,7 @@ let themesExtPoint = PluginsRegistry.registerExtensionPoint<IThemeExtensionPoint
export class ThemeService implements IThemeService {
serviceId = IThemeService;
private knownThemes: ITheme[];
private knownThemes: IThemeData[];
constructor(private pluginService: IPluginService) {
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 => {
let themes = allThemes.filter(t => t.id === themeId);
if (themes.length > 0) {
@ -86,16 +88,16 @@ export class ThemeService implements IThemeService {
});
}
public loadThemeCSS(themeId: string): TPromise<boolean> {
return this.getTheme(themeId).then(theme => {
public applyThemeCSS(themeId: string): TPromise<boolean> {
return this.loadTheme(themeId).then(theme => {
if (theme) {
return loadTheme(theme);
return applyTheme(theme);
}
return null;
});
}
public getThemes(): TPromise<ITheme[]> {
public getThemes(): TPromise<IThemeData[]> {
return this.pluginService.onReady().then(isReady => {
return this.knownThemes;
});
@ -141,7 +143,7 @@ function toCssSelector(str: string) {
return str.replace(/[^_\-a-zA-Z0-9]/g, '-');
}
function loadTheme(theme: ITheme): TPromise<boolean> {
function applyTheme(theme: IThemeData): TPromise<boolean> {
if (theme.styleSheetContent) {
_applyRules(theme.styleSheetContent);
}