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

make cursive work with ncurses-rs v6 #778

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

correabuscar
Copy link

@correabuscar correabuscar commented Apr 11, 2024

but first: ncurses-rs needs the changes in this PR: jeaye/ncurses-rs#218
(technically only the ones in the last 3 commits of April 11th seen here)

However pancurses doesn't need these changes looks like, for cursive to work with it, so 0.17 seems good (but cursive's examples are not tested with 0.17).

The following were used successfully:

  • cargo build
  • cargo test
  • cargo build --all-features
  • cargo test --all-features
  • cargo build --all-targets
  • cargo test --all-targets
  • cargo build --all-targets --all-features
  • cargo test --all-targets --all-features

... on each of these target environments:

  • Gentoo 2.15 default/linux/amd64/23.0/split-usr/no-multilib (stable)
  • NixOS (if PKG_CONFIG_PATH is set to the dir containing ncurses.pc file, or used nix-shell command in cursive repo dir)
  • Fedora 39
  • Ubuntu Desktop 22.04.4 LTS (needs libncurses-dev)
    • tested to work without pkg-config and pkgconf installed.
    • tested to work with pkg-config installed.
  • FreeBSD 14.0-RELEASE
    • some examples tested
    • all examples tested
  • OpenBSD 7.5 GENERIC
    • needs one of LC_CTYPE=en_US.UTF-8 or LANG=en_US.UTF-8 to be set otherwise it looks as if it doesn't have wide chars support so cursive and pancuses examples look pretty broken.
  • MacOS Mojave v10.14.6 (with this)
    • some examples tested
    • all examples tested
  • Windows 11 WSL1 Arch Linux Linux DESKTOP 4.4.0-22621-Microsoft #2506-Microsoft Fri Jan 01 08:00:00 PST 2016 x86_64 GNU/Linux
    • some examples tested
    • all examples tested

TODO:

  • compiles(and passes cargo test) with pancurses (dep) 0.17
  • compiles(and passes cargo test) with pancurses main branch from github with this PR in.
  • see if ncurses::newterm call was ignored without a let _ = before, in v5 too. If so, keep it untouched. It wasn't. No warnings with v5.
  • does cursive need version bump in this PR? ie. version = "0.21.0" or shall this be left to be done by the repo maintainer(s) ?!
  • use exact ncurses-rs version in Cargo.toml after it gets published, ie. so it's not lower than that version, because then it would break compilation of cursive. Note that pancurses doesn't need a version bump (see above), although the examples I'm running are through the PR-ed pancurses only.
  • maybe bump pancurses in Cargo.toml too, after it gets its PR for the v6 ncurses-rs usage.
  • add cargo test --example select_test -- --nocapture in addition to the suggested --bin which doesn't work.
  • fix all warnings (because they were introduced by this PR / the upgrade to ncurses-rs v6)
    • warning: attribute should be applied to a foreign function or static #[link_name="box"] not a foreign function or static, this is on ncurses-rs
    • warning: unused Result that must be used, (for all 3 cases) happens due to CString::new This function will return an error if the supplied bytes contain an internal 0 byte.
      • ncurses::newterm .unwrap() is safe here due to using None as the first arg to newterm
      • ncurses::mvaddstr
      • ncurses::addstr
      • decide what to do when \0 is encountered in the string: ignore, unwrap, rethrow(the ? aka try operator) then fix the warnings for ncurses::mvaddstr and ncurses::addstr above.
      • Make test cases for
        • print_at with string that contains \0 in the middle.
        • print_at_rep with string that contains \0 in the middle.
        • made one #[test] for both because otherwise they'd interfere with each other during parallel testing, well maybe not unless --nocapture is used. Well, let's just say I've had to run reset to restore my terminal.
  • run cargo clippy and fix:
    • errors (there were none)
    • warnings
      • pre this PR warnings
        • warning: this seems like a manual implementation of the non-exhaustive pattern pub enum MouseButton
  • passes cargo test --features="ncurses-backend,ansi,toml"
  • I'm watching(github notifications All Activity) the entire repo for any future-reported breakage, to address it.
  • test that examples compile and run seemingly ok(on Gentoo, NixOS and Fedora):
    • advanced_user_data
    • ansi
    • autocomplete
    • builder
    • colors
    • ctrl_c
    • debug_console
    • dialog
    • edit
    • fixed_layout
    • focus
    • hello_world
    • key_codes
    • linear
    • list_view
    • logs
    • lorem
    • markup
    • menubar
    • mines
    • mutation
    • panels
    • parse
    • pause
    • position
    • progress
    • radio
    • refcell_view
    • scroll
    • select
    • select_test cargo test --example select_test -- --nocapture
    • slider
    • status
    • status_bar_ext
    • stopwatch
    • tcp_server
    • terminal_default
    • text_area
    • theme
    • theme_editor
    • theme_manual
    • themed_view
    • user_data
    • vpv
    • window_title

but ncurses-rs needs the changes in this PR first:
jeaye/ncurses-rs#218
(except the .gitignore and build.rs changes from there)
@correabuscar correabuscar changed the title make it work with ncurses-rs v6 make cursive work with ncurses-rs v6 Apr 11, 2024
@correabuscar

This comment was marked as resolved.

otherwise, nothing would get printed, silently.

for print_at() and print_at_rep() only!

this also fixes warnings about unused Result
--bin might've worked on cargo cca. 2018 ? unsure
but --example works today
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

Successfully merging this pull request may close these issues.

None yet

1 participant