Merge branch 'master' of github.com:dankamongmen/notcurses

pull/1270/head
nick black 4 years ago
commit 6a969e1f52
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -162,6 +162,8 @@ pub use ffi::{
ncdirect_hline_interp, ncdirect_hline_interp,
ncdirect_init, ncdirect_init,
ncdirect_inputready_fd, ncdirect_inputready_fd,
ncdirect_off_styles,
ncdirect_on_styles,
ncdirect_palette_size, ncdirect_palette_size,
ncdirect_printf_aligned, ncdirect_printf_aligned,
ncdirect_putstr, ncdirect_putstr,
@ -169,10 +171,8 @@ pub use ffi::{
ncdirect_render_frame, ncdirect_render_frame,
ncdirect_render_image, ncdirect_render_image,
ncdirect_rounded_box, ncdirect_rounded_box,
ncdirect_set_styles,
ncdirect_stop, ncdirect_stop,
ncdirect_styles_off,
ncdirect_styles_on,
ncdirect_styles_set,
ncdirect_vline_interp, ncdirect_vline_interp,
}; };

@ -4,9 +4,9 @@ use core::ptr::{null, null_mut};
use crate::ffi::sigset_t; use crate::ffi::sigset_t;
use crate::{ use crate::{
cstring, error, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDimension, NcDirect, cstring, error, error_ref_mut, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDimension,
NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb, NcScale, NcDirect, NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb,
NcStyleMask, NcTime, NCRESULT_ERR, NcScale, NcStyleMask, NcTime, NCRESULT_ERR,
}; };
/// # `NcDirect` constructors and destructors /// # `NcDirect` constructors and destructors
@ -34,10 +34,7 @@ impl NcDirect {
/// *C style function: [ncdirect_init()][crate::ncdirect_init].* /// *C style function: [ncdirect_init()][crate::ncdirect_init].*
pub fn with_flags<'a>(flags: NcDirectFlags) -> NcResult<&'a mut NcDirect> { pub fn with_flags<'a>(flags: NcDirectFlags) -> NcResult<&'a mut NcDirect> {
let res = unsafe { crate::ncdirect_init(null(), null_mut(), flags) }; let res = unsafe { crate::ncdirect_init(null(), null_mut(), flags) };
if res == null_mut() { error_ref_mut![res, "Initializing NcDirect"]
return Err(NcError::with_msg(NCRESULT_ERR, "Initializing NcDirect"));
}
Ok(unsafe { &mut *res })
} }
/// Releases this NcDirect and any associated resources. /// Releases this NcDirect and any associated resources.
@ -71,15 +68,9 @@ impl NcDirect {
/// passed to render_frame(). /// passed to render_frame().
/// ///
/// *C style function: [ncdirect_raster_frame()][crate::ncdirect_raster_frame].* /// *C style function: [ncdirect_raster_frame()][crate::ncdirect_raster_frame].*
pub fn raster_frame( pub fn raster_frame(&mut self, faken: &mut NcPlane, align: NcAlign) -> NcResult<()> {
&mut self,
faken: &mut NcPlane,
align: NcAlign,
blitter: NcBlitter,
scale: NcScale,
) -> NcResult<()> {
error![ error![
unsafe { crate::ncdirect_raster_frame(self, faken, align, blitter, scale) }, unsafe { crate::ncdirect_raster_frame(self, faken, align) },
(), (),
"Rastering frame" "Rastering frame"
] ]
@ -105,10 +96,7 @@ impl NcDirect {
scale: NcScale, scale: NcScale,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
let res = unsafe { crate::ncdirect_render_frame(self, cstring![filename], blitter, scale) }; let res = unsafe { crate::ncdirect_render_frame(self, cstring![filename], blitter, scale) };
if res == null_mut() { error_ref_mut![res, "Rendering frame"]
return Err(NcError::with_msg(NCRESULT_ERR, "Rendering frame"));
}
Ok(unsafe { &mut *res })
} }
/// Displays an image using the specified blitter and scaling. /// Displays an image using the specified blitter and scaling.
@ -189,30 +177,29 @@ impl NcDirect {
/// ///
/// *C style function: [ncdirect_bg_rgb()][crate::ncdirect_bg_rgb].* /// *C style function: [ncdirect_bg_rgb()][crate::ncdirect_bg_rgb].*
pub fn bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) -> NcResult<()> { pub fn bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) -> NcResult<()> {
let res = crate::ncdirect_bg_rgb8(self, red, green, blue); error![crate::ncdirect_bg_rgb8(self, red, green, blue)]
error![res]
} }
/// Removes the specified styles. /// Removes the specified styles.
/// ///
/// *C style function: [ncdirect_styles_off()][crate::ncdirect_styles_off].* /// *C style function: [ncdirect_off_styles()][crate::ncdirect_off_styles].*
pub fn styles_off(&mut self, stylebits: NcStyleMask) -> NcResult<()> { pub fn styles_off(&mut self, stylebits: NcStyleMask) -> NcResult<()> {
let res = unsafe { crate::ncdirect_styles_off(self, stylebits.into()) }; let res = unsafe { crate::ncdirect_off_styles(self, stylebits.into()) };
error![res] error![res]
} }
/// Adds the specified styles. /// Adds the specified styles.
/// ///
/// *C style function: [ncdirect_styles_on()][crate::ncdirect_styles_on].* /// *C style function: [ncdirect_on_styles()][crate::ncdirect_on_styles].*
pub fn styles_on(&mut self, stylebits: NcStyleMask) -> NcResult<()> { pub fn styles_on(&mut self, stylebits: NcStyleMask) -> NcResult<()> {
error![unsafe { crate::ncdirect_styles_on(self, stylebits.into()) }] error![unsafe { crate::ncdirect_on_styles(self, stylebits.into()) }]
} }
/// Sets just the specified styles. /// Sets just the specified styles.
/// ///
/// *C style function: [ncdirect_styles_set()][crate::ncdirect_styles_set].* /// *C style function: [ncdirect_set_styles()][crate::ncdirect_set_styles].*
pub fn styles_set(&mut self, stylebits: NcStyleMask) -> NcResult<()> { pub fn styles_set(&mut self, stylebits: NcStyleMask) -> NcResult<()> {
error![unsafe { crate::ncdirect_styles_set(self, stylebits.into()) }] error![unsafe { crate::ncdirect_set_styles(self, stylebits.into()) }]
} }
/// Indicates to use the "default color" for the foreground. /// Indicates to use the "default color" for the foreground.

@ -1,8 +1,8 @@
//! `NcDirect` //! `NcDirect`
// functions already exported by bindgen : 40 // functions already exported by bindgen : 43
// ------------------------------------------ // ------------------------------------------
// (X) wont: 1 // (X) wont: 4
// (#) test: 0 // (#) test: 0
// (W) wrap: 39 / 0 // (W) wrap: 39 / 0
// ------------------------------------------ // ------------------------------------------
@ -34,6 +34,8 @@
//W ncdirect_hline_interp //W ncdirect_hline_interp
//W ncdirect_init //W ncdirect_init
//W ncdirect_inputready_fd //W ncdirect_inputready_fd
//W ncplane_on_styles
//W ncplane_off_styles
//W ncdirect_palette_size //W ncdirect_palette_size
// X ncdirect_printf_aligned // X ncdirect_printf_aligned
//W ncdirect_putstr //W ncdirect_putstr
@ -41,10 +43,11 @@
//W ncdirect_render_frame //W ncdirect_render_frame
//W ncdirect_render_image //W ncdirect_render_image
//W ncdirect_rounded_box //W ncdirect_rounded_box
//W ncplane_set_styles
//W ncdirect_stop //W ncdirect_stop
//W ncdirect_styles_off // X ncdirect_styles_off // deprecated
//W ncdirect_styles_on // X ncdirect_styles_on // deprecated
//W ncdirect_styles_set // X ncdirect_styles_set // deprecated
//W ncdirect_vline_interp //W ncdirect_vline_interp
// //
// functions manually reimplemented: 4 // functions manually reimplemented: 4

@ -7,24 +7,24 @@
// (W) wrap: 0 // (W) wrap: 0
// (#) test: 0 // (#) test: 0
// ----------------------------------------- // -----------------------------------------
// ncvisual_at_yx // ncvisual_at_yx
// ncvisual_decode // ncvisual_decode
// ncvisual_decode_loop // ncvisual_decode_loop
// ncvisual_destroy // ncvisual_destroy
// ncvisual_from_bgra // ncvisual_from_bgra
// ncvisual_from_file // ncvisual_from_file
// ncvisual_from_plane // ncvisual_from_plane
// ncvisual_from_rgba // ncvisual_from_rgba
// ncvisual_geom // ncvisual_geom
// ncvisual_media_defblitter // ncvisual_media_defblitter
// ncvisual_polyfill_yx // ncvisual_polyfill_yx
// ncvisual_render // ncvisual_render
// ncvisual_resize // ncvisual_resize
// ncvisual_rotate // ncvisual_rotate
// ncvisual_set_yx // ncvisual_set_yx
// ncvisual_simple_streamer // ncvisual_simple_streamer
// ncvisual_stream // ncvisual_stream
// ncvisual_subtitle // ncvisual_subtitle
/// How to scale an [`NcVisual`] during rendering /// How to scale an [`NcVisual`] during rendering
/// ///
@ -35,15 +35,27 @@
/// attempt to fill the entirety of the plane. /// attempt to fill the entirety of the plane.
/// ///
pub type NcScale = crate::bindings::ffi::ncscale_e; pub type NcScale = crate::bindings::ffi::ncscale_e;
/// Maintain original size
/// Maintain original size.
pub const NCSCALE_NONE: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_NONE; pub const NCSCALE_NONE: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_NONE;
/// Maintain aspect ratio
/// Maintain aspect ratio.
pub const NCSCALE_SCALE: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_SCALE; pub const NCSCALE_SCALE: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_SCALE;
/// Throw away aspect ratio
/// Throw away aspect ratio.
pub const NCSCALE_STRETCH: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_STRETCH; pub const NCSCALE_STRETCH: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_STRETCH;
/// Maintain original size, admitting high-resolution blitters
/// that don't preserve aspect ratio.
pub const NCSCALE_NONE_HIRES: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_NONE_HIRES;
/// Maintain aspect ratio, admitting high-resolution blitters
/// that don't preserve aspect ratio.
pub const NCSCALE_NONE_HIRES: NcScale = crate::bindings::ffi::ncscale_e_NCSCALE_NONE_HIRES;
/// A visual bit of multimedia opened with LibAV|OIIO /// A visual bit of multimedia opened with LibAV|OIIO
pub type NcVisual = crate::bindings::ffi::ncvisual; pub type NcVisual = crate::bindings::ffi::ncvisual;
/// Options struct for [`NcVisual`] /// Options struct for [`NcVisual`]
pub type NcVisualOptions = crate::bindings::ffi::ncvisual_options; pub type NcVisualOptions = crate::bindings::ffi::ncvisual_options;

Loading…
Cancel
Save