mirror of
https://github.com/dankamongmen/notcurses
synced 2025-04-07 07:10:03 -04:00
We need to use Result<> to manage error flow, at least on the methods API. This way it will finally feel idiomatic Rust and more concise. Also, we can't return a non Result from main. - rename NcResult to NcIntResult. - new NcError & NcResult types. - new error![] macro to reduce boilerplate. - change return type of NcDirect methods to NcResult. - refactor several examples to return NcResult: direct-cursor, poc-direct & poc-kittyzapper. - BONUS: fix test not stopping notcurses context. - update lib doc-comment. - fix typo in readme.
26 lines
505 B
Rust
26 lines
505 B
Rust
//! based on the proof of concept at ../../src/poc/kittyzapper.c
|
|
|
|
use libnotcurses_sys::*;
|
|
|
|
fn main() -> NcResult<()> {
|
|
let ncd = NcDirect::new();
|
|
|
|
ncd.fg_rgb8(100, 100, 100)?;
|
|
ncd.bg_rgb8(0xff, 0xff, 0xff)?;
|
|
printf!("a");
|
|
ncd.bg_rgb8(0, 0, 0)?;
|
|
printf!("b");
|
|
printf!(" ");
|
|
printf!(" ");
|
|
ncd.bg_rgb8(0, 0, 1)?;
|
|
printf!("c");
|
|
printf!(" ");
|
|
printf!(" ");
|
|
ncd.bg_rgb8(0xff, 0xff, 0xff)?;
|
|
printf!("d");
|
|
printf!("\n");
|
|
ncd.stop()?;
|
|
|
|
Ok(())
|
|
}
|