helix icon indicating copy to clipboard operation
helix copied to clipboard

Key remappings for mouse configuration

Open Nilsia opened this issue 1 year ago • 4 comments

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

Nilsia avatar Jan 29 '24 16:01 Nilsia

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.

thecaralice avatar Feb 25 '24 06:02 thecaralice

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)

thecaralice avatar Feb 25 '24 06:02 thecaralice

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.

Nilsia avatar Apr 08 '24 06:04 Nilsia

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.

Nilsia avatar Apr 23 '24 08:04 Nilsia