2020-08-20 16:02:00 +00:00
|
|
|
use std::thread::sleep;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
use cstr_core::CString;
|
|
|
|
|
|
|
|
use libnotcurses_sys as nc;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
2020-11-04 17:31:12 +00:00
|
|
|
let ncd = nc::ncdirect_new();
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-09-21 18:03:18 +00:00
|
|
|
let cols = nc::ncdirect_dim_x(ncd);
|
|
|
|
let rows = nc::ncdirect_dim_y(ncd);
|
|
|
|
println!("terminal size (rows, cols): {}, {}", rows, cols);
|
|
|
|
|
|
|
|
// show current coordinates
|
2020-08-20 16:02:00 +00:00
|
|
|
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());
|
|
|
|
|
2020-09-21 18:03:18 +00:00
|
|
|
// Write HELLO WORLD in steps
|
|
|
|
|
|
|
|
sleep(Duration::new(1, 0));
|
|
|
|
|
2020-08-20 16:02:00 +00:00
|
|
|
nc::ncdirect_putstr(ncd, 0, CString::new("HELLO").unwrap().as_ptr());
|
2020-09-22 11:34:07 +00:00
|
|
|
nc::ncdirect_flush(ncd);
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-09-21 18:03:18 +00:00
|
|
|
sleep(Duration::new(1, 0));
|
|
|
|
|
|
|
|
nc::ncdirect_putstr(ncd, 0, CString::new(" WORLD").unwrap().as_ptr());
|
2020-09-22 11:34:07 +00:00
|
|
|
nc::ncdirect_flush(ncd);
|
2020-09-21 18:03:18 +00:00
|
|
|
|
|
|
|
sleep(Duration::new(1, 0));
|
|
|
|
|
|
|
|
// show current coordinates
|
2020-08-20 16:02:00 +00:00
|
|
|
nc::ncdirect_cursor_yx(ncd, &mut cy, &mut cx);
|
2020-09-21 18:03:18 +00:00
|
|
|
nc::ncdirect_putstr(ncd, 0, CString::new(format!(" ({},{})\n", cy, cx)).unwrap().as_ptr());
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-09-21 18:03:18 +00:00
|
|
|
sleep(Duration::new(1, 0));
|
2020-08-20 16:02:00 +00:00
|
|
|
nc::ncdirect_stop(ncd);
|
|
|
|
}
|
|
|
|
}
|