当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CommonEditorRegistry.commandWeight方法代码示例

本文整理汇总了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]
			}
		});
	}
开发者ID:diarmaidm,项目名称:vscode,代码行数:12,代码来源:debugEditorActions.ts

示例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();
	},
开发者ID:pk-codebox-evo,项目名称:ide-microsoft-vscode,代码行数:30,代码来源:main.contribution.ts

示例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);
}
开发者ID:gokulakrishna9,项目名称:vscode,代码行数:101,代码来源:commands.ts


注:本文中的vs/editor/common/editorCommonExtensions.CommonEditorRegistry.commandWeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。