helix
helix copied to clipboard
Key remappings for mouse configuration
Feature: from the configuration file, it is now possible to map mouse buttons on some helix functionality.
Code: Added new simple structures for Mousemaps, and cloned only few key maps functions into mouse functions, do not hesitate if more are required.
Updated / Added tests for mouses in configuration.
This is a pull request for this issue : https://github.com/helix-editor/helix/issues/7982
Looks like only a dozen or so commands are available for mapping to mouse events, suffixed with _mouse
and non-discoverable (i.e. not listed in ?
picker). I feel like it should be possible to bind other commands to mouse events without duplicating everything.
What I expected to work (aka "two-finger scroll moves through time instead of space" aka xkcd:1806):
[mouse.normal]
scroll_right = "undo"
scroll_left = "redo"
Vim supports that as
nnoremap <ScrollWheelRight> :earlier<CR>
nnoremap <ScrollWheelLeft> :later<CR>
(source: r/vim)
I am trying to concatenate both STATIC_COMMANDS list through a macros without repeating everything, however, the macro does not seem nice. Well you'll see, I do not know if a procedural macros is going to be better for this usage.
I have pushed a new macro which generate the commands, avoiding repetition of code when generation them.
However there are some things that I do not really like :
- the second state of the macro is a bit big, I would have wanted to to something like the generation of the keyboard, but I cannot call macros inside my own macro calls.
- all functions are duplicated, however, this could be avoided with the @both pattern, with converting MouseTrie into an enum that can take both mouse commands and key command. What do you think about that ?
- And the third one is: when generation commands that way, some mouse commands are not suffixed by _mouse, but I cannot find out examples.
I have not handled yet the current buffer focus. If you have any modifications to suggest about the @key/mouse/both, do not hesitate to tell me.