Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected static updateBodyUiTheme(): void {
this.toUpdateUiTheme.dispose();
const type = ThemeService.get().getCurrentTheme().type;
const uiTheme: monaco.editor.BuiltinTheme = type === 'hc' ? 'hc-black' : type === 'light' ? 'vs' : 'vs-dark';
document.body.classList.add(uiTheme);
this.toUpdateUiTheme.push(Disposable.create(() => document.body.classList.remove(uiTheme)));
}
initialize() {
const themeService = ThemeService.get()
this.switchTheme(undefined, themeService.getCurrentTheme())
this.disposable = themeService.onThemeChange(event => this.switchTheme(event.oldTheme, event.newTheme))
}
protected updateTheme(): void {
const theme = ThemeService.get().getCurrentTheme().id;
if (theme === 'dark') {
this.class = 'quick-open-task-configure-dark';
} else if (theme === 'light') {
this.class = 'quick-open-task-configure-bright';
}
}
}
const darkCss = require('../../src/browser/style/debug-dark.useable.css');
const lightCss = require('../../src/browser/style/debug-bright.useable.css');
function updateTheme(): void {
const themeType = ThemeService.get().getCurrentTheme().type;
if (themeType === 'dark' || themeType === 'hc') {
lightCss.unuse();
darkCss.use();
} else if (themeType === 'light') {
darkCss.unuse();
lightCss.use();
}
}
updateTheme();
ThemeService.get().onThemeChange(() => updateTheme());
@injectable()
export class DebugFrontendApplicationContribution extends AbstractViewContribution implements TabBarToolbarContribution, ColorContribution {
@inject(DebugService)
protected readonly debug: DebugService;
@inject(DebugSessionManager)
protected readonly manager: DebugSessionManager;
@inject(DebugConfigurationManager)
protected readonly configurations: DebugConfigurationManager;
@inject(BreakpointManager)
protected readonly breakpointManager: BreakpointManager;
export default new ContainerModule(bind => {
ThemeService.get().setCurrentTheme(LIGHT_THEME_ID);
bind(WorkflowClientContribution).toSelf().inSingletonScope();
bind(LanguageClientContribution).toDynamicValue(ctx => ctx.container.get(WorkflowClientContribution));
});
protected static doRegister(state: MonacoThemingService.MonacoThemeState): Disposable {
const { id, label, description, uiTheme, data } = state;
const type = uiTheme === 'vs' ? 'light' : uiTheme === 'vs-dark' ? 'dark' : 'hc';
const builtInTheme = uiTheme === 'vs' ? BuiltinThemeProvider.lightCss : BuiltinThemeProvider.darkCss;
const toDispose = new DisposableCollection(ThemeService.get().register({
type,
id,
label,
description: description,
editorTheme: data.name!,
activate(): void {
builtInTheme.use();
},
deactivate(): void {
builtInTheme.unuse();
}
}));
this.storeTheme(state, toDispose);
return toDispose;
}
protected getActiveTheme(): WebviewThemeType {
const theme = ThemeService.get().getCurrentTheme();
switch (theme.type) {
case 'light': return 'vscode-light';
case 'dark': return 'vscode-dark';
default: return 'vscode-high-contrast';
}
}
function start() {
const themeService = ThemeService.get()
themeService.loadUserTheme();
const application = container.get(FrontendApplication);
application.start();
}
initialize() {
const themeService = ThemeService.get()
this.switchTheme(undefined, themeService.getCurrentTheme())
this.disposable = themeService.onThemeChange(event => this.switchTheme(event.oldTheme, event.newTheme))
}
import { MonacoEditorModel } from './monaco-editor-model';
import { MonacoEditorService } from './monaco-editor-service';
import { MonacoQuickOpenService } from './monaco-quick-open-service';
import { MonacoTextModelService } from './monaco-text-model-service';
import { MonacoWorkspace } from './monaco-workspace';
import { ThemeService } from '@theia/core/lib/browser/theming';
import IEditorOverrideServices = monaco.editor.IEditorOverrideServices;
function changeTheme(editorTheme: string | undefined) {
const monacoTheme = editorTheme || 'vs-dark';
monaco.editor.setTheme(monacoTheme);
document.body.classList.add(monacoTheme);
}
changeTheme(ThemeService.get().getCurrentTheme().editorTheme);
ThemeService.get().onThemeChange(event => changeTheme(event.newTheme.editorTheme));
@injectable()
export class MonacoEditorProvider {
constructor(
@inject(MonacoEditorService) protected readonly editorService: MonacoEditorService,
@inject(MonacoTextModelService) protected readonly textModelService: MonacoTextModelService,
@inject(MonacoContextMenuService) protected readonly contextMenuService: MonacoContextMenuService,
@inject(MonacoToProtocolConverter) protected readonly m2p: MonacoToProtocolConverter,
@inject(ProtocolToMonacoConverter) protected readonly p2m: ProtocolToMonacoConverter,
@inject(MonacoWorkspace) protected readonly workspace: MonacoWorkspace,
@inject(MonacoCommandServiceFactory) protected readonly commandServiceFactory: MonacoCommandServiceFactory,
@inject(EditorPreferences) protected readonly editorPreferences: EditorPreferences,
@inject(MonacoQuickOpenService) protected readonly quickOpenService: MonacoQuickOpenService
) { }