mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
rust: more 2.1.2 catch-ups
- deprecate old ncdirect_style_* functions. - add `NCSCALE_*_HIRES` constants. - BONUS: update ncdirect_raster_frame, removed parameters.
This commit is contained in:
parent
58bc9bd3bc
commit
b6c84cfce2
@ -162,6 +162,8 @@ pub use ffi::{
|
||||
ncdirect_hline_interp,
|
||||
ncdirect_init,
|
||||
ncdirect_inputready_fd,
|
||||
ncdirect_off_styles,
|
||||
ncdirect_on_styles,
|
||||
ncdirect_palette_size,
|
||||
ncdirect_printf_aligned,
|
||||
ncdirect_putstr,
|
||||
@ -169,10 +171,8 @@ pub use ffi::{
|
||||
ncdirect_render_frame,
|
||||
ncdirect_render_image,
|
||||
ncdirect_rounded_box,
|
||||
ncdirect_set_styles,
|
||||
ncdirect_stop,
|
||||
ncdirect_styles_off,
|
||||
ncdirect_styles_on,
|
||||
ncdirect_styles_set,
|
||||
ncdirect_vline_interp,
|
||||
};
|
||||
|
||||
|
@ -4,9 +4,9 @@ use core::ptr::{null, null_mut};
|
||||
|
||||
use crate::ffi::sigset_t;
|
||||
use crate::{
|
||||
cstring, error, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDimension, NcDirect,
|
||||
NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb, NcScale,
|
||||
NcStyleMask, NcTime, NCRESULT_ERR,
|
||||
cstring, error, error_ref_mut, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDimension,
|
||||
NcDirect, NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb,
|
||||
NcScale, NcStyleMask, NcTime, NCRESULT_ERR,
|
||||
};
|
||||
|
||||
/// # `NcDirect` constructors and destructors
|
||||
@ -34,10 +34,7 @@ impl NcDirect {
|
||||
/// *C style function: [ncdirect_init()][crate::ncdirect_init].*
|
||||
pub fn with_flags<'a>(flags: NcDirectFlags) -> NcResult<&'a mut NcDirect> {
|
||||
let res = unsafe { crate::ncdirect_init(null(), null_mut(), flags) };
|
||||
if res == null_mut() {
|
||||
return Err(NcError::with_msg(NCRESULT_ERR, "Initializing NcDirect"));
|
||||
}
|
||||
Ok(unsafe { &mut *res })
|
||||
error_ref_mut![res, "Initializing NcDirect"]
|
||||
}
|
||||
|
||||
/// Releases this NcDirect and any associated resources.
|
||||
@ -71,15 +68,9 @@ impl NcDirect {
|
||||
/// passed to render_frame().
|
||||
///
|
||||
/// *C style function: [ncdirect_raster_frame()][crate::ncdirect_raster_frame].*
|
||||
pub fn raster_frame(
|
||||
&mut self,
|
||||
faken: &mut NcPlane,
|
||||
align: NcAlign,
|
||||
blitter: NcBlitter,
|
||||
scale: NcScale,
|
||||
) -> NcResult<()> {
|
||||
pub fn raster_frame(&mut self, faken: &mut NcPlane, align: NcAlign) -> NcResult<()> {
|
||||
error![
|
||||
unsafe { crate::ncdirect_raster_frame(self, faken, align, blitter, scale) },
|
||||
unsafe { crate::ncdirect_raster_frame(self, faken, align) },
|
||||
(),
|
||||
"Rastering frame"
|
||||
]
|
||||
@ -105,10 +96,7 @@ impl NcDirect {
|
||||
scale: NcScale,
|
||||
) -> NcResult<&'a mut NcPlane> {
|
||||
let res = unsafe { crate::ncdirect_render_frame(self, cstring![filename], blitter, scale) };
|
||||
if res == null_mut() {
|
||||
return Err(NcError::with_msg(NCRESULT_ERR, "Rendering frame"));
|
||||
}
|
||||
Ok(unsafe { &mut *res })
|
||||
error_ref_mut![res, "Rendering frame"]
|
||||
}
|
||||
|
||||
/// 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].*
|
||||
pub fn bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) -> NcResult<()> {
|
||||
let res = crate::ncdirect_bg_rgb8(self, red, green, blue);
|
||||
error![res]
|
||||
error![crate::ncdirect_bg_rgb8(self, red, green, blue)]
|
||||
}
|
||||
|
||||
/// 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<()> {
|
||||
let res = unsafe { crate::ncdirect_styles_off(self, stylebits.into()) };
|
||||
let res = unsafe { crate::ncdirect_off_styles(self, stylebits.into()) };
|
||||
error![res]
|
||||
}
|
||||
|
||||
/// 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<()> {
|
||||
error![unsafe { crate::ncdirect_styles_on(self, stylebits.into()) }]
|
||||
error![unsafe { crate::ncdirect_on_styles(self, stylebits.into()) }]
|
||||
}
|
||||
|
||||
/// 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<()> {
|
||||
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.
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! `NcDirect`
|
||||
|
||||
// functions already exported by bindgen : 40
|
||||
// functions already exported by bindgen : 43
|
||||
// ------------------------------------------
|
||||
// (X) wont: 1
|
||||
// (X) wont: 4
|
||||
// (#) test: 0
|
||||
// (W) wrap: 39 / 0
|
||||
// ------------------------------------------
|
||||
@ -34,6 +34,8 @@
|
||||
//W ncdirect_hline_interp
|
||||
//W ncdirect_init
|
||||
//W ncdirect_inputready_fd
|
||||
//W ncplane_on_styles
|
||||
//W ncplane_off_styles
|
||||
//W ncdirect_palette_size
|
||||
// X ncdirect_printf_aligned
|
||||
//W ncdirect_putstr
|
||||
@ -41,10 +43,11 @@
|
||||
//W ncdirect_render_frame
|
||||
//W ncdirect_render_image
|
||||
//W ncdirect_rounded_box
|
||||
//W ncplane_set_styles
|
||||
//W ncdirect_stop
|
||||
//W ncdirect_styles_off
|
||||
//W ncdirect_styles_on
|
||||
//W ncdirect_styles_set
|
||||
// X ncdirect_styles_off // deprecated
|
||||
// X ncdirect_styles_on // deprecated
|
||||
// X ncdirect_styles_set // deprecated
|
||||
//W ncdirect_vline_interp
|
||||
//
|
||||
// functions manually reimplemented: 4
|
||||
|
@ -7,24 +7,24 @@
|
||||
// (W) wrap: 0
|
||||
// (#) test: 0
|
||||
// -----------------------------------------
|
||||
// ncvisual_at_yx
|
||||
// ncvisual_decode
|
||||
// ncvisual_decode_loop
|
||||
// ncvisual_destroy
|
||||
// ncvisual_from_bgra
|
||||
// ncvisual_from_file
|
||||
// ncvisual_from_plane
|
||||
// ncvisual_from_rgba
|
||||
// ncvisual_geom
|
||||
// ncvisual_media_defblitter
|
||||
// ncvisual_polyfill_yx
|
||||
// ncvisual_render
|
||||
// ncvisual_resize
|
||||
// ncvisual_rotate
|
||||
// ncvisual_set_yx
|
||||
// ncvisual_simple_streamer
|
||||
// ncvisual_stream
|
||||
// ncvisual_subtitle
|
||||
// ncvisual_at_yx
|
||||
// ncvisual_decode
|
||||
// ncvisual_decode_loop
|
||||
// ncvisual_destroy
|
||||
// ncvisual_from_bgra
|
||||
// ncvisual_from_file
|
||||
// ncvisual_from_plane
|
||||
// ncvisual_from_rgba
|
||||
// ncvisual_geom
|
||||
// ncvisual_media_defblitter
|
||||
// ncvisual_polyfill_yx
|
||||
// ncvisual_render
|
||||
// ncvisual_resize
|
||||
// ncvisual_rotate
|
||||
// ncvisual_set_yx
|
||||
// ncvisual_simple_streamer
|
||||
// ncvisual_stream
|
||||
// ncvisual_subtitle
|
||||
|
||||
/// How to scale an [`NcVisual`] during rendering
|
||||
///
|
||||
@ -35,15 +35,27 @@
|
||||
/// attempt to fill the entirety of the plane.
|
||||
///
|
||||
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;
|
||||
/// Maintain aspect ratio
|
||||
|
||||
/// Maintain aspect ratio.
|
||||
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;
|
||||
|
||||
/// 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
|
||||
pub type NcVisual = crate::bindings::ffi::ncvisual;
|
||||
|
||||
/// Options struct for [`NcVisual`]
|
||||
pub type NcVisualOptions = crate::bindings::ffi::ncvisual_options;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user