diff --git a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts index 7644c520febb385e35bd9480307f38dab2ae6676..2a3a9789ed453e75065d4d4bbd01a9a129832646 100644 --- a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts @@ -44,12 +44,26 @@ export interface IEditorConstructionOptions extends IEditorOptions { * To not create automatically a model, use `model: null`. */ language?: string; + /** + * Initial theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + * To switch a theme, use `monaco.editor.setTheme` + */ + theme?: string; } /** * The options to create a diff editor. */ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions { + /** + * Initial theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + * To switch a theme, use `monaco.editor.setTheme` + */ + theme?: string; } export interface IStandaloneCodeEditor extends ICodeEditor { @@ -193,7 +207,6 @@ export class StandaloneCodeEditor extends CodeEditor implements IStandaloneCodeE export class StandaloneEditor extends StandaloneCodeEditor implements IStandaloneCodeEditor { private _contextViewService: IEditorContextViewService; - private _standaloneThemeService: IStandaloneThemeService; private _ownsModel: boolean; constructor( @@ -206,18 +219,17 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon @IContextKeyService contextKeyService: IContextKeyService, @IKeybindingService keybindingService: IKeybindingService, @IContextViewService contextViewService: IContextViewService, - @IStandaloneThemeService standaloneThemeService: IStandaloneThemeService + @IStandaloneThemeService themeService: IStandaloneThemeService ) { options = options || {}; if (typeof options.theme === 'string') { - options.theme = standaloneThemeService.setTheme(options.theme); + themeService.setTheme(options.theme); } let model: IModel = options.model; delete options.model; - super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, standaloneThemeService); + super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService); this._contextViewService = contextViewService; - this._standaloneThemeService = standaloneThemeService; this._register(toDispose); if (typeof model === 'undefined') { @@ -245,13 +257,6 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon this.dispose(); } - public updateOptions(newOptions: IEditorOptions): void { - if (typeof newOptions.theme === 'string') { - newOptions.theme = this._standaloneThemeService.setTheme(newOptions.theme); - } - super.updateOptions(newOptions); - } - _attachModel(model: IModel): void { super._attachModel(model); if (this._view) { @@ -271,7 +276,6 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon export class StandaloneDiffEditor extends DiffEditorWidget implements IStandaloneDiffEditor { private _contextViewService: IEditorContextViewService; - private _standaloneThemeService: IStandaloneThemeService; private _standaloneKeybindingService: StandaloneKeybindingService; constructor( @@ -282,14 +286,13 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon @IContextKeyService contextKeyService: IContextKeyService, @IKeybindingService keybindingService: IKeybindingService, @IContextViewService contextViewService: IContextViewService, - @IStandaloneThemeService standaloneColorService: IStandaloneThemeService, @IEditorWorkerService editorWorkerService: IEditorWorkerService, @ICodeEditorService codeEditorService: ICodeEditorService, - @IThemeService themeService: IThemeService + @IStandaloneThemeService themeService: IStandaloneThemeService ) { options = options || {}; if (typeof options.theme === 'string') { - options.theme = standaloneColorService.setTheme(options.theme); + options.theme = themeService.setTheme(options.theme); } super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService); @@ -299,7 +302,6 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon } this._contextViewService = contextViewService; - this._standaloneThemeService = standaloneColorService; this._register(toDispose); @@ -314,13 +316,6 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon this.dispose(); } - public updateOptions(newOptions: IEditorOptions): void { - if (typeof newOptions.theme === 'string') { - newOptions.theme = this._standaloneThemeService.setTheme(newOptions.theme); - } - super.updateOptions(newOptions); - } - protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: IEditorOptions): CodeEditor { return instantiationService.createInstance(StandaloneCodeEditor, container, options); } diff --git a/src/vs/editor/browser/standalone/standaloneEditor.ts b/src/vs/editor/browser/standalone/standaloneEditor.ts index 5e5fb63939e7c2c85eaee467d8d5f91c318aec1a..776016912c41f97989582f635de9e76a8d6405de 100644 --- a/src/vs/editor/browser/standalone/standaloneEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneEditor.ts @@ -125,7 +125,6 @@ export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorC services.get(IContextKeyService), services.get(IKeybindingService), services.get(IContextViewService), - services.get(IStandaloneThemeService), services.get(IEditorWorkerService), services.get(ICodeEditorService), services.get(IStandaloneThemeService) @@ -309,6 +308,13 @@ export function defineTheme(themeName: string, themeData: IStandaloneThemeData): StaticServices.standaloneThemeService.get().defineTheme(themeName, themeData); } +/** + * Switches to a theme. + */ +export function setTheme(themeName: string): void { + StaticServices.standaloneThemeService.get().setTheme(themeName); +} + /** * @internal */ @@ -336,6 +342,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { colorizeModelLine: colorizeModelLine, tokenize: tokenize, defineTheme: defineTheme, + setTheme: setTheme, // enums ScrollbarVisibility: ScrollbarVisibility, diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 9e113117580661a1cc2926e85b9d7b76052c50b3..9a2390c4a36e78523e729ec99bcc6f276d85b4b2 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -48,7 +48,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData' import { EditorScrollbar } from 'vs/editor/browser/viewParts/editorScrollbar/editorScrollbar'; import { Minimap } from 'vs/editor/browser/viewParts/minimap/minimap'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; export interface IContentWidgetData { widget: editorBrowser.IContentWidget; @@ -118,6 +118,7 @@ export class View extends ViewEventHandler { this._register(themeService.onThemeChange(theme => { this._context.theme = theme; this.eventDispatcher.emit(new viewEvents.ViewThemeChangedEvent()); + this.render(true, false); })); this.viewParts = []; @@ -144,7 +145,7 @@ export class View extends ViewEventHandler { this.linesContent.setPosition('absolute'); this.domNode = createFastDomNode(document.createElement('div')); - this.domNode.setClassName(this._context.configuration.editor.editorClassName); + this.domNode.setClassName(this.getEditorClassName()); this.overflowGuardContainer = createFastDomNode(document.createElement('div')); PartFingerprints.write(this.overflowGuardContainer, PartFingerprint.OverflowGuard); @@ -305,11 +306,15 @@ export class View extends ViewEventHandler { } + private getEditorClassName() { + return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type); + } + // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { if (e.editorClassName) { - this.domNode.setClassName(this._context.configuration.editor.editorClassName); + this.domNode.setClassName(this.getEditorClassName()); } if (e.layoutInfo) { this._setLayout(); @@ -329,6 +334,10 @@ export class View extends ViewEventHandler { this.outgoingEvents.emitScrollChanged(e); return false; } + public onThemeChanged(e: viewEvents.ViewThemeChangedEvent): boolean { + this.domNode.setClassName(this.getEditorClassName()); + return false; + } // --- end event handlers diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index ff008292f72b6d57fcacd1062499af82f4410b33..b149d37a1113d579a9729d8222f66eb1a1d2c3e4 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -158,16 +158,6 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito super.dispose(); } - public updateOptions(newOptions: IEditorOptions): void { - let oldTheme = this._configuration.editor.viewInfo.theme; - super.updateOptions(newOptions); - let newTheme = this._configuration.editor.viewInfo.theme; - - if (oldTheme !== newTheme) { - this.render(); - } - } - public colorizeModelLine(lineNumber: number, model: editorCommon.IModel = this.model): string { if (!model) { return ''; diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index af15fcfd15c32680dc58f953e703288634ec451a..00a9e0f42e1548869f58191ee23e3537fb66c717 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -32,7 +32,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes'; import Event, { Emitter } from 'vs/base/common/event'; import * as editorOptions from 'vs/editor/common/config/editorOptions'; -import { registerThemingParticipant, IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; +import { registerThemingParticipant, IThemeService, ITheme, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; import { registerColor, scrollbarShadow } from 'vs/platform/theme/common/colorRegistry'; import { Color, RGBA } from 'vs/base/common/color'; import { OverviewRulerZone } from 'vs/editor/common/view/overviewZoneManager'; @@ -148,7 +148,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE private readonly id: number; - private _theme: string; private _domElement: HTMLElement; protected readonly _containerDomElement: HTMLElement; private readonly _overviewDomElement: HTMLElement; @@ -213,7 +212,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE this._domElement = domElement; options = options || {}; - this._theme = options.theme || editorOptions.EDITOR_DEFAULTS.viewInfo.theme; // renderSideBySide this._renderSideBySide = true; if (typeof options.renderSideBySide !== 'undefined') { @@ -240,7 +238,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE this._updateDecorationsRunner = this._register(new RunOnceScheduler(() => this._updateDecorations(), 0)); this._containerDomElement = document.createElement('div'); - this._containerDomElement.className = DiffEditorWidget._getClassName(this._theme, this._renderSideBySide); + this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide); this._containerDomElement.style.position = 'relative'; this._containerDomElement.style.height = '100%'; this._domElement.appendChild(this._containerDomElement); @@ -305,11 +303,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE this._codeEditorService.addDiffEditor(this); - themeService.onThemeChange(t => { + this._register(themeService.onThemeChange(t => { if (this._strategy && this._strategy.applyColors(t)) { this._updateDecorationsRunner.schedule(); } - }); + this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide); + })); } public get ignoreTrimWhitespace(): boolean { @@ -324,12 +323,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return this._renderIndicators; } - private static _getClassName(theme: string, renderSideBySide: boolean): string { + private static _getClassName(theme: ITheme, renderSideBySide: boolean): string { let result = 'monaco-diff-editor monaco-editor-background '; if (renderSideBySide) { result += 'side-by-side '; } - result += theme; + result += getThemeTypeSelector(theme.type); return result; } @@ -486,8 +485,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE } public updateOptions(newOptions: editorOptions.IDiffEditorOptions): void { - // Handle new theme - this._theme = newOptions && newOptions.theme ? newOptions.theme : this._theme; // Handle side by side let renderSideBySideChanged = false; @@ -523,9 +520,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE this._originalIsEditable = Boolean(newOptions.originalEditable); } - // Update class name - this._containerDomElement.className = DiffEditorWidget._getClassName(this._theme, this._renderSideBySide); - this.modifiedEditor.updateOptions(this._adjustOptionsForRightHandSide(newOptions)); this.originalEditor.updateOptions(this._adjustOptionsForLeftHandSide(newOptions, this._originalIsEditable)); @@ -542,6 +536,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE } else { this._setStrategy(new DiffEdtorWidgetInline(this._createDataSource(), this._enableSplitViewResizing)); } + // Update class name + this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide); } } @@ -892,7 +888,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE let result = this._adjustOptionsForSubEditor(options); result.readOnly = !isEditable; result.overviewRulerLanes = 1; - result.theme = this._theme + ' original-in-monaco-diff-editor'; + result.extraEditorClassName = 'original-in-monaco-diff-editor'; return result; } @@ -900,7 +896,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE let result = this._adjustOptionsForSubEditor(options); result.revealHorizontalRightPadding = editorOptions.EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH; result.scrollbar.verticalHasArrows = false; - result.theme = this._theme + ' modified-in-monaco-diff-editor'; + result.extraEditorClassName = 'modified-in-monaco-diff-editor'; return result; } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index afdc566eac9eaa1b00cf1072ce494447b1da04b3..a7751d58adc66059453eed89996f98306277907d 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -111,12 +111,11 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed const opts = this._validatedOptions; const partialEnv = this._getEnvConfiguration(); const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel); - const editorClassName = this._getEditorClassName(opts.viewInfo.theme, opts.viewInfo.fontLigatures, opts.mouseStyle); const env: editorOptions.IEnvironmentalOptions = { outerWidth: partialEnv.outerWidth, outerHeight: partialEnv.outerHeight, fontInfo: this.readConfiguration(bareFontInfo), - editorClassName: editorClassName + ' ' + partialEnv.extraEditorClassName, + extraEditorClassName: partialEnv.extraEditorClassName, isDominatedByLongLines: this._isDominatedByLongLines, lineNumbersDigitCount: this._lineNumbersDigitCount, canUseTranslate3d: partialEnv.canUseTranslate3d, @@ -154,20 +153,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed } return r ? r : 1; } - - private _getEditorClassName(theme: string, fontLigatures: boolean, mouseStyle: 'text' | 'default' | 'copy'): string { - let extra = ''; - if (fontLigatures) { - extra += 'enable-ligatures '; - } - if (mouseStyle === 'default') { - extra += 'mouse-default '; - } else if (mouseStyle === 'copy') { - extra += 'mouse-copy '; - } - return 'monaco-editor ' + extra + theme; - } - protected abstract _getEnvConfiguration(): IEnvConfiguration; protected abstract readConfiguration(styling: BareFontInfo): FontInfo; diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 1ea498ab56b54ee03e5e8439682b24caa6c997ed..6d41b717618c4f5faa3b25517b8474a6432266a3 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -170,11 +170,9 @@ export interface IEditorOptions { */ roundedSelection?: boolean; /** - * Theme to be used for rendering. - * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. - * You can create custom themes via `monaco.editor.defineTheme`. + * Class name to be added to the editor. */ - theme?: string; + extraEditorClassName?: string; /** * Should the editor be read only. * Defaults to false. @@ -683,7 +681,7 @@ export interface EditorWrappingInfo { } export interface InternalEditorViewOptions { - readonly theme: string; + readonly extraEditorClassName: string; readonly disableMonospaceOptimizations: boolean; readonly experimentalScreenReader: boolean; readonly rulers: number[]; @@ -893,7 +891,7 @@ export class InternalEditorOptions { */ private static _equalsViewOptions(a: InternalEditorViewOptions, b: InternalEditorViewOptions): boolean { return ( - a.theme === b.theme + a.extraEditorClassName === b.extraEditorClassName && a.disableMonospaceOptimizations === b.disableMonospaceOptimizations && a.experimentalScreenReader === b.experimentalScreenReader && this._equalsNumberArrays(a.rulers, b.rulers) @@ -1179,7 +1177,7 @@ export interface IEnvironmentalOptions { readonly outerWidth: number; readonly outerHeight: number; readonly fontInfo: FontInfo; - readonly editorClassName: string; + readonly extraEditorClassName: string; readonly isDominatedByLongLines: boolean; readonly lineNumbersDigitCount: number; readonly canUseTranslate3d: boolean; @@ -1473,7 +1471,7 @@ export class EditorOptionsValidator { const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap); return { - theme: _string(opts.theme, defaults.theme), + extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName), disableMonospaceOptimizations: disableMonospaceOptimizations, experimentalScreenReader: _boolean(opts.experimentalScreenReader, defaults.experimentalScreenReader), rulers: rulers, @@ -1630,10 +1628,26 @@ export class InternalEditorOptionsFactory { wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters, }; + let className = 'monaco-editor'; + if (opts.viewInfo.extraEditorClassName) { + className += ' ' + opts.viewInfo.extraEditorClassName; + } + if (env.extraEditorClassName) { + className += ' ' + env.extraEditorClassName; + } + if (opts.viewInfo.fontLigatures) { + className += ' enable-ligatures'; + } + if (opts.mouseStyle === 'default') { + className += ' mouse-default'; + } else if (opts.mouseStyle === 'copy') { + className += ' mouse-copy'; + } + return new InternalEditorOptions({ canUseTranslate3d: opts.disableTranslate3d ? false : env.canUseTranslate3d, pixelRatio: env.pixelRatio, - editorClassName: env.editorClassName, + editorClassName: className, lineHeight: env.fontInfo.lineHeight, readOnly: opts.readOnly, wordSeparators: opts.wordSeparators, @@ -1853,7 +1867,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { useTabStops: true, viewInfo: { - theme: 'vs', + extraEditorClassName: '', disableMonospaceOptimizations: false, experimentalScreenReader: true, rulers: [], diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 8571c7ae3d9896ed586c9aa8044880812ffde7e6..ec0a1873919d7a06bb3f66cf708c1ecd2373d9f6 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -892,6 +892,11 @@ declare module monaco.editor { */ export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; + /** + * Switches to a theme. + */ + export function setTheme(themeName: string): void; + export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; export interface IStandaloneThemeData { @@ -965,12 +970,26 @@ declare module monaco.editor { * To not create automatically a model, use `model: null`. */ language?: string; + /** + * Initial theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + * To switch a theme, use `monaco.editor.setTheme` + */ + theme?: string; } /** * The options to create a diff editor. */ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions { + /** + * Initial theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + * To switch a theme, use `monaco.editor.setTheme` + */ + theme?: string; } export interface IStandaloneCodeEditor extends ICodeEditor { @@ -2717,11 +2736,9 @@ declare module monaco.editor { */ roundedSelection?: boolean; /** - * Theme to be used for rendering. - * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. - * You can create custom themes via `monaco.editor.defineTheme`. + * Class name to be added to the editor. */ - theme?: string; + extraEditorClassName?: string; /** * Should the editor be read only. * Defaults to false. @@ -3163,7 +3180,7 @@ declare module monaco.editor { } export interface InternalEditorViewOptions { - readonly theme: string; + readonly extraEditorClassName: string; readonly disableMonospaceOptimizations: boolean; readonly experimentalScreenReader: boolean; readonly rulers: number[]; diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index cf310d07ac44822ca35d707b19c5763adde6a931..e22ac2936abd67ca8e0c7ce0a10b4095dfe3146c 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -30,7 +30,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; @@ -53,7 +53,7 @@ export class TextDiffEditor extends BaseTextEditor { @IStorageService storageService: IStorageService, @IConfigurationService configurationService: IConfigurationService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index e485441f65f2bc63fdfc8c00249501f1b09b08c3..d9cb5e09200d66a54f6485d17248756f1a9dd3a6 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -21,7 +21,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Scope } from 'vs/workbench/common/memento'; import { getCodeEditor } from 'vs/editor/common/services/codeEditorService'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -58,7 +58,7 @@ export abstract class BaseTextEditor extends BaseEditor { @IInstantiationService private _instantiationService: IInstantiationService, @IStorageService private storageService: IStorageService, @IConfigurationService private _configurationService: IConfigurationService, - @IWorkbenchThemeService protected themeService: IWorkbenchThemeService, + @IThemeService protected themeService: IThemeService, @IModeService private modeService: IModeService, @ITextFileService private textFileService: ITextFileService, @IEditorGroupService protected editorGroupService: IEditorGroupService @@ -66,7 +66,6 @@ export abstract class BaseTextEditor extends BaseEditor { super(id, telemetryService, themeService); this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.handleConfigurationChangeEvent(e.config))); - this.toUnbind.push(themeService.onDidColorThemeChange(e => this.handleConfigurationChangeEvent())); // TODO@theme this should be done from the editor itself and not from the outside } protected get instantiationService(): IInstantiationService { @@ -125,7 +124,6 @@ export abstract class BaseTextEditor extends BaseEditor { objects.assign(overrides, { overviewRulerLanes: 3, lineNumbersMinChars: 3, - theme: this.themeService.getColorTheme().id, fixedOverflowWidgets: true }); diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index c54d7aef429ab96c7647feefc3d77b2d8cda7035..dda89f7447b1d01e528ba09d59e273a27acf1038 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -19,7 +19,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -38,7 +38,7 @@ export class TextResourceEditor extends BaseTextEditor { @IInstantiationService instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @IConfigurationService configurationService: IConfigurationService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @IThemeService themeService: IThemeService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IModeService modeService: IModeService, diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index f473819c5403e798e670c5c34500dcfbd0c6ea92..b2eafe0152165561b9874ab28c502766c5470288 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -38,11 +38,11 @@ import * as debug from 'vs/workbench/parts/debug/common/debug'; import { ClearReplAction } from 'vs/workbench/parts/debug/browser/debugActions'; import { ReplHistory } from 'vs/workbench/parts/debug/common/replHistory'; import { Panel } from 'vs/workbench/browser/panel'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IListService } from 'vs/platform/list/browser/listService'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; const $ = dom.$; @@ -89,7 +89,7 @@ export class Repl extends Panel implements IPrivateReplService { @IInstantiationService private instantiationService: IInstantiationService, @IStorageService private storageService: IStorageService, @IPanelService private panelService: IPanelService, - @IWorkbenchThemeService protected themeService: IWorkbenchThemeService, + @IThemeService protected themeService: IThemeService, @IModelService private modelService: IModelService, @IContextKeyService private contextKeyService: IContextKeyService, @IListService private listService: IListService @@ -105,7 +105,6 @@ export class Repl extends Panel implements IPrivateReplService { this.toDispose.push(this.debugService.getModel().onDidChangeReplElements(() => { this.refreshReplElements(this.debugService.getModel().getReplElements().length === 0); })); - this.toDispose.push(this.themeService.onDidColorThemeChange(e => this.replInput.updateOptions(this.getReplInputOptions()))); // TODO@theme this should be done from the editor itself and not from the outside this.toDispose.push(this.panelService.onDidPanelOpen(panel => this.refreshReplElements(true))); } @@ -280,7 +279,6 @@ export class Repl extends Panel implements IPrivateReplService { }, lineDecorationsWidth: 0, scrollBeyondLastLine: false, - theme: this.themeService.getColorTheme().id, renderLineHighlight: 'none', fixedOverflowWidgets: true }; diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index 1dc4be93f837927c45ca8ce40d63cb9e5567d4bd..3929604de103b94da65dc295b326e089dc9cd98d 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -28,7 +28,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { CancelAction } from 'vs/platform/message/common/message'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -49,7 +49,7 @@ export class TextFileEditor extends BaseTextEditor { @IHistoryService private historyService: IHistoryService, @IConfigurationService configurationService: IConfigurationService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService, diff --git a/src/vs/workbench/parts/output/browser/outputPanel.ts b/src/vs/workbench/parts/output/browser/outputPanel.ts index da6f5e9ff4ca1303252e445a974b999187d40cd4..217bb1972c6ccbb75c9ded3436e984ceddd6e5b7 100644 --- a/src/vs/workbench/parts/output/browser/outputPanel.ts +++ b/src/vs/workbench/parts/output/browser/outputPanel.ts @@ -21,7 +21,7 @@ import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor'; import { OutputEditors, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } from 'vs/workbench/parts/output/common/output'; import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction } from 'vs/workbench/parts/output/browser/outputActions'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -37,7 +37,7 @@ export class OutputPanel extends TextResourceEditor { @IInstantiationService instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @IConfigurationService configurationService: IConfigurationService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @IThemeService themeService: IThemeService, @IOutputService private outputService: IOutputService, @IUntitledEditorService untitledEditorService: IUntitledEditorService, @IContextKeyService private contextKeyService: IContextKeyService, diff --git a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts index b6491b244848ee157c1571403da0bd927ef325b7..da757c92cf5e515bdd4e7139b4dc414fd0a2a2a6 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts @@ -32,7 +32,7 @@ import { SearchWidget, SettingsTabsWidget } from 'vs/workbench/parts/preferences import { ContextKeyExpr, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { Command } from 'vs/editor/common/editorCommonExtensions'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -114,7 +114,7 @@ export class PreferencesEditor extends BaseEditor { @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IContextKeyService private contextKeyService: IContextKeyService, @IInstantiationService private instantiationService: IInstantiationService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService + @IThemeService themeService: IThemeService ) { super(PreferencesEditor.ID, telemetryService, themeService); this.defaultSettingsEditorContextKey = CONTEXT_SETTINGS_EDITOR.bindTo(this.contextKeyService); @@ -473,7 +473,7 @@ export class DefaultPreferencesEditor extends BaseTextEditor { @IInstantiationService instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @IConfigurationService configurationService: IConfigurationService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @IThemeService themeService: IThemeService, @IPreferencesService private preferencesService: IPreferencesService, @IModelService private modelService: IModelService, @IModeService modeService: IModeService, diff --git a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts index ae8cd2085ed1afd0b01c9a2aaa9039e78d3341f6..d0c04742e177ed4b34048343e8e0543440a0989d 100644 --- a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts +++ b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts @@ -17,7 +17,6 @@ import { EditorOptions } from 'vs/workbench/common/editor'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { WalkThroughInput } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughInput'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { marked } from 'vs/base/common/marked/marked'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -38,7 +37,7 @@ import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService' import { Parts, IPartService } from 'vs/workbench/services/part/common/partService'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; -import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; export const WALK_THROUGH_FOCUS = new RawContextKey('interactivePlaygroundFocus', false); @@ -94,7 +93,7 @@ export class WalkThroughPart extends BaseEditor { constructor( @ITelemetryService telemetryService: ITelemetryService, @IInstantiationService private instantiationService: IInstantiationService, - @IWorkbenchThemeService protected themeService: IWorkbenchThemeService, + @IThemeService protected themeService: IThemeService, @IOpenerService private openerService: IOpenerService, @IFileService private fileService: IFileService, @IModelService protected modelService: IModelService, @@ -328,8 +327,8 @@ export class WalkThroughPart extends BaseEditor { innerContent.classList.add('walkThroughContent'); // only for markdown files const markdown = this.expandMacros(content); innerContent.innerHTML = marked(markdown, { renderer }); - this.style(innerContent); - this.contentDisposables.push(this.themeService.onDidColorThemeChange(() => this.style(innerContent))); + this.style(this.themeService.getTheme(), innerContent); + this.contentDisposables.push(this.themeService.onThemeChange(theme => this.style(theme, innerContent))); this.content.appendChild(innerContent); model.snippets.forEach((snippet, i) => { @@ -378,7 +377,6 @@ export class WalkThroughPart extends BaseEditor { } })); - this.contentDisposables.push(this.themeService.onDidColorThemeChange(theme => editor.updateOptions({ theme: theme.id }))); // TODO@theme this should be done from the editor itself and not from the outside this.contentDisposables.push(this.configurationService.onDidUpdateConfiguration(() => editor.updateOptions(this.getEditorOptions(snippet.textEditorModel.getModeId())))); this.contentDisposables.push(once(editor.onMouseDown)(() => { @@ -429,7 +427,6 @@ export class WalkThroughPart extends BaseEditor { overviewRulerLanes: 3, fixedOverflowWidgets: true, lineNumbersMinChars: 1, - theme: this.themeService.getColorTheme().id, minimap: false, }; } @@ -443,7 +440,7 @@ export class WalkThroughPart extends BaseEditor { } } - private style(div: HTMLElement) { + private style(theme: ITheme, div: HTMLElement) { const styleElement = this.partService.getContainer(Parts.EDITOR_PART); // TODO@theme styles should come in via theme registry const { color, backgroundColor, fontFamily, fontWeight, fontSize } = window.getComputedStyle(styleElement); div.style.color = color;