From 125ab361e6213367d111c80ed0e8d9fdbaabb1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Sat, 12 Jun 2021 21:29:03 +0200 Subject: [PATCH] [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. --- rust/src/bindings.rs | 6 ++++ rust/src/cells/mod.rs | 3 +- rust/src/direct/mod.rs | 7 +++-- rust/src/input/mod.rs | 38 +++++++++++++---------- rust/src/notcurses/mod.rs | 5 +-- rust/src/palette/mod.rs | 4 ++- rust/src/palette/reimplemented.rs | 4 +-- rust/src/plane/mod.rs | 5 ++- rust/src/visual/methods.rs | 13 ++------ rust/src/visual/mod.rs | 8 +++-- tools/function-summary/PENDING-changes.md | 21 +++++-------- 11 files changed, 61 insertions(+), 53 deletions(-) diff --git a/rust/src/bindings.rs b/rust/src/bindings.rs index 12edb1275..a2d05a832 100644 --- a/rust/src/bindings.rs +++ b/rust/src/bindings.rs @@ -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, diff --git a/rust/src/cells/mod.rs b/rust/src/cells/mod.rs index 4bfdc6be4..a6ddf40eb 100644 --- a/rust/src/cells/mod.rs +++ b/rust/src/cells/mod.rs @@ -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 diff --git a/rust/src/direct/mod.rs b/rust/src/direct/mod.rs index 1af8f31d8..bd5bb6407 100644 --- a/rust/src/direct/mod.rs +++ b/rust/src/direct/mod.rs @@ -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 diff --git a/rust/src/input/mod.rs b/rust/src/input/mod.rs index 0d82f3f94..c9c598109 100644 --- a/rust/src/input/mod.rs +++ b/rust/src/input/mod.rs @@ -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 +} diff --git a/rust/src/notcurses/mod.rs b/rust/src/notcurses/mod.rs index 41df3ddbb..6c9c73171 100644 --- a/rust/src/notcurses/mod.rs +++ b/rust/src/notcurses/mod.rs @@ -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 diff --git a/rust/src/palette/mod.rs b/rust/src/palette/mod.rs index 67266472f..904683f50 100644 --- a/rust/src/palette/mod.rs +++ b/rust/src/palette/mod.rs @@ -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; diff --git a/rust/src/palette/reimplemented.rs b/rust/src/palette/reimplemented.rs index c5e8ad711..48b58d374 100644 --- a/rust/src/palette/reimplemented.rs +++ b/rust/src/palette/reimplemented.rs @@ -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, diff --git a/rust/src/plane/mod.rs b/rust/src/plane/mod.rs index c04609bd3..09da7beeb 100644 --- a/rust/src/plane/mod.rs +++ b/rust/src/plane/mod.rs @@ -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 diff --git a/rust/src/visual/methods.rs b/rust/src/visual/methods.rs index 629eca043..8252f7f37 100644 --- a/rust/src/visual/methods.rs +++ b/rust/src/visual/methods.rs @@ -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 { 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]; } } diff --git a/rust/src/visual/mod.rs b/rust/src/visual/mod.rs index 026d575d1..8e63f3f43 100644 --- a/rust/src/visual/mod.rs +++ b/rust/src/visual/mod.rs @@ -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. diff --git a/tools/function-summary/PENDING-changes.md b/tools/function-summary/PENDING-changes.md index c9b864ff5..0743dca76 100644 --- a/tools/function-summary/PENDING-changes.md +++ b/tools/function-summary/PENDING-changes.md @@ -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