提交 40dac139 编写于 作者: I isidor

zen mode: esc to exit zen mode with lowest weight

上级 4ad6d178
......@@ -13,11 +13,13 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import platform = require('vs/base/common/platform');
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindings } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { CloseEditorAction, ReportIssueAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseFolderAction, CloseWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction } from 'vs/workbench/electron-browser/actions';
import { MessagesVisibleContext, NoEditorsVisibleContext } from 'vs/workbench/electron-browser/workbench';
import { MessagesVisibleContext, NoEditorsVisibleContext, InZenModeContext } from 'vs/workbench/electron-browser/workbench';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
const closeEditorOrWindowKeybindings: IKeybindings = { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } };
......@@ -70,6 +72,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: '_workbench.exitZenMode',
weight: 0,
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InZenModeContext,
primary: KeyCode.Escape
});
// Configuration: Workbench
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
......
......@@ -92,6 +92,7 @@ import { IWindowConfiguration } from 'vs/workbench/electron-browser/common';
export const MessagesVisibleContext = new RawContextKey<boolean>('globalMessageVisible', false);
export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen', false);
export const InZenModeContext = new RawContextKey<boolean>('inZenMode', false);
export const NoEditorsVisibleContext: ContextKeyExpr = EditorsVisibleContext.toNegated();
interface WorkbenchParams {
......@@ -166,6 +167,7 @@ export class Workbench implements IPartService {
private editorBackgroundDelayer: Delayer<void>;
private messagesVisibleContext: IContextKey<boolean>;
private editorsVisibleContext: IContextKey<boolean>;
private inZenMode: IContextKey<boolean>;
private hasFilesToCreateOpenOrDiff: boolean;
private zenMode: {
active: boolean;
......@@ -243,6 +245,7 @@ export class Workbench implements IPartService {
// Contexts
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService);
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
this.inZenMode = InZenModeContext.bindTo(this.contextKeyService);
// Register Listeners
this.registerListeners();
......@@ -842,14 +845,12 @@ export class Workbench implements IPartService {
// Apply as CSS class
const isFullscreen = browser.isFullscreen();
let exitedZenMode = false;
if (isFullscreen) {
this.addClass('fullscreen');
} else {
this.removeClass('fullscreen');
if (this.zenMode.transitionedToFullScreen) {
this.zenMode.active = false;
exitedZenMode = true;
if (this.zenMode.transitionedToFullScreen && this.zenMode.active) {
this.toggleZenMode();
}
}
......@@ -857,8 +858,6 @@ export class Workbench implements IPartService {
const hasCustomTitle = this.getCustomTitleBarStyle() === 'custom';
if (hasCustomTitle) {
this._onTitleBarVisibilityChange.fire();
}
if (hasCustomTitle || exitedZenMode) {
this.layout(); // handle title bar when fullscreen changes
}
}
......@@ -1070,6 +1069,7 @@ export class Workbench implements IPartService {
public toggleZenMode(): void {
this.zenMode.active = !this.zenMode.active;
this.inZenMode.set(this.zenMode.active);
Object.keys(this.zenMode.isPartVisible).forEach(key => this.zenMode.isPartVisible[key] = false);
if (!this.zenMode.active && this.zenMode.transitionedToFullScreen && browser.isFullscreen()) {
// Zen mode transitioned to full screen, now that we are out of zen mode we need to go out of full screen
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册