本文整理汇总了TypeScript中vs/platform/keybinding/common/keybindingsRegistry.KeybindingsRegistry.WEIGHT.editorContrib方法的典型用法代码示例。如果您正苦于以下问题:TypeScript KeybindingsRegistry.WEIGHT.editorContrib方法的具体用法?TypeScript KeybindingsRegistry.WEIGHT.editorContrib怎么用?TypeScript KeybindingsRegistry.WEIGHT.editorContrib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/platform/keybinding/common/keybindingsRegistry.KeybindingsRegistry.WEIGHT
的用法示例。
在下文中一共展示了KeybindingsRegistry.WEIGHT.editorContrib方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor() {
super({
id: 'closeBreakpointWidget',
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
kbOpts: {
weight: KeybindingsRegistry.WEIGHT.editorContrib(8),
kbExpr: EditorContextKeys.focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
});
}
示例2: registerCommands
//.........这里部分代码省略.........
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// List
if (focused instanceof List || focused instanceof PagedList) {
const list = focused;
list.setSelection(range(list.length));
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.toggleExpand',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: WorkbenchListFocusContextKey,
primary: KeyCode.Space,
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// Tree only
if (focused && !(focused instanceof List || focused instanceof PagedList)) {
const tree = focused;
const focus = tree.getFocus();
if (focus) {
tree.toggleExpansion(focus);
}
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.clear',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: WorkbenchListFocusContextKey,
primary: KeyCode.Escape,
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// Tree only
if (focused && !(focused instanceof List || focused instanceof PagedList)) {
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: ContextKeyExpr.and(NoEditorsVisibleContext, SingleEditorGroupsContext),
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
handler: accessor => {
const windowService = accessor.get(IWindowService);
windowService.closeWindow();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.exitZenMode',
weight: KeybindingsRegistry.WEIGHT.editorContrib(-1000),
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InEditorZenModeContext,
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.removeFromRecentlyOpened', function (accessor: ServicesAccessor, path: string) {
const windowsService = accessor.get(IWindowsService);
return windowsService.removeFromRecentlyOpened([path]).then(() => void 0);
});
}
示例3:
return editorService.openEditor(profilerInput, { pinned: true }, false).then(() => TPromise.as(true));
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'profiler.newProfiler',
weight: KeybindingsRegistry.WEIGHT.builtinExtension(),
when: undefined,
primary: KeyMod.Alt | KeyCode.KEY_P,
mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_P },
handler: CommandsRegistry.getCommand('profiler.newProfiler').handler
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'profiler.toggleStartStop',
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
when: undefined,
primary: KeyMod.Alt | KeyCode.KEY_S,
mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_S },
handler: (accessor: ServicesAccessor) => {
let profilerService: IProfilerService = accessor.get(IProfilerService);
let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService);
let activeEditor = editorService.getActiveEditor();
if (activeEditor instanceof ProfilerEditor) {
let profilerInput = activeEditor.input;
if (profilerInput.state.isRunning) {
return profilerService.stopSession(profilerInput.id);
} else {
// clear data when profiler is started
profilerInput.data.clear();
示例4: registerSingleton
registerSingleton(IWebviewEditorService, WebviewEditorService);
const webviewDeveloperCategory = localize('developer', "Developer");
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
const showNextFindWdigetCommand = new ShowWebViewEditorFindWidgetCommand({
id: ShowWebViewEditorFindWidgetCommand.ID,
precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS,
kbOpts: {
primary: KeyMod.CtrlCmd | KeyCode.KEY_F
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule(showNextFindWdigetCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
const showNextFindTermCommand = new ShowWebViewEditorFindTermCommand({
id: 'editor.action.webvieweditor.showNextFindTerm',
precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED,
kbOpts: {
primary: KeyMod.Alt | KeyCode.DownArrow
}
}, true);
KeybindingsRegistry.registerCommandAndKeybindingRule(showNextFindTermCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
const showPreviousFindTermCommand = new ShowWebViewEditorFindTermCommand({
id: 'editor.action.webvieweditor.showPreviousFindTerm',
precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED,
kbOpts: {
示例5: registerCommands
//.........这里部分代码省略.........
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.clear',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: WorkbenchListFocusContextKey,
primary: KeyCode.Escape,
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// Tree only
if (focused && !(focused instanceof List || focused instanceof PagedList)) {
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: KeybindingsRegistry.WEIGHT.editorContrib(-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, IEditorOptions, EditorPosition]) {
const editorService = accessor.get(IWorkbenchEditorService);
const [resource, options, column] = args;
return editorService.openEditor({ resource, options }, 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);
}
示例6: getWebViewEditor
private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor {
const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor;
if (activeEditor.isWebviewEditor) {
return activeEditor;
}
return null;
}
}
const showFindCommand = new ShowWebViewEditorFindCommand({
id: 'editor.action.webvieweditor.showFind',
precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS,
kbOpts: {
primary: KeyMod.CtrlCmd | KeyCode.KEY_F
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule(showFindCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
class HideWebViewEditorFindCommand extends Command {
public runCommand(accessor: ServicesAccessor, args: any): void {
const webViewEditor = this.getWebViewEditor(accessor);
if (webViewEditor) {
webViewEditor.hideFind();
}
}
private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor {
const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor;
if (activeEditor.isWebviewEditor) {
return activeEditor;
}
return null;