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

Escape key not detected the first time #21

Closed
CyanideForBreakfast opened this issue Apr 6, 2022 · 6 comments
Closed

Escape key not detected the first time #21

CyanideForBreakfast opened this issue Apr 6, 2022 · 6 comments

Comments

@CyanideForBreakfast
Copy link

On fetching input, Escape key event doesn't seem to be detected the first time. It takes two key-presses to detect Escape key for the first time after which it is detected at each key press.

Reproducible example -

use libnotcurses_sys::{widgets::*, *};
use env_logger;
use log::info;
use nix::poll::{ poll, PollFd, PollFlags };

fn main() -> NcResult<()> {
    env_logger::init();
    reader()
}

fn reader() -> NcResult<()> {
    let mut nc = unsafe { Nc::new()? };
    let mut stp = unsafe { nc.stdplane() };
    
    let input_fd = PollFd::new(
        unsafe { c_api::notcurses_inputready_fd(nc as *mut Nc) },
        PollFlags::POLLIN);

    let mut input_details = NcInput::new_empty();
    loop {
        if let Ok(_) = poll(&mut [input_fd], -1) {
            let recorded_input = nc.get_nblock(Some(&mut input_details))?;
            info!("Recieved {:?} {:?}", recorded_input, input_details);
        }
    }

    unsafe { nc.stop()? };
    Ok(())
}

Viewing the logs RUST_LOG=trace cargo run would reveal that each other keyboard input (characters, Tab etc) is detected on one key-press, only Escape key takes two.

The behavior is the same if I don't use polling and simply loop delayed get(). My Escape key appears to be registering perfectly for other applications so I doubt it is the issue.

Terminals - Alacritty, XTerm.

Please confirm this if this behavior is reproducible and is a bug.

@joseluis
Copy link
Collaborator

joseluis commented Apr 6, 2022

I can confirm this is happening for me too with the notcurses-input C app, therefore I recommend opening an issue in the main notcurses repo.

@dankamongmen
Copy link
Owner

i'll go ahead and make one, thanks!

@dankamongmen
Copy link
Owner

This is not happening for me in Kitty, fwiw. About to attempt verification with alacritty/XTerm.

@dankamongmen
Copy link
Owner

confirmed in alacritty/xterm. further work will take place in dankamongmen/notcurses#2646. Thanks for the report!

@dankamongmen
Copy link
Owner

i've fixed this upstream, to the best of my testing, and will cut 3.0.8 within the next few days including this fix. hack on everybody

@dankamongmen
Copy link
Owner

dankamongmen/notcurses#2648

@joseluis joseluis closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants