[BUG] Build error when using `ncurses-backend`
Describe the bug
When trying to build my File Editor TUI using ncurses-backend I am getting an implementation error related to cursive v0.21.1. As I upgraded to cursive v0.21.1, this error does not occur in cursive v0.20.0.
To Reproduce
Build any app on MacOS using ncurses-backend this error occurs.
Expected behavior A working Build.
Environment
- MacOS
- Backend used:
ncurses - Current locale:
LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
- Cursive version:
v0.21.1
Additional context Error trace:
Compiling cursive v0.21.1
error[E0425]: cannot find value `BUTTON5_DOUBLE_CLICKED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:267:52
|
267 | (mevent.bstate == ncurses::BUTTON5_DOUBLE_CLICKED as mmask_t)
| ^^^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_DOUBLE_CLICKED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:129:1
|
129 | pub const BUTTON1_DOUBLE_CLICKED: i32 = 8;
| ------------------------------------- similarly named constant `BUTTON1_DOUBLE_CLICKED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_RELEASED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:437:18
|
437 | ncurses::BUTTON5_RELEASED
| ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_RELEASED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:126:1
|
126 | pub const BUTTON1_RELEASED: i32 = 1;
| ------------------------------- similarly named constant `BUTTON1_RELEASED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_PRESSED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:438:20
|
438 | | ncurses::BUTTON5_PRESSED
| ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_PRESSED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:127:1
|
127 | pub const BUTTON1_PRESSED: i32 = 2;
| ------------------------------ similarly named constant `BUTTON1_PRESSED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_CLICKED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:439:20
|
439 | | ncurses::BUTTON5_CLICKED
| ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_CLICKED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:128:1
|
128 | pub const BUTTON1_CLICKED: i32 = 4;
| ------------------------------ similarly named constant `BUTTON1_CLICKED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_DOUBLE_CLICKED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:440:20
|
440 | | ncurses::BUTTON5_DOUBLE_CLICKED
| ^^^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_DOUBLE_CLICKED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:129:1
|
129 | pub const BUTTON1_DOUBLE_CLICKED: i32 = 8;
| ------------------------------------- similarly named constant `BUTTON1_DOUBLE_CLICKED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_TRIPLE_CLICKED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:441:20
|
441 | | ncurses::BUTTON5_TRIPLE_CLICKED => MouseButton::Button5,
| ^^^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_TRIPLE_CLICKED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:130:1
|
130 | pub const BUTTON1_TRIPLE_CLICKED: i32 = 16;
| ------------------------------------- similarly named constant `BUTTON1_TRIPLE_CLICKED` defined here
error[E0531]: cannot find unit struct, unit variant or constant `BUTTON5_PRESSED` in crate `ncurses`
--> /Users/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive-0.21.1/src/backends/curses/n.rs:466:18
|
466 | ncurses::BUTTON5_PRESSED => f(MouseEvent::WheelDown),
| ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `BUTTON1_PRESSED`
|
::: /Users/nils/Documents/code/sys/omega/target/debug/build/ncurses-0d2a84155b7472a5/out/raw_constants.rs:127:1
|
127 | pub const BUTTON1_PRESSED: i32 = 2;
| ------------------------------ similarly named constant `BUTTON1_PRESSED` defined here
Some errors have detailed explanations: E0425, E0531.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `cursive` (lib) due to 7 previous errors
Hi, and thanks for the report!
I'm not super familiar with building ncurses on macos (you may have better luck using the crossterm backend for example). It looks like an issue in the ncurses-rs crate. Unfortunately this repo has since been archived, and will likely not get fixes.
We could consider switching to another ncurses rust bindings, maybe https://github.com/narfit66/ncursesw-rs (though it also hasn't been updated for 3 years).
Is there a reason you need the ncurses backend specifically, and not crossterm or termion? The main advantage of ncurses is the somewhat better input support (things like shift/ctrl + Fn keys are better supported, at least on linux). It also used to have a performance advantage, but the other backends should have caught up by now.
I just want to have working color support for macOS built in terminal app. The built in terminal is a little bit quirky because (1) users can have there own terminal coloring, which interferes with coloring from crossterm/termion, and (2) not by default enabled 256-color & truecolor support. The easiest fix for me was to use ncurses which is able to handle these edge cases…