mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 18:48:00 +00:00
Split IKeybindingService to different files
This commit is contained in:
parent
7f7d0b9f17
commit
a3ee47a555
|
@ -57,7 +57,7 @@ declare module monaco.editor {
|
|||
export interface ICommandHandler {
|
||||
(...args:any[]): void;
|
||||
}
|
||||
#include(vs/platform/keybinding/common/keybinding): IKeybindingContextKey
|
||||
#include(vs/platform/contextkey/common/contextkey): IKeybindingContextKey
|
||||
#include(vs/editor/browser/standalone/standaloneServices): IEditorOverrideServices
|
||||
#include(vs/platform/markers/common/markers): IMarkerData
|
||||
#include(vs/editor/browser/standalone/colorizer): IColorizerOptions, IColorizerElementOptions
|
||||
|
|
|
@ -16,9 +16,11 @@ import {IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, I
|
|||
import {AbstractExtensionService, ActivatedExtension} from 'vs/platform/extensions/common/abstractExtensionService';
|
||||
import {IExtensionDescription} from 'vs/platform/extensions/common/extensions';
|
||||
import {ICommandService, ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {KeybindingService, KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
|
||||
import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
|
||||
import {KeybindingService} from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IKeybindingService, IKeybindingItem} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IConfirmation, IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
|
|
|
@ -9,7 +9,8 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
|||
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingContextKey, IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel, IModelChangedEvent, EventType} from 'vs/editor/common/editorCommon';
|
||||
|
|
|
@ -20,7 +20,8 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect
|
|||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {CommandService} from 'vs/platform/commands/common/commandService';
|
||||
import {IOpenerService} from 'vs/platform/opener/common/opener';
|
||||
import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {MarkerService} from 'vs/platform/markers/common/markerService';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as timer from 'vs/base/common/timer';
|
|||
import * as browser from 'vs/base/browser/browser';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import {StyleMutator} from 'vs/base/browser/styleMutator';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
|
|
|
@ -12,7 +12,7 @@ import * as browser from 'vs/base/browser/browser';
|
|||
import * as dom from 'vs/base/browser/dom';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor';
|
||||
import {CommonEditorConfiguration} from 'vs/editor/common/config/commonEditorConfig';
|
||||
|
|
|
@ -14,7 +14,7 @@ import * as dom from 'vs/base/browser/dom';
|
|||
import {StyleMutator} from 'vs/base/browser/styleMutator';
|
||||
import {ISashEvent, IVerticalSashLayoutProvider, Sash} from 'vs/base/browser/ui/sash/sash';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import {DefaultConfig} from 'vs/editor/common/config/defaultConfig';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import * as objects from 'vs/base/common/objects';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {ICodeEditorWidgetCreationOptions, IConfigurationChangedEvent, IEditorOptions} from 'vs/editor/common/editorCommon';
|
||||
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
||||
|
|
|
@ -12,7 +12,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import {ServicesAccessor, IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingContextKey, IKeybindingScopeLocation, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingScopeLocation, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {CommonEditorConfiguration} from 'vs/editor/common/config/commonEditorConfig';
|
||||
import {DefaultConfig} from 'vs/editor/common/config/defaultConfig';
|
||||
|
|
|
@ -8,7 +8,8 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingService, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindings} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICommandAndKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
||||
|
|
|
@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import {IActionDescriptor, ICommonCodeEditor, IEditorAction} from 'vs/editor/common/editorCommon';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {EditorAction} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export abstract class AbstractInternalEditorAction {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import {Selection} from 'vs/editor/common/core/selection';
|
|||
import {ModeTransition} from 'vs/editor/common/core/modeTransition';
|
||||
import {IndentRange} from 'vs/editor/common/model/indentRanges';
|
||||
import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
import {KbExpr, KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import {ICommonCodeEditor, ModeContextKeys} from 'vs/editor/common/editorCommon';
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
|
|||
import {StyleMutator} from 'vs/base/browser/styleMutator';
|
||||
import {Widget} from 'vs/base/browser/ui/widget';
|
||||
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {GlobalScreenReaderNVDA} from 'vs/editor/common/config/commonEditorConfig';
|
||||
import {ICommonCodeEditor, IEditorContribution, EditorContextKeys} from 'vs/editor/common/editorCommon';
|
||||
|
|
|
@ -13,7 +13,8 @@ import * as dom from 'vs/base/browser/dom';
|
|||
import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
import {ActionItem, Separator} from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import {IContextMenuService, IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMenuService, IMenu, MenuId} from 'vs/platform/actions/common/actions';
|
||||
import {ICommonCodeEditor, IEditorContribution, MouseTargetType, EditorContextKeys} from 'vs/editor/common/editorCommon';
|
||||
import {editorAction, ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions';
|
||||
|
|
|
@ -16,7 +16,8 @@ import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
|
|||
import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
import {StyleMutator} from 'vs/base/browser/styleMutator';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {KbExpr, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {editorAction, ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions';
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
'use strict';
|
||||
|
||||
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
|
||||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import {FindWidget, IFindController} from 'vs/editor/contrib/find/browser/findWidget';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import * as nls from 'vs/nls';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {Disposable} from 'vs/base/common/lifecycle';
|
||||
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
|
|
|
@ -10,7 +10,7 @@ import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
|||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {editorAction, ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {OnTypeFormattingEditProviderRegistry} from 'vs/editor/common/modes';
|
||||
import {getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits} from '../common/format';
|
||||
|
|
|
@ -30,7 +30,7 @@ import {ReferencesController} from 'vs/editor/contrib/referenceSearch/browser/re
|
|||
import {ReferencesModel} from 'vs/editor/contrib/referenceSearch/browser/referencesModel';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {PeekContext} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
import ModeContextKeys = editorCommon.ModeContextKeys;
|
||||
import EditorContextKeys = editorCommon.EditorContextKeys;
|
||||
|
|
|
@ -17,7 +17,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import * as dom from 'vs/base/browser/dom';
|
||||
import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMarker, IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
|
|
|
@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
|||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KbExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
|
||||
|
|
|
@ -17,7 +17,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
|
|||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import { ICommonCodeEditor, ICursorSelectionChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Context, provideSignatureHelp } from '../common/parameterHints';
|
||||
|
||||
const $ = dom.emmet;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
|||
import { SignatureHelp, SignatureHelpProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { KbCtxKey } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KbCtxKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const Context = {
|
||||
Visible: new KbCtxKey<boolean>('parameterHintsVisible', false),
|
||||
|
|
|
@ -9,7 +9,7 @@ import {onUnexpectedError} from 'vs/base/common/errors';
|
|||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {optional} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {CommandsRegistry, ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
|
|
@ -11,7 +11,7 @@ import Severity from 'vs/base/common/severity';
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {IInstantiationService, optional} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingContextKey, IKeybindingService, KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService, KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IConfigurationService, getConfigurationValue} from 'vs/platform/configuration/common/configuration';
|
||||
|
|
|
@ -12,7 +12,7 @@ import Severity from 'vs/base/common/severity';
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IProgressService} from 'vs/platform/progress/common/progress';
|
||||
import {editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {ICodeEditor, IEditorMouseEvent} from 'vs/editor/browser/editorBrowser';
|
|||
import {Disposable} from 'vs/base/common/lifecycle';
|
||||
import {EndOfLinePreference, IEditorContribution, ICursorSelectionChangedEvent, IConfigurationChangedEvent} from 'vs/editor/common/editorCommon';
|
||||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {RunOnceScheduler} from 'vs/base/common/async';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import * as collections from 'vs/base/common/collections';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
|
|||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KbExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ISuggestSupport, SuggestRegistry } from 'vs/editor/common/modes';
|
||||
|
|
|
@ -17,7 +17,8 @@ import { IDelegate, IFocusChangeEvent, IRenderer, ISelectionChangeEvent } from '
|
|||
import { List } from 'vs/base/browser/ui/list/listWidget';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingContextKey, IKeybindingService, IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { Context as SuggestContext } from '../common/suggest';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
import {KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {KbCtxKey, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingService, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {ISnippetsRegistry, Extensions, getNonWhitespacePrefix, ISnippet} from 'vs/editor/common/modes/snippetsRegistry';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {ISuggestResult, ISuggestSupport, ISuggestion, SuggestRegistry} from 'vs/
|
|||
import {ISnippetsRegistry, Extensions} from 'vs/editor/common/modes/snippetsRegistry';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const Context = {
|
||||
Visible: new KbCtxKey<boolean>('suggestWidgetVisible', false),
|
||||
|
|
|
@ -19,7 +19,7 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
|||
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
|
||||
import {IOptions, ZoneWidget} from './zoneWidget';
|
||||
import {EmbeddedCodeEditorWidget} from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
||||
import {KbExpr, KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export var IPeekViewService = createDecorator<IPeekViewService>('peekViewService');
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
|||
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService';
|
||||
import {ICommandService, NullCommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService, IKeybindingScopeLocation} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, IKeybindingScopeLocation} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {MockKeybindingService} from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {IdGenerator} from 'vs/base/common/idGenerator';
|
|||
import {IJSONSchema} from 'vs/base/common/jsonSchema';
|
||||
import {forEach} from 'vs/base/common/collections';
|
||||
import {IExtensionPointUser, IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {MenuId, MenuRegistry} from 'vs/platform/actions/common/actions';
|
||||
|
||||
namespace schema {
|
||||
|
|
|
@ -9,7 +9,8 @@ import Actions = require('vs/base/common/actions');
|
|||
import WinJS = require('vs/base/common/winjs.base');
|
||||
import Descriptors = require('vs/platform/instantiation/common/descriptors');
|
||||
import Instantiation = require('vs/platform/instantiation/common/instantiation');
|
||||
import {KbExpr, IKeybindings, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindings} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
|
|
|
@ -9,7 +9,7 @@ import Event, {Emitter} from 'vs/base/common/event';
|
|||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IAction} from 'vs/base/common/actions';
|
||||
import {values} from 'vs/base/common/collections';
|
||||
import {KbExpr, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {MenuId, MenuRegistry, ICommandAction, MenuItemAction, IMenu, IMenuItem, IMenuService} from 'vs/platform/actions/common/actions';
|
||||
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
|
||||
export class ResourceContextKey implements IKeybindingContextKey<URI> {
|
||||
|
|
288
src/vs/platform/contextkey/browser/contextKeyService.ts
Normal file
288
src/vs/platform/contextkey/browser/contextKeyService.ts
Normal file
|
@ -0,0 +1,288 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./keybindings';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {CommandsRegistry} from 'vs/platform/commands/common/commands';
|
||||
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IKeybindingContextKey, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID, KEYBINDING_CONTEXT_ATTR, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import Event, {Emitter, debounceEvent} from 'vs/base/common/event';
|
||||
|
||||
export class KeybindingContext {
|
||||
protected _parent: KeybindingContext;
|
||||
protected _value: any;
|
||||
protected _id: number;
|
||||
|
||||
constructor(id: number, parent: KeybindingContext) {
|
||||
this._id = id;
|
||||
this._parent = parent;
|
||||
this._value = Object.create(null);
|
||||
this._value['_contextId'] = id;
|
||||
}
|
||||
|
||||
public setValue(key: string, value: any): boolean {
|
||||
// console.log('SET ' + key + ' = ' + value + ' ON ' + this._id);
|
||||
if (this._value[key] !== value) {
|
||||
this._value[key] = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public removeValue(key: string): boolean {
|
||||
// console.log('REMOVE ' + key + ' FROM ' + this._id);
|
||||
return delete this._value[key];
|
||||
}
|
||||
|
||||
public getValue<T>(key: string): T {
|
||||
const ret = this._value[key];
|
||||
if (typeof ret === 'undefined' && this._parent) {
|
||||
return this._parent.getValue<T>(key);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public fillInContext(bucket: any): void {
|
||||
if (this._parent) {
|
||||
this._parent.fillInContext(bucket);
|
||||
}
|
||||
for (let key in this._value) {
|
||||
bucket[key] = this._value[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigAwareKeybindingContext extends KeybindingContext {
|
||||
|
||||
private _emitter: Emitter<string>;
|
||||
private _subscription: IDisposable;
|
||||
|
||||
constructor(id: number, configurationService: IConfigurationService, emitter:Emitter<string>) {
|
||||
super(id, null);
|
||||
|
||||
this._emitter = emitter;
|
||||
this._subscription = configurationService.onDidUpdateConfiguration(e => this._updateConfigurationContext(e.config));
|
||||
this._updateConfigurationContext(configurationService.getConfiguration());
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this._subscription.dispose();
|
||||
}
|
||||
|
||||
private _updateConfigurationContext(config: any) {
|
||||
|
||||
// remove old config.xyz values
|
||||
for (let key in this._value) {
|
||||
if (key.indexOf('config.') === 0) {
|
||||
delete this._value[key];
|
||||
}
|
||||
}
|
||||
|
||||
// add new value from config
|
||||
const walk = (obj: any, keys: string[]) => {
|
||||
for (let key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
keys.push(key);
|
||||
let value = obj[key];
|
||||
if (typeof value === 'boolean') {
|
||||
const configKey = keys.join('.');
|
||||
this._value[configKey] = value;
|
||||
this._emitter.fire(configKey);
|
||||
} else if (typeof value === 'object') {
|
||||
walk(value, keys);
|
||||
}
|
||||
keys.pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(config, ['config']);
|
||||
}
|
||||
}
|
||||
|
||||
class KeybindingContextKey<T> implements IKeybindingContextKey<T> {
|
||||
|
||||
private _parent: AbstractKeybindingService;
|
||||
private _key: string;
|
||||
private _defaultValue: T;
|
||||
|
||||
constructor(parent: AbstractKeybindingService, key: string, defaultValue: T) {
|
||||
this._parent = parent;
|
||||
this._key = key;
|
||||
this._defaultValue = defaultValue;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
public set(value: T): void {
|
||||
this._parent.setContext(this._key, value);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
if (typeof this._defaultValue === 'undefined') {
|
||||
this._parent.removeContext(this._key);
|
||||
} else {
|
||||
this._parent.setContext(this._key, this._defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public get(): T {
|
||||
return this._parent.getContextValue<T>(this._key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export abstract class AbstractKeybindingService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
protected _onDidChangeContext: Event<string[]>;
|
||||
protected _onDidChangeContextKey: Emitter<string>;
|
||||
protected _myContextId: number;
|
||||
|
||||
constructor(myContextId: number) {
|
||||
this._myContextId = myContextId;
|
||||
this._onDidChangeContextKey = new Emitter<string>();
|
||||
}
|
||||
|
||||
public createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T> {
|
||||
return new KeybindingContextKey(this, key, defaultValue);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
if (!this._onDidChangeContext) {
|
||||
this._onDidChangeContext = debounceEvent(this._onDidChangeContextKey.event, (prev: string[], cur) => {
|
||||
if (!prev) {
|
||||
prev = [cur];
|
||||
} else if (prev.indexOf(cur) < 0) {
|
||||
prev.push(cur);
|
||||
}
|
||||
return prev;
|
||||
}, 25);
|
||||
}
|
||||
return this._onDidChangeContext;
|
||||
}
|
||||
|
||||
public createScoped(domNode: IKeybindingScopeLocation): IKeybindingService {
|
||||
return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode);
|
||||
}
|
||||
|
||||
public contextMatchesRules(rules: KbExpr): boolean {
|
||||
const ctx = Object.create(null);
|
||||
this.getContext(this._myContextId).fillInContext(ctx);
|
||||
const result = KeybindingResolver.contextMatchesRules(ctx, rules);
|
||||
// console.group(rules.serialize() + ' -> ' + result);
|
||||
// rules.keys().forEach(key => { console.log(key, ctx[key]); });
|
||||
// console.groupEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
public getContextValue<T>(key: string): T {
|
||||
return this.getContext(this._myContextId).getValue<T>(key);
|
||||
}
|
||||
|
||||
public setContext(key: string, value: any): void {
|
||||
if(this.getContext(this._myContextId).setValue(key, value)) {
|
||||
this._onDidChangeContextKey.fire(key);
|
||||
}
|
||||
}
|
||||
|
||||
public removeContext(key: string): void {
|
||||
if(this.getContext(this._myContextId).removeValue(key)) {
|
||||
this._onDidChangeContextKey.fire(key);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract getContext(contextId: number): KeybindingContext;
|
||||
public abstract createChildContext(parentContextId?: number): number;
|
||||
public abstract disposeContext(contextId: number): void;
|
||||
|
||||
}
|
||||
|
||||
export abstract class KeybindingService extends AbstractKeybindingService implements IKeybindingService {
|
||||
|
||||
private _lastContextId: number;
|
||||
private _contexts: {
|
||||
[contextId: string]: KeybindingContext;
|
||||
};
|
||||
|
||||
private _toDispose: IDisposable[] = [];
|
||||
|
||||
constructor(configurationService: IConfigurationService) {
|
||||
super(0);
|
||||
this._lastContextId = 0;
|
||||
this._contexts = Object.create(null);
|
||||
|
||||
const myContext = new ConfigAwareKeybindingContext(this._myContextId, configurationService, this._onDidChangeContextKey);
|
||||
this._contexts[String(this._myContextId)] = myContext;
|
||||
this._toDispose.push(myContext);
|
||||
|
||||
// Uncomment this to see the contexts continuously logged
|
||||
// let lastLoggedValue: string = null;
|
||||
// setInterval(() => {
|
||||
// let values = Object.keys(this._contexts).map((key) => this._contexts[key]);
|
||||
// let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n');
|
||||
// if (lastLoggedValue !== logValue) {
|
||||
// lastLoggedValue = logValue;
|
||||
// console.log(lastLoggedValue);
|
||||
// }
|
||||
// }, 2000);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public getContext(contextId: number): KeybindingContext {
|
||||
return this._contexts[String(contextId)];
|
||||
}
|
||||
|
||||
public createChildContext(parentContextId: number = this._myContextId): number {
|
||||
let id = (++this._lastContextId);
|
||||
this._contexts[String(id)] = new KeybindingContext(id, this.getContext(parentContextId));
|
||||
return id;
|
||||
}
|
||||
|
||||
public disposeContext(contextId: number): void {
|
||||
delete this._contexts[String(contextId)];
|
||||
}
|
||||
}
|
||||
|
||||
CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) {
|
||||
accessor.get(IKeybindingService).createKey(String(contextKey), contextValue);
|
||||
});
|
||||
|
||||
class ScopedKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
private _parent: AbstractKeybindingService;
|
||||
private _domNode: IKeybindingScopeLocation;
|
||||
|
||||
constructor(parent: AbstractKeybindingService, emitter: Emitter<string>, domNode: IKeybindingScopeLocation) {
|
||||
super(parent.createChildContext());
|
||||
this._parent = parent;
|
||||
this._onDidChangeContextKey = emitter;
|
||||
this._domNode = domNode;
|
||||
this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(this._myContextId));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._parent.disposeContext(this._myContextId);
|
||||
this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
return this._parent.onDidChangeContext;
|
||||
}
|
||||
|
||||
public getContext(contextId: number): KeybindingContext {
|
||||
return this._parent.getContext(contextId);
|
||||
}
|
||||
|
||||
public createChildContext(parentContextId: number = this._myContextId): number {
|
||||
return this._parent.createChildContext(parentContextId);
|
||||
}
|
||||
|
||||
public disposeContext(contextId: number): void {
|
||||
this._parent.disposeContext(contextId);
|
||||
}
|
||||
}
|
462
src/vs/platform/contextkey/common/contextkey.ts
Normal file
462
src/vs/platform/contextkey/common/contextkey.ts
Normal file
|
@ -0,0 +1,462 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event from 'vs/base/common/event';
|
||||
|
||||
export const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
|
||||
export enum KbExprType {
|
||||
KbDefinedExpression = 1,
|
||||
KbNotExpression = 2,
|
||||
KbEqualsExpression = 3,
|
||||
KbNotEqualsExpression = 4,
|
||||
KbAndExpression = 5
|
||||
}
|
||||
|
||||
export interface KbExpr {
|
||||
getType(): KbExprType;
|
||||
equals(other: KbExpr): boolean;
|
||||
evaluate(context: any): boolean;
|
||||
normalize(): KbExpr;
|
||||
serialize(): string;
|
||||
keys(): string[];
|
||||
}
|
||||
|
||||
function cmp(a:KbExpr, b:KbExpr): number {
|
||||
let aType = a.getType();
|
||||
let bType = b.getType();
|
||||
if (aType !== bType) {
|
||||
return aType - bType;
|
||||
}
|
||||
switch(aType) {
|
||||
case KbExprType.KbDefinedExpression:
|
||||
return (<KbDefinedExpression>a).cmp(<KbDefinedExpression>b);
|
||||
case KbExprType.KbNotExpression:
|
||||
return (<KbNotExpression>a).cmp(<KbNotExpression>b);
|
||||
case KbExprType.KbEqualsExpression:
|
||||
return (<KbEqualsExpression>a).cmp(<KbEqualsExpression>b);
|
||||
case KbExprType.KbNotEqualsExpression:
|
||||
return (<KbNotEqualsExpression>a).cmp(<KbNotEqualsExpression>b);
|
||||
default:
|
||||
throw new Error('Unknown KbExpr!');
|
||||
}
|
||||
}
|
||||
|
||||
export class KbDefinedExpression implements KbExpr {
|
||||
constructor(protected key: string) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbDefinedExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbDefinedExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbDefinedExpression) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
return (!!context[this.key]);
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbEqualsExpression implements KbExpr {
|
||||
constructor(private key: string, private value: any) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbEqualsExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbEqualsExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
if (this.value < other.value) {
|
||||
return -1;
|
||||
}
|
||||
if (this.value > other.value) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbEqualsExpression) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
/* tslint:disable:triple-equals */
|
||||
// Intentional ==
|
||||
return (context[this.key] == this.value);
|
||||
/* tslint:enable:triple-equals */
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (typeof this.value === 'boolean') {
|
||||
if (this.value) {
|
||||
return new KbDefinedExpression(this.key);
|
||||
}
|
||||
return new KbNotExpression(this.key);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (typeof this.value === 'boolean') {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
|
||||
return this.key + ' == \'' + this.value + '\'';
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbNotEqualsExpression implements KbExpr {
|
||||
constructor(private key: string, private value: any) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbNotEqualsExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbNotEqualsExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
if (this.value < other.value) {
|
||||
return -1;
|
||||
}
|
||||
if (this.value > other.value) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbNotEqualsExpression) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
/* tslint:disable:triple-equals */
|
||||
// Intentional !=
|
||||
return (context[this.key] != this.value);
|
||||
/* tslint:enable:triple-equals */
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (typeof this.value === 'boolean') {
|
||||
if (this.value) {
|
||||
return new KbNotExpression(this.key);
|
||||
}
|
||||
return new KbDefinedExpression(this.key);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (typeof this.value === 'boolean') {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
|
||||
return this.key + ' != \'' + this.value + '\'';
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbNotExpression implements KbExpr {
|
||||
constructor(private key: string) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbNotExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbNotExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbNotExpression) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
return (!context[this.key]);
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return '!' + this.key;
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbAndExpression implements KbExpr {
|
||||
private expr: KbExpr[];
|
||||
|
||||
constructor(expr: KbExpr[]) {
|
||||
this.expr = KbAndExpression._normalizeArr(expr);
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbAndExpression;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbAndExpression) {
|
||||
if (this.expr.length !== other.expr.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
if (!this.expr[i].equals(other.expr[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
if (!this.expr[i].evaluate(context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static _normalizeArr(arr:KbExpr[]): KbExpr[] {
|
||||
let expr: KbExpr[] = [];
|
||||
|
||||
if (arr) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
let e = arr[i];
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
e = e.normalize();
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof KbAndExpression) {
|
||||
expr = expr.concat(e.expr);
|
||||
continue;
|
||||
}
|
||||
|
||||
expr.push(e);
|
||||
}
|
||||
|
||||
expr.sort(cmp);
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (this.expr.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.expr.length === 1) {
|
||||
return this.expr[0];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (this.expr.length === 0) {
|
||||
return '';
|
||||
}
|
||||
if (this.expr.length === 1) {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
return this.expr.map(e => e.serialize()).join(' && ');
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
const result: string[] = [];
|
||||
for (let expr of this.expr) {
|
||||
result.push(...expr.keys());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export class KbCtxKey<T> extends KbDefinedExpression {
|
||||
|
||||
private _defaultValue: T;
|
||||
|
||||
constructor(key:string, defaultValue:T) {
|
||||
super(key);
|
||||
this._defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public bindTo(target:IKeybindingService): IKeybindingContextKey<T> {
|
||||
return target.createKey(this.key, this._defaultValue);
|
||||
}
|
||||
|
||||
public getValue(target:IKeybindingService): T {
|
||||
return target.getContextValue<T>(this.key);
|
||||
}
|
||||
|
||||
public toNegated(): KbExpr {
|
||||
return KbExpr.not(this.key);
|
||||
}
|
||||
|
||||
public isEqualTo(value:string): KbExpr {
|
||||
return KbExpr.equals(this.key, value);
|
||||
}
|
||||
}
|
||||
|
||||
export let KbExpr = {
|
||||
has: (key: string) => new KbDefinedExpression(key),
|
||||
equals: (key: string, value: any) => new KbEqualsExpression(key, value),
|
||||
notEquals: (key: string, value: any) => new KbNotEqualsExpression(key, value),
|
||||
not: (key: string) => new KbNotExpression(key),
|
||||
and: (...expr: KbExpr[]) => new KbAndExpression(expr),
|
||||
deserialize: (serialized: string): KbExpr => {
|
||||
if (!serialized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let pieces = serialized.split('&&');
|
||||
let result = new KbAndExpression(pieces.map(p => KbExpr._deserializeOne(p)));
|
||||
return result.normalize();
|
||||
},
|
||||
|
||||
_deserializeOne: (serializedOne: string): KbExpr => {
|
||||
serializedOne = serializedOne.trim();
|
||||
|
||||
if (serializedOne.indexOf('!=') >= 0) {
|
||||
let pieces = serializedOne.split('!=');
|
||||
return new KbNotEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1]));
|
||||
}
|
||||
|
||||
if (serializedOne.indexOf('==') >= 0) {
|
||||
let pieces = serializedOne.split('==');
|
||||
return new KbEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1]));
|
||||
}
|
||||
|
||||
if (/^\!\s*/.test(serializedOne)) {
|
||||
return new KbNotExpression(serializedOne.substr(1).trim());
|
||||
}
|
||||
|
||||
return new KbDefinedExpression(serializedOne);
|
||||
},
|
||||
|
||||
_deserializeValue: (serializedValue: string): any => {
|
||||
serializedValue = serializedValue.trim();
|
||||
|
||||
if (serializedValue === 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (serializedValue === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = /^'([^']*)'$/.exec(serializedValue);
|
||||
if (m) {
|
||||
return m[1].trim();
|
||||
}
|
||||
|
||||
return serializedValue;
|
||||
}
|
||||
};
|
||||
|
||||
export interface IKeybindingContextKey<T> {
|
||||
set(value: T): void;
|
||||
reset(): void;
|
||||
get(): T;
|
||||
}
|
||||
|
||||
export interface IKeybindingScopeLocation {
|
||||
setAttribute(attr: string, value: string): void;
|
||||
removeAttribute(attr: string): void;
|
||||
}
|
||||
|
||||
export interface IKeybindingContext {
|
||||
fillInContext(bucket: any): void;
|
||||
}
|
||||
|
||||
export let IKeybindingService = createDecorator<IKeybindingService>('keybindingService');
|
||||
|
||||
export interface IKeybindingService {
|
||||
_serviceBrand: any;
|
||||
dispose(): void;
|
||||
|
||||
onDidChangeContext: Event<string[]>;
|
||||
createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T>;
|
||||
contextMatchesRules(rules: KbExpr): boolean;
|
||||
getContextValue<T>(key: string): T;
|
||||
|
||||
createScoped(domNode: IKeybindingScopeLocation): IKeybindingService;
|
||||
|
||||
getContext(contextId: number): IKeybindingContext;
|
||||
}
|
||||
|
||||
export const SET_CONTEXT_COMMAND_ID = 'setContext';
|
|
@ -15,137 +15,13 @@ import * as dom from 'vs/base/browser/dom';
|
|||
import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
import {ICommandService, CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, IKeybindingService2, SET_CONTEXT_COMMAND_ID, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, KEYBINDING_CONTEXT_ATTR} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import Event, {Emitter, debounceEvent} from 'vs/base/common/event';
|
||||
|
||||
let KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
|
||||
export class KeybindingContext {
|
||||
protected _parent: KeybindingContext;
|
||||
protected _value: any;
|
||||
protected _id: number;
|
||||
|
||||
constructor(id: number, parent: KeybindingContext) {
|
||||
this._id = id;
|
||||
this._parent = parent;
|
||||
this._value = Object.create(null);
|
||||
this._value['_contextId'] = id;
|
||||
}
|
||||
|
||||
public setValue(key: string, value: any): boolean {
|
||||
// console.log('SET ' + key + ' = ' + value + ' ON ' + this._id);
|
||||
if (this._value[key] !== value) {
|
||||
this._value[key] = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public removeValue(key: string): boolean {
|
||||
// console.log('REMOVE ' + key + ' FROM ' + this._id);
|
||||
return delete this._value[key];
|
||||
}
|
||||
|
||||
public getValue<T>(key: string): T {
|
||||
const ret = this._value[key];
|
||||
if (typeof ret === 'undefined' && this._parent) {
|
||||
return this._parent.getValue<T>(key);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public fillInContext(bucket: any): void {
|
||||
if (this._parent) {
|
||||
this._parent.fillInContext(bucket);
|
||||
}
|
||||
for (let key in this._value) {
|
||||
bucket[key] = this._value[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigAwareKeybindingContext extends KeybindingContext {
|
||||
|
||||
private _emitter: Emitter<string>;
|
||||
private _subscription: IDisposable;
|
||||
|
||||
constructor(id: number, configurationService: IConfigurationService, emitter:Emitter<string>) {
|
||||
super(id, null);
|
||||
|
||||
this._emitter = emitter;
|
||||
this._subscription = configurationService.onDidUpdateConfiguration(e => this._updateConfigurationContext(e.config));
|
||||
this._updateConfigurationContext(configurationService.getConfiguration());
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this._subscription.dispose();
|
||||
}
|
||||
|
||||
private _updateConfigurationContext(config: any) {
|
||||
|
||||
// remove old config.xyz values
|
||||
for (let key in this._value) {
|
||||
if (key.indexOf('config.') === 0) {
|
||||
delete this._value[key];
|
||||
}
|
||||
}
|
||||
|
||||
// add new value from config
|
||||
const walk = (obj: any, keys: string[]) => {
|
||||
for (let key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
keys.push(key);
|
||||
let value = obj[key];
|
||||
if (typeof value === 'boolean') {
|
||||
const configKey = keys.join('.');
|
||||
this._value[configKey] = value;
|
||||
this._emitter.fire(configKey);
|
||||
} else if (typeof value === 'object') {
|
||||
walk(value, keys);
|
||||
}
|
||||
keys.pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(config, ['config']);
|
||||
}
|
||||
}
|
||||
|
||||
class KeybindingContextKey<T> implements IKeybindingContextKey<T> {
|
||||
|
||||
private _parent: AbstractKeybindingService;
|
||||
private _key: string;
|
||||
private _defaultValue: T;
|
||||
|
||||
constructor(parent: AbstractKeybindingService, key: string, defaultValue: T) {
|
||||
this._parent = parent;
|
||||
this._key = key;
|
||||
this._defaultValue = defaultValue;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
public set(value: T): void {
|
||||
this._parent.setContext(this._key, value);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
if (typeof this._defaultValue === 'undefined') {
|
||||
this._parent.removeContext(this._key);
|
||||
} else {
|
||||
this._parent.setContext(this._key, this._defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public get(): T {
|
||||
return this._parent.getContextValue<T>(this._key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class KeybindingService2 implements IKeybindingService2 {
|
||||
export abstract class KeybindingService2 implements IKeybindingService2 {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _toDispose: IDisposable[] = [];
|
||||
|
@ -316,157 +192,3 @@ export class KeybindingService2 implements IKeybindingService2 {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class AbstractKeybindingService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
protected _onDidChangeContext: Event<string[]>;
|
||||
protected _onDidChangeContextKey: Emitter<string>;
|
||||
protected _myContextId: number;
|
||||
|
||||
constructor(myContextId: number) {
|
||||
this._myContextId = myContextId;
|
||||
this._onDidChangeContextKey = new Emitter<string>();
|
||||
}
|
||||
|
||||
public createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T> {
|
||||
return new KeybindingContextKey(this, key, defaultValue);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
if (!this._onDidChangeContext) {
|
||||
this._onDidChangeContext = debounceEvent(this._onDidChangeContextKey.event, (prev: string[], cur) => {
|
||||
if (!prev) {
|
||||
prev = [cur];
|
||||
} else if (prev.indexOf(cur) < 0) {
|
||||
prev.push(cur);
|
||||
}
|
||||
return prev;
|
||||
}, 25);
|
||||
}
|
||||
return this._onDidChangeContext;
|
||||
}
|
||||
|
||||
public createScoped(domNode: IKeybindingScopeLocation): IKeybindingService {
|
||||
return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode);
|
||||
}
|
||||
|
||||
public contextMatchesRules(rules: KbExpr): boolean {
|
||||
const ctx = Object.create(null);
|
||||
this.getContext(this._myContextId).fillInContext(ctx);
|
||||
const result = KeybindingResolver.contextMatchesRules(ctx, rules);
|
||||
// console.group(rules.serialize() + ' -> ' + result);
|
||||
// rules.keys().forEach(key => { console.log(key, ctx[key]); });
|
||||
// console.groupEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
public getContextValue<T>(key: string): T {
|
||||
return this.getContext(this._myContextId).getValue<T>(key);
|
||||
}
|
||||
|
||||
public setContext(key: string, value: any): void {
|
||||
if(this.getContext(this._myContextId).setValue(key, value)) {
|
||||
this._onDidChangeContextKey.fire(key);
|
||||
}
|
||||
}
|
||||
|
||||
public removeContext(key: string): void {
|
||||
if(this.getContext(this._myContextId).removeValue(key)) {
|
||||
this._onDidChangeContextKey.fire(key);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract getContext(contextId: number): KeybindingContext;
|
||||
public abstract createChildContext(parentContextId?: number): number;
|
||||
public abstract disposeContext(contextId: number): void;
|
||||
|
||||
}
|
||||
|
||||
export abstract class KeybindingService extends AbstractKeybindingService implements IKeybindingService {
|
||||
|
||||
private _lastContextId: number;
|
||||
private _contexts: {
|
||||
[contextId: string]: KeybindingContext;
|
||||
};
|
||||
|
||||
private _toDispose: IDisposable[] = [];
|
||||
|
||||
constructor(configurationService: IConfigurationService) {
|
||||
super(0);
|
||||
this._lastContextId = 0;
|
||||
this._contexts = Object.create(null);
|
||||
|
||||
const myContext = new ConfigAwareKeybindingContext(this._myContextId, configurationService, this._onDidChangeContextKey);
|
||||
this._contexts[String(this._myContextId)] = myContext;
|
||||
this._toDispose.push(myContext);
|
||||
|
||||
// Uncomment this to see the contexts continuously logged
|
||||
// let lastLoggedValue: string = null;
|
||||
// setInterval(() => {
|
||||
// let values = Object.keys(this._contexts).map((key) => this._contexts[key]);
|
||||
// let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n');
|
||||
// if (lastLoggedValue !== logValue) {
|
||||
// lastLoggedValue = logValue;
|
||||
// console.log(lastLoggedValue);
|
||||
// }
|
||||
// }, 2000);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public getContext(contextId: number): KeybindingContext {
|
||||
return this._contexts[String(contextId)];
|
||||
}
|
||||
|
||||
public createChildContext(parentContextId: number = this._myContextId): number {
|
||||
let id = (++this._lastContextId);
|
||||
this._contexts[String(id)] = new KeybindingContext(id, this.getContext(parentContextId));
|
||||
return id;
|
||||
}
|
||||
|
||||
public disposeContext(contextId: number): void {
|
||||
delete this._contexts[String(contextId)];
|
||||
}
|
||||
}
|
||||
|
||||
CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) {
|
||||
accessor.get(IKeybindingService).createKey(String(contextKey), contextValue);
|
||||
});
|
||||
|
||||
class ScopedKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
private _parent: AbstractKeybindingService;
|
||||
private _domNode: IKeybindingScopeLocation;
|
||||
|
||||
constructor(parent: AbstractKeybindingService, emitter: Emitter<string>, domNode: IKeybindingScopeLocation) {
|
||||
super(parent.createChildContext());
|
||||
this._parent = parent;
|
||||
this._onDidChangeContextKey = emitter;
|
||||
this._domNode = domNode;
|
||||
this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(this._myContextId));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._parent.disposeContext(this._myContextId);
|
||||
this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR);
|
||||
}
|
||||
|
||||
public get onDidChangeContext(): Event<string[]> {
|
||||
return this._parent.onDidChangeContext;
|
||||
}
|
||||
|
||||
public getContext(contextId: number): KeybindingContext {
|
||||
return this._parent.getContext(contextId);
|
||||
}
|
||||
|
||||
public createChildContext(parentContextId: number = this._myContextId): number {
|
||||
return this._parent.createChildContext(parentContextId);
|
||||
}
|
||||
|
||||
public disposeContext(contextId: number): void {
|
||||
this._parent.disposeContext(contextId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event from 'vs/base/common/event';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export interface IUserFriendlyKeybinding {
|
||||
key: string;
|
||||
|
@ -32,425 +32,6 @@ export interface IKeybindings {
|
|||
};
|
||||
}
|
||||
|
||||
export enum KbExprType {
|
||||
KbDefinedExpression = 1,
|
||||
KbNotExpression = 2,
|
||||
KbEqualsExpression = 3,
|
||||
KbNotEqualsExpression = 4,
|
||||
KbAndExpression = 5
|
||||
}
|
||||
|
||||
export interface KbExpr {
|
||||
getType(): KbExprType;
|
||||
equals(other: KbExpr): boolean;
|
||||
evaluate(context: any): boolean;
|
||||
normalize(): KbExpr;
|
||||
serialize(): string;
|
||||
keys(): string[];
|
||||
}
|
||||
|
||||
function cmp(a:KbExpr, b:KbExpr): number {
|
||||
let aType = a.getType();
|
||||
let bType = b.getType();
|
||||
if (aType !== bType) {
|
||||
return aType - bType;
|
||||
}
|
||||
switch(aType) {
|
||||
case KbExprType.KbDefinedExpression:
|
||||
return (<KbDefinedExpression>a).cmp(<KbDefinedExpression>b);
|
||||
case KbExprType.KbNotExpression:
|
||||
return (<KbNotExpression>a).cmp(<KbNotExpression>b);
|
||||
case KbExprType.KbEqualsExpression:
|
||||
return (<KbEqualsExpression>a).cmp(<KbEqualsExpression>b);
|
||||
case KbExprType.KbNotEqualsExpression:
|
||||
return (<KbNotEqualsExpression>a).cmp(<KbNotEqualsExpression>b);
|
||||
default:
|
||||
throw new Error('Unknown KbExpr!');
|
||||
}
|
||||
}
|
||||
|
||||
export class KbDefinedExpression implements KbExpr {
|
||||
constructor(protected key: string) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbDefinedExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbDefinedExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbDefinedExpression) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
return (!!context[this.key]);
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbEqualsExpression implements KbExpr {
|
||||
constructor(private key: string, private value: any) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbEqualsExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbEqualsExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
if (this.value < other.value) {
|
||||
return -1;
|
||||
}
|
||||
if (this.value > other.value) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbEqualsExpression) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
/* tslint:disable:triple-equals */
|
||||
// Intentional ==
|
||||
return (context[this.key] == this.value);
|
||||
/* tslint:enable:triple-equals */
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (typeof this.value === 'boolean') {
|
||||
if (this.value) {
|
||||
return new KbDefinedExpression(this.key);
|
||||
}
|
||||
return new KbNotExpression(this.key);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (typeof this.value === 'boolean') {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
|
||||
return this.key + ' == \'' + this.value + '\'';
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbNotEqualsExpression implements KbExpr {
|
||||
constructor(private key: string, private value: any) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbNotEqualsExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbNotEqualsExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
if (this.value < other.value) {
|
||||
return -1;
|
||||
}
|
||||
if (this.value > other.value) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbNotEqualsExpression) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
/* tslint:disable:triple-equals */
|
||||
// Intentional !=
|
||||
return (context[this.key] != this.value);
|
||||
/* tslint:enable:triple-equals */
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (typeof this.value === 'boolean') {
|
||||
if (this.value) {
|
||||
return new KbNotExpression(this.key);
|
||||
}
|
||||
return new KbDefinedExpression(this.key);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (typeof this.value === 'boolean') {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
|
||||
return this.key + ' != \'' + this.value + '\'';
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbNotExpression implements KbExpr {
|
||||
constructor(private key: string) {
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbNotExpression;
|
||||
}
|
||||
|
||||
public cmp(other:KbNotExpression): number {
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
if (this.key > other.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbNotExpression) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
return (!context[this.key]);
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return '!' + this.key;
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
return [this.key];
|
||||
}
|
||||
}
|
||||
|
||||
export class KbAndExpression implements KbExpr {
|
||||
private expr: KbExpr[];
|
||||
|
||||
constructor(expr: KbExpr[]) {
|
||||
this.expr = KbAndExpression._normalizeArr(expr);
|
||||
}
|
||||
|
||||
public getType(): KbExprType {
|
||||
return KbExprType.KbAndExpression;
|
||||
}
|
||||
|
||||
public equals(other: KbExpr): boolean {
|
||||
if (other instanceof KbAndExpression) {
|
||||
if (this.expr.length !== other.expr.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
if (!this.expr[i].equals(other.expr[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public evaluate(context: any): boolean {
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
if (!this.expr[i].evaluate(context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static _normalizeArr(arr:KbExpr[]): KbExpr[] {
|
||||
let expr: KbExpr[] = [];
|
||||
|
||||
if (arr) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
let e = arr[i];
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
e = e.normalize();
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof KbAndExpression) {
|
||||
expr = expr.concat(e.expr);
|
||||
continue;
|
||||
}
|
||||
|
||||
expr.push(e);
|
||||
}
|
||||
|
||||
expr.sort(cmp);
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
public normalize(): KbExpr {
|
||||
if (this.expr.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.expr.length === 1) {
|
||||
return this.expr[0];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
if (this.expr.length === 0) {
|
||||
return '';
|
||||
}
|
||||
if (this.expr.length === 1) {
|
||||
return this.normalize().serialize();
|
||||
}
|
||||
return this.expr.map(e => e.serialize()).join(' && ');
|
||||
}
|
||||
|
||||
public keys(): string[]{
|
||||
const result: string[] = [];
|
||||
for (let expr of this.expr) {
|
||||
result.push(...expr.keys());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export class KbCtxKey<T> extends KbDefinedExpression {
|
||||
|
||||
private _defaultValue: T;
|
||||
|
||||
constructor(key:string, defaultValue:T) {
|
||||
super(key);
|
||||
this._defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public bindTo(target:IKeybindingService): IKeybindingContextKey<T> {
|
||||
return target.createKey(this.key, this._defaultValue);
|
||||
}
|
||||
|
||||
public getValue(target:IKeybindingService): T {
|
||||
return target.getContextValue<T>(this.key);
|
||||
}
|
||||
|
||||
public toNegated(): KbExpr {
|
||||
return KbExpr.not(this.key);
|
||||
}
|
||||
|
||||
public isEqualTo(value:string): KbExpr {
|
||||
return KbExpr.equals(this.key, value);
|
||||
}
|
||||
}
|
||||
|
||||
export let KbExpr = {
|
||||
has: (key: string) => new KbDefinedExpression(key),
|
||||
equals: (key: string, value: any) => new KbEqualsExpression(key, value),
|
||||
notEquals: (key: string, value: any) => new KbNotEqualsExpression(key, value),
|
||||
not: (key: string) => new KbNotExpression(key),
|
||||
and: (...expr: KbExpr[]) => new KbAndExpression(expr),
|
||||
deserialize: (serialized: string): KbExpr => {
|
||||
if (!serialized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let pieces = serialized.split('&&');
|
||||
let result = new KbAndExpression(pieces.map(p => KbExpr._deserializeOne(p)));
|
||||
return result.normalize();
|
||||
},
|
||||
|
||||
_deserializeOne: (serializedOne: string): KbExpr => {
|
||||
serializedOne = serializedOne.trim();
|
||||
|
||||
if (serializedOne.indexOf('!=') >= 0) {
|
||||
let pieces = serializedOne.split('!=');
|
||||
return new KbNotEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1]));
|
||||
}
|
||||
|
||||
if (serializedOne.indexOf('==') >= 0) {
|
||||
let pieces = serializedOne.split('==');
|
||||
return new KbEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1]));
|
||||
}
|
||||
|
||||
if (/^\!\s*/.test(serializedOne)) {
|
||||
return new KbNotExpression(serializedOne.substr(1).trim());
|
||||
}
|
||||
|
||||
return new KbDefinedExpression(serializedOne);
|
||||
},
|
||||
|
||||
_deserializeValue: (serializedValue: string): any => {
|
||||
serializedValue = serializedValue.trim();
|
||||
|
||||
if (serializedValue === 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (serializedValue === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
let m = /^'([^']*)'$/.exec(serializedValue);
|
||||
if (m) {
|
||||
return m[1].trim();
|
||||
}
|
||||
|
||||
return serializedValue;
|
||||
}
|
||||
};
|
||||
|
||||
export interface IKeybindingItem {
|
||||
keybinding: number;
|
||||
command: string;
|
||||
|
@ -459,38 +40,8 @@ export interface IKeybindingItem {
|
|||
weight2: number;
|
||||
}
|
||||
|
||||
export interface IKeybindingContextKey<T> {
|
||||
set(value: T): void;
|
||||
reset(): void;
|
||||
get(): T;
|
||||
}
|
||||
|
||||
export let IKeybindingService = createDecorator<IKeybindingService>('keybindingService');
|
||||
|
||||
export interface IKeybindingScopeLocation {
|
||||
setAttribute(attr: string, value: string): void;
|
||||
removeAttribute(attr: string): void;
|
||||
}
|
||||
|
||||
export interface IKeybindingService {
|
||||
_serviceBrand: any;
|
||||
dispose(): void;
|
||||
|
||||
onDidChangeContext: Event<string[]>;
|
||||
createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T>;
|
||||
contextMatchesRules(rules: KbExpr): boolean;
|
||||
getContextValue<T>(key: string): T;
|
||||
|
||||
createScoped(domNode: IKeybindingScopeLocation): IKeybindingService;
|
||||
|
||||
getContext(contextId: number): IKeybindingContext;
|
||||
}
|
||||
|
||||
export interface IKeybindingContext {
|
||||
fillInContext(bucket: any): void;
|
||||
}
|
||||
|
||||
export let IKeybindingService2 = createDecorator<IKeybindingService2>('keybindingService2');
|
||||
|
||||
export interface IKeybindingService2 {
|
||||
_serviceBrand: any;
|
||||
|
||||
|
@ -504,4 +55,3 @@ export interface IKeybindingService2 {
|
|||
customKeybindingsCount(): number;
|
||||
}
|
||||
|
||||
export const SET_CONTEXT_COMMAND_ID = 'setContext';
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
import {BinaryKeybindings, ISimplifiedPlatform, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export interface IResolveResult {
|
||||
enterChord: number;
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
import {BinaryKeybindings, KeyCode} from 'vs/base/common/keyCodes';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import {IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem, IKeybindings} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
import * as assert from 'assert';
|
||||
import {BinaryKeybindings, KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {IOSupport, KeybindingResolver, NormalizedKeybindingItem} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IKeybindingItem, KbAndExpression, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbAndExpression, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
suite('Keybinding Service', () => {
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import Event from 'vs/base/common/event';
|
||||
import {IKeybindingContextKey, IKeybindingService, IKeybindingContext, IKeybindingService2, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService, IKeybindingContext, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
class MockKeybindingContextKey<T> implements IKeybindingContextKey<T> {
|
||||
private _key: string;
|
||||
|
|
|
@ -18,7 +18,8 @@ import {UntitledEditorInput} from 'vs/workbench/common/editor/untitledEditorInpu
|
|||
import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {KbExpr, IKeybindings} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindings} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {TextDiffEditor} from 'vs/workbench/browser/parts/editor/textDiffEditor';
|
||||
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
||||
import {BinaryResourceDiffEditor} from 'vs/workbench/browser/parts/editor/binaryDiffEditor';
|
||||
|
|
|
@ -30,7 +30,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
|||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {TabsTitleControl} from 'vs/workbench/browser/parts/editor/tabsTitleControl';
|
||||
|
|
|
@ -24,7 +24,8 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti
|
|||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMenuService} from 'vs/platform/actions/common/actions';
|
||||
import {TitleControl} from 'vs/workbench/browser/parts/editor/titleControl';
|
||||
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||
|
|
|
@ -35,7 +35,7 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect
|
|||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IThemeService} from 'vs/workbench/services/themes/common/themeService';
|
||||
|
||||
export const TextCompareEditorVisible = new KbCtxKey<boolean>('textCompareEditorVisible', false);
|
||||
|
|
|
@ -29,7 +29,8 @@ import {StandardMouseEvent} from 'vs/base/browser/mouseEvent';
|
|||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||
import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {CloseEditorsInGroupAction, SplitEditorAction, CloseEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, CloseRightEditorsInGroupAction, ShowEditorsInGroupAction} from 'vs/workbench/browser/parts/editor/editorActions';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {createActionItem, fillInActions} from 'vs/platform/actions/browser/menuItemActionItem';
|
||||
|
|
|
@ -37,7 +37,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
|
|||
import {IMessageService, Severity} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||
import {IKeybindingService, KbCtxKey, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, KbCtxKey, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IHistoryService} from 'vs/workbench/services/history/common/history';
|
||||
|
||||
const HELP_PREFIX = '?';
|
||||
|
|
|
@ -46,7 +46,8 @@ import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'
|
|||
import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService';
|
||||
import {WorkbenchKeybindingService, WorkbenchKeybindingService2} from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
|
||||
import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace';
|
||||
import {KbExpr, KbCtxKey, IKeybindingService, IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr, KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IActivityService} from 'vs/workbench/services/activity/common/activityService';
|
||||
import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService';
|
||||
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
|
||||
|
|
|
@ -18,7 +18,7 @@ import editorbrowser = require('vs/editor/browser/editorBrowser');
|
|||
import {ZoneWidget} from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import debug = require('vs/workbench/parts/debug/common/debug');
|
||||
import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import {Range} from 'vs/editor/common/core/range';
|
||||
import editorCommon = require('vs/editor/common/editorCommon');
|
||||
import editorbrowser = require('vs/editor/browser/editorBrowser');
|
||||
import {KbExpr, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import debug = require('vs/workbench/parts/debug/common/debug');
|
||||
import model = require('vs/workbench/parts/debug/common/debugModel');
|
||||
|
|
|
@ -11,7 +11,7 @@ import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
|||
import editor = require('vs/editor/common/editorCommon');
|
||||
import {Source} from 'vs/workbench/parts/debug/common/debugSource';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {KbCtxKey, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.debug';
|
||||
export const REPL_ID = 'workbench.panel.repl';
|
||||
|
|
|
@ -17,7 +17,7 @@ import severity from 'vs/base/common/severity';
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import aria = require('vs/base/browser/ui/aria/aria');
|
||||
import editorbrowser = require('vs/editor/browser/editorBrowser');
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
|
||||
|
|
|
@ -12,7 +12,7 @@ import {editorAction} from 'vs/editor/common/editorCommonExtensions';
|
|||
import {Handler, ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon';
|
||||
|
||||
import {KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
@editorAction
|
||||
class ExpandAbbreviationAction extends BasicEmmetEditorAction {
|
||||
|
|
|
@ -30,7 +30,7 @@ import {EditorInput, EditorOptions} from 'vs/workbench/common/editor';
|
|||
import {BaseEditor} from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
||||
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export class ExplorerViewlet extends Viewlet {
|
||||
private viewletContainer: Builder;
|
||||
|
|
|
@ -38,7 +38,7 @@ import {IPartService} from 'vs/workbench/services/part/common/partService';
|
|||
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||
import {IWorkspace} from 'vs/platform/workspace/common/workspace';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
|
|
|
@ -14,7 +14,7 @@ import {EncodingMode, EditorInput, IFileEditorInput, ConfirmResult, IWorkbenchEd
|
|||
import {IFileStat, IFilesConfiguration, IBaseStat, IResolveContentOptions} from 'vs/platform/files/common/files';
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {FileStat} from 'vs/workbench/parts/files/common/explorerViewModel';
|
||||
import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
/**
|
||||
* Explorer viewlet id.
|
||||
|
|
|
@ -19,7 +19,7 @@ import {OUTPUT_MIME, OUTPUT_MODE_ID, OUTPUT_PANEL_ID, IOutputService} from 'vs/w
|
|||
import panel = require('vs/workbench/browser/panel');
|
||||
import {EditorContextKeys} from 'vs/editor/common/editorCommon';
|
||||
import {CommandsRegistry, ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
// Register Service
|
||||
registerSingleton(IOutputService, OutputService);
|
||||
|
|
|
@ -45,7 +45,8 @@ import {IMessageService} from 'vs/platform/message/common/message';
|
|||
import {ISearchService} from 'vs/platform/search/common/search';
|
||||
import {IProgressService} from 'vs/platform/progress/common/progress';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {IKeybindingService, IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {KeyCode, CommonKeybindings} from 'vs/base/common/keyCodes';
|
||||
import { PatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget';
|
||||
|
|
|
@ -15,7 +15,8 @@ import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
|||
import { Button } from 'vs/base/browser/ui/button/button';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { KbExpr, KbCtxKey, IKeybindingService, IKeybindingService2, IKeybindingContextKey } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KbExpr, KbCtxKey, IKeybindingService, IKeybindingContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.search';
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import processes = require('vs/base/node/processes');
|
|||
import {Builder} from 'vs/base/browser/builder';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {KbCtxKey, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const TERMINAL_PANEL_ID = 'workbench.panel.terminal';
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ import xterm = require('xterm');
|
|||
import {Dimension} from 'vs/base/browser/builder';
|
||||
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMessageService, Severity} from 'vs/platform/message/common/message';
|
||||
import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
|
||||
import {ITerminalProcess, ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal';
|
||||
|
|
|
@ -14,7 +14,8 @@ import {IActionItem} from 'vs/base/browser/ui/actionbar/actionbar';
|
|||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {ITerminalFont, TerminalConfigHelper} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
|
||||
|
|
|
@ -14,7 +14,7 @@ import {Builder} from 'vs/base/browser/builder';
|
|||
import {EndOfLinePreference} from 'vs/editor/common/editorCommon';
|
||||
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IMessageService, Severity} from 'vs/platform/message/common/message';
|
||||
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
|
||||
import {IPartService} from 'vs/workbench/services/part/common/partService';
|
||||
|
|
|
@ -12,11 +12,13 @@ import * as platform from 'vs/base/common/platform';
|
|||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import {KeybindingService, KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
|
||||
import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
|
||||
import {KeybindingService} from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService, IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey';
|
||||
import {IKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
|
|
Loading…
Reference in a new issue