本文整理匯總了TypeScript中vs/editor/common/editorCommonExtensions.CommonEditorRegistry.commandWeight方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommonEditorRegistry.commandWeight方法的具體用法?TypeScript CommonEditorRegistry.commandWeight怎麽用?TypeScript CommonEditorRegistry.commandWeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/editorCommonExtensions.CommonEditorRegistry
的用法示例。
在下文中一共展示了CommonEditorRegistry.commandWeight方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor() {
super({
id: 'closeBreakpointWidget',
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
kbOpts: {
weight: CommonEditorRegistry.commandWeight(8),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
});
}
示例2: KeyChord
// close the window when the last editor is closed by reusing the same keybinding
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeWindow',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: NoEditorsVisibleContext,
primary: closeEditorOrWindowKeybindings.primary,
handler: accessor => {
const windowService = accessor.get(IWindowIPCService);
windowService.getWindow().close();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.exitZenMode',
weight: CommonEditorRegistry.commandWeight(-1000),
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InZenModeContext,
primary: KeyChord(KeyCode.Escape, KeyCode.Escape)
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.quit',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
handler(accessor: ServicesAccessor) {
const windowsService = accessor.get(IWindowsService);
windowsService.quit();
},
示例3: registerCommands
//.........這裏部分代碼省略.........
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.clear',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ListFocusContext,
primary: KeyCode.Escape,
handler: (accessor) => {
const listService = accessor.get(IListService);
const focused = listService.getFocused();
// Tree only
if (focused && !(focused instanceof List)) {
const tree = focused;
if (tree.getSelection().length) {
tree.clearSelection({ origin: 'keyboard' });
return void 0;
}
if (tree.getFocus()) {
tree.clearFocus({ origin: 'keyboard' });
return void 0;
}
}
}
});
// --- commands
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeWindow', // close the window when the last editor is closed by reusing the same keybinding
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: NoEditorsVisibleContext,
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
handler: accessor => {
const windowService = accessor.get(IWindowService);
windowService.closeWindow();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.exitZenMode',
weight: CommonEditorRegistry.commandWeight(-1000),
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InZenModeContext,
primary: KeyChord(KeyCode.Escape, KeyCode.Escape)
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.quit',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
handler(accessor: ServicesAccessor) {
const windowsService = accessor.get(IWindowsService);
windowsService.quit();
},
when: void 0,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Q,
win: { primary: void 0 }
});
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorPosition]) {
const editorService = accessor.get(IWorkbenchEditorService);
let [leftResource, rightResource, label, description, options, position] = args;
if (!options || typeof options !== 'object') {
options = {
preserveFocus: false
};
}
if (!label) {
label = nls.localize('diffLeftRightLabel', "{0} ⡠{1}", leftResource.toString(true), rightResource.toString(true));
}
return editorService.openEditor({ leftResource, rightResource, label, description, options }, position).then(() => {
return void 0;
});
});
CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, number]) {
const editorService = accessor.get(IWorkbenchEditorService);
const [resource, column] = args;
return editorService.openEditor({ resource }, column).then(() => {
return void 0;
});
});
CommandsRegistry.registerCommand('_files.pickFolderAndOpen', openFolderCommand);
CommandsRegistry.registerCommand('workbench.action.files.openFileInNewWindow', openFileInNewWindowCommand);
CommandsRegistry.registerCommand('workbench.action.files.openFolderInNewWindow', openFolderInNewWindowCommand);
CommandsRegistry.registerCommand('workbench.action.files.openFileFolderInNewWindow', openFileFolderInNewWindowCommand);
CommandsRegistry.registerCommand('workbench.action.openWorkspaceInNewWindow', openWorkspaceInNewWindowCommand);
}