Skip to content

Commit

Permalink
get rid of a warning when using newterm
Browse files Browse the repository at this point in the history
newterm https://github.com/jeaye/ncurses-rs/blob/3aa22bc279e4929e3ab69d49f75a18eda3e431e9/src/lib.rs#L1023-L1029
CString::new https://doc.rust-lang.org/std/ffi/struct.CString.html#method.new

bubble up this newterm error

as suggested here: #778 (comment)

Co-authored-by: Alexandre Bury <[email protected]>

preserve original error in the panic report

otherwise, we'd not know why ncurses-rs newterm errored

directly include the variable name in the format! expression

as suggested here: #778 (comment)

Co-authored-by: Alexandre Bury <[email protected]>
  • Loading branch information
correabuscar and gyscos committed Jun 7, 2024
1 parent d6810f9 commit 192dd1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cursive/src/backends/curses/n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ impl Backend {
let path = CString::new(output_path).unwrap();
unsafe { libc::fopen(path.as_ptr(), mode.as_ptr()) }
};
ncurses::newterm(None, output, input);
ncurses::newterm(None, output, input).map_err(|e| {
io::Error::new(io::ErrorKind::Other, format!("could not call newterm: {e}"))
})?;

// Enable keypad (like arrows)
ncurses::keypad(ncurses::stdscr(), true);

Expand Down

0 comments on commit 192dd1f

Please sign in to comment.