mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
fbe4352233
- receive a variable number of arguments. - make rsleep use methods and deal with NcResult. - new fsleep to flush an NcDirect context. - fix macro usages in examples.
41 lines
881 B
Rust
41 lines
881 B
Rust
//! Example 'direct-cursor'
|
|
//!
|
|
//! Explore cursor functions in direct mode
|
|
//!
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
fn main() -> NcResult<()> {
|
|
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];
|
|
}
|
|
sleep![0, 300];
|
|
ncd.putstr(0, "\nbye!\n\n")?;
|
|
fsleep![ncd, 0, 600];
|
|
|
|
ncd.clear()?;
|
|
sleep![1];
|
|
|
|
ncd.stop()?;
|
|
Ok(())
|
|
}
|