Is a dynamic menu listing register contents possible? #280
-
Beta Was this translation helpful? Give feedback.
Answered by
SecretPocketCat
Feb 4, 2025
Replies: 1 comment
-
I'm gonna answer myself a couple years later after coming back to Dance 😅. // yank to register menu
{
"key": "shift+y",
"command": "dance.run",
"args": {
"code": [
"const registers = 'arstneio';",
"const items = {};",
"for (register of registers) {",
" items[register] = { text: await Registers.value(register, 0), command: 'dance.selections.saveText', args: { register } };",
"}",
"const menu = { title: `Yank to [register]`, items };",
"await showMenu(menu);"
]
},
"when": "editorTextFocus && dance.mode == 'normal'"
},
// paste from register menu
{
"key": "shift+p",
"command": "dance.run",
"args": {
"code": [
"const registers = 'arstneio';",
"const items = {};",
"for (register of registers) {",
" items[register] = { text: await Registers.value(register, 0), command: 'dance.edit.insert', args: { register } };",
"}",
"const menu = { title: `Paste from [register]`, items };",
"await showMenu(menu);"
]
},
"when": "editorTextFocus && dance.mode == 'normal'"
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SecretPocketCat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm gonna answer myself a couple years later after coming back to Dance 😅.
Not sure whether it was possible back then, but now it's with a
dance.run
binding coupled with acode
arg.The following snippet dynamically creates a menu with an item for each homerow key (colemak), show's the content of each register and either yanks into the register or pastes from it: