From 6b22e76b6a7a074924f801ac54105cd3825fd9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 16 Sep 2021 13:09:09 +0200 Subject: [PATCH 1/3] [rust] move NcPixelImpl to notcurses mod --- rust/src/notcurses/mod.rs | 25 +++++++++++++++++++++++++ rust/src/visual/mod.rs | 23 ----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/rust/src/notcurses/mod.rs b/rust/src/notcurses/mod.rs index 003151c5e..04f587391 100644 --- a/rust/src/notcurses/mod.rs +++ b/rust/src/notcurses/mod.rs @@ -220,3 +220,28 @@ pub const NCALIGN_CENTER: NcAlign = crate::bindings::ffi::ncalign_e_NCALIGN_CENT /// Do not align an [`NcPlane`][crate::NcPlane] or terminal. pub const NCALIGN_UNALIGNED: NcAlign = crate::bindings::ffi::ncalign_e_NCALIGN_UNALIGNED; + +// NcPixelImpl ----------------------------------------------------------------- + +/// Pixel blitting implementations. (Informative only). +/// +/// Returned by [`check_pixel_support`][Notcurses#method.check_pixel_support]. +pub type NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e; + +/// No pixel support. +pub const NCPIXEL_NONE: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_NONE; +/// Sixel +pub const NCPIXEL_SIXEL: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_SIXEL; +/// Linux framebuffer. +pub const NCPIXEL_LINUXFB: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_LINUXFB; +/// iTerm2 +pub const NCPIXEL_ITERM2: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_ITERM2; +/// Kitty prior to C=1 and animation. +pub const NCPIXEL_KITTY_STATIC: NcPixelImpl = + crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_STATIC; +/// Kitty with animation but not reflexive composition. +pub const NCPIXEL_KITTY_ANIMATED: NcPixelImpl = + crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_ANIMATED; +/// Kitty with reflexive composition. +pub const NCPIXEL_KITTY_SELFREF: NcPixelImpl = + crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_SELFREF; diff --git a/rust/src/visual/mod.rs b/rust/src/visual/mod.rs index b374133c0..b184c1916 100644 --- a/rust/src/visual/mod.rs +++ b/rust/src/visual/mod.rs @@ -235,29 +235,6 @@ pub const NCBLIT_DEFAULT: NcBlitter = crate::bindings::ffi::ncblitter_e_NCBLIT_D /// See [Sixel in Wikipedia](https://en.wikipedia.org/wiki/Sixel). pub const NCBLIT_PIXEL: NcBlitter = crate::bindings::ffi::ncblitter_e_NCBLIT_PIXEL; -/// Pixel blitting implementations. (Informative only). -/// -/// Returned by [`check_pixel_support`][Notcurses#method.check_pixel_support]. -pub type NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e; - -/// No pixel support. -pub const NCPIXEL_NONE: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_NONE; -/// Sixel -pub const NCPIXEL_SIXEL: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_SIXEL; -/// Linux framebuffer. -pub const NCPIXEL_LINUXFB: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_LINUXFB; -/// iTerm2 -pub const NCPIXEL_ITERM2: NcPixelImpl = crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_ITERM2; -/// Kitty prior to C=1 and animation. -pub const NCPIXEL_KITTY_STATIC: NcPixelImpl = - crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_STATIC; -/// Kitty with animation but not reflexive composition. -pub const NCPIXEL_KITTY_ANIMATED: NcPixelImpl = - crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_ANIMATED; -/// Kitty with reflexive composition. -pub const NCPIXEL_KITTY_SELFREF: NcPixelImpl = - crate::bindings::ffi::ncpixelimpl_e_NCPIXEL_KITTY_SELFREF; - /// Contains the pixel geometry information as returned by the /// NcPlane.[pixelgeom()][crate::NcPlane#method.pixelgeom] method. /// From ac5b31960c9ce45d01479620ebd7865fd60d13b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 16 Sep 2021 13:10:40 +0200 Subject: [PATCH 2/3] [rust] replace `*_getc` functions by `*_get` --- rust/src/bindings.rs | 4 ++-- rust/src/direct/methods.rs | 4 +--- rust/src/direct/reimplemented.rs | 6 +++--- rust/src/notcurses/methods.rs | 5 ++--- rust/src/notcurses/reimplemented.rs | 6 ++---- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/rust/src/bindings.rs b/rust/src/bindings.rs index de8697cdb..da87d6a8f 100644 --- a/rust/src/bindings.rs +++ b/rust/src/bindings.rs @@ -189,7 +189,7 @@ pub use ffi::{ ncdirect_dim_y, ncdirect_double_box, ncdirect_flush, - ncdirect_getc, + ncdirect_get, ncdirect_init, ncdirect_inputready_fd, ncdirect_off_styles, @@ -794,7 +794,7 @@ pub use ffi::{ notcurses_debug, notcurses_detected_terminal, notcurses_drop_planes, - notcurses_getc, + notcurses_get, notcurses_init, notcurses_inputready_fd, notcurses_lex_blitter, diff --git a/rust/src/direct/methods.rs b/rust/src/direct/methods.rs index ea7abed7a..5a77a45fd 100644 --- a/rust/src/direct/methods.rs +++ b/rust/src/direct/methods.rs @@ -571,9 +571,7 @@ impl NcDirect { } else { ninput = null_mut(); } - let c = unsafe { - core::char::from_u32_unchecked(crate::ncdirect_getc(self, ntime, null_mut(), ninput)) - }; + let c = unsafe { core::char::from_u32_unchecked(crate::ncdirect_get(self, ntime, ninput)) }; if c as u32 as i32 == NCRESULT_ERR { return Err(NcError::new()); } diff --git a/rust/src/direct/reimplemented.rs b/rust/src/direct/reimplemented.rs index ac542b0da..d8a80b6e8 100644 --- a/rust/src/direct/reimplemented.rs +++ b/rust/src/direct/reimplemented.rs @@ -1,6 +1,6 @@ //! `ncdirect_*` reimplemented functions. -use core::ptr::{null, null_mut}; +use core::ptr::null; use crate::{ cstring, NcCapabilities, NcChannels, NcComponent, NcDim, NcDirect, NcInput, NcIntResult, NcRgb, @@ -68,7 +68,7 @@ pub fn ncdirect_capabilities(ncd: &NcDirect) -> NcCapabilities { // TODO: use from_u32 & return Option. #[inline] pub fn ncdirect_getc_blocking(ncd: &mut NcDirect, input: &mut NcInput) -> char { - unsafe { core::char::from_u32_unchecked(crate::ncdirect_getc(ncd, null(), null_mut(), input)) } + unsafe { core::char::from_u32_unchecked(crate::ncdirect_get(ncd, null(), input)) } } /// @@ -81,7 +81,7 @@ pub fn ncdirect_getc_blocking(ncd: &mut NcDirect, input: &mut NcInput) -> char { pub fn ncdirect_getc_nblock(ncd: &mut NcDirect, input: &mut NcInput) -> char { unsafe { let ts = NcTime::new(); - core::char::from_u32_unchecked(crate::ncdirect_getc(ncd, &ts, null_mut(), input)) + core::char::from_u32_unchecked(crate::ncdirect_get(ncd, &ts, input)) } } diff --git a/rust/src/notcurses/methods.rs b/rust/src/notcurses/methods.rs index 8d2d0473b..15137c595 100644 --- a/rust/src/notcurses/methods.rs +++ b/rust/src/notcurses/methods.rs @@ -331,9 +331,8 @@ impl Nc { } else { ninput = null_mut(); } - let c = unsafe { - core::char::from_u32_unchecked(crate::notcurses_getc(self, ntime, null_mut(), ninput)) - }; + let c = + unsafe { core::char::from_u32_unchecked(crate::notcurses_get(self, ntime, ninput)) }; if c as u32 as i32 == NCRESULT_ERR { return Err(NcError::new()); } diff --git a/rust/src/notcurses/reimplemented.rs b/rust/src/notcurses/reimplemented.rs index c04278c30..875e698bd 100644 --- a/rust/src/notcurses/reimplemented.rs +++ b/rust/src/notcurses/reimplemented.rs @@ -44,7 +44,7 @@ pub fn notcurses_getc_nblock(nc: &mut Nc, input: &mut NcInput) -> char { tv_sec: 0, tv_nsec: 0, }; - core::char::from_u32_unchecked(crate::notcurses_getc(nc, &ts, null_mut(), input)) + core::char::from_u32_unchecked(crate::notcurses_get(nc, &ts, input)) } } @@ -63,9 +63,7 @@ pub fn notcurses_getc_blocking(nc: &mut Nc, input: Option<&mut NcInput>) -> char } else { input_ptr = null_mut(); } - unsafe { - core::char::from_u32_unchecked(crate::notcurses_getc(nc, null(), null_mut(), input_ptr)) - } + unsafe { core::char::from_u32_unchecked(crate::notcurses_get(nc, null(), input_ptr)) } } /// [notcurses_stdplane()][crate::notcurses_stdplane], plus free bonus From 5c3fdbe67799fbed667c6733810f09428c5b72fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 16 Sep 2021 13:13:26 +0200 Subject: [PATCH 3/3] [rust] minor docs & style fixes --- rust/Cargo.toml | 6 ++---- rust/src/channel/mod.rs | 2 +- rust/src/input/mod.rs | 9 +++------ rust/src/plane/mod.rs | 4 ---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 9281fe25d..a8a3604a8 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,8 +2,8 @@ name = "libnotcurses-sys" version = "2.4.1" authors = [ - "nick black ", - "José Luis Cruz " + "nick black ", + "José Luis Cruz " ] license = "MIT OR Apache-2.0" edition = "2018" @@ -29,8 +29,6 @@ libc = { version = "^0.2.80", default-features = false } cty = "^0.2.1" [build-dependencies] -# https://github.com/rust-lang/rust-bindgen/blob/master/CHANGELOG.md#0551 -# https://pkgs.org/search/?q=bindgen bindgen = "^0.57" pkg-config = "^0.3.18" diff --git a/rust/src/channel/mod.rs b/rust/src/channel/mod.rs index 3ea6c938a..ec1716b5e 100644 --- a/rust/src/channel/mod.rs +++ b/rust/src/channel/mod.rs @@ -281,7 +281,7 @@ pub const NCALPHA_FG_RGB_MASK: u64 = crate::bindings::ffi::NC_FG_RGB_MASK; /// pub type NcChannels = u64; -#[deprecated] +#[deprecated = "use NcChannels instead"] #[doc(hidden)] pub type NcChannelPair = NcChannels; diff --git a/rust/src/input/mod.rs b/rust/src/input/mod.rs index bab193a9a..1769e8191 100644 --- a/rust/src/input/mod.rs +++ b/rust/src/input/mod.rs @@ -15,13 +15,10 @@ use crate::NcDim; mod keycodes; pub use keycodes::*; -/// Reads and decodes input events +/// Reads and decodes input events. /// -/// Reads from stdin and decodes the input to stdout, -/// including synthesized events and mouse events. -/// -/// -/// Notcurses provides input from keyboards and mice. +/// Reads from stdin and decodes the input to stdout, including synthesized +/// events and mouse events. Notcurses provides input from keyboards and mice. /// Single Unicode codepoints are received from the keyboard, directly encoded /// as `u32`. /// diff --git a/rust/src/plane/mod.rs b/rust/src/plane/mod.rs index 486fbe4d2..2cc36acb9 100644 --- a/rust/src/plane/mod.rs +++ b/rust/src/plane/mod.rs @@ -53,7 +53,6 @@ //W ncplane_move_bottom //W ncplane_move_top //W ncplane_move_yx -// X ncplane_new // deprecated //W# ncplane_notcurses //W# ncplane_notcurses_const //W ncplane_off_styles @@ -110,9 +109,6 @@ // ncplane_set_userptr //W ncplane_stain //W ncplane_styles -// X ncplane_styles_off // deprecated -// X ncplane_styles_on // deprecated -// X ncplane_styles_set // deprecated //W ncplane_translate //W ncplane_translate_abs // ncplane_userptr