Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key remappings for mouse configuration #9469

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Nilsia
Copy link

@Nilsia Nilsia commented Jan 29, 2024

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 : #7982

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Feb 7, 2024
@the-mikedavis the-mikedavis added the S-waiting-on-review Status: Awaiting review from a maintainer. label Feb 10, 2024
mouse_keys::MIDDLE => MouseEventKind::Down(MouseButton::Middle),
mouse_keys::RIGHT => MouseEventKind::Down(MouseButton::Right),
mouse_keys::SCROLL_DOWN => MouseEventKind::ScrollDown,
mouse_keys::SCROLL_UP => MouseEventKind::ScrollUp,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot left and right scroll here

@thecaralice
Copy link

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
Copy link

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)

}

fn scroll_mouse_impl(cx: &mut Context, evt: &MouseEvent, dir: Direction, _: &mut EditorView) {
let current_view = cx.editor.tree.focus;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if a picker has the focus?

currently the mouse wheel does not scroll the code preview in the picker, but the code in the current buffer.

@Nilsia
Copy link
Author

Nilsia commented Apr 8, 2024

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
Copy link
Author

Nilsia commented Apr 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants