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

Borders are printed as garbage #494

Closed
krytarowski opened this issue Aug 22, 2020 · 8 comments
Closed

Borders are printed as garbage #494

krytarowski opened this issue Aug 22, 2020 · 8 comments

Comments

@krytarowski
Copy link

Bug report.

https://i.imgur.com/yXdIiER.png

Problem description

https://github.com/gyscos/cursive/blob/main/doc/tutorial_2.md

use cursive::Cursive;
use cursive::views::Dialog;

fn main() {
    let mut siv = cursive::default();

    siv.add_layer(Dialog::text("This is a survey!\nPress <Next> when you're ready.")
        .title("Important survey")
        .button("Next", show_next));

    siv.run();
}

fn show_next(s: &mut Cursive) {
    s.pop_layer();
    s.add_layer(Dialog::text("Did you do the thing?")
        .title("Question 1")
        .button("Yes!", |s| show_answer(s, "I knew it! Well done!"))
        .button("No!", |s| show_answer(s, "I knew you couldn't be trusted!"))
        .button("Uh?", |s| s.add_layer(Dialog::info("Try again!"))));
}

fn show_answer(s: &mut Cursive, msg: &str) {
    s.pop_layer();
    s.add_layer(Dialog::text(msg)
        .title("Results")
        .button("Finish", |s| s.quit()));
}

Environment

  • Operating system: NetBSD chieftec 9.99.70 NetBSD 9.99.70 (GENERIC) #0: Tue Aug 11 17:40:05 CEST 2020 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
  • Backend used: ncurses
    • If using ncurses on linux, ncurses version? 6.2
  • Current locale (run locale in a terminal).
LANG=""
LC_CTYPE="pl_PL.UTF-8"
LC_COLLATE="C"
LC_TIME="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_ALL="pl_PL.UTF-8"
  • Cursive version (from crates.io, from git, ...) libcursive-04d5190404da43a1, cursive-04d5190404da43a1
@krytarowski
Copy link
Author

Analysis of the bug in cursive: https://www.unitedbsd.com/d/233-spotify/49

@hrkfdn
Copy link

hrkfdn commented Aug 24, 2020

This appears to be a problem in the pancurses backend. The ncurses backend fixes it like this: https://github.com/gyscos/cursive/blob/main/cursive/src/backends/curses/n.rs#L90

I'd assume something similar needs to be done in the pancurses backend.

EDIT: It also seems to be set in the pancurses library itself: ihalila/pancurses@16139e4 -- not sure why it doesn't work on NetBSD.

@gyscos
Copy link
Owner

gyscos commented Aug 25, 2020

I updated the ncurses backend to use libc::setlocale instead of the ncurses one. Pancurses will need its own fix to do the same.
Does this help?

@krytarowski
Copy link
Author

That's progress. Now waiting for ncurses-rs and pancurses fix.

@hrkfdn
Copy link

hrkfdn commented Aug 25, 2020

@krytarowski Can you confirm that this fixes the ncurses-backend on NetBSD?

@gyscos
Copy link
Owner

gyscos commented Aug 25, 2020

Pancurses may take longer to update, as the main author has been away from github for the last year or so. :S
We can always add a libc::setlocale in the backend code here, it's probably fine to run it multiple times.

@gyscos
Copy link
Owner

gyscos commented Aug 26, 2020

Well, until pancurses merges ihalila/pancurses#78, I updated the backend here to call setlocale. Does it fix your issue?

@krytarowski
Copy link
Author

krytarowski commented Aug 26, 2020

Fixed with:

[dependencies]
cursive = { git = "https://github.com/gyscos/cursive", rev = "eec4dd8e68dccddd61b2c1cc70b3aafa11a5302" }

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