Example #1
0
	constructor() {
		super(
			'editor.action.removeCommentLine',
			nls.localize('comment.line.remove', "Remove Line Comment"),
			'Remove Line Comment',
			Type.ForceRemove
		);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);

		this.kbOpts = {
			kbExpr: KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable),
			primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U)
		};
	}
Example #2
0
	constructor() {
		super(
			'editor.action.commentLine',
			nls.localize('comment.line', "Toggle Line Comment"),
			'Toggle Line Comment',
			Type.Toggle
		);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);

		this.kbOpts = {
			kbExpr: KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable),
			primary: KeyMod.CtrlCmd | KeyCode.US_SLASH
		};
	}
Example #3
0
function registerClipboardAction(desc: IClipboardCommand, alias: string, weight: number) {
	if (!browser.supportsExecCommand(desc.execCommand)) {
		return;
	}

	CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(desc.ctor, desc.id, desc.label, {
		handler: execCommandToHandler.bind(null, desc.id, desc.execCommand),
		context: ContextKey.None,
		primary: desc.primary,
		secondary: desc.secondary,
		win: desc.win,
		linux: desc.linux,
		mac: desc.mac,
		kbExpr: KbExpr.has(editorCommon.KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS)
	}, alias));

	MenuRegistry.appendMenuItem(MenuId.EditorContext, {
		command: {
			id: desc.id,
			title: desc.label
		},
		group: `9_cutcopypaste`,
		order: weight,
		when: desc.kbExpr
	});
}
Example #4
0
	constructor(id:string, label:string, alias:string, left:boolean) {
		super(id, label, alias, true);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);

		this.left = left;
	}
Example #5
0
	constructor() {
		super(
			'editor.action.blockComment',
			nls.localize('comment.block', "Toggle Block Comment"),
			'Toggle Block Comment',
			true
		);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);

		this.kbOpts = {
			kbExpr: KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable),
			primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
			linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }
		};
	}
Example #6
0
	constructor() {
		super(
			'editor.emmet.action.expandAbbreviation',
			nls.localize('expandAbbreviationAction', "Emmet: Expand Abbreviation"),
			'Emmet: Expand Abbreviation',
			'expand_abbreviation',
			{
				primary: KeyCode.Tab,
				kbExpr: KbExpr.and(
					EditorContextKeys.TextFocus,
					EditorContextKeys.HasOnlyEmptySelection,
					EditorContextKeys.HasSingleSelection,
					EditorContextKeys.TabDoesNotMoveFocus,
					KbExpr.has('config.emmet.triggerExpansionOnTab')
				)
			}
		);
	}
	constructor() {
		super(
			'editor.action.showSnippets',
			nls.localize('snippet.suggestions.label', "Insert Snippet"),
			'Insert Snippet',
			true
		);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);
	}
Example #8
0
	constructor() {
		super(
			'editor.action.addCommentLine',
			nls.localize('comment.line.add', "Add Line Comment"),
			'Add Line Comment',
			Type.ForceAdd
		);

		this.kbOpts = {
			kbExpr: KbExpr.and(EditorKbExpr.TextFocus, EditorKbExpr.Writable),
			primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C)
		};
	}
Example #9
0
		forEach(value, entry => {
			if (!schema.isValidMenuItems(entry.value, collector)) {
				return;
			}

			const menu = schema.parseMenuId(entry.key);
			if (!menu) {
				collector.warn(localize('menuId.invalid', "`{0}` is not a valid menu identifier", entry.key));
				return;
			}

			for (let item of entry.value) {
				let command = MenuRegistry.getCommand(item.command);
				let alt = item.alt && MenuRegistry.getCommand(item.alt);

				if (!command) {
					collector.warn(localize('missing.command', "Menu item references a command `{0}` which is not defined in the 'commands' section.", item.command));
				}
				if (item.alt && !alt) {
					collector.warn(localize('missing.altCommand', "Menu item references an alt-command `{0}` which is not defined in the 'commands' section.", item.alt));
				}
				if (item.command === item.alt) {
					collector.info(localize('dupe.command', "Menu item references the same command as default and alt-command"));
				}

				if (item.alt && menu !== MenuId.EditorTitle && item.group !== 'navigation') {
					collector.info(localize('nosupport.altCommand', "Sorry, but currently only the 'navigation' group of the 'editor/title' menu supports alt-commands"));
				}

				let group: string;
				let order: number;
				if (item.group) {
					const idx = item.group.lastIndexOf('@');
					if (idx > 0) {
						group = item.group.substr(0, idx);
						order = Number(item.group.substr(idx + 1)) || undefined;
					} else {
						group = item.group;
					}
				}

				MenuRegistry.appendMenuItem(menu, {
					command,
					alt,
					group,
					order,
					when: KbExpr.deserialize(item.when)
				});
			}
		});
Example #10
0
	constructor() {
		super(
			'editor.action.clipboardCutAction',
			nls.localize('actions.clipboard.cutLabel', "Cut"),
			'Cut',
			true,
			'cut'
		);

		this._precondition = KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable);

		this.kbOpts = {
			kbExpr: KbExpr.and(EditorContextKeys.TextFocus, EditorContextKeys.Writable),
			primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
			win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] }
		};

		this.menuOpts = {
			kbExpr: EditorContextKeys.Writable,
			menu: MenuId.EditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			order: 1
		};
	}