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-08-20 16:02:00 +00:00
|
|
|
unsafe {
|
2020-11-16 22:53:07 +00:00
|
|
|
let ncd = NcDirect::new();
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-11-16 22:53:07 +00:00
|
|
|
let cols = ncdirect_dim_x(ncd);
|
|
|
|
let rows = ncdirect_dim_y(ncd);
|
2020-09-21 18:03:18 +00:00
|
|
|
println!("terminal size (rows, cols): {}, {}", rows, cols);
|
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.putstr(0, "The current coordinates are")?;
|
|
|
|
ncd.flush()?;
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-11-18 01:43:29 +00:00
|
|
|
for _n in 0..20 {
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.putstr(0, ".")?;
|
|
|
|
ncd.flush()?;
|
2020-11-18 01:43:29 +00:00
|
|
|
sleep![50];
|
|
|
|
}
|
2020-09-21 18:03:18 +00:00
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
if let Some((cy, cx)) = ncd.cursor_yx() {
|
|
|
|
ncd.putstr(0, &format!(" ({},{})\n", cy, cx))?;
|
|
|
|
}
|
2020-11-18 01:43:29 +00:00
|
|
|
sleep![1000];
|
|
|
|
|
|
|
|
let sentence = vec!["And", "now", "I", "will", "clear", "the", "screen", ".", ".", "."];
|
|
|
|
for word in sentence {
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.putstr(0, &format!["{} ", word])?;
|
|
|
|
ncd.flush()?;
|
2020-11-18 01:43:29 +00:00
|
|
|
sleep![200];
|
|
|
|
}
|
|
|
|
sleep![300];
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.putstr(0, "\nbye!\n\n")?;
|
|
|
|
ncd.flush()?;
|
2020-11-18 01:43:29 +00:00
|
|
|
sleep![600];
|
2020-09-21 18:03:18 +00:00
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.clear()?;
|
2020-11-18 01:43:29 +00:00
|
|
|
sleep![1000];
|
2020-08-20 16:02:00 +00:00
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.stop()?;
|
2020-08-20 16:02:00 +00:00
|
|
|
}
|
2020-12-25 04:16:34 +00:00
|
|
|
Ok(())
|
2020-08-20 16:02:00 +00:00
|
|
|
}
|