I put this code in my init.moon
howl.bindings.push ctrl_e: 'howl-moon-eval'
Then in any buffer I can select a snippet of moonscript code and press ctrl_e to evaluate it
insertmethod that inserts text at the cursor.
To get the editor you just need
howl.app.editor, so this code works for me:
This inserts text at the cursor position
OK, so to finally make it a command:
howl.command.register name: 'type-hello' description: 'types "hello" at cursor position' handler: -> howl.app.editor\insert('hello')
Note that you can just select this snippet in your editor and eval it, the command is immediately registered.
alt_x and press tab, start typing
type-h and you should see the command. You can run it too.
Finally, let's give it a shortcut:
howl.bindings.push f3: 'type-hello'
Now f3 should invoke your new command. Hope this works.
insert(text, pos). Since it takes the position, you need to get the cursor position
howl.app.editor.cursor.posand pass it in.
howl.mode(by means of
debug.setupvalue) to make
word_patterna config variable
Is there an easy way to get
Editor-local key bindings, like in other text editors?
I'm writing a language bundle, and its key bindings can only work for a few select languages.
Right now the keymap is global, and I get error messages when I use those keys in other files.
(The bundle "hijacks" keys like
Even if I only push the keymap when a specific mode is activated, the issue will still be there if I have more than one file opened.
The only ways (that I can think of) to achieve similar effect is to either
Editor.buffer.file.extensionfrom within the key handlers and, if not the right one, let the key event propagate further , or
editor-*focusedevents, and proactively push/remove the keymap from the bindings stack.
One of these will probably get me what I want, but it looks like too much work, compared to what I've used in other editors.
I read the modes docs, and it seems like they can't help either.
So, again, is there an easier way?