2020-12-24 18:56:12 +00:00
|
|
|
//! based on the proof of concept at ../../src/poc/direct.c
|
|
|
|
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
fn main() -> NcResult<()> {
|
2020-12-25 16:40:37 +00:00
|
|
|
let ncd = NcDirect::new()?;
|
2020-12-24 18:56:12 +00:00
|
|
|
|
|
|
|
let dimy = ncd.dim_y();
|
|
|
|
let dimx = ncd.dim_x();
|
|
|
|
for _ in 0..dimy {
|
|
|
|
for _ in 0..dimx {
|
|
|
|
printf!("X");
|
|
|
|
}
|
|
|
|
}
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.flush()?;
|
2020-12-24 18:56:12 +00:00
|
|
|
|
2020-12-29 01:51:05 +00:00
|
|
|
ncd.set_fg_rgb(0xff8080)?;
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.styles_on(NCSTYLE_STANDOUT)?;
|
2020-12-24 18:56:12 +00:00
|
|
|
printf!(" erp erp \n");
|
2020-12-29 01:51:05 +00:00
|
|
|
ncd.set_fg_rgb(0x80ff80)?;
|
2020-12-24 18:56:12 +00:00
|
|
|
printf!(" erp erp \n");
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.styles_off(NCSTYLE_STANDOUT)?;
|
2020-12-24 18:56:12 +00:00
|
|
|
printf!(" erp erp \n");
|
2020-12-29 01:51:05 +00:00
|
|
|
ncd.set_fg_rgb(0xff8080)?;
|
2020-12-24 18:56:12 +00:00
|
|
|
printf!(" erp erp \n");
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.cursor_right(dimx / 2)?;
|
|
|
|
ncd.cursor_up(dimy / 2)?;
|
2020-12-24 18:56:12 +00:00
|
|
|
printf!(" erperperp! \n");
|
|
|
|
|
|
|
|
let (mut y, x);
|
|
|
|
|
2020-12-25 18:35:21 +00:00
|
|
|
if let Ok((_y, _x)) = ncd.cursor_yx() {
|
2020-12-24 18:56:12 +00:00
|
|
|
y = _y;
|
|
|
|
x = _x;
|
|
|
|
printf!("\n\tRead cursor position: y: %d x: %d\n", y, x);
|
2020-12-25 04:16:34 +00:00
|
|
|
|
2020-12-24 18:56:12 +00:00
|
|
|
y += 2;
|
|
|
|
while y > 3 {
|
|
|
|
let up = if y >= 3 { 3 } else { y };
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.cursor_up(up)?;
|
|
|
|
ncd.flush()?;
|
2020-12-24 18:56:12 +00:00
|
|
|
y -= up;
|
|
|
|
|
|
|
|
let newy;
|
2020-12-25 18:35:21 +00:00
|
|
|
if let Ok((_y, _)) = ncd.cursor_yx() {
|
2020-12-24 18:56:12 +00:00
|
|
|
newy = _y;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2020-12-25 04:16:34 +00:00
|
|
|
|
2020-12-24 18:56:12 +00:00
|
|
|
if newy != y {
|
|
|
|
eprintln!("Expected {}, got {}", y, newy);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf!("\n\tRead cursor position: y: %d x: %d\n", newy, x);
|
|
|
|
y += 2;
|
|
|
|
}
|
|
|
|
} else {
|
2020-12-25 16:40:37 +00:00
|
|
|
return Err(NcError::with_msg(-10, "Couldn't read cursor position."));
|
2020-12-24 18:56:12 +00:00
|
|
|
}
|
2020-12-24 23:53:03 +00:00
|
|
|
|
2020-12-25 04:16:34 +00:00
|
|
|
ncd.stop()?;
|
|
|
|
Ok(())
|
2020-12-24 18:56:12 +00:00
|
|
|
}
|