rust: review functions; update headers

pull/1097/head
joseLuís 4 years ago
parent 40621b7b95
commit cb16c52eef

@ -1,59 +1,60 @@
// functions already exported by bindgen : 6
// -----------------------------------------
// - cell_duplicate
// - cell_extended_gcluster
// - cell_load
// - cell_release
// - cells_double_box
// - cells_rounded_box
// cell_duplicate
// cell_extended_gcluster
// cell_load
// cell_release
// cells_double_box
// cells_rounded_box
//
// static inline functions to reimplement: 42
// ------------------------------------------ (done / (x) wont / remaining)
// (+) implement : 40 / 2 / 0
// (#) unit tests: 0 / 2 / 40
// static inline functions total: 42
// ------------------------------------------ (implement / remaining)
// (X) wont: 2
// (+) done: 40 / 0
// (#) test: 0 / 40
// ------------------------------------------
//+cell_bchannel
//+cell_bg_alpha
//+cell_bg_default_p
//+cell_bg_palindex
//+cell_bg_palindex_p
//+cell_bg_rgb
//+cell_bg_rgb8
//+cellcmp
//+cell_double_wide_p
//+cell_extract
//+cell_fchannel
//+cell_fg_alpha
//+cell_fg_default_p
//+cell_fg_palindex
//+cell_fg_palindex_p
//+cell_fg_rgb
//+cell_fg_rgb8
//+cell_init
//+cell_load_simple
//+cell_prime
//+cell_set_bchannel
//+cell_set_bg_alpha
//+cell_set_bg_default
//+cell_set_bg_palindex
//+cell_set_bg_rgb
//+cell_set_bg_rgb8
//xcell_set_bg_rgb8_clipped // unneeded
//+cell_set_fchannel
//+cell_set_fg_alpha
//+cell_set_fg_default
//+cell_set_fg_palindex
//+cell_set_fg_rgb
//+cell_set_fg_rgb8
//xcell_set_fg_rgb8_clipped // unneeded
//+cells_load_box
//+cell_strdup
//+cell_styles
//+cell_styles_off
//+cell_styles_on
//+cell_styles_set
//+cell_wide_left_p
//+cell_wide_right_p
//+ cell_bchannel
//+ cell_bg_alpha
//+ cell_bg_default_p
//+ cell_bg_palindex
//+ cell_bg_palindex_p
//+ cell_bg_rgb
//+ cell_bg_rgb8
//+ cellcmp
//+ cell_double_wide_p
//+ cell_extract
//+ cell_fchannel
//+ cell_fg_alpha
//+ cell_fg_default_p
//+ cell_fg_palindex
//+ cell_fg_palindex_p
//+ cell_fg_rgb
//+ cell_fg_rgb8
//+ cell_init
//+ cell_load_simple
//+ cell_prime
//+ cell_set_bchannel
//+ cell_set_bg_alpha
//+ cell_set_bg_default
//+ cell_set_bg_palindex
//+ cell_set_bg_rgb
//+ cell_set_bg_rgb8
//X cell_set_bg_rgb8_clipped // unneeded
//+ cell_set_fchannel
//+ cell_set_fg_alpha
//+ cell_set_fg_default
//+ cell_set_fg_palindex
//+ cell_set_fg_rgb
//+ cell_set_fg_rgb8
//X cell_set_fg_rgb8_clipped // unneeded
//+ cells_load_box
//+ cell_strdup
//+ cell_styles
//+ cell_styles_off
//+ cell_styles_on
//+ cell_styles_set
//+ cell_wide_left_p
//+ cell_wide_right_p
use crate as nc;
use nc::types::{

@ -1,4 +1,4 @@
// ---------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// - The channel components are u8 instead of u32.
// Because of type enforcing, some runtime checks are now unnecessary.
//
@ -9,53 +9,56 @@
// - `channel_set_rgb_clipped()`
// - `channels_set_fg_rgb8_clipped()`
// - `channels_set_bg_rgb8_clipped()`
// ---------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
// functions already exported by bindgen : 0
// ------------------------------------------
//
// static inline functions to reimplement: 37
// ------------------------------------------ (done / (x) wont / remaining)
// (+) implement : 34 / 3 / 0
// (#) unit tests: 14 / 3 / 20
// static inline functions total: 39
// ------------------------------------------ (implement / remaining)
// (X) wont: 3
// (+) done: 34 / 2
// (#) test: 14 / 22
// ------------------------------------------
//#channel_alpha
//#channel_b
//#channel_default_p
//#channel_g
//+channel_palindex_p
//#channel_r
//#channel_rgb
//#channels_bchannel
//+channels_bg_alpha
//+channels_bg_default_p
//+channels_bg_palindex_p
//+channels_bg_rgb
//+channels_bg_rgb8
//#channels_combine
//+channel_set
//#channel_set_alpha
//#channel_set_default
//#channel_set_rgb
//xchannel_set_rgb_clipped
//#channels_fchannel
//+channels_fg_alpha
//+channels_fg_default_p
//+channels_fg_palindex_p
//+channels_fg_rgb
//+channels_fg_rgb8
//#channels_set_bchannel
//+channels_set_bg_alpha
//+channels_set_bg_default
//+channels_set_bg_rgb
//+channels_set_bg_rgb8
//xchannels_set_bg_rgb8_clipped
//#channels_set_fchannel
//+channels_set_fg_alpha
//+channels_set_fg_default
//+channels_set_fg_rgb
//+channels_set_fg_rgb8
//xchannels_set_fg_rgb8_clipped
//# channel_alpha
//# channel_b
//# channel_default_p
//# channel_g
//+ channel_palindex_p
//# channel_r
//# channel_rgb8
//# channels_bchannel
//+ channels_bg_alpha
//+ channels_bg_default_p
//+ channels_bg_palindex_p
//+ channels_bg_rgb
//+ channels_bg_rgb8
//# channels_combine
//+ channel_set
//# channel_set_alpha
//# channel_set_default
//# channel_set_rgb8
//X channel_set_rgb_clipped
//# channels_fchannel
//+ channels_fg_alpha
//+ channels_fg_default_p
//+ channels_fg_palindex_p
//+ channels_fg_rgb
//+ channels_fg_rgb8
//# channels_set_bchannel
//+ channels_set_bg_alpha
//+ channels_set_bg_default
// channels_set_bg_palindex
//+ channels_set_bg_rgb
//+ channels_set_bg_rgb8
//X channels_set_bg_rgb8_clipped
//# channels_set_fchannel
//+ channels_set_fg_alpha
//+ channels_set_fg_default
// channels_set_fg_palindex
//+ channels_set_fg_rgb
//+ channels_set_fg_rgb8
//X channels_set_fg_rgb8_clipped
use crate as nc;

@ -1,8 +1,8 @@
// functions already exported by bindgen : 30
// functions already exported by bindgen : 38
// ------------------------------------------
// ncdirect_bg
// ncdirect_bg_default
// ncdirect_bg_palindex
// ncdirect_bg_rgb
// ncdirect_box
// ncdirect_canopen_images
// ncdirect_canutf8
@ -20,11 +20,14 @@
// ncdirect_dim_x
// ncdirect_dim_y
// ncdirect_double_box
// ncdirect_fg
// ncdirect_fg_default
// ncdirect_fg_palindex
// ncdirect_fg_rgb
// ncdirect_flush
// ncdirect_getc
// ncdirect_hline_interp
// ncdirect_init
// ncdirect_init // wrapped at start()
// ncdirect_inputready_fd
// ncdirect_palette_size
// ncdirect_printf_aligned
// ncdirect_putstr
@ -35,7 +38,6 @@
// ncdirect_styles_on
// ncdirect_styles_set
// ncdirect_vline_interp
//
use crate as nc;
use nc::types::DirectMode;
@ -48,22 +50,10 @@ extern "C" {
///
/// Initialize a direct-mode notcurses context on the tty.
///
/// Direct mode supportes a limited subset of notcurses routines,
/// and neither supports nor requires notcurses_render().
/// This can be used to add color and styling to text in the standard output paradigm.
/// Direct mode supports a limited subset of notcurses routines,
/// and neither supports nor requires notcurses_render(). This can be
/// used to add color and styling to text in the standard output paradigm.
/// Returns NULL on error, including any failure initializing terminfo.
pub unsafe fn ncdirect_start() -> *mut DirectMode {
nc::ncdirect_init(core::ptr::null(), libc_stdout(), 0)
}
#[cfg(test)]
mod test {
// use super::nc;
// use serial_test::serial;
/*
#[test]
#[serial]
fn () {
}
*/
}

@ -1,25 +1,23 @@
// functions already exported by bindgen : 0
// ------------------------------------------
//
// static inline functions to reimplement: 2
// ------------------------------------------ (done / (x) wont / remaining)
// (+) implement : 2 / 0 / 0
// (#) unit tests: 0 / 0 / 2
// static inline functions total: 2
// ------------------------------------------ (done / remaining)
// (+) done: 2 / 0
// (#) test: 0 / 2
// ------------------------------------------
//+nckey_mouse_p
//+nckey_supppuab_p
//+ nckey_mouse_p
//+ nckey_supppuab_p
use crate as nc;
/// Is this char32_t a Supplementary Private Use Area-B codepoint?
// TODO: TEST
#[inline]
pub fn nckey_supppuab_p(w: u32) -> bool {
w >= 0x100000 && w <= 0x10fffd
}
/// Is the event a synthesized mouse event?
// TODO: TEST
#[inline]
pub fn nckey_mouse_p(r: u32) -> bool {
r >= nc::NCKEY_BUTTON1 && r <= nc::NCKEY_RELEASE

@ -1,6 +1,7 @@
// functions already exported by bindgen : 35
// functions already exported by bindgen : 36
// ------------------------------------------
// notcurses_at_yx
// notcurses_bottom
// notcurses_canchangecolor
// notcurses_canfade
// notcurses_canopen_images
@ -23,10 +24,11 @@
// notcurses_palette_size
// notcurses_refresh
// notcurses_render
// notcurses_render_to_buffer
// notcurses_render_to_file
// notcurses_stats
// notcurses_stats_alloc
// notcurses_stats_reset
// notcurses_stats
// notcurses_stdplane
// notcurses_stdplane_const
// notcurses_stop
@ -34,24 +36,26 @@
// notcurses_str_scalemode
// notcurses_supported_styles
// notcurses_top
// notcurses_ucs32_to_utf8
// notcurses_version
// notcurses_version_components
//
// static inline functions to reimplement: 4
// ----------------------------------------- (done / (x) wont / remaining)
// (+) implement : 4 / 0 / 1
// (#) unit tests: 0 / 0 / 5
// static inline functions total: 6
// ----------------------------------------- (done / remaining)
// (+) implement : 5 / 1
// (#) unit tests: 0 / 6
// -----------------------------------------
//+notcurses_align
//+notcurses_getc_blocking
//+notcurses_getc_nblock
//+notcurses_stddim_yx
//+notcurses_term_dim_yx
//+ notcurses_align
//+ notcurses_getc_blocking
//+ notcurses_getc_nblock
//+ notcurses_stddim_yx
// notcurses_stddim_yx_const
//+ notcurses_term_dim_yx
use core::ptr::null;
use crate as nc;
use nc::types::{Align, Input, FullMode, Plane, ALIGN_CENTER, ALIGN_LEFT};
use nc::types::{Align, FullMode, Input, Plane, ALIGN_CENTER, ALIGN_LEFT};
/// return the offset into 'availcols' at which 'cols' ought be output given the requirements of 'align'
// TODO: TEST
@ -117,6 +121,11 @@ pub fn notcurses_term_dim_yx(nc: &FullMode, rows: &mut i32, cols: &mut i32) {
}
}
// TODO
// pub unsafe fn notcurses_start() -> *mut FullMode {
// nc::notcurses_init(core::ptr::null(), libc_stdout())
// }
#[cfg(test)]
mod test {
// use super::nc;

@ -8,20 +8,19 @@
// palette256_new
// palette256_use
//
// static inline functions to reimplement: 3
// ----------------------------------------- (done / (x) wont / remaining)
// (+) implement : 3 / 0 / 0
// (#) unit tests: 0 / 0 / 3
// static inline functions total: 3
// ----------------------------------------- (done / remaining)
// (+) implement : 3 / 0
// (#) unit tests: 0 / 3
// -----------------------------------------
//+palette256_get_rgb
//+palette256_set
//+palette256_set_rgb
//+ palette256_get_rgb
//+ palette256_set
//+ palette256_set_rgb
use crate as nc;
use nc::types::{Channel, Color, Palette, PaletteIndex, Rgb};
/// Set the different color components of an entry inside a palette store.
// TODO: TEST
#[inline]
pub fn palette256_set_rgb(
palette: &mut Palette,
@ -34,14 +33,12 @@ pub fn palette256_set_rgb(
}
/// Same as `palette256_set_rgb()` but set an assembled 24 bit channel at once.
// TODO: TEST
#[inline]
pub fn palette256_set(palette: &mut Palette, idx: PaletteIndex, rgb: Rgb) {
nc::channel_set(&mut palette.chans[idx as usize], rgb);
}
/// Extract the three 8-bit R/G/B components from an entry inside a palette store.
// TODO: TEST
#[inline]
pub fn palette256_get_rgb(
palette: &Palette,

@ -11,21 +11,21 @@
// functions already exported by bindgen : 0
// -----------------------------------------
//
// static inline functions to reimplement: 10
// ------------------------------------------ (done / (x) wont / remaining)
// (+) implement : 10 / 0 / 0
// (#) unit tests: 0 / 0 / 10
// static inline functions total: 10
// ------------------------------------------ (done / remaining)
// (+) implement : 10 / 0
// (#) unit tests: 0 / 10
// ------------------------------------------
//+ncpixel
//+ncpixel_a
//+ncpixel_b
//+ncpixel_g
//+ncpixel_r
//+ncpixel_set_a
//+ncpixel_set_b
//+ncpixel_set_g
//+ncpixel_set_r
//+ncpixel_set_rgb
//+ ncpixel
//+ ncpixel_a
//+ ncpixel_b
//+ ncpixel_g
//+ ncpixel_r
//+ ncpixel_set_a
//+ ncpixel_set_b
//+ ncpixel_set_g
//+ ncpixel_set_r
//+ ncpixel_set_rgb
use crate as nc;
use nc::types::{Color, Pixel};

@ -1,8 +1,7 @@
// functions already exported by bindgen : 94
// functions already exported by bindgen : 97
// ------------------------------------------
// ncplane_above
// ncplane_at_cursor
// ncplane_attr
// ncplane_at_yx
// ncplane_base
// ncplane_below
@ -35,8 +34,11 @@
// ncplane_move_bottom
// ncplane_move_top
// ncplane_move_yx
// ncplane_new
// ncplane_notcurses
// ncplane_notcurses_const
// ncplane_off_styles
// ncplane_on_styles
// ncplane_parent
// ncplane_parent_const
// ncplane_polyfill_yx
@ -60,7 +62,6 @@
// ncplane_rgba
// ncplane_rotate_ccw
// ncplane_rotate_cw
// ncplane_set_attr
// ncplane_set_base
// ncplane_set_base_cell
// ncplane_set_bchannel
@ -79,8 +80,10 @@
// ncplane_set_fg_rgb8
// ncplane_set_fg_rgb8_clipped
// ncplane_set_scrolling
// ncplane_set_styles
// ncplane_set_userptr
// ncplane_stain
// ncplane_styles
// ncplane_styles_off
// ncplane_styles_on
// ncplane_styles_set
@ -95,57 +98,54 @@
// ncplane_y
// ncplane_yx
//
// NOTE: functions removed:
// ncplane_styles (duplicates ncplane_attr)
//
// static inline functions to reimplement: 41
// ------------------------------------------ (done / (x) wont / remaining)
// (+) implement: 34 / 7 / 0
// (#) unit test: 0 / 7 / 34
// static inline functions total: 42
// ------------------------------------------ (implement / remaining)
// (X) wont: 8
// (+) done: 32 / 2
// (#) test: 0 / 34
// ------------------------------------------
//+ncplane_align
//+ncplane_at_cursor_cell
//+ncplane_at_yx_cell
//+ncplane_bchannel
//+ncplane_bg_alpha
//+ncplane_bg_default_p
//+ncplane_bg_rgb
//+ncplane_bg_rgb8
//+ncplane_box_sized
//+ncplane_dim_x
//+ncplane_dim_y
//+ncplane_double_box
//+ncplane_double_box_sized
//+ncplane_fchannel
//+ncplane_fg <<<<
//+ncplane_fg_alpha
//+ncplane_fg_default_p
//+ncplane_fg_rgb
//+ncplane_fg_rgb8
//+ncplane_gradient_sized // u64|u32 https://github.com/dankamongmen/notcurses/issues/920
//+ncplane_hline
//+ncplane_perimeter
//+ncplane_perimeter_double
//+ncplane_perimeter_rounded
//+ncplane_putc
// ncplane_putchar
// ncplane_putchar_yx
//+ncplane_putegc
//+ncplane_putnstr
//+ncplane_putstr
//xncplane_putwc // I don't think these will be needed from Rust. See:
//xncplane_putwc_stained
//xncplane_putwc_yx // https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/content/features_of_rust/strings.html
//xncplane_putwegc //
//xncplane_putwegc_yx //
//xncplane_putwstr //
//xncplane_putwstr_aligned //
//xncplane_putwstr_yx //
//+ncplane_resize_simple
//+ncplane_rounded_box
//+ncplane_rounded_box_sized
//+ncplane_vline
//+ncplane_vprintf
//+ ncplane_align
//+ ncplane_at_cursor_cell
//+ ncplane_at_yx_cell
//+ ncplane_bchannel
//+ ncplane_bg_alpha
//+ ncplane_bg_default_p
//+ ncplane_bg_rgb
//+ ncplane_bg_rgb8
//+ ncplane_box_sized
//+ ncplane_dim_x
//+ ncplane_dim_y
//+ ncplane_double_box
//+ ncplane_double_box_sized
//+ ncplane_fchannel
//+ ncplane_fg_alpha
//+ ncplane_fg_default_p
//+ ncplane_fg_rgb
//+ ncplane_fg_rgb8
//+ ncplane_gradient_sized // u64|u32 https://github.com/dankamongmen/notcurses/issues/920
//+ ncplane_hline
//+ ncplane_perimeter
//+ ncplane_perimeter_double
//+ ncplane_perimeter_rounded
//+ ncplane_putc
// ncplane_putchar
// ncplane_putchar_yx
//+ ncplane_putegc
//+ ncplane_putnstr
//+ ncplane_putstr
//X ncplane_putwc // I don't think these will be needed from Rust. See:
//X ncplane_putwc_stained
//X ncplane_putwc_yx // https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/content/features_of_rust/strings.html
//X ncplane_putwegc //
//X ncplane_putwegc_yx //
//X ncplane_putwstr //
//X ncplane_putwstr_aligned //
//X ncplane_putwstr_yx //
//+ ncplane_resize_simple
//+ ncplane_rounded_box
//+ ncplane_rounded_box_sized
//+ ncplane_vline
//+ ncplane_vprintf
//
// NOTE: TODO: Still remains all the ncplane_printf* functions/macros (at the end)

Loading…
Cancel
Save