diff --git a/keybinding-generator/cli.mts b/keybinding-generator/cli.mts index 29ef531dea..8f283a4501 100644 --- a/keybinding-generator/cli.mts +++ b/keybinding-generator/cli.mts @@ -8,6 +8,7 @@ import { generateKeybindings, generateKeybindingsForPrefixArgument, generateKeybindingsForTypeCharInRectMarkMode, + generateKeybindingsForRegisterCommands, } from "./generate-keybindings.mjs"; const srcFilePath = "./keybindings.json"; @@ -32,6 +33,11 @@ keybindingSrcs.forEach((keybindingSrc) => { dstKeybindings.push(...generateKeybindingsForTypeCharInRectMarkMode()); return; } + if (keybindingSrc.$special == "registerCommandTypes") { + console.log("Adding keybindings for register commands"); + dstKeybindings.push(...generateKeybindingsForRegisterCommands()); + return; + } if (!isKeyBindingSource(keybindingSrc)) { throw new Error(`${JSON.stringify(keybindingSrc)} is not a valid source`); diff --git a/keybinding-generator/generate-keybindings.mts b/keybinding-generator/generate-keybindings.mts index 799d87a1da..9430c09acb 100644 --- a/keybinding-generator/generate-keybindings.mts +++ b/keybinding-generator/generate-keybindings.mts @@ -296,3 +296,34 @@ export function generateKeybindingsForTypeCharInRectMarkMode(): KeyBinding[] { return keybindings; } + +export function generateKeybindingsForRegisterCommands(): KeyBinding[] { + const keybindings: KeyBinding[] = []; + + // Ascii all printable characters excluding delete. + // Ref: https://www.ascii-code.com/ + const asciiPrintableChars: string[] = []; + // ' ' ~ '~' + for (let charCode = 0x20; charCode <= 0x7e; charCode++) { + asciiPrintableChars.push(String.fromCharCode(charCode)); + } + + for (const char of asciiPrintableChars) { + keybindings.push({ + key: char, + when: "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + command: "emacs-mcx.RegisterSaveCommand", + args: [char], + }); + } + + for (const char of asciiPrintableChars) { + keybindings.push({ + key: char, + when: "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + command: "emacs-mcx.RegisterInsertCommand", + args: [char], + }); + } + return keybindings; +} diff --git a/keybindings.json b/keybindings.json index 1a836c2ff3..9d5aae00bf 100644 --- a/keybindings.json +++ b/keybindings.json @@ -745,6 +745,19 @@ "command": "emacs-mcx.killRectangle", "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" }, + { + "key": "s", // ctrl+x r s + "command": "emacs-mcx.StartRegisterSaveCommand", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" + }, + { + "key": "i", // ctrl+x r i + "command": "emacs-mcx.StartRegisterInsertCommand", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" + }, + { + "$special": "registerCommandTypes" + }, { "key": "y", // ctrl+x r y "command": "emacs-mcx.yankRectangle", diff --git a/package.json b/package.json index d219aa7853..d4ed76afa1 100644 --- a/package.json +++ b/package.json @@ -3958,6 +3958,1536 @@ "command": "emacs-mcx.killRectangle", "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" }, + { + "key": "s", + "command": "emacs-mcx.StartRegisterSaveCommand", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" + }, + { + "key": "i", + "command": "emacs-mcx.StartRegisterInsertCommand", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus" + }, + { + "key": " ", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + " " + ] + }, + { + "key": "!", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "!" + ] + }, + { + "key": "\"", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "\"" + ] + }, + { + "key": "#", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "#" + ] + }, + { + "key": "$", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "$" + ] + }, + { + "key": "%", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "%" + ] + }, + { + "key": "&", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "&" + ] + }, + { + "key": "'", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "'" + ] + }, + { + "key": "(", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "(" + ] + }, + { + "key": ")", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + ")" + ] + }, + { + "key": "*", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "*" + ] + }, + { + "key": "+", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "+" + ] + }, + { + "key": ",", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "," + ] + }, + { + "key": "-", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "-" + ] + }, + { + "key": ".", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "." + ] + }, + { + "key": "/", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "/" + ] + }, + { + "key": "0", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "0" + ] + }, + { + "key": "1", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "1" + ] + }, + { + "key": "2", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "2" + ] + }, + { + "key": "3", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "3" + ] + }, + { + "key": "4", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "4" + ] + }, + { + "key": "5", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "5" + ] + }, + { + "key": "6", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "6" + ] + }, + { + "key": "7", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "7" + ] + }, + { + "key": "8", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "8" + ] + }, + { + "key": "9", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "9" + ] + }, + { + "key": ":", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + ":" + ] + }, + { + "key": ";", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + ";" + ] + }, + { + "key": "<", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "<" + ] + }, + { + "key": "=", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "=" + ] + }, + { + "key": ">", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + ">" + ] + }, + { + "key": "?", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "?" + ] + }, + { + "key": "@", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "@" + ] + }, + { + "key": "A", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "A" + ] + }, + { + "key": "B", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "B" + ] + }, + { + "key": "C", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "C" + ] + }, + { + "key": "D", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "D" + ] + }, + { + "key": "E", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "E" + ] + }, + { + "key": "F", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "F" + ] + }, + { + "key": "G", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "G" + ] + }, + { + "key": "H", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "H" + ] + }, + { + "key": "I", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "I" + ] + }, + { + "key": "J", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "J" + ] + }, + { + "key": "K", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "K" + ] + }, + { + "key": "L", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "L" + ] + }, + { + "key": "M", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "M" + ] + }, + { + "key": "N", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "N" + ] + }, + { + "key": "O", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "O" + ] + }, + { + "key": "P", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "P" + ] + }, + { + "key": "Q", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "Q" + ] + }, + { + "key": "R", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "R" + ] + }, + { + "key": "S", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "S" + ] + }, + { + "key": "T", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "T" + ] + }, + { + "key": "U", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "U" + ] + }, + { + "key": "V", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "V" + ] + }, + { + "key": "W", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "W" + ] + }, + { + "key": "X", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "X" + ] + }, + { + "key": "Y", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "Y" + ] + }, + { + "key": "Z", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "Z" + ] + }, + { + "key": "[", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "[" + ] + }, + { + "key": "\\", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "\\" + ] + }, + { + "key": "]", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "]" + ] + }, + { + "key": "^", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "^" + ] + }, + { + "key": "_", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "_" + ] + }, + { + "key": "`", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "`" + ] + }, + { + "key": "a", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "a" + ] + }, + { + "key": "b", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "b" + ] + }, + { + "key": "c", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "c" + ] + }, + { + "key": "d", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "d" + ] + }, + { + "key": "e", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "e" + ] + }, + { + "key": "f", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "f" + ] + }, + { + "key": "g", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "g" + ] + }, + { + "key": "h", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "h" + ] + }, + { + "key": "i", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "i" + ] + }, + { + "key": "j", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "j" + ] + }, + { + "key": "k", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "k" + ] + }, + { + "key": "l", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "l" + ] + }, + { + "key": "m", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "m" + ] + }, + { + "key": "n", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "n" + ] + }, + { + "key": "o", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "o" + ] + }, + { + "key": "p", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "p" + ] + }, + { + "key": "q", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "q" + ] + }, + { + "key": "r", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "r" + ] + }, + { + "key": "s", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "s" + ] + }, + { + "key": "t", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "t" + ] + }, + { + "key": "u", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "u" + ] + }, + { + "key": "v", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "v" + ] + }, + { + "key": "w", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "w" + ] + }, + { + "key": "x", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "x" + ] + }, + { + "key": "y", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "y" + ] + }, + { + "key": "z", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "z" + ] + }, + { + "key": "{", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "{" + ] + }, + { + "key": "|", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "|" + ] + }, + { + "key": "}", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "}" + ] + }, + { + "key": "~", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterSaveMode", + "command": "emacs-mcx.RegisterSaveCommand", + "args": [ + "~" + ] + }, + { + "key": " ", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + " " + ] + }, + { + "key": "!", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "!" + ] + }, + { + "key": "\"", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "\"" + ] + }, + { + "key": "#", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "#" + ] + }, + { + "key": "$", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "$" + ] + }, + { + "key": "%", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "%" + ] + }, + { + "key": "&", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "&" + ] + }, + { + "key": "'", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "'" + ] + }, + { + "key": "(", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "(" + ] + }, + { + "key": ")", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + ")" + ] + }, + { + "key": "*", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "*" + ] + }, + { + "key": "+", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "+" + ] + }, + { + "key": ",", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "," + ] + }, + { + "key": "-", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "-" + ] + }, + { + "key": ".", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "." + ] + }, + { + "key": "/", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "/" + ] + }, + { + "key": "0", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "0" + ] + }, + { + "key": "1", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "1" + ] + }, + { + "key": "2", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "2" + ] + }, + { + "key": "3", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "3" + ] + }, + { + "key": "4", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "4" + ] + }, + { + "key": "5", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "5" + ] + }, + { + "key": "6", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "6" + ] + }, + { + "key": "7", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "7" + ] + }, + { + "key": "8", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "8" + ] + }, + { + "key": "9", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "9" + ] + }, + { + "key": ":", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + ":" + ] + }, + { + "key": ";", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + ";" + ] + }, + { + "key": "<", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "<" + ] + }, + { + "key": "=", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "=" + ] + }, + { + "key": ">", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + ">" + ] + }, + { + "key": "?", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "?" + ] + }, + { + "key": "@", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "@" + ] + }, + { + "key": "A", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "A" + ] + }, + { + "key": "B", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "B" + ] + }, + { + "key": "C", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "C" + ] + }, + { + "key": "D", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "D" + ] + }, + { + "key": "E", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "E" + ] + }, + { + "key": "F", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "F" + ] + }, + { + "key": "G", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "G" + ] + }, + { + "key": "H", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "H" + ] + }, + { + "key": "I", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "I" + ] + }, + { + "key": "J", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "J" + ] + }, + { + "key": "K", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "K" + ] + }, + { + "key": "L", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "L" + ] + }, + { + "key": "M", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "M" + ] + }, + { + "key": "N", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "N" + ] + }, + { + "key": "O", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "O" + ] + }, + { + "key": "P", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "P" + ] + }, + { + "key": "Q", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "Q" + ] + }, + { + "key": "R", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "R" + ] + }, + { + "key": "S", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "S" + ] + }, + { + "key": "T", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "T" + ] + }, + { + "key": "U", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "U" + ] + }, + { + "key": "V", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "V" + ] + }, + { + "key": "W", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "W" + ] + }, + { + "key": "X", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "X" + ] + }, + { + "key": "Y", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "Y" + ] + }, + { + "key": "Z", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "Z" + ] + }, + { + "key": "[", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "[" + ] + }, + { + "key": "\\", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "\\" + ] + }, + { + "key": "]", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "]" + ] + }, + { + "key": "^", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "^" + ] + }, + { + "key": "_", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "_" + ] + }, + { + "key": "`", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "`" + ] + }, + { + "key": "a", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "a" + ] + }, + { + "key": "b", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "b" + ] + }, + { + "key": "c", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "c" + ] + }, + { + "key": "d", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "d" + ] + }, + { + "key": "e", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "e" + ] + }, + { + "key": "f", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "f" + ] + }, + { + "key": "g", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "g" + ] + }, + { + "key": "h", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "h" + ] + }, + { + "key": "i", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "i" + ] + }, + { + "key": "j", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "j" + ] + }, + { + "key": "k", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "k" + ] + }, + { + "key": "l", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "l" + ] + }, + { + "key": "m", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "m" + ] + }, + { + "key": "n", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "n" + ] + }, + { + "key": "o", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "o" + ] + }, + { + "key": "p", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "p" + ] + }, + { + "key": "q", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "q" + ] + }, + { + "key": "r", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "r" + ] + }, + { + "key": "s", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "s" + ] + }, + { + "key": "t", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "t" + ] + }, + { + "key": "u", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "u" + ] + }, + { + "key": "v", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "v" + ] + }, + { + "key": "w", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "w" + ] + }, + { + "key": "x", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "x" + ] + }, + { + "key": "y", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "y" + ] + }, + { + "key": "z", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "z" + ] + }, + { + "key": "{", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "{" + ] + }, + { + "key": "|", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "|" + ] + }, + { + "key": "}", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "}" + ] + }, + { + "key": "~", + "when": "emacs-mcx.acceptingRectCommand && editorTextFocus && emacs-mcx.inRegisterInsertMode", + "command": "emacs-mcx.RegisterInsertCommand", + "args": [ + "~" + ] + }, { "key": "y", "command": "emacs-mcx.yankRectangle", diff --git a/src/commands/registers.ts b/src/commands/registers.ts new file mode 100644 index 0000000000..388f48d266 --- /dev/null +++ b/src/commands/registers.ts @@ -0,0 +1,56 @@ +import * as vscode from "vscode"; +import { EmacsCommand, IEmacsCommandInterrupted } from "."; + +// Will bind this this to C-x r s +export class StartRegisterSaveCommand extends EmacsCommand implements IEmacsCommandInterrupted { + public readonly id = "StartRegisterSaveCommand"; + + private acceptingRegisterSaveCommand = false; + + private startRegisterSaveCommand(): void { + this.acceptingRegisterSaveCommand = true; + vscode.commands.executeCommand("setContext", "emacs-mcx.inRegisterSaveMode", true); + } + + private stopRegisterSaveCommand(): void { + this.acceptingRegisterSaveCommand = false; + vscode.commands.executeCommand("setContext", "emacs-mcx.inRegisterSaveMode", false); + } + + public execute(): void { + this.startRegisterSaveCommand(); + } + + public onDidInterruptTextEditor(): void { + if (this.acceptingRegisterSaveCommand) { + this.stopRegisterSaveCommand(); + } + } +} + +// Will bind this this to C-x r i +export class StartRegisterInsertCommand extends EmacsCommand implements IEmacsCommandInterrupted { + public readonly id = "StartRegisterInsertCommand"; + + private acceptingRegisterInsertCommand = false; + + public startRegisterInsertCommand(): void { + this.acceptingRegisterInsertCommand = true; + vscode.commands.executeCommand("setContext", "emacs-mcx.inRegisterInsertMode", true); + } + + private stopRegisterInsertCommand(): void { + this.acceptingRegisterInsertCommand = false; + vscode.commands.executeCommand("setContext", "emacs-mcx.inRegisterInsertMode", false); + } + + public execute(): void { + this.startRegisterInsertCommand(); + } + + public onDidInterruptTextEditor(): void { + if (this.acceptingRegisterInsertCommand) { + this.stopRegisterInsertCommand(); + } + } +} diff --git a/src/emulator-map.ts b/src/emulator-map.ts index 8be96e2a92..2bebe30f14 100644 --- a/src/emulator-map.ts +++ b/src/emulator-map.ts @@ -7,11 +7,13 @@ export class EmacsEmulatorMap { private emacsEmulatorMap: Map; private killRing: KillRing; private minibuffer: Minibuffer; + private textRegister: Map; - constructor(killRing: KillRing, minibuffer: Minibuffer) { + constructor(killRing: KillRing, minibuffer: Minibuffer, textRegister: Map) { this.emacsEmulatorMap = new Map(); this.killRing = killRing; this.minibuffer = minibuffer; + this.textRegister = textRegister; } public getOrCreate(editor: TextEditor): [EmacsEmulator, boolean] { @@ -22,7 +24,7 @@ export class EmacsEmulatorMap { if (!emacsEmulator) { isNew = true; - emacsEmulator = new EmacsEmulator(editor, this.killRing, this.minibuffer); + emacsEmulator = new EmacsEmulator(editor, this.killRing, this.minibuffer, this.textRegister); this.emacsEmulatorMap.set(editorId, emacsEmulator); } else { emacsEmulator.setTextEditor(editor); diff --git a/src/emulator.ts b/src/emulator.ts index ea3037d9aa..858715b357 100644 --- a/src/emulator.ts +++ b/src/emulator.ts @@ -10,6 +10,8 @@ import * as KillCommands from "./commands/kill"; import * as MoveCommands from "./commands/move"; import * as PareditCommands from "./commands/paredit"; import * as RectangleCommands from "./commands/rectangle"; +import { StartRegisterSaveCommand, StartRegisterInsertCommand } from "./commands/registers"; +import { getNonEmptySelections } from "./commands/helpers/selection"; import { RecenterTopBottom } from "./commands/recenter"; import { EmacsCommandRegistry } from "./commands/registry"; import { KillYanker } from "./kill-yank"; @@ -38,6 +40,7 @@ export interface IEmacsController { export class EmacsEmulator implements IEmacsController, vscode.Disposable { private textEditor: TextEditor; + private textRegister: Map; private commandRegistry: EmacsCommandRegistry; @@ -107,10 +110,12 @@ export class EmacsEmulator implements IEmacsController, vscode.Disposable { textEditor: TextEditor, killRing: KillRing | null = null, minibuffer: Minibuffer = new InputBoxMinibuffer(), + textRegister: Map = new Map(), ) { this.textEditor = textEditor; this.setNativeSelections(this.rectMode ? [] : textEditor.selections); // TODO: `[]` is workaround. + this.textRegister = textRegister; this.markRing = new MarkRing(Configuration.instance.markRingMax); this.prevExchangedMarks = null; @@ -172,6 +177,9 @@ export class EmacsEmulator implements IEmacsController, vscode.Disposable { this.killYanker = killYanker; // TODO: To be removed this.registerDisposable(killYanker); + this.commandRegistry.register(new StartRegisterSaveCommand(this)); + this.commandRegistry.register(new StartRegisterInsertCommand(this)); + const rectangleState: RectangleCommands.RectangleState = { latestKilledRectangle: [], }; @@ -592,4 +600,59 @@ export class EmacsEmulator implements IEmacsController, vscode.Disposable { } }); } + + public saveRegister(arg: string): void { + const selectionsAfterRectDisabled = + this.inRectMarkMode && + this.nativeSelections.map((selection) => { + const newLine = selection.active.line; + const newChar = Math.min(selection.active.character, selection.anchor.character); + return new vscode.Selection(newLine, newChar, newLine, newChar); + }); + const selections = getNonEmptySelections(this.textEditor); + if (selectionsAfterRectDisabled) { + this.textEditor.selections = selectionsAfterRectDisabled; + } + // selections is now a list of non empty selections, iterate through them and + // build a single variable combinedtext + let i = 0; + let combinedtext = ""; + while (i < selections.length) { + combinedtext = combinedtext + this.textEditor.document.getText(selections[i]); + i++; + } + + const register_string = arg; + if (register_string == null) { + return; + } + + this.textRegister.set(register_string, combinedtext); + // After copying the selection, get out of mark mode and de-select the selections + this.exitMarkMode(); + this.makeSelectionsEmpty(); + } + + public async insertRegister(arg: string): Promise { + if (!this.textRegister.has(arg)) { + return; + } + + const textToInsert = this.textRegister.get(arg); + if (textToInsert == undefined) { + return; + } + // Looking for how to insert-replace with selections highlighted.... must copy-paste from Yank command + const selections = this.textEditor.selections; + + await this.textEditor.edit((editBuilder) => { + selections.forEach((selection) => { + if (!selection.isEmpty) { + editBuilder.delete(selection); + } + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + editBuilder.insert(selection.start, textToInsert); + }); + }); + } } diff --git a/src/extension.ts b/src/extension.ts index 3a237eea57..f91523f0cb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -22,8 +22,9 @@ export function activate(context: vscode.ExtensionContext): void { const killRing = new KillRing(Configuration.instance.killRingMax); const minibuffer = new InputBoxMinibuffer(); + const textRegister = new Map(); - const emulatorMap = new EmacsEmulatorMap(killRing, minibuffer); + const emulatorMap = new EmacsEmulatorMap(killRing, minibuffer, textRegister); function getAndUpdateEmulator() { const activeTextEditor = vscode.window.activeTextEditor; @@ -358,6 +359,36 @@ export function activate(context: vscode.ExtensionContext): void { emulator.runCommand("paredit.backwardKillSexp"); }); + registerEmulatorCommand("emacs-mcx.StartRegisterSaveCommand", (emulator) => { + return emulator.runCommand("StartRegisterSaveCommand"); + }); + + registerEmulatorCommand("emacs-mcx.StartRegisterInsertCommand", (emulator) => { + return emulator.runCommand("StartRegisterInsertCommand"); + }); + + registerEmulatorCommand("emacs-mcx.RegisterSaveCommand", (emulator, args) => { + if (!Array.isArray(args)) { + return; + } + const arg = args[0]; + if (typeof arg !== "string") { + return; + } + return emulator.saveRegister(arg); + }); + + registerEmulatorCommand("emacs-mcx.RegisterInsertCommand", (emulator, args) => { + if (!Array.isArray(args)) { + return; + } + const arg = args[0]; + if (typeof arg !== "string") { + return; + } + return emulator.insertRegister(arg); + }); + vscode.commands.registerCommand("emacs-mcx.executeCommands", async (...args: any[]) => { if (1 <= args.length) { executeCommands(args[0]);