From ed748a516221c40227895280f0eec30fd99f63a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 20 Aug 2020 18:02:00 +0200 Subject: [PATCH] rust: new example: direct cursor issue: only updates the screen after a newline --- rust/examples/direct-cursor.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 rust/examples/direct-cursor.rs diff --git a/rust/examples/direct-cursor.rs b/rust/examples/direct-cursor.rs new file mode 100644 index 000000000..a31e9cea5 --- /dev/null +++ b/rust/examples/direct-cursor.rs @@ -0,0 +1,27 @@ +use std::thread::sleep; +use std::time::Duration; + +use cstr_core::CString; + +use libnotcurses_sys as nc; + +fn main() { + unsafe { + let ncd = nc::ncdirect_start(); + + let (mut cy, mut cx) = (0,0); + nc::ncdirect_cursor_yx(ncd, &mut cy, &mut cx); + nc::ncdirect_putstr(ncd, 0, CString::new(format!("({},{})\n", cy, cx)).unwrap().as_ptr()); + + // ISSUE 1: printing without a newline doesn't update the screen + sleep(Duration::new(2, 0)); + nc::ncdirect_putstr(ncd, 0, CString::new("HELLO").unwrap().as_ptr()); + sleep(Duration::new(2, 0)); + nc::ncdirect_putstr(ncd, 0, CString::new("WORLD").unwrap().as_ptr()); + + nc::ncdirect_cursor_yx(ncd, &mut cy, &mut cx); + nc::ncdirect_putstr(ncd, 0, CString::new(format!("({},{})\n", cy, cx)).unwrap().as_ptr()); + + nc::ncdirect_stop(ncd); + } +}