prepare modules for pending work

pull/875/head
joseLuís 4 years ago
parent 8759572632
commit 799407f98c

@ -1,4 +1,4 @@
// Already exported by bindgen:
// Already exported by bindgen: 6
//
// - cell_duplicate
// - cell_extended_gcluster
@ -7,20 +7,60 @@
// - cells_double_box
// - cells_rounded_box
//
// Already done by dankamongmen:
// - cell_prime
// - cells_load_box
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h:
// - lines: 543-718 (18 functions)
// - lines: 1729-1901 (26 functions)
// - lines: 2056-2084 (1 function)
// -----------------------------
// - total: 45
// - from notcurses.h: 45
// - done: ±2
// - remaining: 43
//
// ---------------
// + reimplemented
// # and unit test
// --------------
// cell_bchannel
// cell_bg
// cell_bg_alpha
// cell_bg_default_p
// cell_bg_palindex
// cell_bg_palindex_p
// cell_bg_rgb
// cell_blend_bchannel
// cell_blend_fchannel
// cellcmp
// cell_double_wide_p
// cell_extract
// cell_fchannel
// cell_fg
// cell_fg_alpha
// cell_fg_default_p
// cell_fg_palindex
// cell_fg_palindex_p
// cell_fg_rgb
// cell_init
// cell_load_simple
//+cell_prime
// cell_set_bchannel
// cell_set_bg
// cell_set_bg_alpha
// cell_set_bg_default
// cell_set_bg_palindex
// cell_set_bg_rgb
// cell_set_bg_rgb_clipped
// cell_set_fchannel
// cell_set_fg
// cell_set_fg_alpha
// cell_set_fg_default
// cell_set_fg_palindex
// cell_set_fg_rgb
// cell_set_fg_rgb_clipped
// cell_simple_p
//+cells_load_box // FIXME
// cell_strdup
// cell_styles
// cell_styles_off
// cell_styles_on
// cell_styles_set
// cell_wide_left_p
// cell_wide_right_p
//
// NOTE:
// - ? gcluster (&str) > type alias?
@ -60,6 +100,7 @@ pub fn cell_prime(
/// have loaded before the error are cell_release()d. There must be at least
/// six EGCs in gcluster.
// TODO: TEST
// FIXME missing cell_prime()s
pub fn cells_load_box(
plane: *mut ffi::ncplane,
attrs: u32,
@ -72,7 +113,6 @@ pub fn cells_load_box(
_vl: *mut ffi::cell,
gcluster: &str,
) -> IntResult {
// FIXME cell_prime()s
cell_prime(plane, _ul, gcluster, attrs, channels)
}
// static inline int

@ -21,6 +21,56 @@
// - `channels_set_fg_alpha()`
// - `channels_set_bg_alpha()`
//
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 38
// - done: ±37
// - remaining: 1
//
// ---------------
// + reimplemented
// # and unit test
// x not needed
// --------------
//#channel_alpha
//#channel_b
//#channel_default_p // FIXME TEST
//#channel_g
//+channel_palindex_p
//#channel_r
//#channel_rgb
//#channels_bchannel
//+channels_bg
//+channels_bg_alpha
//+channels_bg_default_p
//+channels_bg_palindex_p
//+channels_bg_rgb
// channels_blend // TODO
//#channels_combine
//+channel_set
//#channel_set_alpha
//#channel_set_default
//#channel_set_rgb
//xchannel_set_rgb_clipped
//#channels_fchannel
//+channels_fg
//+channels_fg_alpha
//+channels_fg_default_p
//+channels_fg_palindex_p
//+channels_fg_rgb
//#channels_set_bchannel
//+channels_set_bg
//+channels_set_bg_alpha
//+channels_set_bg_default
//+channels_set_bg_rgb
//xchannels_set_bg_rgb_clipped
//#channels_set_fchannel
//+channels_set_fg
//+channels_set_fg_alpha
//+channels_set_fg_default
//+channels_set_fg_rgb
//xchannels_set_fg_rgb_clipped
//
#![allow(dead_code)]
use crate as ffi;
@ -323,6 +373,45 @@ pub fn channels_set_bg_default(channels: &mut ChannelPair) -> ChannelPair {
*channels
}
/// Returns the result of blending two channels. 'blends' indicates how heavily
/// 'c1' ought be weighed. If 'blends' is 0, 'c1' will be entirely replaced by
/// 'c2'. If 'c1' is otherwise the default color, 'c1' will not be touched,
/// since we can't blend default colors. Likewise, if 'c2' is a default color,
/// it will not be used (unless 'blends' is 0).
///
/// Palette-indexed colors do not blend, and since we need the attrword to store
/// them, we just don't fuck wit' 'em here. Do not pass me palette-indexed
/// channels! I will eat them.
// TODO
// static inline unsigned
// channels_blend(unsigned c1, unsigned c2, unsigned* blends){
// if(channel_alpha(c2) == CELL_ALPHA_TRANSPARENT){
// return c1; // do *not* increment *blends
// }
// unsigned rsum, gsum, bsum;
// channel_rgb(c2, &rsum, &gsum, &bsum);
// bool c2default = channel_default_p(c2);
// if(*blends == 0){
// // don't just return c2, or you set wide status and all kinds of crap
// if(channel_default_p(c2)){
// channel_set_default(&c1);
// }else{
// channel_set_rgb(&c1, rsum, gsum, bsum);
// }
// channel_set_alpha(&c1, channel_alpha(c2));
// }else if(!c2default && !channel_default_p(c1)){
// rsum = (channel_r(c1) * *blends + rsum) / (*blends + 1);
// gsum = (channel_g(c1) * *blends + gsum) / (*blends + 1);
// bsum = (channel_b(c1) * *blends + bsum) / (*blends + 1);
// channel_set_rgb(&c1, rsum, gsum, bsum);
// channel_set_alpha(&c1, channel_alpha(c2));
// }
// ++*blends;
// return c1;
// }
#[cfg(test)]
mod test {
use super::{ffi, Channel, ChannelPair};

@ -0,0 +1,31 @@
// Already exported by bindgen: 0
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 2
// - done: 0
// - remaining: 2
//
// ---------------
// + reimplemented
// # and unit test
// --------------
// nckey_mouse_p
// nckey_supppuab_p
//
// use std::ffi::CString;
//
// use crate as ffi;
// use crate::types::{ChannelPair, IntResult};
// // Is this char32_t a Supplementary Private Use Area-B codepoint?
// static inline bool
// nckey_supppuab_p(char32_t w){
// return w >= 0x100000 && w <= 0x10fffd;
// }
//
// // Is the event a synthesized mouse event?
// static inline bool
// nckey_mouse_p(char32_t r){
// return r >= NCKEY_BUTTON1 && r <= NCKEY_RELEASE;
// }

@ -3,11 +3,19 @@
#![allow(non_snake_case)]
mod cells;
mod channels;
mod channel;
mod key;
mod nc;
mod palette;
mod pixel;
mod plane;
mod types;
pub use cells::*;
pub use channels::*;
pub use channel::*;
pub use key::*;
pub use nc::*;
pub use palette::*;
pub use pixel::*;
pub use plane::*;
pub use types::*;

@ -0,0 +1,92 @@
// Already exported by bindgen: 35
//
// notcurses_at_yx
// notcurses_canchangecolor
// notcurses_canfade
// notcurses_canopen_images
// notcurses_canopen_videos
// notcurses_cansixel
// notcurses_cantruecolor
// notcurses_canutf8
// notcurses_cursor_disable
// notcurses_cursor_enable
// notcurses_debug
// notcurses_drop_planes
// notcurses_getc
// notcurses_init
// notcurses_inputready_fd
// notcurses_lex_blitter
// notcurses_lex_margins
// notcurses_lex_scalemode
// notcurses_mouse_disable
// notcurses_mouse_enable
// notcurses_palette_size
// notcurses_refresh
// notcurses_render
// notcurses_render_to_file
// notcurses_reset_stats
// notcurses_stats
// notcurses_stdplane
// notcurses_stdplane_const
// notcurses_stop
// notcurses_str_blitter
// notcurses_str_scalemode
// notcurses_supported_styles
// notcurses_top
// notcurses_version
// notcurses_version_components
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 4
// - done: 0
// - remaining: 4
//
// ---------------
// + reimplemented
// # and unit test
// --------------
// notcurses_getc_blocking
// notcurses_getc_nblock
// notcurses_stddim_yx
// notcurses_term_dim_yx
// use std::ffi::CString;
//
// use crate as ffi;
// use crate::types::{ChannelPair, IntResult};
// // 'ni' may be NULL if the caller is uninterested in event details. If no event
// // is ready, returns 0.
// static inline char32_t
// notcurses_getc_nblock(struct notcurses* n, ncinput* ni){
// sigset_t sigmask;
// sigfillset(&sigmask);
// struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
// return notcurses_getc(n, &ts, &sigmask, ni);
// }
//
// // 'ni' may be NULL if the caller is uninterested in event details. Blocks
// // until an event is processed or a signal is received.
// static inline char32_t
// notcurses_getc_blocking(struct notcurses* n, ncinput* ni){
// sigset_t sigmask;
// sigemptyset(&sigmask);
// return notcurses_getc(n, NULL, &sigmask, ni);
// }
//
// // notcurses_stdplane(), plus free bonus dimensions written to non-NULL y/x!
// static inline struct ncplane*
// notcurses_stddim_yx(struct notcurses* nc, int* RESTRICT y, int* RESTRICT x){
// struct ncplane* s = notcurses_stdplane(nc); // can't fail
// ncplane_dim_yx(s, y, x); // accepts NULL
// return s;
// }
//
// // Return our current idea of the terminal dimensions in rows and cols.
// static inline void
// notcurses_term_dim_yx(const struct notcurses* n, int* RESTRICT rows, int* RESTRICT cols){
// ncplane_dim_yx(notcurses_stdplane_const(n), rows, cols);
// }

@ -0,0 +1,44 @@
// Already exported by bindgen: 3
//
// palette256_free
// palette256_new
// palette256_use
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 3
// - done: 0
// - remaining: 3
//
// ---------------
// + reimplemented
// # and unit test
// --------------
// palette256_get_rgb
// palette256_set
// palette256_set_rgb
// // Manipulate entries in the palette store 'p'. These are *not* locked.
// static inline int
// palette256_set_rgb(palette256* p, int idx, int r, int g, int b){
// if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){
// return -1;
// }
// return channel_set_rgb(&p->chans[idx], r, g, b);
// }
//
// static inline int
// palette256_set(palette256* p, int idx, unsigned rgb){
// if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){
// return -1;
// }
// return channel_set(&p->chans[idx], rgb);
// }
//
// static inline int
// palette256_get_rgb(const palette256* p, int idx, unsigned* RESTRICT r, unsigned* RESTRICT g, unsigned* RESTRICT b){
// if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){
// return -1;
// }
// return channel_rgb(p->chans[idx], r, g, b);
// }

@ -0,0 +1,108 @@
// Already exported by bindgen: 0
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 10
// - done: 0
// - remaining: 10
//
// ---------------
// + reimplemented
// # and unit test
// --------------
//
// 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 std::ffi::CString;
//
// use crate as ffi;
// use crate::types::{ChannelPair, IntResult};
// // The ncpixel API facilitates direct management of the pixels within an
// // ncvisual (ncvisuals keep a backing store of 32-bit RGBA pixels, and render
// // them down to terminal graphics in ncvisual_render()).
// static inline uint32_t
// ncpixel(int r, int g, int b){
// if(r < 0) r = 0;
// if(r > 255) r = 255;
// if(g < 0) g = 0;
// if(g > 255) g = 255;
// if(b < 0) b = 0;
// if(b > 255) b = 255;
// return 0xff000000ul | r | (b << 8u) | (g << 16u);
// }
//
// static inline unsigned
// ncpixel_a(uint32_t pixel){
// return (pixel & 0xff0000fful) >> 24u;
// }
//
// static inline unsigned
// ncpixel_r(uint32_t pixel){
// return (pixel & 0x000000fful);
// }
//
// static inline int
// ncpixel_g(uint32_t pixel){
// return (pixel & 0x00ff0000ul) >> 16u;
// }
//
// static inline int
// ncpixel_b(uint32_t pixel){
// return (pixel & 0x0000ff00ul) >> 8u;
// }
//
// static inline int
// ncpixel_set_a(uint32_t* pixel, int a){
// if(a > 255 || a < 0){
// return -1;
// }
// *pixel = (*pixel & 0x00fffffful) | (a << 24u);
// return 0;
// }
//
// static inline int
// ncpixel_set_r(uint32_t* pixel, int r){
// if(r > 255 || r < 0){
// return -1;
// }
// *pixel = (*pixel & 0xffffff00ul) | r;
// return 0;
// }
//
// static inline int
// ncpixel_set_g(uint32_t* pixel, int g){
// if(g > 255 || g < 0){
// return -1;
// }
// *pixel = (*pixel & 0xff00fffful) | (g << 16u);
// return 0;
// }
//
// static inline int
// ncpixel_set_b(uint32_t* pixel, int b){
// if(b > 255 || b < 0){
// return -1;
// }
// *pixel = (*pixel & 0xffff00fful) | (b << 8u);
// return 0;
// }
//
// // set the RGB values of an RGB pixel
// static inline int
// ncpixel_set_rgb(uint32_t* pixel, int r, int g, int b){
// if(ncpixel_set_r(pixel, r) || ncpixel_set_g(pixel, g) || ncpixel_set_b(pixel, b)){
// return -1;
// }
// return 0;
// }

@ -1,9 +1,144 @@
// Already done by dankamongmen:
// Already exported by bindgen: 86
//
// - ncplane_putstr
// - ncplane_dim_y
// - ncplane_dim_x
// - ncplane_perimeter
// ncplane_aligned
// ncplane_at_cursor
// ncplane_attr
// ncplane_at_yx
// ncplane_base
// ncplane_below
// ncplane_bound
// ncplane_box
// ncplane_center_abs
// ncplane_channels
// ncplane_contents
// ncplane_cursor_move_yx
// ncplane_cursor_yx
// ncplane_destroy
// ncplane_dim_yx
// ncplane_dup
// ncplane_erase
// ncplane_fadein
// ncplane_fadein_iteration
// ncplane_fadeout
// ncplane_fadeout_iteration
// ncplane_format
// ncplane_gradient
// ncplane_greyscale
// ncplane_highgradient
// ncplane_hline_interp
// ncplane_home
// ncplane_mergedown
// ncplane_move_above
// ncplane_move_below
// ncplane_move_bottom
// ncplane_move_top
// ncplane_move_yx
// ncplane_new
// ncplane_notcurses
// ncplane_notcurses_const
// ncplane_polyfill_yx
// ncplane_pulse
// ncplane_putc_yx
// ncplane_putegc_stainable
// ncplane_putegc_yx
// ncplane_putnstr_aligned
// ncplane_putnstr_yx
// ncplane_putsimple_stainable
// ncplane_putstr_aligned
// ncplane_putstr_stainable
// ncplane_putstr_yx
// ncplane_puttext
// ncplane_putwegc_stainable
// ncplane_qrcode
// ncplane_reparent
// ncplane_resize
// ncplane_rgba
// ncplane_rotate_ccw
// ncplane_rotate_cw
// ncplane_set_attr
// ncplane_set_base
// ncplane_set_base_cell
// ncplane_set_bg
// ncplane_set_bg_alpha
// ncplane_set_bg_default
// ncplane_set_bg_palindex
// ncplane_set_bg_rgb
// ncplane_set_bg_rgb_clipped
// ncplane_set_channels
// ncplane_set_fg
// ncplane_set_fg_alpha
// ncplane_set_fg_default
// ncplane_set_fg_palindex
// ncplane_set_fg_rgb
// ncplane_set_fg_rgb_clipped
// ncplane_set_scrolling
// ncplane_set_userptr
// ncplane_stain
// ncplane_styles
// ncplane_styles_off
// ncplane_styles_on
// ncplane_styles_set
// ncplane_translate
// ncplane_translate_abs
// ncplane_userptr
// ncplane_vline_interp
// ncplane_vprintf_aligned
// ncplane_vprintf_stainable
// ncplane_vprintf_yx
// ncplane_yx
//
//
// FUNCTIONS TO REIMPLEMENT:
// - from notcurses.h: 42
// - done: ±4
// - remaining: 38
//
// ---------------
// + reimplemented
// # and unit test
// --------------
// ncplane_align
// ncplane_at_cursor_cell
// ncplane_at_yx_cell
// ncplane_bchannel
// ncplane_bg
// ncplane_bg_alpha
// ncplane_bg_default_p
// ncplane_bg_rgb
// 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_gradient_sized
// ncplane_highgradient_sized
// ncplane_hline
//+ncplane_perimeter
// ncplane_perimeter_double
// ncplane_perimeter_rounded
// ncplane_putc
// ncplane_putegc
// ncplane_putnstr
// ncplane_putsimple
// ncplane_putsimple_yx
//+ncplane_putstr
// ncplane_putwc
// ncplane_putwc_yx
// ncplane_putwegc
// ncplane_putwegc_yx
// ncplane_putwstr
// ncplane_putwstr_aligned
// ncplane_putwstr_yx
// ncplane_resize_simple
// ncplane_rounded_box
// ncplane_rounded_box_sized
// ncplane_vline
// ncplane_vprintf
use std::ffi::CString;
use std::ptr::null_mut;
@ -50,3 +185,475 @@ pub fn ncplane_perimeter(
) -> IntResult {
unsafe { ffi::ncplane_cursor_move_yx(plane, 0, 0) }
}
// // Resize the plane, retaining what data we can (everything, unless we're
// // shrinking in some dimension). Keep the origin where it is.
// static inline int
// ncplane_resize_simple(struct ncplane* n, int ylen, int xlen){
// int oldy, oldx;
// ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
// int keepleny = oldy > ylen ? ylen : oldy;
// int keeplenx = oldx > xlen ? xlen : oldx;
// return ncplane_resize(n, 0, 0, keepleny, keeplenx, 0, 0, ylen, xlen);
// }
//
// // Retrieve the current contents of the cell under the cursor into 'c'. This
// // cell is invalidated if the associated plane is destroyed.
// static inline int
// ncplane_at_cursor_cell(struct ncplane* n, cell* c){
// char* egc = ncplane_at_cursor(n, &c->attrword, &c->channels);
// if(!egc){
// return -1;
// }
// uint64_t channels = c->channels; // need to preserve wide flag
// int r = cell_load(n, c, egc);
// c->channels = channels;
// if(r < 0){
// free(egc);
// }
// return r;
// }
//
// // Retrieve the current contents of the specified cell into 'c'. This cell is
// // invalidated if the associated plane is destroyed.
// static inline int
// ncplane_at_yx_cell(struct ncplane* n, int y, int x, cell* c){
// char* egc = ncplane_at_yx(n, y, x, &c->attrword, &c->channels);
// if(!egc){
// return -1;
// }
// uint64_t channels = c->channels; // need to preserve wide flag
// int r = cell_load(n, c, egc);
// c->channels = channels;
// free(egc);
// return r;
// }
//
// // Return the column at which 'c' cols ought start in order to be aligned
// // according to 'align' within ncplane 'n'. Returns INT_MAX on invalid 'align'.
// // Undefined behavior on negative 'c'.
// static inline int
// ncplane_align(const struct ncplane* n, ncalign_e align, int c){
// if(align == NCALIGN_LEFT){
// return 0;
// }
// int cols = ncplane_dim_x(n);
// if(c > cols){
// return 0;
// }
// if(align == NCALIGN_CENTER){
// return (cols - c) / 2;
// }else if(align == NCALIGN_RIGHT){
// return cols - c;
// }
// return INT_MAX;
// }
//
// // Call ncplane_putc_yx() for the current cursor location.
// static inline int
// ncplane_putc(struct ncplane* n, const cell* c){
// return ncplane_putc_yx(n, -1, -1, c);
// }
//
// // Replace the EGC underneath us, but retain the styling. The current styling
// // of the plane will not be changed.
// //
// // Replace the cell at the specified coordinates with the provided 7-bit char
// // 'c'. Advance the cursor by 1. On success, returns 1. On failure, returns -1.
// // This works whether the underlying char is signed or unsigned.
// static inline int
// ncplane_putsimple_yx(struct ncplane* n, int y, int x, char c){
// cell ce = CELL_INITIALIZER((uint32_t)c, ncplane_attr(n), ncplane_channels(n));
// if(!cell_simple_p(&ce)){
// return -1;
// }
// return ncplane_putc_yx(n, y, x, &ce);
// }
//
// // Call ncplane_putsimple_yx() at the current cursor location.
// static inline int
// ncplane_putsimple(struct ncplane* n, char c){
// return ncplane_putsimple_yx(n, -1, -1, c);
// }
//
//
// // Call ncplane_putegc() at the current cursor location.
// static inline int
// ncplane_putegc(struct ncplane* n, const char* gclust, int* sbytes){
// return ncplane_putegc_yx(n, -1, -1, gclust, sbytes);
// }
//
// // ncplane_putegc(), but following a conversion from wchar_t to UTF-8 multibyte.
// static inline int
// ncplane_putwegc(struct ncplane* n, const wchar_t* gclust, int* sbytes){
// // maximum of six UTF8-encoded bytes per wchar_t
// const size_t mbytes = (wcslen(gclust) * WCHAR_MAX_UTF8BYTES) + 1;
// char* mbstr = (char*)malloc(mbytes); // need cast for c++ callers
// if(mbstr == NULL){
// return -1;
// }
// size_t s = wcstombs(mbstr, gclust, mbytes);
// if(s == (size_t)-1){
// free(mbstr);
// return -1;
// }
// int ret = ncplane_putegc(n, mbstr, sbytes);
// free(mbstr);
// return ret;
// }
//
// // Call ncplane_putwegc() after successfully moving to y, x.
// static inline int
// ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust,
// int* sbytes){
// if(ncplane_cursor_move_yx(n, y, x)){
// return -1;
// }
// return ncplane_putwegc(n, gclust, sbytes);
// }
//
// static inline int
// ncplane_putstr(struct ncplane* n, const char* gclustarr){
// return ncplane_putstr_yx(n, -1, -1, gclustarr);
// }
//
// static inline int
// ncplane_putnstr(struct ncplane* n, size_t s, const char* gclustarr){
// return ncplane_putnstr_yx(n, -1, -1, s, gclustarr);
// }
//
// // ncplane_putstr(), but following a conversion from wchar_t to UTF-8 multibyte.
// static inline int
// ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr){
// // maximum of six UTF8-encoded bytes per wchar_t
// const size_t mbytes = (wcslen(gclustarr) * WCHAR_MAX_UTF8BYTES) + 1;
// char* mbstr = (char*)malloc(mbytes); // need cast for c++ callers
// if(mbstr == NULL){
// return -1;
// }
// size_t s = wcstombs(mbstr, gclustarr, mbytes);
// if(s == (size_t)-1){
// free(mbstr);
// return -1;
// }
// int ret = ncplane_putstr_yx(n, y, x, mbstr);
// free(mbstr);
// return ret;
// }
//
// static inline int
// ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
// const wchar_t* gclustarr){
// int width = wcswidth(gclustarr, INT_MAX);
// int xpos = ncplane_align(n, align, width);
// return ncplane_putwstr_yx(n, y, xpos, gclustarr);
// }
//
// static inline int
// ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr){
// return ncplane_putwstr_yx(n, -1, -1, gclustarr);
// }
//
// // Replace the cell at the specified coordinates with the provided wide char
// // 'w'. Advance the cursor by the character's width as reported by wcwidth().
// // On success, returns 1. On failure, returns -1.
// static inline int
// ncplane_putwc_yx(struct ncplane* n, int y, int x, wchar_t w){
// wchar_t warr[2] = { w, L'\0' };
// return ncplane_putwstr_yx(n, y, x, warr);
// }
//
// // Call ncplane_putwc() at the current cursor position.
// static inline int
// ncplane_putwc(struct ncplane* n, wchar_t w){
// return ncplane_putwc_yx(n, -1, -1, w);
// }
//
// static inline int
// ncplane_vprintf(struct ncplane* n, const char* format, va_list ap){
// return ncplane_vprintf_yx(n, -1, -1, format, ap);
// }
//
// static inline int
// ncplane_printf(struct ncplane* n, const char* format, ...)
// __attribute__ ((format (printf, 2, 3)));
//
// static inline int
// ncplane_printf(struct ncplane* n, const char* format, ...){
// va_list va;
// va_start(va, format);
// int ret = ncplane_vprintf(n, format, va);
// va_end(va);
// return ret;
// }
//
// static inline int
// ncplane_printf_yx(struct ncplane* n, int y, int x, const char* format, ...)
// __attribute__ ((format (printf, 4, 5)));
//
// static inline int
// ncplane_printf_yx(struct ncplane* n, int y, int x, const char* format, ...){
// va_list va;
// va_start(va, format);
// int ret = ncplane_vprintf_yx(n, y, x, format, va);
// va_end(va);
// return ret;
// }
//
// static inline int
// ncplane_printf_aligned(struct ncplane* n, int y, ncalign_e align,
// const char* format, ...)
// __attribute__ ((format (printf, 4, 5)));
//
// static inline int
// ncplane_printf_aligned(struct ncplane* n, int y, ncalign_e align, const char* format, ...){
// va_list va;
// va_start(va, format);
// int ret = ncplane_vprintf_aligned(n, y, align, format, va);
// va_end(va);
// return ret;
// }
//
// static inline int
// ncplane_printf_stainable(struct ncplane* n, const char* format, ...)
// __attribute__ ((format (printf, 2, 3)));
//
// static inline int
// ncplane_printf_stainable(struct ncplane* n, const char* format, ...){
// va_list va;
// va_start(va, format);
// int ret = ncplane_vprintf_stainable(n, format, va);
// va_end(va);
// return ret;
// }
//
// static inline int
// ncplane_hline(struct ncplane* n, const cell* c, int len){
// return ncplane_hline_interp(n, c, len, c->channels, c->channels);
// }
//
// static inline int
// ncplane_vline(struct ncplane* n, const cell* c, int len){
// return ncplane_vline_interp(n, c, len, c->channels, c->channels);
// }
//
// // Draw a box with its upper-left corner at the current cursor position, having
// // dimensions 'ylen'x'xlen'. See ncplane_box() for more information. The
// // minimum box size is 2x2, and it cannot be drawn off-screen.
// static inline int
// ncplane_box_sized(struct ncplane* n, const cell* ul, const cell* ur,
// const cell* ll, const cell* lr, const cell* hline,
// const cell* vline, int ylen, int xlen, unsigned ctlword){
// int y, x;
// ncplane_cursor_yx(n, &y, &x);
// return ncplane_box(n, ul, ur, ll, lr, hline, vline, y + ylen - 1,
// x + xlen - 1, ctlword);
// }
//
// static inline int
// ncplane_perimeter(struct ncplane* n, const cell* ul, const cell* ur,
// const cell* ll, const cell* lr, const cell* hline,
// const cell* vline, unsigned ctlword){
// if(ncplane_cursor_move_yx(n, 0, 0)){
// return -1;
// }
// int dimy, dimx;
// ncplane_dim_yx(n, &dimy, &dimx);
// return ncplane_box_sized(n, ul, ur, ll, lr, hline, vline, dimy, dimx, ctlword);
// }
//
// // Draw a gradient with its upper-left corner at the current cursor position,
// // having dimensions 'ylen'x'xlen'. See ncplane_gradient for more information.
// static inline int
// ncplane_gradient_sized(struct ncplane* n, const char* egc, uint32_t attrword,
// uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr,
// int ylen, int xlen){
// if(ylen < 1 || xlen < 1){
// return -1;
// }
// int y, x;
// ncplane_cursor_yx(n, &y, &x);
// return ncplane_gradient(n, egc, attrword, ul, ur, ll, lr, y + ylen - 1, x + xlen - 1);
// }
//
// static inline int
// ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
// uint32_t ll, uint32_t lr, int ylen, int xlen){
// if(ylen < 1 || xlen < 1){
// return -1;
// }
// int y, x;
// if(!notcurses_canutf8(ncplane_notcurses_const(n))){
// // this works because the uin32_ts we pass in will be promoted to uint64_ts
// // via extension, and the space will employ the background. mwahh!
// return ncplane_gradient_sized(n, " ", 0, ul, ur, ll, lr, ylen, xlen);
// }
// ncplane_cursor_yx(n, &y, &x);
// return ncplane_highgradient(n, ul, ur, ll, lr, y + ylen - 1, x + xlen - 1);
// }
//
// // Extract the 32-bit working background channel from an ncplane.
// static inline unsigned
// ncplane_bchannel(const struct ncplane* nc){
// return channels_bchannel(ncplane_channels(nc));
// }
//
// // Extract the 32-bit working foreground channel from an ncplane.
// static inline unsigned
// ncplane_fchannel(const struct ncplane* nc){
// return channels_fchannel(ncplane_channels(nc));
// }
//
// // Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs.
// static inline unsigned
// ncplane_fg(const struct ncplane* nc){
// return channels_fg(ncplane_channels(nc));
// }
//
// // Extract 24 bits of working background RGB from an ncplane, shifted to LSBs.
// static inline unsigned
// ncplane_bg(const struct ncplane* nc){
// return channels_bg(ncplane_channels(nc));
// }
//
// // Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs.
// static inline unsigned
// ncplane_fg_alpha(const struct ncplane* nc){
// return channels_fg_alpha(ncplane_channels(nc));
// }
//
// // Is the plane's foreground using the "default foreground color"?
// static inline bool
// ncplane_fg_default_p(const struct ncplane* nc){
// return channels_fg_default_p(ncplane_channels(nc));
// }
//
// // Extract 2 bits of background alpha from 'struct ncplane', shifted to LSBs.
// static inline unsigned
// ncplane_bg_alpha(const struct ncplane* nc){
// return channels_bg_alpha(ncplane_channels(nc));
// }
//
// // Is the plane's background using the "default background color"?
// static inline bool
// ncplane_bg_default_p(const struct ncplane* nc){
// return channels_bg_default_p(ncplane_channels(nc));
// }
//
// // Extract 24 bits of foreground RGB from 'n', split into components.
// static inline unsigned
// ncplane_fg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){
// return channels_fg_rgb(ncplane_channels(n), r, g, b);
// }
//
// // Extract 24 bits of background RGB from 'n', split into components.
// static inline unsigned
// ncplane_bg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){
// return channels_bg_rgb(ncplane_channels(n), r, g, b);
// }
//
//
// static inline int
// ncplane_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
// int ystop, int xstop, unsigned ctlword){
// int ret = 0;
// cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
// cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
// cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
// if((ret = cells_rounded_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){
// ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
// }
// cell_release(n, &ul); cell_release(n, &ur);
// cell_release(n, &ll); cell_release(n, &lr);
// cell_release(n, &hl); cell_release(n, &vl);
// return ret;
// }
//
// static inline int
// ncplane_perimeter_rounded(struct ncplane* n, uint32_t attrword,
// uint64_t channels, unsigned ctlword){
// if(ncplane_cursor_move_yx(n, 0, 0)){
// return -1;
// }
// int dimy, dimx;
// ncplane_dim_yx(n, &dimy, &dimx);
// cell ul = CELL_TRIVIAL_INITIALIZER;
// cell ur = CELL_TRIVIAL_INITIALIZER;
// cell ll = CELL_TRIVIAL_INITIALIZER;
// cell lr = CELL_TRIVIAL_INITIALIZER;
// cell vl = CELL_TRIVIAL_INITIALIZER;
// cell hl = CELL_TRIVIAL_INITIALIZER;
// if(cells_rounded_box(n, attrword, channels, &ul, &ur, &ll, &lr, &hl, &vl)){
// return -1;
// }
// int r = ncplane_box_sized(n, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
// cell_release(n, &ul); cell_release(n, &ur);
// cell_release(n, &ll); cell_release(n, &lr);
// cell_release(n, &hl); cell_release(n, &vl);
// return r;
// }
//
// static inline int
// ncplane_rounded_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
// int ylen, int xlen, unsigned ctlword){
// int y, x;
// ncplane_cursor_yx(n, &y, &x);
// return ncplane_rounded_box(n, attr, channels, y + ylen - 1,
// x + xlen - 1, ctlword);
// }
//
// API int cells_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
// cell* ul, cell* ur, cell* ll, cell* lr,
// cell* hl, cell* vl);
//
// static inline int
// ncplane_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
// int ystop, int xstop, unsigned ctlword){
// int ret = 0;
// cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
// cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
// cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
// if((ret = cells_double_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){
// ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
// }
// cell_release(n, &ul); cell_release(n, &ur);
// cell_release(n, &ll); cell_release(n, &lr);
// cell_release(n, &hl); cell_release(n, &vl);
// return ret;
// }
//
// static inline int
// ncplane_perimeter_double(struct ncplane* n, uint32_t attrword,
// uint64_t channels, unsigned ctlword){
// if(ncplane_cursor_move_yx(n, 0, 0)){
// return -1;
// }
// int dimy, dimx;
// ncplane_dim_yx(n, &dimy, &dimx);
// cell ul = CELL_TRIVIAL_INITIALIZER;
// cell ur = CELL_TRIVIAL_INITIALIZER;
// cell ll = CELL_TRIVIAL_INITIALIZER;
// cell lr = CELL_TRIVIAL_INITIALIZER;
// cell vl = CELL_TRIVIAL_INITIALIZER;
// cell hl = CELL_TRIVIAL_INITIALIZER;
// if(cells_double_box(n, attrword, channels, &ul, &ur, &ll, &lr, &hl, &vl)){
// return -1;
// }
// int r = ncplane_box_sized(n, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
// cell_release(n, &ul); cell_release(n, &ur);
// cell_release(n, &ll); cell_release(n, &lr);
// cell_release(n, &hl); cell_release(n, &vl);
// return r;
// }
//
// static inline int
// ncplane_double_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
// int ylen, int xlen, unsigned ctlword){
// int y, x;
// ncplane_cursor_yx(n, &y, &x);
// return ncplane_double_box(n, attr, channels, y + ylen - 1,
// x + xlen - 1, ctlword);
// }
//

Loading…
Cancel
Save