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

ratatui-minimal has strange behavior #14

Closed
pm100 opened this issue Apr 21, 2023 · 8 comments
Closed

ratatui-minimal has strange behavior #14

pm100 opened this issue Apr 21, 2023 · 8 comments

Comments

@pm100
Copy link
Contributor

pm100 commented Apr 21, 2023

  • sometimes when started there is an extra blank line and the cursor is positioned on the second line
  • if I type a single character it is repeated in the widget

image

Here I simply ran it and typed hello world

It only fails on windows, works on linux (WSL unbuntu 20)

BTW - minimal (with tui) works fine

@pm100
Copy link
Contributor Author

pm100 commented Apr 23, 2023

also checked on mac, works fine.

I tried to debug on windows (my main dev env) and it seemed that crossterm was generating extra events. This loop doesn't really involve ratatui. But maybe its something to do with how ratatui sets up crossterm, or what term.draw is doing

   loop {
        term.draw(|f| {
            f.render_widget(textarea.widget(), f.size());
        })?;
        match crossterm::event::read()?.into() {
            Input { key: Key::Esc, .. } => break,
            input => {
                textarea.input(input);
            }
        }
    }

but I ran out of time to investigate further. I am away from my main dev env for 6 weeks, sorry I cannot add more info

@kitsuniru
Copy link

kitsuniru commented May 1, 2023

@pm100 key doubling problem occurs in vscode terminal, but not in pure, this is crossterm problem, as i think
but in usual cmd/powershell it doesnt doubled (idk why)

main reason - app reacts to Press and Release event both as one key event

possible solution - check for event kind before action, like

if let Event::Key(key) = event::read()? {
            if key.kind == KeyEventKind::Press {
                    .....
            }
    }  

@pm100
Copy link
Contributor Author

pm100 commented May 1, 2023 via email

@kitsuniru
Copy link

kitsuniru commented May 1, 2023 via email

@pm100
Copy link
Contributor Author

pm100 commented May 2, 2023 via email

@pm100
Copy link
Contributor Author

pm100 commented May 3, 2023

I checked. This fails if run directly from powershell command line

minbug

and works fine with tui.

minbug2

@pm100
Copy link
Contributor Author

pm100 commented May 5, 2023

the cause is this crossterm-rs/crossterm#745

i have a fix to the tui-textarea inut handling which I am testing. Will PR soon

@rhysd
Copy link
Owner

rhysd commented May 9, 2023

This should be fixed by 68f4e0d

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