From 192dd1f92c0a5b7f652b32363be5e535d8a5c294 Mon Sep 17 00:00:00 2001 From: correabuscar Date: Thu, 11 Apr 2024 18:38:29 +0200 Subject: [PATCH] get rid of a warning when using newterm 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: https://github.com/gyscos/cursive/pull/778#discussion_r1617327653 Co-authored-by: Alexandre Bury 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: https://github.com/gyscos/cursive/pull/778#discussion_r1617636632 Co-authored-by: Alexandre Bury --- cursive/src/backends/curses/n.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cursive/src/backends/curses/n.rs b/cursive/src/backends/curses/n.rs index a17c96e2..dd8c0a27 100644 --- a/cursive/src/backends/curses/n.rs +++ b/cursive/src/backends/curses/n.rs @@ -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);