提交 8a33db65 编写于 作者: A Alex Dima

Add Inspect Key Mapppings action

上级 0ebecd5c
......@@ -7,3 +7,4 @@ import './electron-browser/toggleRenderControlCharacter';
import './electron-browser/toggleRenderWhitespace';
import './electron-browser/toggleWordWrap';
import './electron-browser/wordWrapMigration';
import './electron-browser/inspectKeybindings';
/*---------------------------------------------------------------------------------------------
* 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 * as nls from 'vs/nls';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { editorAction, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import URI from 'vs/base/common/uri';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
@editorAction
class InspectKeyMap extends EditorAction {
constructor() {
super({
id: 'workbench.action.inspectKeyMappings',
label: nls.localize('workbench.action.inspectKeyMap', "Developer: Inspect Key Mapppings"),
alias: 'Developer: Inspect Key Mapppings',
precondition: null
});
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
const keybindingService = accessor.get(IKeybindingService);
const editorService = accessor.get(IWorkbenchEditorService);
const untitledEditorService = accessor.get(IUntitledEditorService);
if (keybindingService instanceof WorkbenchKeybindingService) {
console.log(keybindingService.dumpDebugInfo());
const resource = URI.from({ scheme: UntitledEditorInput.SCHEMA, path: `KeyMap` });
const input = untitledEditorService.createOrGet(resource, null, keybindingService.dumpDebugInfo());
editorService.openEditor(input, { pinned: true });
}
}
}
......@@ -9,6 +9,7 @@ import { Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
export interface IKeyboardMapper {
dumpRawDebugInfo(): string;
dumpDebugInfo(): string;
resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[];
resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding;
......
......@@ -153,6 +153,7 @@ interface IHardwareCodeMapping {
export class MacLinuxKeyboardMapper implements IKeyboardMapper {
private readonly _rawMappings: IMacLinuxKeyboardMapping;
private readonly _OS: OperatingSystem;
private readonly _codeInfo: IHardwareCodeMapping[];
private readonly _hwToKb: number[] = [];
......@@ -161,7 +162,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
private readonly _kbToHw: number[][] = [];
constructor(rawMappings: IMacLinuxKeyboardMapping, OS: OperatingSystem) {
this._rawMappings = rawMappings;
this._OS = OS;
this._hwToKb = [];
......@@ -283,6 +284,10 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
}
public dumpRawDebugInfo(): string {
return JSON.stringify(this._rawMappings, null, '\t');
}
public dumpDebugInfo(): string {
let result: string[] = [];
......
......@@ -177,12 +177,14 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
export class WindowsKeyboardMapper implements IKeyboardMapper {
private readonly _rawMappings: IWindowsKeyboardMapping;
private readonly _codeInfo: IHardwareCodeMapping[];
private readonly _hwToKb: KeyCode[];
private readonly _kbToLabel: string[] = [];
private readonly _kbExists: boolean[];
constructor(rawMappings: IWindowsKeyboardMapping) {
this._rawMappings = rawMappings;
this._hwToKb = [];
this._kbToLabel = [];
this._kbExists = [];
......@@ -241,6 +243,10 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
}
}
public dumpRawDebugInfo(): string {
return JSON.stringify(this._rawMappings, null, '\t');
}
public dumpDebugInfo(): string {
let result: string[] = [];
......
......@@ -186,6 +186,10 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
});
}
public dumpDebugInfo(): string {
return this._keyboardMapper.dumpDebugInfo() + `\n\n\nraw info: \n` + this._keyboardMapper.dumpRawDebugInfo();
}
private _safeGetConfig(): IUserFriendlyKeybinding[] {
let rawConfig = this.userKeybindings.getConfig();
if (Array.isArray(rawConfig)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册