/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { Event } from '../../../../vs/base/common/event'; import { KeyCode, ResolvedKeybinding, } from '../../../../vs/base/common/keyCodes'; import { IContextKeyService, IContextKeyServiceTarget, } from '../../../../vs/platform/contextkey/common/contextkey'; import { createDecorator } from '../../../../vs/platform/instantiation/common/instantiation'; import { IResolveResult } from '../../../../vs/platform/keybinding/common/keybindingResolver'; import { ResolvedKeybindingItem } from '../../../../vs/platform/keybinding/common/resolvedKeybindingItem'; export const enum KeybindingSource { Default = 1, User, } export interface IKeybindingEvent { source: KeybindingSource; } export interface IKeyboardEvent { readonly _standardKeyboardEventBrand: true; readonly ctrlKey: boolean; readonly shiftKey: boolean; readonly altKey: boolean; readonly metaKey: boolean; readonly keyCode: KeyCode; } export const IKeybindingService = createDecorator('keybindingService'); export interface IKeybindingService { readonly _serviceBrand: undefined; onDidUpdateKeybindings: Event; /** * Resolve and dispatch `keyboardEvent` and invoke the command. */ dispatchEvent(e: IKeyboardEvent, target: IContextKeyServiceTarget): boolean; /** * Resolve and dispatch `keyboardEvent`, but do not invoke the command or change inner state. */ softDispatch( keyboardEvent: IKeyboardEvent, target: IContextKeyServiceTarget ): IResolveResult | null; /** * Look up the preferred (last defined) keybinding for a command. * @returns The preferred keybinding or null if the command is not bound. */ lookupKeybinding( commandId: string, context?: IContextKeyService ): ResolvedKeybinding | undefined; getKeybindings(): readonly ResolvedKeybindingItem[]; /** * Will the given key event produce a character that's rendered on screen, e.g. in a * text box. *Note* that the results of this function can be incorrect. */ mightProducePrintableCharacter(event: IKeyboardEvent): boolean; }