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

Allow to specify button to use in hints.mouse #8486

Open
kchibisov opened this issue Feb 17, 2025 · 11 comments
Open

Allow to specify button to use in hints.mouse #8486

kchibisov opened this issue Feb 17, 2025 · 11 comments

Comments

@kchibisov
Copy link
Member

Should be relatively simple, just additional button = field with default to Left, so it's not a breaking change.

@thithib
Copy link

thithib commented Feb 17, 2025

Note that hints.mouse is currently about underlining the hint when hovering over the hint text, and not about specifying a mouse binding that triggers the action/command.

Just to be clear, what #4063 was asking initially (and what I'm interested in) is the ability to right click on a URL in order to copy it to the clipboard, without opening it.

@kchibisov
Copy link
Member Author

kchibisov commented Feb 17, 2025

mouse is of form mouse = { enabled = true | false, mods = "" }, so adding button = will be fine.

@risangbaskoro
Copy link

What is default for MouseBindings when the user, for example, set the mouse.button = "Right"?

@kchibisov
Copy link
Member Author

The default mouse binding is to expand selection.

@risangbaskoro
Copy link

risangbaskoro commented Feb 22, 2025

I am thinking of modifying generate_hint_bindings in ui_config.rs to also push a MouseBinding to Mouse with the trigger being HintMouse.button.

Something like:

    pub fn generate_hint_bindings(&mut self) {
        for hint in &self.hints.enabled {
            let binding = match &hint.binding {
                Some(binding) => binding,
                None => continue,
            };

            if let Some(hint_mouse) = hint.mouse {
                if hint_mouse.enabled {
                    let mouse_binding = MouseBinding {
                        trigger: hint_mouse.button.0,
                        mods: hint_mouse.mods.0,
                        mode: binding.mode.mode,
                        notmode: binding.mode.not_mode,
                        action: Action::Hint(hint.clone()),
                    };
                    self.mouse.bindings.0.push(mouse_binding);
                }
            }

            // Keyboard binding after...
        }
    }

Am I going in the right direction?

@kchibisov
Copy link
Member Author

Do you want to purge the default that way? I think we should just purge the default or something and it's general with keyboard.

@risangbaskoro
Copy link

Any hint on how you want the conflict to resolve if the mouse.button is already in default MouseBindings?

@kchibisov
Copy link
Member Author

Default should be purged, like it's right now. If you have them in two places, both should act. Maybe @chrisduerr has a better idea how to deal with it, since we have the same issue with keyboard hints.

@chrisduerr
Copy link
Member

Maybe @chrisduerr has a better idea how to deal with it, since we have the same issue with keyboard hints.

There's a reason why I don't want to implement this.

@risangbaskoro
Copy link

I apologize for asking this question. I am new to the codebase.

What function that enables me to disable hint selection if the hint is triggered by a mouse button? I noticed left click always open the pattern too (in MacOS).

Also, I think we can remove from default only the same key registered by mouse.button. E.g. if mouse.button = "Right", then we can remove only Right mouse bindings from the default. What do you think?

@kchibisov
Copy link
Member Author

The logic on how things are removed should be the same as for the regular keyboard/mouse bindings.

What function that enables me to disable hint selection if the hint is triggered by a mouse button? I noticed left click always open the pattern too (in MacOS).

Not sure what you mean by that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants