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

Can't scroll using mouse in a terminal ? #153

Closed
Adham-A opened this issue Jul 27, 2023 · 6 comments
Closed

Can't scroll using mouse in a terminal ? #153

Adham-A opened this issue Jul 27, 2023 · 6 comments
Labels

Comments

@Adham-A
Copy link
Contributor

Adham-A commented Jul 27, 2023

Hello,
I can't seem to scroll using my mouse in a terminal, I tried outside and inside vscode but without success. Is it even possible or is it an issue on my computer ?

@Canop
Copy link
Owner

Canop commented Jul 27, 2023

vscode ? Is that issue related to bacon ?

If it is, then yes, you should be able to use the mouse wheel to scroll the report in bacon.

@Adham-A
Copy link
Contributor Author

Adham-A commented Jul 28, 2023

I'm on Windows, and I tried in Git Bash, CMD and powershell and I still have the same issue outside of vscode this time

@Adham-A
Copy link
Contributor Author

Adham-A commented Aug 21, 2023

On Linux

  • Scrolling fires the "Up" & "Down" events, same as using those buttons on the keyboard.

On Windows

  • No events are fired, but there is supposed to be.

Investigations :

I tried getting Mouse Events instead of key events inside the project with no luck, I then tried in an empty project with only termimad and I didn't succeed either. I then directly tried with crossterm and it worked, firing ScrollDown & ScrollUp

After some investigation you have to :

   // Have to do this part because of crossterm
    let mut stdout = io::stdout();
    execute!(
        stdout,
        EnableMouseCapture, // termimad::crossterm::event::EnableMouseCapture
    )?;
    // Have to do this part because of crossterm`

And then match the events :

#[cfg(windows)]
Event::Mouse(mouse_event) => {
    let key_code =
    match mouse_event.kind {
        MouseEventKind::ScrollDown => {KeyCode::Down}
        MouseEventKind::ScrollUp => {KeyCode::Up}
        _ => {KeyCode::Null}
    };
    action = keybindings.get(KeyEvent::new(key_code,KeyModifiers::NONE));
}
#[cfg(not(windows))]
_ => {}

If this is going to be merged :

I created an action using Down and Up to try to stay coherent to the rest.
And I will welcome some feedback to have something cleaner especially regarding the crossterm part with EnableMouseCapture.

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

Thanks for the investigation. I should have rememembered this myself as I had the problem before in broot.

Regarding your code, I'll comment on the PR

@Canop
Copy link
Owner

Canop commented Sep 15, 2023

Now fixed in 2.13.0

@Canop Canop closed this as completed Sep 15, 2023
@willhansen
Copy link

(On linux)

Works in normal terminals, but not in tmux. I think tmux detects if the program captures mouse events, and forwards the mouse events to the program only if so.

Probably related to the mentioned EnableMouseCapture thing.

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

No branches or pull requests

3 participants