Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/disable keybindings on windows #755

Merged
merged 3 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to the "emacs-mcx" extension will be documented in this file.

## [Unreleased]
### Fixed
- Disable Emacs-like cursor movements when the find or replace widgets are focused on Windows, because the cursor on the OS native UIs cannot be controlled by extensions.

## [0.28.0] - 2021-04-09
### Added
- Add `C-x C-c`.
Expand Down
13 changes: 6 additions & 7 deletions keybinding-generator/generate-keybindings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface KeyBindingSource {
key?: string;
keys?: string[];
command: string;
command?: string;
when?: string;
whens?: string[];
args?: (string | number)[];
Expand All @@ -10,7 +10,7 @@ export interface KeyBindingSource {
export interface KeyBinding {
key?: string;
mac?: string;
command: string;
command?: string;
when?: string;
args?: (string | number)[];
}
Expand Down Expand Up @@ -111,7 +111,7 @@ export function generateKeybindings(src: KeyBindingSource): KeyBinding[] {
// Generate keybindings using ESC and Ctrl+[ as meta.
const keystrokes = key.split(" ").filter((k) => k);
if (keystrokes.length === 1) {
const keyWithEscapeMeta = replaceMetaWithEscape(key)
const keyWithEscapeMeta = replaceMetaWithEscape(key);
keybindings.push({
key: keyWithEscapeMeta,
command: src.command,
Expand All @@ -129,7 +129,6 @@ export function generateKeybindings(src: KeyBindingSource): KeyBinding[] {
`"${key}" includes more than one key strokes then it's meta key specification cannot be converted to "ESC" and "ctrl+[".`
);
}

} else {
keybindings.push({
key,
Expand Down Expand Up @@ -161,7 +160,7 @@ export function isKeyBindingSource(maybeSrc: { [key: string]: any }): maybeSrc i
}

// Check for .command
if (typeof maybeSrc.command !== "string") {
if (typeof maybeSrc.command !== "undefined" && typeof maybeSrc.command !== "string") {
return false;
}

Expand Down Expand Up @@ -244,12 +243,12 @@ export function generateKeybindingsForPrefixArgument(): KeyBinding[] {
keybindings.push({
key: "enter",
command: "emacs-mcx.newLine",
when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly"
when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly",
});
keybindings.push({
key: "backspace",
command: "emacs-mcx.deleteBackwardChar",
when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly"
when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly",
});

return keybindings;
Expand Down
32 changes: 32 additions & 0 deletions keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,38 @@
"command": "editor.action.startFindReplaceAction",
"when": "editorFocus"
},
// Disable Emacs-like keybindings on the find and replace widgets (native UI).
// See https://github.com/whitphx/vscode-emacs-mcx/issues/55
{
"keys": [
"ctrl+f",
"ctrl+b",
"ctrl+p",
"ctrl+n",
"ctrl+a",
"ctrl+e",
"alt+f",
"alt+b",
"alt+m",
"ctrl+d",
"ctrl+h",
"alt+d",
"ctrl+k",
"ctrl+w",
"alt+w",
"ctrl+y",
"alt+y",
"ctrl+m",
"ctrl+j",
"alt+l",
"alt+u",
"alt+backspace"
],
"whens": [
"isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing",
"isWindows && replaceInputFocussed && !isComposing"
]
},
// addSelectionToNext/PreviousFindMatch
{
"key": "ctrl+meta+n",
Expand Down
176 changes: 176 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,182 @@
"command": "editor.action.startFindReplaceAction",
"when": "editorFocus && config.emacs-mcx.useMetaPrefixCtrlLeftBracket"
},
{
"key": "ctrl+f",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+b",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+p",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+n",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+a",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+e",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+f",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+b",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+m",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+d",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+h",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+d",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+k",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+w",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+w",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+y",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+y",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+m",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+j",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+l",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+u",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "alt+backspace",
"when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing"
},
{
"key": "ctrl+f",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+b",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+p",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+n",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+a",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+e",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+f",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+b",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+m",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+d",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+h",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+d",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+k",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+w",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+w",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+y",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+y",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+m",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+j",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+l",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+u",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "alt+backspace",
"when": "isWindows && replaceInputFocussed && !isComposing"
},
{
"key": "ctrl+alt+n",
"command": "emacs-mcx.addSelectionToNextFindMatch",
Expand Down