2020-11-16 22:53:07 +00:00
|
|
|
//! Example 'direct-cursor'
|
|
|
|
//!
|
|
|
|
//! Explore cursor functions in direct mode
|
|
|
|
//!
|
|
|
|
|
|
|
|
use libnotcurses_sys::*;
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
fn main() -> NcResult<()> {
|
2020-12-26 04:14:27 +00:00
|
|
|
let ncd = NcDirect::new()?;
|
|
|
|
|
|
|
|
let cols = ncd.dim_x();
|
|
|
|
let rows = ncd.dim_y();
|
|
|
|
println!("terminal size (rows, cols): {}, {}", rows, cols);
|
|
|
|
|
|
|
|
ncd.putstr(0, "The current coordinates are")?;
|
|
|
|
|
|
|
|
for _n in 0..40 {
|
|
|
|
fsleep![ncd, 0, 30];
|
|
|
|
ncd.putstr(0, ".")?;
|
|
|
|
}
|
|
|
|
|
|
|
|
let (cy, cx) = ncd.cursor_yx()?;
|
|
|
|
ncd.putstr(0, &format!(" ({},{})\n", cy, cx))?;
|
|
|
|
sleep![1];
|
|
|
|
|
|
|
|
let sentence = vec!["And", "now", "I", "will", "clear", "the", "screen", ".", ".", "."];
|
|
|
|
for word in sentence {
|
|
|
|
ncd.putstr(0, &format!["{} ", word])?;
|
|
|
|
fsleep![ncd, 0, 150];
|
2020-08-20 16:02:00 +00:00
|
|
|
}
|
2020-12-26 04:14:27 +00:00
|
|
|
sleep![0, 300];
|
|
|
|
ncd.putstr(0, "\nbye!\n\n")?;
|
|
|
|
fsleep![ncd, 0, 600];
|
|
|
|
|
|
|
|
ncd.clear()?;
|
|
|
|
sleep![1];
|
|
|
|
|
|
|
|
ncd.stop()?;
|
2020-12-25 04:16:34 +00:00
|
|
|
Ok(())
|
2020-08-20 16:02:00 +00:00
|
|
|
}
|