rust: add simple wrapper over ncdirect_init

pull/931/head
joseLuís 4 years ago
parent d17460b875
commit 9dc847c8b5

@ -2,14 +2,9 @@ use cstr_core::CString;
use libnotcurses_sys as nc;
extern "C" {
fn libc_stdout() -> *mut nc::_IO_FILE;
}
fn main() {
unsafe {
let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr());
let ncd: *mut nc::ncdirect = nc::ncdirect_init(std::ptr::null(), libc_stdout());
let ncd = nc::ncdirect_start();
render_image(&mut *ncd, nc::ncblitter_e_NCBLIT_1x1);
render_image(&mut *ncd, nc::ncblitter_e_NCBLIT_2x1);

@ -0,0 +1,71 @@
// functions already exported by bindgen : 30
// ------------------------------------------
// ncdirect_bg
// ncdirect_bg_default
// ncdirect_bg_palindex
// ncdirect_box
// ncdirect_canopen_images
// ncdirect_canutf8
// ncdirect_clear
// ncdirect_cursor_disable
// ncdirect_cursor_down
// ncdirect_cursor_enable
// ncdirect_cursor_left
// ncdirect_cursor_move_yx
// ncdirect_cursor_pop
// ncdirect_cursor_push
// ncdirect_cursor_right
// ncdirect_cursor_up
// ncdirect_cursor_yx
// ncdirect_dim_x
// ncdirect_dim_y
// ncdirect_double_box
// ncdirect_fg
// ncdirect_fg_default
// ncdirect_fg_palindex
// ncdirect_hline_interp
// ncdirect_init
// ncdirect_palette_size
// ncdirect_printf_aligned
// ncdirect_putstr
// ncdirect_render_image
// ncdirect_rounded_box
// ncdirect_stop
// ncdirect_styles_off
// ncdirect_styles_on
// ncdirect_styles_set
// ncdirect_vline_interp
//
use crate as ffi;
use ffi::ncdirect;
extern "C" {
fn libc_stdout() -> *mut ffi::_IO_FILE;
}
/// A simple ncdirect_init() wrapper
///
/// Initialize a direct-mode notcurses context on the tty.
///
/// Direct mode supportes a limited subset of notcurses routines,
/// and neither supports nor requires notcurses_render().
/// This can be used to add color and styling to text in the standard output paradigm.
/// Returns NULL on error, including any failure initializing terminfo.
pub unsafe fn ncdirect_start() -> *mut ncdirect {
ffi::ncdirect_init(core::ptr::null(), libc_stdout())
}
#[cfg(test)]
mod test {
// use super::ffi;
// use serial_test::serial;
/*
#[test]
#[serial]
fn () {
}
*/
}

@ -16,6 +16,7 @@ mod macros;
mod cells;
mod channel;
mod direct;
mod key;
mod keycodes;
mod nc;
@ -25,6 +26,7 @@ mod plane;
mod types;
pub use cells::*;
pub use channel::*;
pub use direct::*;
pub use key::*;
pub use keycodes::*;
pub use nc::*;

Loading…
Cancel
Save