[rust] add pending functions

- include new functions: ncdirect_stream, ncdirect_supported_styles, ncdirect_styles, nccell_width, ncinput_nomod_p.
- account for functions: ncplane_halign, ncplane_valign.
- rename ncpalette_get_rgb and ncpalette_set_rgb to ncpalette_get_rgb8 and ncpalette_set_rgb8 respectively.
- minor formatting fixes.
This commit is contained in:
joseLuís 2021-06-12 21:29:03 +02:00
parent d695a8206f
commit 125ab361e6
11 changed files with 61 additions and 53 deletions

View File

@ -60,6 +60,7 @@ pub use ffi::{
nccell_extended_gcluster,
nccell_load,
nccell_release,
nccell_width,
nccells_double_box,
nccells_rounded_box,
};
@ -182,6 +183,9 @@ pub use ffi::{
ncdirect_set_fg_rgb,
ncdirect_set_styles,
ncdirect_stop,
ncdirect_stream,
ncdirect_styles,
ncdirect_supported_styles,
ncdirect_vline_interp,
};
@ -382,6 +386,7 @@ pub use ffi::{
ncplane_dim_yx,
ncplane_dup,
ncplane_erase,
ncplane_erase_region,
ncplane_fadein,
ncplane_fadein_iteration,
ncplane_fadeout,
@ -760,6 +765,7 @@ pub use ffi::{
notcurses_core_init,
notcurses_cursor_disable,
notcurses_cursor_enable,
notcurses_cursor_yx,
notcurses_debug,
notcurses_debug_caps,
notcurses_drop_planes,

View File

@ -1,12 +1,13 @@
//! `NcCell`
// functions already exported by bindgen : 6
// functions already exported by bindgen : 7
// -----------------------------------------
// (W) wrap: 4
// (#) test: 0
// ------------------------------------------
//… nccell_extended_gcluster
//… nccell_load
// nccell_width
//W nccells_double_box
//W nccells_rounded_box
//W nccell_duplicate

View File

@ -1,10 +1,10 @@
//! `NcDirect`
// total: 47
// total: 50
// ---------------------------------------------------
// (X) 1 : wont do
//
// (f) 42 : unsafe ffi function exported by bindgen
// (f) 45 : unsafe ffi function exported by bindgen
// (w) 0 : safely wrapped ffi function
// (r) 4 : static function manually reimplemented
//
@ -56,6 +56,9 @@
// fm ncdirect_rounded_box
// fm ncplane_set_styles
// fm ncdirect_stop
// f ncdirect_stream
// f ncdirect_styles
// f ncdirect_supported_styles
// fm ncdirect_vline_interp
// rm ncdirect_bg_rgb8
// rm ncdirect_fg_rgb8

View File

@ -1,12 +1,13 @@
//! `NcInput` & `NcKey`
// functions manually reimplemented: 1
// functions manually reimplemented: 4
// ------------------------------------------
// (+) done: 3 / 0
// (#) test: 0 / 3
// ------------------------------------------
// + ncinput_equal_p
// + nckey_mouse_p
// + nckey_nomod_p
// + nckey_supppuab_p
use crate::NcDim;
@ -35,21 +36,6 @@ pub use keycodes::*;
/// For all events, modifiers (e.g. "Alt") are carried as bools in this struct.
pub type NcInput = crate::bindings::ffi::ncinput;
/// Compares two ncinput structs for data equality by doing a field-by-field
/// comparison for equality (excepting seqnum).
///
/// Returns true if the two are data-equivalent.
pub const fn ncinput_equal_p(n1: NcInput, n2: NcInput) -> bool {
if n1.id != n2.id {
return false;
}
if n1.y != n2.y || n1.x != n2.x {
return false;
}
// do not check seqnum
true
}
/// New NcInput.
impl NcInput {
/// New empty NcInput.
@ -119,6 +105,21 @@ impl NcInput {
}
}
/// Compares two ncinput structs for data equality by doing a field-by-field
/// comparison for equality (excepting seqnum).
///
/// Returns true if the two are data-equivalent.
pub const fn ncinput_equal_p(n1: NcInput, n2: NcInput) -> bool {
if n1.id != n2.id {
return false;
}
if n1.y != n2.y || n1.x != n2.x {
return false;
}
// do not check seqnum
true
}
/// Is this [char] a Supplementary Private Use Area-B codepoint?
///
/// Links:
@ -134,3 +135,8 @@ pub const fn nckey_supppuab_p(w: char) -> bool {
pub const fn nckey_mouse_p(r: char) -> bool {
r >= NCKEY_BUTTON1 && r <= NCKEY_RELEASE
}
/// Are all the modifiers off (alt, control, shift)?
pub const fn ncinput_nomod_p(input: &NcInput) -> bool {
!input.alt && !input.ctrl && !input.shift
}

View File

@ -1,10 +1,10 @@
//! `Notcurses`
// total: 51
// total: 52
// ---------------------------------------------------
// (X) 1 : wont do
//
// (f) 44 : unsafe ffi function exported by bindgen
// (f) 45 : unsafe ffi function exported by bindgen
// (w) 0 : safely wrapped ffi function
// (r) 6 : static function manually reimplemented
//
@ -28,6 +28,7 @@
//~f notcurses_core_init
// fm notcurses_cursor_disable
// fm notcurses_cursor_enable
// f notcurses_cursor_yx
// fmt notcurses_debug
// fm notcurses_debug_caps
// fmt notcurses_drop_planes

View File

@ -13,15 +13,17 @@
//W ncpalette_new
//W ncpalette_use
//
// functions manually reimplemented: 3
// functions manually reimplemented: 5
// -----------------------------------------
// (+) done: 3 / 0
// (#) test: 0
// (W) wrap: 3 / 0
// -----------------------------------------
//W+ ncpalette_get_rgb
// ncpalette_get_rgb8
//W+ ncpalette_set
//W+ ncpalette_set_rgb
// ncpalette_set_rgb8
mod methods;
mod reimplemented;

View File

@ -8,7 +8,7 @@ use crate::{NcChannel, NcColor, NcPalette, NcPaletteIndex, NcRgb};
/// *Method: NcPalette.[get_rgb()][NcPalette#method.get_rgb].*
/// *Method: NcPalette.[get_rgb8()][NcPalette#method.get_rgb8].*
#[inline]
pub fn ncpalette_get_rgb(
pub fn ncpalette_get_rgb8(
palette: &NcPalette,
index: NcPaletteIndex,
red: &mut NcColor,
@ -30,7 +30,7 @@ pub fn ncpalette_set(palette: &mut NcPalette, index: NcPaletteIndex, rgb: NcRgb)
///
/// *Method: NcPalette.[set_rgb()][NcPalette#method.set_rgb].*
#[inline]
pub fn ncpalette_set_rgb(
pub fn ncpalette_set_rgb8(
palette: &mut NcPalette,
index: NcPaletteIndex,
red: NcColor,

View File

@ -1,6 +1,6 @@
//! `NcPlane`
// functions already exported by bindgen : 113
// functions already exported by bindgen : 116
// -------------------------------------------
// (X) wont: 10
// (D) depr: 4
@ -33,6 +33,7 @@
//W# ncplane_dim_yx
//W ncplane_dup
//W# ncplane_erase
// ncplane_erase_region
//W ncplane_fadein
//W ncplane_fadein_iteration
//W ncplane_fadeout
@ -40,6 +41,7 @@
//W ncplane_format
//W ncplane_gradient
//W ncplane_greyscale
// ncplane_halign
//W ncplane_highgradient
//W ncplane_highgradient_sized
// ncplane_hline_interp
@ -113,6 +115,7 @@
//W ncplane_translate
//W ncplane_translate_abs
// ncplane_userptr
// ncplane_valign
// ncplane_vline_interp
// X ncplane_vprintf_aligned
// X ncplane_vprintf_stained

View File

@ -516,9 +516,7 @@ impl NcDirectF {
options: &NcVisualOptions,
) -> NcResult<&mut NcDirectV> {
error_ref_mut![
unsafe {
crate::ncdirectf_render(ncd, self, options)
},
unsafe { crate::ncdirectf_render(ncd, self, options) },
"NcVisual.render()"
]
}
@ -532,14 +530,7 @@ impl NcDirectF {
) -> NcResult<NcVGeom> {
let mut geom = NcVGeom::new();
let res = unsafe {
crate::ncdirectf_geom(
ncd,
self,
options,
&mut geom,
)
};
let res = unsafe { crate::ncdirectf_geom(ncd, self, options, &mut geom) };
error![res, "NcDirectF.ncdirectf_geom()", geom];
}
}

View File

@ -1,4 +1,4 @@
// functions already exported by bindgen : 22
// functions already exported by bindgen : 24
// -----------------------------------------
// (W) wrap: 20
// (#) test: 0
@ -10,6 +10,7 @@
//W ncvisual_at_yx
//W ncvisual_decode
//W ncvisual_decode_loop
// ncvisual_default_blitter
//W ncvisual_destroy
//W ncvisual_from_bgra
//W ncvisual_from_file
@ -19,6 +20,7 @@
//W ncvisual_blitter_geom
//W ncvisual_media_defblitter
//W ncvisual_polyfill_yx
// ncvisual_plane_create
//W ncvisual_render
//W ncvisual_resize
//W ncvisual_rotate
@ -32,7 +34,7 @@ use crate::{NcChannel, NcDim, NcRgb};
mod methods;
/// How to scale an [`NcVisual`] during rendering
/// How to scale an [`NcVisual`] during rendering.
///
/// - [`NCSCALE_NONE`] will apply no scaling.
/// - [`NCSCALE_SCALE`] scales a visual to the plane's size,
@ -155,7 +157,7 @@ pub const NCVISUAL_OPTION_HORALIGNED: u32 = crate::bindings::ffi::NCVISUAL_OPTIO
/// Uses non-interpolative scaling.
pub const NCVISUAL_OPTION_NOINTERPOLATE: u32 = crate::bindings::ffi::NCVISUAL_OPTION_NOINTERPOLATE;
/// Blitter Mode (`NCBLIT_*`)
/// The blitter mode to use for rasterizing an [`NcVisual`].
///
/// We never blit full blocks, but instead spaces (more efficient) with the
/// background set to the desired foreground.

View File

@ -5,24 +5,17 @@ PENDING changes
## from changes-20210406-20210410.txt
bindgen add:
- [ ] ncdirect_stream
- [x] ncdirect_stream
## from changes-20120518-20210603.txt …
- ncdirect_styles
- ncdirect_supported_styles
- [x] ncdirect_styles
- [x] ncdirect_supported_styles
- ncplane_erase_region
- ncplane_align
- [x] ncplane_erase_region
- ncvisual_default_blitter
- ncvisualplane_create
- [x] nccell_width
- nccell_width
- [x] notcurses_cursor_yx
- ncpalette_get_rgb8
- ncpalette_set_rgb8
- notcurses_cursor_yx
- ncinput_nomod_p
- [x] ncinput_nomod_p