cursive icon indicating copy to clipboard operation
cursive copied to clipboard

[BUG] Terminal unresponsive when using Cursive with crossterm-backend and echo

Open joelparkerhenderson opened this issue 1 year ago • 4 comments

(UPDATE: The bug is due to https://github.com/crossterm-rs/crossterm/issues/500 and there is work in progress to fix it at https://github.com/crossterm-rs/crossterm/pull/711)

The bug seems to be unique to the crossterm-backend, so I'm reporting the bug here: https://github.com/crossterm-rs/crossterm/issues/725

The rest of this text is copy/paste from the link above.

Describe the bug

Terminal is unresponsive when using Crossterm and Cursive, when enabling Cursive feature crossterm-backend.

Specifically, Cursive launches the TUI, but it doesn't respond to key presses.

For comparison, the same app works fine with other Cursive backends, including ncurses, pancurses, termion.

To Reproduce

Minimal reproduction code.

File Cargo.toml includes:

[dependencies]
cursive = { version = "*", features = ["crossterm-backend"] }

File main.rs:

fn main() {
    let mut c = cursive::crossterm();
    c.run();
}

Run:

./target/debug/demo

Cursive shows a blank screen, as expected.

Press ctrl-c to exit, as expected.

Run:

echo "" | ./target/debug/demo

Cursive shows a blank screen, as expected.

Press ctrl-c to exit-- but it doesn't work. This is the bug. A real-world app with more kinds of inputs has all of the fail, such as for Checkbox, EditView, tec.

Expected behavior

Expected: Cursive responds to keys.

Actual: Cursive does not responds to keys.

I've confirmed this problem happens with other kinds of UI/UX, such as other keypresses, and also by using other Cursive functionality, such as a TextView, or EditView, or Button, etc.

OS

macOS Ventura 13.0 on a MacBook Pro with Apple M1 Max chip

Terminal/Console

macOS Terminal app i.e. the default macOS terminal application

Question

When the Crossterm documentation states "It supports all UNIX and Windows terminals down to Windows 7", does Crossterm currently support UNIX on macOS with Apple M1? I ask because I see some past posts that discuss Crossterm macOS M1 issues/incompatibilities/roadmaps.

If yes, then what's the next step please, to troubleshoot this bug?

If no, then could a maintainer edit to the README and documentation to note that Crossterm is currently not intending to be run on macOS with Apple M1?

Thank you for your consideration.

joelparkerhenderson avatar Oct 30 '22 19:10 joelparkerhenderson

Hi, and thanks for the report!

Note that the sample code here listens to the escape key, not 'q'.

Can you run the other examples from this repository? If you press Ctrl-C, does it quit the application?

If you use the termion backend, does it work properly?

gyscos avatar Oct 30 '22 19:10 gyscos

(UPDATE: The bug is due to https://github.com/crossterm-rs/crossterm/issues/500 and there is work in progress to fix it at https://github.com/crossterm-rs/crossterm/pull/711)

Thank you. I goofed on the minimal example-- my apologies-- I have now corrected it above.

The real code is http://github.com/sixarm/checkline-rust-crate/

When the code uses crossterm, then the entire terminal hangs, including ctrl-c.

When the code uses termion, or ncurses, then everything works as expected.

In case it's helpful to see, I tried the Crossterm examples, and found the same symptom...

Reproduce:

git clone [email protected]:crossterm-rs/crossterm.git
cd crossterm/examples/interactive-demo
cargo build

This succeeds:

./target/debug/interactive-demo

This hangs:

echo "" | ./target/debug/interactive-demo

joelparkerhenderson avatar Oct 31 '22 01:10 joelparkerhenderson

Arf yeah it's unfortunate that crossterm doesn't support /dev/tty on macOS. I suppose until they fix it, another backend like termion may be a better solution.

gyscos avatar Nov 01 '22 19:11 gyscos

Yes. Termion succeeds with stdin, but crashes with stdout pipe.

Pseudocode example:

$ echo "foo" | myapp
hello world

$ echo "foo" | myapp | grep "h"
(crash)

The same app works fine using ncurses backend.

joelparkerhenderson avatar Nov 02 '22 06:11 joelparkerhenderson