mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
Merge branch 'master' of github.com:dankamongmen/notcurses
This commit is contained in:
commit
2bb546e3ac
@ -1,6 +1,6 @@
|
|||||||
# notcurses
|
# notcurses
|
||||||
|
|
||||||
Python bindings for the C [https://github.com/dankamongmen/notcurses Notcurses]
|
Python bindings for the C [Notcurses](https://github.com/dankamongmen/notcurses)
|
||||||
library. Notcurses is a blingful library for building complex, vibrant textual
|
library. Notcurses is a blingful library for building complex, vibrant textual
|
||||||
user interfaces (TUIs) on modern terminal emulators, of which these Python
|
user interfaces (TUIs) on modern terminal emulators, of which these Python
|
||||||
bindings offer nowhere near complete coverage.
|
bindings offer nowhere near complete coverage.
|
||||||
|
@ -6,22 +6,22 @@ fn main() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let ncd = nc::ncdirect_new();
|
let ncd = nc::ncdirect_new();
|
||||||
|
|
||||||
render_image(&mut *ncd, nc::ncblitter_e_NCBLIT_1x1);
|
render_image(&mut *ncd, nc::NCBLIT_1x1);
|
||||||
render_image(&mut *ncd, nc::ncblitter_e_NCBLIT_2x1);
|
render_image(&mut *ncd, nc::NCBLIT_2x1);
|
||||||
render_image(&mut *ncd, nc::ncblitter_e_NCBLIT_BRAILLE);
|
render_image(&mut *ncd, nc::NCBLIT_BRAILLE);
|
||||||
|
|
||||||
nc::ncdirect_stop(ncd);
|
nc::ncdirect_stop(ncd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_image(ncd: &mut nc::ncdirect, blit: nc::ncblitter_e) {
|
fn render_image(ncd: &mut nc::NcDirect, blit: nc::NcBlitter) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if nc::ncdirect_render_image(
|
if nc::ncdirect_render_image(
|
||||||
ncd,
|
ncd,
|
||||||
CString::new("image-16x16.png").unwrap().as_ptr(),
|
CString::new("image-16x16.png").unwrap().as_ptr(),
|
||||||
nc::ncalign_e_NCALIGN_CENTER,
|
nc::NCALIGN_CENTER,
|
||||||
blit,
|
blit,
|
||||||
nc::ncscale_e_NCSCALE_NONE,
|
nc::NCSCALE_NONE,
|
||||||
) != 0
|
) != 0
|
||||||
{
|
{
|
||||||
panic!("ERR: ncdirect_render_image. \
|
panic!("ERR: ncdirect_render_image. \
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! Curated re-exports of the bindgen generated bindings,
|
//! Curated re-exports of the `bindgen` bindings
|
||||||
//!
|
//!
|
||||||
//! The full list of bindings is under the bindgen submodule
|
//! The full list of bindings is under the
|
||||||
|
//! [`bindgen`](../bindgen/index.html) submodule
|
||||||
//!
|
//!
|
||||||
//
|
//
|
||||||
// WARNING: DO NOT EXECUTE RUSTFMT ON THIS FILE.
|
// WARNING: DO NOT EXECUTE RUSTFMT ON THIS FILE.
|
||||||
@ -10,57 +11,43 @@
|
|||||||
// [clippy & bindgen](https://github.com/rust-lang/rust-bindgen/issues/1470)
|
// [clippy & bindgen](https://github.com/rust-lang/rust-bindgen/issues/1470)
|
||||||
#[allow(clippy::all)]
|
#[allow(clippy::all)]
|
||||||
pub mod bindgen {
|
pub mod bindgen {
|
||||||
|
//! Automatically generated Rust FFI bindings
|
||||||
|
//!
|
||||||
|
//! All of the notcurses functions and some of the constants are reexported
|
||||||
|
//! by the [`bindings`](../bindings/index.html) module.
|
||||||
|
//! While the structs, enums and some other constants are type aliased in
|
||||||
|
//! the [`types`](../types/index.html) module, in order to follow the
|
||||||
|
//! Rust API Guidelines as much as possible.
|
||||||
|
//!
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miscellaneous ---------------------------------------------------------------
|
// Miscellaneous ---------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
_IO_FILE,
|
_IO_FILE,
|
||||||
__va_list_tag,
|
__va_list_tag,
|
||||||
|
|
||||||
// functions
|
|
||||||
timespec,
|
timespec,
|
||||||
};
|
};
|
||||||
|
|
||||||
// align -----------------------------------------------------------------------
|
// blitset ---------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
|
||||||
// type definitions
|
|
||||||
ncalign_e,
|
|
||||||
|
|
||||||
// constants
|
pub(crate) use bindgen::{
|
||||||
ncalign_e_NCALIGN_CENTER,
|
// structs
|
||||||
ncalign_e_NCALIGN_LEFT,
|
blitset
|
||||||
ncalign_e_NCALIGN_RIGHT,
|
|
||||||
ncalign_e_NCALIGN_UNALIGNED,
|
|
||||||
};
|
|
||||||
|
|
||||||
// ncblit ---------------------------------------------------------------------
|
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
|
||||||
// type definitions
|
|
||||||
ncblitter_e,
|
|
||||||
|
|
||||||
// constants
|
|
||||||
ncblitter_e_NCBLIT_1x1,
|
|
||||||
ncblitter_e_NCBLIT_2x1,
|
|
||||||
ncblitter_e_NCBLIT_2x2,
|
|
||||||
ncblitter_e_NCBLIT_3x2,
|
|
||||||
ncblitter_e_NCBLIT_4x1,
|
|
||||||
ncblitter_e_NCBLIT_8x1,
|
|
||||||
ncblitter_e_NCBLIT_BRAILLE,
|
|
||||||
ncblitter_e_NCBLIT_DEFAULT,
|
|
||||||
ncblitter_e_NCBLIT_SIXEL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// cell ------------------------------------------------------------------------
|
// cell ------------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
cell,
|
cell,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
cell_duplicate,
|
cell_duplicate,
|
||||||
cell_extended_gcluster,
|
cell_extended_gcluster,
|
||||||
@ -87,13 +74,46 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// channel ---------------------------------------------------------------------
|
// channel ---------------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// constants
|
// constants
|
||||||
CHANNEL_ALPHA_MASK
|
CHANNEL_ALPHA_MASK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ncalign ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
pub(crate) use bindgen::{
|
||||||
|
// type definitions
|
||||||
|
ncalign_e,
|
||||||
|
|
||||||
|
// constants
|
||||||
|
ncalign_e_NCALIGN_CENTER,
|
||||||
|
ncalign_e_NCALIGN_LEFT,
|
||||||
|
ncalign_e_NCALIGN_RIGHT,
|
||||||
|
ncalign_e_NCALIGN_UNALIGNED,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ncblitter -------------------------------------------------------------------
|
||||||
|
|
||||||
|
pub(crate) use bindgen::{
|
||||||
|
// type definitions
|
||||||
|
ncblitter_e,
|
||||||
|
|
||||||
|
// constants
|
||||||
|
ncblitter_e_NCBLIT_1x1,
|
||||||
|
ncblitter_e_NCBLIT_2x1,
|
||||||
|
ncblitter_e_NCBLIT_2x2,
|
||||||
|
ncblitter_e_NCBLIT_3x2,
|
||||||
|
ncblitter_e_NCBLIT_4x1,
|
||||||
|
ncblitter_e_NCBLIT_8x1,
|
||||||
|
ncblitter_e_NCBLIT_BRAILLE,
|
||||||
|
ncblitter_e_NCBLIT_DEFAULT,
|
||||||
|
ncblitter_e_NCBLIT_SIXEL,
|
||||||
|
};
|
||||||
|
|
||||||
// ncbox -----------------------------------------------------------------------
|
// ncbox -----------------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// constants
|
// constants
|
||||||
@ -110,11 +130,14 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncdirect --------------------------------------------------------------------
|
// ncdirect --------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncdirect,
|
ncdirect,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncdirect_bg_default,
|
ncdirect_bg_default,
|
||||||
ncdirect_bg_palindex,
|
ncdirect_bg_palindex,
|
||||||
@ -162,11 +185,14 @@ pub use bindgen::{
|
|||||||
|
|
||||||
|
|
||||||
// ncfadectx -------------------------------------------------------------------
|
// ncfadectx -------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncfadectx,
|
ncfadectx,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncfadectx_free,
|
ncfadectx_free,
|
||||||
ncfadectx_iterations,
|
ncfadectx_iterations,
|
||||||
@ -174,15 +200,15 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncinput ---------------------------------------------------------------------
|
// ncinput ---------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncinput,
|
ncinput,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncloglevel ------------------------------------------------------------------
|
// ncloglevel ------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// type definitions
|
// type definitions
|
||||||
ncloglevel_e,
|
ncloglevel_e,
|
||||||
|
|
||||||
@ -199,12 +225,15 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncfdplane -------------------------------------------------------------------
|
// ncfdplane -------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncfdplane,
|
ncfdplane,
|
||||||
ncfdplane_options,
|
ncfdplane_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncfdplane_create,
|
ncfdplane_create,
|
||||||
ncfdplane_destroy,
|
ncfdplane_destroy,
|
||||||
@ -212,13 +241,17 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncmenu ----------------------------------------------------------------------
|
// ncmenu ----------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
|
// structs
|
||||||
ncmenu,
|
ncmenu,
|
||||||
ncmenu_item,
|
ncmenu_item,
|
||||||
ncmenu_options,
|
ncmenu_options,
|
||||||
ncmenu_section,
|
ncmenu_section,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncmenu_create,
|
ncmenu_create,
|
||||||
ncmenu_destroy,
|
ncmenu_destroy,
|
||||||
@ -239,21 +272,25 @@ pub use bindgen::{
|
|||||||
NCMENU_OPTION_HIDING,
|
NCMENU_OPTION_HIDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncmetric
|
// ncmetric --------------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncmetric
|
ncmetric
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncmultiselector
|
// ncmultiselector -------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncmultiselector,
|
ncmultiselector,
|
||||||
ncmselector_item,
|
ncmselector_item,
|
||||||
ncmultiselector_options,
|
ncmultiselector_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncmultiselector_create,
|
ncmultiselector_create,
|
||||||
ncmultiselector_destroy,
|
ncmultiselector_destroy,
|
||||||
@ -262,11 +299,15 @@ pub use bindgen::{
|
|||||||
ncmultiselector_selected,
|
ncmultiselector_selected,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncplane
|
// ncplane ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
pub(crate) use bindgen::{
|
||||||
|
// structs
|
||||||
|
ncplane,
|
||||||
|
};
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
ncplane,
|
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
ncplane_above,
|
ncplane_above,
|
||||||
ncplane_at_cursor,
|
ncplane_at_cursor,
|
||||||
@ -370,14 +411,17 @@ pub use bindgen::{
|
|||||||
NCPLANE_OPTION_HORALIGNED,
|
NCPLANE_OPTION_HORALIGNED,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncplot
|
// ncplot ----------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncdplot, // f64
|
ncdplot, // f64
|
||||||
ncuplot, // u64
|
ncuplot, // u64
|
||||||
ncplot_options,
|
ncplot_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncdplot_add_sample,
|
ncdplot_add_sample,
|
||||||
ncdplot_create,
|
ncdplot_create,
|
||||||
@ -401,12 +445,16 @@ pub use bindgen::{
|
|||||||
NCPLOT_OPTION_VERTICALI,
|
NCPLOT_OPTION_VERTICALI,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncreader
|
// ncreader --------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
|
// structs
|
||||||
ncreader,
|
ncreader,
|
||||||
ncreader_options,
|
ncreader_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncreader_clear,
|
ncreader_clear,
|
||||||
ncreader_contents,
|
ncreader_contents,
|
||||||
@ -427,12 +475,16 @@ pub use bindgen::{
|
|||||||
NCREADER_OPTION_VERSCROLL,
|
NCREADER_OPTION_VERSCROLL,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncreel
|
// ncreel ----------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
|
// structs
|
||||||
ncreel,
|
ncreel,
|
||||||
ncreel_options,
|
ncreel_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncreel_add,
|
ncreel_add,
|
||||||
ncreel_create,
|
ncreel_create,
|
||||||
@ -451,9 +503,9 @@ pub use bindgen::{
|
|||||||
NCREEL_OPTION_INFINITESCROLL,
|
NCREEL_OPTION_INFINITESCROLL,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncscale
|
// ncscale ---------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// type definitions
|
// type definitions
|
||||||
ncscale_e,
|
ncscale_e,
|
||||||
|
|
||||||
@ -464,13 +516,16 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncselector ------------------------------------------------------------------
|
// ncselector ------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncselector,
|
ncselector,
|
||||||
ncselector_item,
|
ncselector_item,
|
||||||
ncselector_options,
|
ncselector_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncselector_additem,
|
ncselector_additem,
|
||||||
ncselector_create,
|
ncselector_create,
|
||||||
@ -484,13 +539,14 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncstats ---------------------------------------------------------------------
|
// ncstats ---------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncstats,
|
ncstats,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ncstyle ---------------------------------------------------------------------
|
// ncstyle ---------------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// constants
|
// constants
|
||||||
@ -508,11 +564,14 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// nctablet --------------------------------------------------------------------
|
// nctablet --------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
nctablet,
|
nctablet,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
nctablet_ncplane,
|
nctablet_ncplane,
|
||||||
nctablet_plane,
|
nctablet_plane,
|
||||||
@ -520,12 +579,15 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ncvisual --------------------------------------------------------------------
|
// ncvisual --------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
ncvisual,
|
ncvisual,
|
||||||
ncvisual_options,
|
ncvisual_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
ncvisual_at_yx,
|
ncvisual_at_yx,
|
||||||
ncvisual_decode,
|
ncvisual_decode,
|
||||||
@ -547,12 +609,15 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// notcurses -------------------------------------------------------------------
|
// notcurses -------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
notcurses,
|
notcurses,
|
||||||
notcurses_options,
|
notcurses_options,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
notcurses_at_yx,
|
notcurses_at_yx,
|
||||||
notcurses_bottom,
|
notcurses_bottom,
|
||||||
@ -605,11 +670,14 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// palette ---------------------------------------------------------------------
|
// palette ---------------------------------------------------------------------
|
||||||
#[doc(inline)]
|
|
||||||
pub use bindgen::{
|
pub(crate) use bindgen::{
|
||||||
// structs
|
// structs
|
||||||
palette256,
|
palette256,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use bindgen::{
|
||||||
// functions
|
// functions
|
||||||
palette256_free,
|
palette256_free,
|
||||||
palette256_new,
|
palette256_new,
|
||||||
@ -620,13 +688,14 @@ pub use bindgen::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// sig -------------------------------------------------------------------------
|
// sig -------------------------------------------------------------------------
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use bindgen::{
|
pub use bindgen::{
|
||||||
// type definitions
|
// type definitions
|
||||||
sigset_t,
|
sigset_t,
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
sigaction,
|
//sigaction,
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
sigaddset,
|
sigaddset,
|
||||||
|
@ -58,10 +58,19 @@
|
|||||||
|
|
||||||
use libc::strcmp;
|
use libc::strcmp;
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
use nc::types::{
|
cell_extended_gcluster, cell_load, cell_release, channels_bchannel, channels_bg_alpha,
|
||||||
AlphaBits, Cell, CellGcluster, Channel, ChannelPair, Color, IntResult, NcPlane, PaletteIndex,
|
channels_bg_default_p, channels_bg_palindex_p, channels_bg_rgb, channels_bg_rgb8,
|
||||||
StyleMask, EGC,
|
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, channels_set_fchannel,
|
||||||
|
channels_set_fg_alpha, channels_set_fg_default, channels_set_fg_rgb, channels_set_fg_rgb8,
|
||||||
|
types::{
|
||||||
|
AlphaBits, Cell, CellGcluster, Channel, Channels, Color, Egc, IntResult, NcPlane,
|
||||||
|
PaletteIndex, StyleMask,
|
||||||
|
},
|
||||||
|
CELL_ALPHA_OPAQUE, CELL_BGDEFAULT_MASK, CELL_BG_PALETTE, CELL_FGDEFAULT_MASK, CELL_FG_PALETTE,
|
||||||
|
CELL_NOBACKGROUND_MASK, CELL_WIDEASIAN_MASK, NCSTYLE_MASK,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// cell_load(), plus blast the styling with 'style' and 'channels'.
|
/// cell_load(), plus blast the styling with 'style' and 'channels'.
|
||||||
@ -77,23 +86,23 @@ use nc::types::{
|
|||||||
///
|
///
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
pub unsafe fn cell_prime(
|
pub unsafe fn cell_prime(
|
||||||
plane: &mut nc::ncplane,
|
plane: &mut NcPlane,
|
||||||
cell: &mut nc::cell,
|
cell: &mut Cell,
|
||||||
gcluster: EGC,
|
gcluster: Egc,
|
||||||
style: StyleMask,
|
style: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
cell.stylemask = style;
|
cell.stylemask = style;
|
||||||
cell.channels = channels;
|
cell.channels = channels;
|
||||||
unsafe { nc::cell_load(plane, cell, gcluster as u32 as *const i8) }
|
unsafe { cell_load(plane, cell, gcluster as u32 as *const i8) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// load up six cells with the EGCs necessary to draw a box.
|
/// load up six cells with the [Egc](type.Egc.html)s necessary to draw a box.
|
||||||
///
|
///
|
||||||
/// returns 0 on success, -1 on error.
|
/// returns 0 on success, -1 on error.
|
||||||
///
|
///
|
||||||
/// on error, any cells this function might have loaded before the error
|
/// on error, any cells this function might have loaded before the error
|
||||||
/// are cell_release()d. There must be at least six EGCs in gcluster.
|
/// are cell_release()d. There must be at least six `Egc`s in gcluster.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
@ -103,14 +112,14 @@ pub unsafe fn cell_prime(
|
|||||||
pub unsafe fn cells_load_box(
|
pub unsafe fn cells_load_box(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
style: StyleMask,
|
style: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ul: &mut Cell,
|
ul: &mut Cell,
|
||||||
ur: &mut Cell,
|
ur: &mut Cell,
|
||||||
ll: &mut Cell,
|
ll: &mut Cell,
|
||||||
lr: &mut Cell,
|
lr: &mut Cell,
|
||||||
hl: &mut Cell,
|
hl: &mut Cell,
|
||||||
vl: &mut Cell,
|
vl: &mut Cell,
|
||||||
gcluster: EGC,
|
gcluster: Egc,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
// mutable copy for pointer arithmetics:
|
// mutable copy for pointer arithmetics:
|
||||||
let mut gclu = gcluster as u32 as *const i8;
|
let mut gclu = gcluster as u32 as *const i8;
|
||||||
@ -143,23 +152,23 @@ pub unsafe fn cells_load_box(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, hl);
|
cell_release(plane, hl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, lr);
|
cell_release(plane, lr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, ll);
|
cell_release(plane, ll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, ur);
|
cell_release(plane, ur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, ul);
|
cell_release(plane, ul);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-1
|
-1
|
||||||
@ -176,7 +185,7 @@ pub fn cell_init(cell: &mut Cell) {
|
|||||||
/// static inline void
|
/// static inline void
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_styles_set(cell: &mut Cell, stylebits: StyleMask) {
|
pub fn cell_styles_set(cell: &mut Cell, stylebits: StyleMask) {
|
||||||
cell.stylemask = stylebits & nc::NCSTYLE_MASK as u16;
|
cell.stylemask = stylebits & NCSTYLE_MASK as u16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the style bits from the cell.
|
/// Extract the style bits from the cell.
|
||||||
@ -189,44 +198,44 @@ pub fn cell_styles(cell: &Cell) -> StyleMask {
|
|||||||
/// they're actively supported or not.
|
/// they're actively supported or not.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_styles_on(cell: &mut Cell, stylebits: StyleMask) {
|
pub fn cell_styles_on(cell: &mut Cell, stylebits: StyleMask) {
|
||||||
cell.stylemask |= stylebits & nc::NCSTYLE_MASK as u16;
|
cell.stylemask |= stylebits & NCSTYLE_MASK as u16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the specified styles (in the LSBs) from the cell's existing spec.
|
/// Remove the specified styles (in the LSBs) from the cell's existing spec.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_styles_off(cell: &mut Cell, stylebits: StyleMask) {
|
pub fn cell_styles_off(cell: &mut Cell, stylebits: StyleMask) {
|
||||||
cell.stylemask &= !(stylebits & nc::NCSTYLE_MASK as u16);
|
cell.stylemask &= !(stylebits & NCSTYLE_MASK as u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the default color for the foreground.
|
/// Use the default color for the foreground.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fg_default(cell: &mut Cell) {
|
pub fn cell_set_fg_default(cell: &mut Cell) {
|
||||||
nc::channels_set_fg_default(&mut cell.channels);
|
channels_set_fg_default(&mut cell.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the default color for the background.
|
/// Use the default color for the background.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bg_default(cell: &mut Cell) {
|
pub fn cell_set_bg_default(cell: &mut Cell) {
|
||||||
nc::channels_set_bg_default(&mut cell.channels);
|
channels_set_bg_default(&mut cell.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the foreground alpha.
|
/// Set the foreground alpha.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fg_alpha(cell: &mut Cell, alpha: AlphaBits) {
|
pub fn cell_set_fg_alpha(cell: &mut Cell, alpha: AlphaBits) {
|
||||||
nc::channels_set_fg_alpha(&mut cell.channels, alpha);
|
channels_set_fg_alpha(&mut cell.channels, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the background alpha.
|
/// Set the background alpha.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bg_alpha(cell: &mut Cell, alpha: AlphaBits) {
|
pub fn cell_set_bg_alpha(cell: &mut Cell, alpha: AlphaBits) {
|
||||||
nc::channels_set_bg_alpha(&mut cell.channels, alpha);
|
channels_set_bg_alpha(&mut cell.channels, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does the cell contain an East Asian Wide codepoint?
|
/// Does the cell contain an East Asian Wide codepoint?
|
||||||
// NOTE: remove casting when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
|
// NOTE: remove casting when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_double_wide_p(cell: &Cell) -> bool {
|
pub fn cell_double_wide_p(cell: &Cell) -> bool {
|
||||||
(cell.channels & nc::CELL_WIDEASIAN_MASK as u64) != 0
|
(cell.channels & CELL_WIDEASIAN_MASK as u64) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this the right half of a wide character?
|
/// Is this the right half of a wide character?
|
||||||
@ -241,18 +250,16 @@ pub fn cell_wide_left_p(cell: &Cell) -> bool {
|
|||||||
cell_double_wide_p(cell) && cell.gcluster != 0
|
cell_double_wide_p(cell) && cell.gcluster != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// copy the UTF8-encoded EGC out of the cell, whether simple or complex. the
|
/// copy the UTF8-encoded Egc out of the cell, whether simple or complex. the
|
||||||
/// result is not tied to the ncplane, and persists across erases / destruction.
|
/// result is not tied to the ncplane, and persists across erases / destruction.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_strdup(plane: &NcPlane, cell: &Cell) -> EGC {
|
pub fn cell_strdup(plane: &NcPlane, cell: &Cell) -> Egc {
|
||||||
core::char::from_u32(
|
core::char::from_u32(unsafe { libc::strdup(cell_extended_gcluster(plane, cell)) } as i32 as u32)
|
||||||
unsafe { libc::strdup(nc::cell_extended_gcluster(plane, cell)) } as i32 as u32,
|
.expect("wrong char")
|
||||||
)
|
|
||||||
.expect("wrong char")
|
|
||||||
|
|
||||||
// unsafer option B (maybe faster, TODO: bench)
|
// unsafer option B (maybe faster, TODO: bench)
|
||||||
// unsafe {
|
// unsafe {
|
||||||
// core::char::from_u32_unchecked(libc::strdup(nc::cell_extended_gcluster(plane, cell)) as i32 as u32)
|
// core::char::from_u32_unchecked(libc::strdup(cell_extended_gcluster(plane, cell)) as i32 as u32)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,8 +269,8 @@ pub fn cell_extract(
|
|||||||
plane: &NcPlane,
|
plane: &NcPlane,
|
||||||
cell: &Cell,
|
cell: &Cell,
|
||||||
stylemask: &mut StyleMask,
|
stylemask: &mut StyleMask,
|
||||||
channels: &mut ChannelPair,
|
channels: &mut Channels,
|
||||||
) -> EGC {
|
) -> Egc {
|
||||||
if *stylemask != 0 {
|
if *stylemask != 0 {
|
||||||
*stylemask = cell.stylemask;
|
*stylemask = cell.stylemask;
|
||||||
}
|
}
|
||||||
@ -273,9 +280,9 @@ pub fn cell_extract(
|
|||||||
cell_strdup(plane, cell)
|
cell_strdup(plane, cell)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the two cells are distinct EGCs, attributes, or channels.
|
/// Returns true if the two cells are distinct `Egc`s, attributes, or channels.
|
||||||
/// The actual egcpool index needn't be the same--indeed, the planes needn't even
|
/// The actual egcpool index needn't be the same--indeed, the planes needn't even
|
||||||
/// be the same. Only the expanded EGC must be equal. The EGC must be bit-equal;
|
/// be the same. Only the expanded Egc must be equal. The Egc must be bit-equal;
|
||||||
/// it would probably be better to test whether they're Unicode-equal FIXME.
|
/// it would probably be better to test whether they're Unicode-equal FIXME.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cellcmp(plane1: &NcPlane, cell1: &Cell, plane2: &NcPlane, cell2: &Cell) -> bool {
|
pub fn cellcmp(plane1: &NcPlane, cell1: &Cell, plane2: &NcPlane, cell2: &Cell) -> bool {
|
||||||
@ -287,8 +294,8 @@ pub fn cellcmp(plane1: &NcPlane, cell1: &Cell, plane2: &NcPlane, cell2: &Cell) -
|
|||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
strcmp(
|
strcmp(
|
||||||
nc::cell_extended_gcluster(plane1, cell1),
|
cell_extended_gcluster(plane1, cell1),
|
||||||
nc::cell_extended_gcluster(plane2, cell2),
|
cell_extended_gcluster(plane2, cell2),
|
||||||
) != 0
|
) != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,11 +303,11 @@ pub fn cellcmp(plane1: &NcPlane, cell1: &Cell, plane2: &NcPlane, cell2: &Cell) -
|
|||||||
///
|
///
|
||||||
// NOTE: remove casting for CELL_WIEDASIAN_MASK when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
|
// NOTE: remove casting for CELL_WIEDASIAN_MASK when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_load_simple(plane: &mut NcPlane, cell: &mut Cell, ch: EGC) -> i32 {
|
pub fn cell_load_simple(plane: &mut NcPlane, cell: &mut Cell, ch: Egc) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, cell);
|
cell_release(plane, cell);
|
||||||
}
|
}
|
||||||
cell.channels &= !(nc::CELL_WIDEASIAN_MASK as u64 | nc::CELL_NOBACKGROUND_MASK);
|
cell.channels &= !(CELL_WIDEASIAN_MASK as u64 | CELL_NOBACKGROUND_MASK);
|
||||||
cell.gcluster = ch as CellGcluster;
|
cell.gcluster = ch as CellGcluster;
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
@ -308,74 +315,74 @@ pub fn cell_load_simple(plane: &mut NcPlane, cell: &mut Cell, ch: EGC) -> i32 {
|
|||||||
/// Extract the 32-bit background channel from a cell.
|
/// Extract the 32-bit background channel from a cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bchannel(cell: &Cell) -> Channel {
|
pub fn cell_bchannel(cell: &Cell) -> Channel {
|
||||||
nc::channels_bchannel(cell.channels)
|
channels_bchannel(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 32-bit foreground channel from a cell.
|
/// Extract the 32-bit foreground channel from a cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fchannel(cell: &Cell) -> Channel {
|
pub fn cell_fchannel(cell: &Cell) -> Channel {
|
||||||
nc::channels_fchannel(cell.channels)
|
channels_fchannel(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 32-bit background channel of a cell.
|
/// Set the 32-bit background channel of a cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bchannel(cell: &mut Cell, channel: Channel) -> ChannelPair {
|
pub fn cell_set_bchannel(cell: &mut Cell, channel: Channel) -> Channels {
|
||||||
nc::channels_set_bchannel(&mut cell.channels, channel)
|
channels_set_bchannel(&mut cell.channels, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 32-bit foreground channel of a cell.
|
/// Set the 32-bit foreground channel of a cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fchannel(cell: &mut Cell, channel: Channel) -> ChannelPair {
|
pub fn cell_set_fchannel(cell: &mut Cell, channel: Channel) -> Channels {
|
||||||
nc::channels_set_fchannel(&mut cell.channels, channel)
|
channels_set_fchannel(&mut cell.channels, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from 'cell', shifted to LSBs.
|
/// Extract 24 bits of foreground RGB from 'cell', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fg_rgb(cell: &Cell) -> Channel {
|
pub fn cell_fg_rgb(cell: &Cell) -> Channel {
|
||||||
nc::channels_fg_rgb(cell.channels)
|
channels_fg_rgb(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of background RGB from 'cell', shifted to LSBs.
|
/// Extract 24 bits of background RGB from 'cell', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bg_rgb(cell: &Cell) -> Channel {
|
pub fn cell_bg_rgb(cell: &Cell) -> Channel {
|
||||||
nc::channels_bg_rgb(cell.channels)
|
channels_bg_rgb(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of foreground alpha from 'cell', shifted to LSBs.
|
/// Extract 2 bits of foreground alpha from 'cell', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fg_alpha(cell: &Cell) -> AlphaBits {
|
pub fn cell_fg_alpha(cell: &Cell) -> AlphaBits {
|
||||||
nc::channels_fg_alpha(cell.channels)
|
channels_fg_alpha(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of background alpha from 'cell', shifted to LSBs.
|
/// Extract 2 bits of background alpha from 'cell', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bg_alpha(cell: &Cell) -> AlphaBits {
|
pub fn cell_bg_alpha(cell: &Cell) -> AlphaBits {
|
||||||
nc::channels_bg_alpha(cell.channels)
|
channels_bg_alpha(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from 'cell', split into components.
|
/// Extract 24 bits of foreground RGB from 'cell', split into components.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fg_rgb8(cell: &Cell, red: &mut Color, green: &mut Color, blue: &mut Color) -> Channel {
|
pub fn cell_fg_rgb8(cell: &Cell, red: &mut Color, green: &mut Color, blue: &mut Color) -> Channel {
|
||||||
nc::channels_fg_rgb8(cell.channels, red, green, blue)
|
channels_fg_rgb8(cell.channels, red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of background RGB from 'cell', split into components.
|
/// Extract 24 bits of background RGB from 'cell', split into components.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bg_rgb8(cell: &Cell, red: &mut Color, green: &mut Color, blue: &mut Color) -> Channel {
|
pub fn cell_bg_rgb8(cell: &Cell, red: &mut Color, green: &mut Color, blue: &mut Color) -> Channel {
|
||||||
nc::channels_bg_rgb8(cell.channels, red, green, blue)
|
channels_bg_rgb8(cell.channels, red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the r, g, and b cell for the foreground component of this 64-bit
|
/// Set the r, g, and b cell for the foreground component of this 64-bit
|
||||||
/// 'cell' variable, and mark it as not using the default color.
|
/// 'cell' variable, and mark it as not using the default color.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fg_rgb8(cell: &mut Cell, red: Color, green: Color, blue: Color) {
|
pub fn cell_set_fg_rgb8(cell: &mut Cell, red: Color, green: Color, blue: Color) {
|
||||||
nc::channels_set_fg_rgb8(&mut cell.channels, red, green, blue);
|
channels_set_fg_rgb8(&mut cell.channels, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as `cell_set_fg_rgb8()` but with an assembled 24-bit RGB value.
|
/// Same as `cell_set_fg_rgb8()` but with an assembled 24-bit RGB value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fg_rgb(cell: &mut Cell, channel: Channel) {
|
pub fn cell_set_fg_rgb(cell: &mut Cell, channel: Channel) {
|
||||||
nc::channels_set_fg_rgb(&mut cell.channels, channel);
|
channels_set_fg_rgb(&mut cell.channels, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the cell's foreground palette index, set the foreground palette index
|
/// Set the cell's foreground palette index, set the foreground palette index
|
||||||
@ -384,9 +391,9 @@ pub fn cell_set_fg_rgb(cell: &mut Cell, channel: Channel) {
|
|||||||
// NOTE: this function now can't fail
|
// NOTE: this function now can't fail
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_fg_palindex(cell: &mut Cell, index: PaletteIndex) {
|
pub fn cell_set_fg_palindex(cell: &mut Cell, index: PaletteIndex) {
|
||||||
cell.channels |= nc::CELL_FGDEFAULT_MASK;
|
cell.channels |= CELL_FGDEFAULT_MASK;
|
||||||
cell.channels |= nc::CELL_FG_PALETTE;
|
cell.channels |= CELL_FG_PALETTE;
|
||||||
cell_set_fg_alpha(cell, nc::CELL_ALPHA_OPAQUE);
|
cell_set_fg_alpha(cell, CELL_ALPHA_OPAQUE);
|
||||||
cell.channels &= 0xff000000ffffffff_u64;
|
cell.channels &= 0xff000000ffffffff_u64;
|
||||||
cell.channels |= (index as u64) << 32;
|
cell.channels |= (index as u64) << 32;
|
||||||
}
|
}
|
||||||
@ -402,14 +409,14 @@ pub fn cell_fg_palindex(cell: &Cell) -> PaletteIndex {
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bg_rgb8(cell: &mut Cell, red: Color, green: Color, blue: Color) {
|
pub fn cell_set_bg_rgb8(cell: &mut Cell, red: Color, green: Color, blue: Color) {
|
||||||
nc::channels_set_bg_rgb8(&mut cell.channels, red, green, blue);
|
channels_set_bg_rgb8(&mut cell.channels, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as `cell_set_fg_rgb8()` but with an assembled 24-bit RGB value.
|
/// Same as `cell_set_fg_rgb8()` but with an assembled 24-bit RGB value.
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bg_rgb(cell: &mut Cell, channel: Channel) {
|
pub fn cell_set_bg_rgb(cell: &mut Cell, channel: Channel) {
|
||||||
nc::channels_set_bg_rgb(&mut cell.channels, channel);
|
channels_set_bg_rgb(&mut cell.channels, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the cell's background palette index, set the background palette index
|
/// Set the cell's background palette index, set the background palette index
|
||||||
@ -418,9 +425,9 @@ pub fn cell_set_bg_rgb(cell: &mut Cell, channel: Channel) {
|
|||||||
// NOTE: this function now can't fail
|
// NOTE: this function now can't fail
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_set_bg_palindex(cell: &mut Cell, index: PaletteIndex) {
|
pub fn cell_set_bg_palindex(cell: &mut Cell, index: PaletteIndex) {
|
||||||
cell.channels |= nc::CELL_BGDEFAULT_MASK as u64;
|
cell.channels |= CELL_BGDEFAULT_MASK as u64;
|
||||||
cell.channels |= nc::CELL_BG_PALETTE as u64;
|
cell.channels |= CELL_BG_PALETTE as u64;
|
||||||
cell_set_bg_alpha(cell, nc::CELL_ALPHA_OPAQUE);
|
cell_set_bg_alpha(cell, CELL_ALPHA_OPAQUE);
|
||||||
cell.channels &= 0xffffffffff000000;
|
cell.channels &= 0xffffffffff000000;
|
||||||
cell.channels |= index as u64;
|
cell.channels |= index as u64;
|
||||||
}
|
}
|
||||||
@ -434,13 +441,13 @@ pub fn cell_bg_palindex(cell: &Cell) -> PaletteIndex {
|
|||||||
/// Is the foreground using the "default foreground color"?
|
/// Is the foreground using the "default foreground color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fg_default_p(cell: &Cell) -> bool {
|
pub fn cell_fg_default_p(cell: &Cell) -> bool {
|
||||||
nc::channels_fg_default_p(cell.channels)
|
channels_fg_default_p(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_fg_palindex_p(cell: &Cell) -> bool {
|
pub fn cell_fg_palindex_p(cell: &Cell) -> bool {
|
||||||
nc::channels_fg_palindex_p(cell.channels)
|
channels_fg_palindex_p(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the background using the "default background color"? The "default
|
/// Is the background using the "default background color"? The "default
|
||||||
@ -448,13 +455,13 @@ pub fn cell_fg_palindex_p(cell: &Cell) -> bool {
|
|||||||
/// terminal-effected transparency.
|
/// terminal-effected transparency.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bg_default_p(cell: &Cell) -> bool {
|
pub fn cell_bg_default_p(cell: &Cell) -> bool {
|
||||||
nc::channels_bg_default_p(cell.channels)
|
channels_bg_default_p(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_bg_palindex_p(cell: &Cell) -> bool {
|
pub fn cell_bg_palindex_p(cell: &Cell) -> bool {
|
||||||
nc::channels_bg_palindex_p(cell.channels)
|
channels_bg_palindex_p(cell.channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -60,9 +60,11 @@
|
|||||||
//+ channels_set_fg_rgb8
|
//+ channels_set_fg_rgb8
|
||||||
//X channels_set_fg_rgb8_clipped
|
//X channels_set_fg_rgb8_clipped
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
|
types::{AlphaBits, Channel, Channels, Color, Rgb},
|
||||||
use nc::types::{AlphaBits, Channel, ChannelPair, Color, Rgb};
|
CELL_ALPHA_HIGHCONTRAST, CELL_ALPHA_OPAQUE, CELL_BGDEFAULT_MASK, CELL_BG_PALETTE,
|
||||||
|
CELL_BG_RGB_MASK, CHANNEL_ALPHA_MASK,
|
||||||
|
};
|
||||||
|
|
||||||
/// Extract the 8-bit red component from a 32-bit channel.
|
/// Extract the 8-bit red component from a 32-bit channel.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -96,82 +98,82 @@ pub fn channel_rgb8(channel: Channel, r: &mut Color, g: &mut Color, b: &mut Colo
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_set_rgb8(channel: &mut Channel, r: Color, g: Color, b: Color) {
|
pub fn channel_set_rgb8(channel: &mut Channel, r: Color, g: Color, b: Color) {
|
||||||
let rgb: Rgb = (r as Channel) << 16 | (g as Channel) << 8 | (b as Channel);
|
let rgb: Rgb = (r as Channel) << 16 | (g as Channel) << 8 | (b as Channel);
|
||||||
*channel = (*channel & !nc::CELL_BG_RGB_MASK) | nc::CELL_BGDEFAULT_MASK | rgb;
|
*channel = (*channel & !CELL_BG_RGB_MASK) | CELL_BGDEFAULT_MASK | rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as channel_set_rgb8(), but provide an assembled, packed 24 bits of rgb.
|
/// Same as channel_set_rgb8(), but provide an assembled, packed 24 bits of rgb.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_set(channel: &mut Channel, rgb: Rgb) {
|
pub fn channel_set(channel: &mut Channel, rgb: Rgb) {
|
||||||
*channel = (*channel & !nc::CELL_BG_RGB_MASK) | nc::CELL_BGDEFAULT_MASK | (rgb & 0x00ffffff);
|
*channel = (*channel & !CELL_BG_RGB_MASK) | CELL_BGDEFAULT_MASK | (rgb & 0x00ffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 2-bit alpha component from a 32-bit channel.
|
/// Extract the 2-bit alpha component from a 32-bit channel.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_alpha(channel: Channel) -> AlphaBits {
|
pub fn channel_alpha(channel: Channel) -> AlphaBits {
|
||||||
channel & nc::CHANNEL_ALPHA_MASK
|
channel & CHANNEL_ALPHA_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 2-bit alpha component of the 32-bit channel.
|
/// Set the 2-bit alpha component of the 32-bit channel.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_set_alpha(channel: &mut Channel, alpha: AlphaBits) {
|
pub fn channel_set_alpha(channel: &mut Channel, alpha: AlphaBits) {
|
||||||
let alpha_clean = alpha & nc::CHANNEL_ALPHA_MASK;
|
let alpha_clean = alpha & CHANNEL_ALPHA_MASK;
|
||||||
*channel = alpha_clean | (*channel & !nc::CHANNEL_ALPHA_MASK);
|
*channel = alpha_clean | (*channel & !CHANNEL_ALPHA_MASK);
|
||||||
|
|
||||||
if alpha != nc::CELL_ALPHA_OPAQUE {
|
if alpha != CELL_ALPHA_OPAQUE {
|
||||||
// indicate that we are *not* using the default background color
|
// indicate that we are *not* using the default background color
|
||||||
*channel |= nc::CELL_BGDEFAULT_MASK;
|
*channel |= CELL_BGDEFAULT_MASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this channel using the "default color" rather than RGB/palette-indexed?
|
/// Is this channel using the "default color" rather than RGB/palette-indexed?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_default_p(channel: Channel) -> bool {
|
pub fn channel_default_p(channel: Channel) -> bool {
|
||||||
(channel & nc::CELL_BGDEFAULT_MASK) == 0
|
(channel & CELL_BGDEFAULT_MASK) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this channel using palette-indexed color rather than RGB?
|
/// Is this channel using palette-indexed color rather than RGB?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_palindex_p(channel: Channel) -> bool {
|
pub fn channel_palindex_p(channel: Channel) -> bool {
|
||||||
!channel_default_p(channel) && (channel & nc::CELL_BG_PALETTE) == 0
|
!channel_default_p(channel) && (channel & CELL_BG_PALETTE) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark the channel as using its default color, which also marks it opaque.
|
/// Mark the channel as using its default color, which also marks it opaque.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channel_set_default(channel: &mut Channel) -> Channel {
|
pub fn channel_set_default(channel: &mut Channel) -> Channel {
|
||||||
*channel &= !(nc::CELL_BGDEFAULT_MASK | nc::CELL_ALPHA_HIGHCONTRAST); // < NOTE shouldn't be better CHANNEL_ALPHA_MASK?
|
*channel &= !(CELL_BGDEFAULT_MASK | CELL_ALPHA_HIGHCONTRAST); // < NOTE shouldn't be better CHANNEL_ALPHA_MASK?
|
||||||
*channel
|
*channel
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 32-bit background channel from a channel pair.
|
/// Extract the 32-bit background channel from a channel pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bchannel(channels: ChannelPair) -> Channel {
|
pub fn channels_bchannel(channels: Channels) -> Channel {
|
||||||
(channels & 0xffffffff_u64) as Channel
|
(channels & 0xffffffff_u64) as Channel
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 32-bit foreground channel from a channel pair.
|
/// Extract the 32-bit foreground channel from a channel pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fchannel(channels: ChannelPair) -> Channel {
|
pub fn channels_fchannel(channels: Channels) -> Channel {
|
||||||
channels_bchannel(channels >> 32)
|
channels_bchannel(channels >> 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 32-bit background channel of a channel pair.
|
/// Set the 32-bit background channel of a channel pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_bchannel(channels: &mut ChannelPair, bchannel: Channel) -> ChannelPair {
|
pub fn channels_set_bchannel(channels: &mut Channels, bchannel: Channel) -> Channels {
|
||||||
*channels = (*channels & 0xffffffff00000000_u64) | bchannel as u64;
|
*channels = (*channels & 0xffffffff00000000_u64) | bchannel as u64;
|
||||||
*channels
|
*channels
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 32-bit foreground channel of a channel pair.
|
/// Set the 32-bit foreground channel of a channel pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_fchannel(channels: &mut ChannelPair, fchannel: Channel) -> ChannelPair {
|
pub fn channels_set_fchannel(channels: &mut Channels, fchannel: Channel) -> Channels {
|
||||||
*channels = (*channels & 0xffffffff_u64) | (fchannel as u64) << 32;
|
*channels = (*channels & 0xffffffff_u64) | (fchannel as u64) << 32;
|
||||||
*channels
|
*channels
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Combine two channels into a channel pair.
|
/// Combine two channels into a channel pair.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_combine(fchannel: Channel, bchannel: Channel) -> ChannelPair {
|
pub fn channels_combine(fchannel: Channel, bchannel: Channel) -> Channels {
|
||||||
let mut channels: ChannelPair = 0;
|
let mut channels: Channels = 0;
|
||||||
channels_set_fchannel(&mut channels, fchannel);
|
channels_set_fchannel(&mut channels, fchannel);
|
||||||
channels_set_bchannel(&mut channels, bchannel);
|
channels_set_bchannel(&mut channels, bchannel);
|
||||||
channels
|
channels
|
||||||
@ -179,32 +181,32 @@ pub fn channels_combine(fchannel: Channel, bchannel: Channel) -> ChannelPair {
|
|||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from 'channels', shifted to LSBs.
|
/// Extract 24 bits of foreground RGB from 'channels', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fg_rgb(channels: ChannelPair) -> Channel {
|
pub fn channels_fg_rgb(channels: Channels) -> Channel {
|
||||||
channels_fchannel(channels) & nc::CELL_BG_RGB_MASK
|
channels_fchannel(channels) & CELL_BG_RGB_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of background RGB from 'channels', shifted to LSBs.
|
/// Extract 24 bits of background RGB from 'channels', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bg_rgb(channels: ChannelPair) -> Channel {
|
pub fn channels_bg_rgb(channels: Channels) -> Channel {
|
||||||
channels_bchannel(channels) & nc::CELL_BG_RGB_MASK
|
channels_bchannel(channels) & CELL_BG_RGB_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of foreground alpha from 'channels', shifted to LSBs.
|
/// Extract 2 bits of foreground alpha from 'channels', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fg_alpha(channels: ChannelPair) -> AlphaBits {
|
pub fn channels_fg_alpha(channels: Channels) -> AlphaBits {
|
||||||
channel_alpha(channels_fchannel(channels))
|
channel_alpha(channels_fchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of background alpha from 'channels', shifted to LSBs.
|
/// Extract 2 bits of background alpha from 'channels', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bg_alpha(channels: ChannelPair) -> AlphaBits {
|
pub fn channels_bg_alpha(channels: Channels) -> AlphaBits {
|
||||||
channel_alpha(channels_bchannel(channels))
|
channel_alpha(channels_bchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from 'channels', split into subchannels.
|
/// Extract 24 bits of foreground RGB from 'channels', split into subchannels.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fg_rgb8(
|
pub fn channels_fg_rgb8(
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
r: &mut Color,
|
r: &mut Color,
|
||||||
g: &mut Color,
|
g: &mut Color,
|
||||||
b: &mut Color,
|
b: &mut Color,
|
||||||
@ -215,7 +217,7 @@ pub fn channels_fg_rgb8(
|
|||||||
/// Extract 24 bits of background RGB from 'channels', split into subchannels.
|
/// Extract 24 bits of background RGB from 'channels', split into subchannels.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bg_rgb8(
|
pub fn channels_bg_rgb8(
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
r: &mut Color,
|
r: &mut Color,
|
||||||
g: &mut Color,
|
g: &mut Color,
|
||||||
b: &mut Color,
|
b: &mut Color,
|
||||||
@ -226,7 +228,7 @@ pub fn channels_bg_rgb8(
|
|||||||
/// Set the r, g, and b channels for the foreground component of this 64-bit
|
/// Set the r, g, and b channels for the foreground component of this 64-bit
|
||||||
/// 'channels' variable, and mark it as not using the default color.
|
/// 'channels' variable, and mark it as not using the default color.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_fg_rgb8(channels: &mut ChannelPair, r: Color, g: Color, b: Color) {
|
pub fn channels_set_fg_rgb8(channels: &mut Channels, r: Color, g: Color, b: Color) {
|
||||||
let mut channel = channels_fchannel(*channels);
|
let mut channel = channels_fchannel(*channels);
|
||||||
channel_set_rgb8(&mut channel, r, g, b);
|
channel_set_rgb8(&mut channel, r, g, b);
|
||||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||||
@ -234,7 +236,7 @@ pub fn channels_set_fg_rgb8(channels: &mut ChannelPair, r: Color, g: Color, b: C
|
|||||||
|
|
||||||
/// Same as channels_set_fg_rgb8 but set an assembled 24 bit channel at once.
|
/// Same as channels_set_fg_rgb8 but set an assembled 24 bit channel at once.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_fg_rgb(channels: &mut ChannelPair, rgb: Rgb) {
|
pub fn channels_set_fg_rgb(channels: &mut Channels, rgb: Rgb) {
|
||||||
let mut channel = channels_fchannel(*channels);
|
let mut channel = channels_fchannel(*channels);
|
||||||
channel_set(&mut channel, rgb);
|
channel_set(&mut channel, rgb);
|
||||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||||
@ -243,7 +245,7 @@ pub fn channels_set_fg_rgb(channels: &mut ChannelPair, rgb: Rgb) {
|
|||||||
/// Set the r, g, and b channels for the background component of this 64-bit
|
/// Set the r, g, and b channels for the background component of this 64-bit
|
||||||
/// 'channels' variable, and mark it as not using the default color.
|
/// 'channels' variable, and mark it as not using the default color.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_bg_rgb8(channels: &mut ChannelPair, r: Color, g: Color, b: Color) {
|
pub fn channels_set_bg_rgb8(channels: &mut Channels, r: Color, g: Color, b: Color) {
|
||||||
let mut channel = channels_bchannel(*channels);
|
let mut channel = channels_bchannel(*channels);
|
||||||
channel_set_rgb8(&mut channel, r, g, b);
|
channel_set_rgb8(&mut channel, r, g, b);
|
||||||
channels_set_bchannel(channels, channel);
|
channels_set_bchannel(channels, channel);
|
||||||
@ -251,7 +253,7 @@ pub fn channels_set_bg_rgb8(channels: &mut ChannelPair, r: Color, g: Color, b: C
|
|||||||
|
|
||||||
/// Same as channels_set_bg_rgb8 but set an assembled 24 bit channel at once.
|
/// Same as channels_set_bg_rgb8 but set an assembled 24 bit channel at once.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_bg_rgb(channels: &mut ChannelPair, rgb: Rgb) {
|
pub fn channels_set_bg_rgb(channels: &mut Channels, rgb: Rgb) {
|
||||||
let mut channel = channels_bchannel(*channels);
|
let mut channel = channels_bchannel(*channels);
|
||||||
channel_set(&mut channel, rgb);
|
channel_set(&mut channel, rgb);
|
||||||
channels_set_bchannel(channels, channel);
|
channels_set_bchannel(channels, channel);
|
||||||
@ -259,19 +261,19 @@ pub fn channels_set_bg_rgb(channels: &mut ChannelPair, rgb: Rgb) {
|
|||||||
|
|
||||||
/// Set the 2-bit alpha component of the foreground channel.
|
/// Set the 2-bit alpha component of the foreground channel.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_fg_alpha(channels: &mut ChannelPair, alpha: AlphaBits) {
|
pub fn channels_set_fg_alpha(channels: &mut Channels, alpha: AlphaBits) {
|
||||||
let mut channel = channels_fchannel(*channels);
|
let mut channel = channels_fchannel(*channels);
|
||||||
channel_set_alpha(&mut channel, alpha);
|
channel_set_alpha(&mut channel, alpha);
|
||||||
*channels = (channel as ChannelPair) << 32 | *channels & 0xffffffff_u64;
|
*channels = (channel as Channels) << 32 | *channels & 0xffffffff_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the 2-bit alpha component of the background channel.
|
/// Set the 2-bit alpha component of the background channel.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_bg_alpha(channels: &mut ChannelPair, alpha: AlphaBits) {
|
pub fn channels_set_bg_alpha(channels: &mut Channels, alpha: AlphaBits) {
|
||||||
let mut alpha_clean = alpha;
|
let mut alpha_clean = alpha;
|
||||||
if alpha == nc::CELL_ALPHA_HIGHCONTRAST {
|
if alpha == CELL_ALPHA_HIGHCONTRAST {
|
||||||
// forbidden for background alpha, so makes it opaque
|
// forbidden for background alpha, so makes it opaque
|
||||||
alpha_clean = nc::CELL_ALPHA_OPAQUE;
|
alpha_clean = CELL_ALPHA_OPAQUE;
|
||||||
}
|
}
|
||||||
let mut channel = channels_bchannel(*channels);
|
let mut channel = channels_bchannel(*channels);
|
||||||
channel_set_alpha(&mut channel, alpha_clean);
|
channel_set_alpha(&mut channel, alpha_clean);
|
||||||
@ -280,13 +282,13 @@ pub fn channels_set_bg_alpha(channels: &mut ChannelPair, alpha: AlphaBits) {
|
|||||||
|
|
||||||
/// Is the foreground using the "default foreground color"?
|
/// Is the foreground using the "default foreground color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fg_default_p(channels: ChannelPair) -> bool {
|
pub fn channels_fg_default_p(channels: Channels) -> bool {
|
||||||
channel_default_p(channels_fchannel(channels))
|
channel_default_p(channels_fchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the foreground using indexed palette color?
|
/// Is the foreground using indexed palette color?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_fg_palindex_p(channels: ChannelPair) -> bool {
|
pub fn channels_fg_palindex_p(channels: Channels) -> bool {
|
||||||
channel_palindex_p(channels_fchannel(channels))
|
channel_palindex_p(channels_fchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,19 +296,19 @@ pub fn channels_fg_palindex_p(channels: ChannelPair) -> bool {
|
|||||||
/// background color" must generally be used to take advantage of
|
/// background color" must generally be used to take advantage of
|
||||||
/// terminal-effected transparency.
|
/// terminal-effected transparency.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bg_default_p(channels: ChannelPair) -> bool {
|
pub fn channels_bg_default_p(channels: Channels) -> bool {
|
||||||
channel_default_p(channels_bchannel(channels))
|
channel_default_p(channels_bchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the background using indexed palette color?
|
/// Is the background using indexed palette color?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_bg_palindex_p(channels: ChannelPair) -> bool {
|
pub fn channels_bg_palindex_p(channels: Channels) -> bool {
|
||||||
channel_palindex_p(channels_bchannel(channels))
|
channel_palindex_p(channels_bchannel(channels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark the foreground channel as using its default color.
|
/// Mark the foreground channel as using its default color.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_fg_default(channels: &mut ChannelPair) -> ChannelPair {
|
pub fn channels_set_fg_default(channels: &mut Channels) -> Channels {
|
||||||
let mut channel = channels_fchannel(*channels);
|
let mut channel = channels_fchannel(*channels);
|
||||||
channel_set_default(&mut channel);
|
channel_set_default(&mut channel);
|
||||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||||
@ -315,7 +317,7 @@ pub fn channels_set_fg_default(channels: &mut ChannelPair) -> ChannelPair {
|
|||||||
|
|
||||||
/// Mark the background channel as using its default color.
|
/// Mark the background channel as using its default color.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_set_bg_default(channels: &mut ChannelPair) -> ChannelPair {
|
pub fn channels_set_bg_default(channels: &mut Channels) -> Channels {
|
||||||
let mut channel = channels_bchannel(*channels);
|
let mut channel = channels_bchannel(*channels);
|
||||||
channel_set_default(&mut channel);
|
channel_set_default(&mut channel);
|
||||||
channels_set_bchannel(channels, channel);
|
channels_set_bchannel(channels, channel);
|
||||||
@ -324,7 +326,10 @@ pub fn channels_set_bg_default(channels: &mut ChannelPair) -> ChannelPair {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::{nc, Channel, ChannelPair};
|
use super::{Channel, Channels};
|
||||||
|
use crate::{
|
||||||
|
CELL_ALPHA_BLEND, CELL_ALPHA_HIGHCONTRAST, CELL_ALPHA_OPAQUE, CELL_ALPHA_TRANSPARENT,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -369,25 +374,25 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn channel_alpha() {
|
fn channel_alpha() {
|
||||||
let c: Channel = 0x112233 | nc::CELL_ALPHA_TRANSPARENT;
|
let c: Channel = 0x112233 | CELL_ALPHA_TRANSPARENT;
|
||||||
assert_eq!(super::channel_alpha(c), nc::CELL_ALPHA_TRANSPARENT);
|
assert_eq!(super::channel_alpha(c), CELL_ALPHA_TRANSPARENT);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
fn channel_set_alpha() {
|
fn channel_set_alpha() {
|
||||||
let mut c: Channel = 0x112233;
|
let mut c: Channel = 0x112233;
|
||||||
super::channel_set_alpha(&mut c, nc::CELL_ALPHA_HIGHCONTRAST);
|
super::channel_set_alpha(&mut c, CELL_ALPHA_HIGHCONTRAST);
|
||||||
assert_eq!(nc::CELL_ALPHA_HIGHCONTRAST, super::channel_alpha(c));
|
assert_eq!(CELL_ALPHA_HIGHCONTRAST, super::channel_alpha(c));
|
||||||
|
|
||||||
super::channel_set_alpha(&mut c, nc::CELL_ALPHA_TRANSPARENT);
|
super::channel_set_alpha(&mut c, CELL_ALPHA_TRANSPARENT);
|
||||||
assert_eq!(nc::CELL_ALPHA_TRANSPARENT, super::channel_alpha(c));
|
assert_eq!(CELL_ALPHA_TRANSPARENT, super::channel_alpha(c));
|
||||||
|
|
||||||
super::channel_set_alpha(&mut c, nc::CELL_ALPHA_BLEND);
|
super::channel_set_alpha(&mut c, CELL_ALPHA_BLEND);
|
||||||
assert_eq!(nc::CELL_ALPHA_BLEND, super::channel_alpha(c));
|
assert_eq!(CELL_ALPHA_BLEND, super::channel_alpha(c));
|
||||||
|
|
||||||
super::channel_set_alpha(&mut c, nc::CELL_ALPHA_OPAQUE);
|
super::channel_set_alpha(&mut c, CELL_ALPHA_OPAQUE);
|
||||||
assert_eq!(nc::CELL_ALPHA_OPAQUE, super::channel_alpha(c));
|
assert_eq!(CELL_ALPHA_OPAQUE, super::channel_alpha(c));
|
||||||
// TODO: CHECK for nc::CELL_BGDEFAULT_MASK
|
// TODO: CHECK for CELL_BGDEFAULT_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -395,7 +400,7 @@ mod test {
|
|||||||
fn channel_set_default() {
|
fn channel_set_default() {
|
||||||
const DEFAULT: Channel = 0x112233;
|
const DEFAULT: Channel = 0x112233;
|
||||||
|
|
||||||
let mut c: Channel = DEFAULT | nc::CELL_ALPHA_TRANSPARENT;
|
let mut c: Channel = DEFAULT | CELL_ALPHA_TRANSPARENT;
|
||||||
assert!(c != DEFAULT);
|
assert!(c != DEFAULT);
|
||||||
|
|
||||||
super::channel_set_default(&mut c);
|
super::channel_set_default(&mut c);
|
||||||
@ -409,10 +414,10 @@ mod test {
|
|||||||
assert_eq!(true, super::channel_default_p(c));
|
assert_eq!(true, super::channel_default_p(c));
|
||||||
|
|
||||||
// TODO FIXME: test for the false result
|
// TODO FIXME: test for the false result
|
||||||
// let _ = super::channel_set_alpha(&mut c, nc::CELL_ALPHA_TRANSPARENT);
|
// let _ = super::channel_set_alpha(&mut c, CELL_ALPHA_TRANSPARENT);
|
||||||
// assert_eq!(false, super::channel_default_p(c));
|
// assert_eq!(false, super::channel_default_p(c));
|
||||||
|
|
||||||
let _ = super::channel_set_alpha(&mut c, nc::CELL_ALPHA_OPAQUE);
|
let _ = super::channel_set_alpha(&mut c, CELL_ALPHA_OPAQUE);
|
||||||
assert_eq!(true, super::channel_default_p(c));
|
assert_eq!(true, super::channel_default_p(c));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
@ -420,7 +425,7 @@ mod test {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn channels_set_fchannel__channels_fchannel() {
|
fn channels_set_fchannel__channels_fchannel() {
|
||||||
let fc: Channel = 0x112233;
|
let fc: Channel = 0x112233;
|
||||||
let mut cp: ChannelPair = 0;
|
let mut cp: Channels = 0;
|
||||||
super::channels_set_fchannel(&mut cp, fc);
|
super::channels_set_fchannel(&mut cp, fc);
|
||||||
assert_eq!(super::channels_fchannel(cp), fc);
|
assert_eq!(super::channels_fchannel(cp), fc);
|
||||||
}
|
}
|
||||||
@ -429,7 +434,7 @@ mod test {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn channels_set_bchannel__channels_bchannel() {
|
fn channels_set_bchannel__channels_bchannel() {
|
||||||
let bc: Channel = 0x112233;
|
let bc: Channel = 0x112233;
|
||||||
let mut cp: ChannelPair = 0;
|
let mut cp: Channels = 0;
|
||||||
super::channels_set_bchannel(&mut cp, bc);
|
super::channels_set_bchannel(&mut cp, bc);
|
||||||
assert_eq!(super::channels_bchannel(cp), bc);
|
assert_eq!(super::channels_bchannel(cp), bc);
|
||||||
}
|
}
|
||||||
@ -438,8 +443,8 @@ mod test {
|
|||||||
fn channels_combine() {
|
fn channels_combine() {
|
||||||
let bc: Channel = 0x112233;
|
let bc: Channel = 0x112233;
|
||||||
let fc: Channel = 0x445566;
|
let fc: Channel = 0x445566;
|
||||||
let mut cp1: ChannelPair = 0;
|
let mut cp1: Channels = 0;
|
||||||
let mut _cp2: ChannelPair = 0;
|
let mut _cp2: Channels = 0;
|
||||||
super::channels_set_bchannel(&mut cp1, bc);
|
super::channels_set_bchannel(&mut cp1, bc);
|
||||||
super::channels_set_fchannel(&mut cp1, fc);
|
super::channels_set_fchannel(&mut cp1, fc);
|
||||||
_cp2 = super::channels_combine(fc, bc);
|
_cp2 = super::channels_combine(fc, bc);
|
||||||
|
@ -39,11 +39,14 @@
|
|||||||
// ncdirect_styles_set
|
// ncdirect_styles_set
|
||||||
// ncdirect_vline_interp
|
// ncdirect_vline_interp
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
use nc::types::{NcDirect, NcDirectFlags};
|
bindgen::_IO_FILE,
|
||||||
|
ncdirect_init,
|
||||||
|
types::{NcDirect, NcDirectFlags},
|
||||||
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn libc_stdout() -> *mut nc::_IO_FILE;
|
fn libc_stdout() -> *mut _IO_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A simple ncdirect_init() wrapper using the default options.
|
/// A simple ncdirect_init() wrapper using the default options.
|
||||||
@ -66,5 +69,5 @@ pub unsafe fn ncdirect_new() -> *mut NcDirect {
|
|||||||
/// - NCDIRECT_OPTION_INHIBIT_SETLOCALE
|
/// - NCDIRECT_OPTION_INHIBIT_SETLOCALE
|
||||||
///
|
///
|
||||||
pub unsafe fn ncdirect_with_flags(flags: NcDirectFlags) -> *mut NcDirect {
|
pub unsafe fn ncdirect_with_flags(flags: NcDirectFlags) -> *mut NcDirect {
|
||||||
nc::ncdirect_init(core::ptr::null(), libc_stdout(), flags)
|
ncdirect_init(core::ptr::null(), libc_stdout(), flags)
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
//+ ncinput_equal_p
|
//+ ncinput_equal_p
|
||||||
|
|
||||||
use crate as nc;
|
use crate::types::NcInput;
|
||||||
use nc::types::NcInput;
|
|
||||||
|
|
||||||
/// Compare two ncinput structs for data equality by doing a field-by-field
|
/// Compare two ncinput structs for data equality by doing a field-by-field
|
||||||
/// comparison for equality (excepting seqnum).
|
/// comparison for equality (excepting seqnum).
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
//+ nckey_mouse_p
|
//+ nckey_mouse_p
|
||||||
//+ nckey_supppuab_p
|
//+ nckey_supppuab_p
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{NCKEY_BUTTON1, NCKEY_RELEASE};
|
||||||
|
|
||||||
/// Is this u32 a Supplementary Private Use Area-B codepoint?
|
/// Is this u32 a Supplementary Private Use Area-B codepoint?
|
||||||
///
|
///
|
||||||
@ -24,7 +24,7 @@ pub fn nckey_supppuab_p(w: u32) -> bool {
|
|||||||
/// Is the event a synthesized mouse event?
|
/// Is the event a synthesized mouse event?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn nckey_mouse_p(r: u32) -> bool {
|
pub fn nckey_mouse_p(r: u32) -> bool {
|
||||||
r >= nc::NCKEY_BUTTON1 && r <= nc::NCKEY_RELEASE
|
r >= NCKEY_BUTTON1 && r <= NCKEY_RELEASE
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
use crate as nc;
|
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use nc::Cell;
|
|
||||||
|
use crate::Cell;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! cell_initializer {
|
macro_rules! cell_initializer {
|
||||||
( $c:expr, $s:expr, $chan:expr ) => {
|
( $c:expr, $s:expr, $chan:expr ) => {
|
||||||
Cell {
|
Cell {
|
||||||
gcluster: $c as u32,
|
gcluster: $c as u32,
|
||||||
gcluster_backstop: 0 as EGCBackstop,
|
gcluster_backstop: 0 as EgcBackstop,
|
||||||
reserved: 0,
|
reserved: 0,
|
||||||
stylemask: $s,
|
stylemask: $s,
|
||||||
channels: $chan,
|
channels: $chan,
|
||||||
|
@ -54,10 +54,18 @@
|
|||||||
|
|
||||||
use core::ptr::null;
|
use core::ptr::null;
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
use nc::types::{NcAlign, NcInput, NcPlane, Notcurses, NCALIGN_CENTER, NCALIGN_LEFT};
|
// NOTE: can't use libc::timespec nor libc::sigset_t
|
||||||
|
// with notcurses_getc(()
|
||||||
use nc::timespec; // NOTE: can't use libc::timespec with notcurses_getc(()
|
bindings::{sigemptyset, sigfillset, sigset_t, timespec},
|
||||||
|
ncplane_dim_yx,
|
||||||
|
notcurses_getc,
|
||||||
|
notcurses_stdplane,
|
||||||
|
notcurses_stdplane_const,
|
||||||
|
types::{NcAlign, NcInput, NcPlane, Notcurses},
|
||||||
|
NCALIGN_CENTER,
|
||||||
|
NCALIGN_LEFT,
|
||||||
|
};
|
||||||
|
|
||||||
/// return the offset into 'availcols' at which 'cols' ought be output given the requirements of 'align'
|
/// return the offset into 'availcols' at which 'cols' ought be output given the requirements of 'align'
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -76,16 +84,17 @@ pub fn notcurses_align(availcols: i32, align: NcAlign, cols: i32) -> i32 {
|
|||||||
|
|
||||||
/// 'input' may be NULL if the caller is uninterested in event details.
|
/// 'input' may be NULL if the caller is uninterested in event details.
|
||||||
/// If no event is ready, returns 0.
|
/// If no event is ready, returns 0.
|
||||||
|
// TODO: use pakr-signals
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_getc_nblock(nc: &mut Notcurses, input: &mut NcInput) -> char {
|
pub fn notcurses_getc_nblock(nc: &mut Notcurses, input: &mut NcInput) -> char {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
let mut sigmask = sigset_t { __val: [0; 16] };
|
||||||
nc::sigfillset(&mut sigmask);
|
sigfillset(&mut sigmask);
|
||||||
let ts = timespec {
|
let ts = timespec {
|
||||||
tv_sec: 0,
|
tv_sec: 0,
|
||||||
tv_nsec: 0,
|
tv_nsec: 0,
|
||||||
};
|
};
|
||||||
core::char::from_u32_unchecked(nc::notcurses_getc(nc, &ts, &mut sigmask, input))
|
core::char::from_u32_unchecked(notcurses_getc(nc, &ts, &mut sigmask, input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,9 +103,9 @@ pub fn notcurses_getc_nblock(nc: &mut Notcurses, input: &mut NcInput) -> char {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_getc_nblocking(nc: &mut Notcurses, input: &mut NcInput) -> char {
|
pub fn notcurses_getc_nblocking(nc: &mut Notcurses, input: &mut NcInput) -> char {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
let mut sigmask = sigset_t { __val: [0; 16] };
|
||||||
nc::sigemptyset(&mut sigmask);
|
sigemptyset(&mut sigmask);
|
||||||
core::char::from_u32_unchecked(nc::notcurses_getc(nc, null(), &mut sigmask, input))
|
core::char::from_u32_unchecked(notcurses_getc(nc, null(), &mut sigmask, input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +113,8 @@ pub fn notcurses_getc_nblocking(nc: &mut Notcurses, input: &mut NcInput) -> char
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_stddim_yx(nc: &mut Notcurses, y: &mut i32, x: &mut i32) -> NcPlane {
|
pub fn notcurses_stddim_yx(nc: &mut Notcurses, y: &mut i32, x: &mut i32) -> NcPlane {
|
||||||
unsafe {
|
unsafe {
|
||||||
let s = nc::notcurses_stdplane(nc);
|
let s = notcurses_stdplane(nc);
|
||||||
nc::ncplane_dim_yx(s, y, x);
|
ncplane_dim_yx(s, y, x);
|
||||||
*s
|
*s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,13 +123,13 @@ pub fn notcurses_stddim_yx(nc: &mut Notcurses, y: &mut i32, x: &mut i32) -> NcPl
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_term_dim_yx(nc: &Notcurses, rows: &mut i32, cols: &mut i32) {
|
pub fn notcurses_term_dim_yx(nc: &Notcurses, rows: &mut i32, cols: &mut i32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(nc::notcurses_stdplane_const(nc), rows, cols);
|
ncplane_dim_yx(notcurses_stdplane_const(nc), rows, cols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// pub unsafe fn notcurses_new() -> *mut Notcurses {
|
// pub unsafe fn notcurses_new() -> *mut Notcurses {
|
||||||
// nc::notcurses_init(core::ptr::null(), libc_stdout())
|
// notcurses_init(core::ptr::null(), libc_stdout())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
//+ palette256_set
|
//+ palette256_set
|
||||||
//+ palette256_set_rgb
|
//+ palette256_set_rgb
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
use nc::types::{Channel, Color, Palette, PaletteIndex, Rgb};
|
channel_rgb8, channel_set, channel_set_rgb8,
|
||||||
|
types::{Channel, Color, Palette, PaletteIndex, Rgb},
|
||||||
|
};
|
||||||
|
|
||||||
/// Set the different color components of an entry inside a palette store.
|
/// Set the different color components of an entry inside a palette store.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -29,13 +31,13 @@ pub fn palette256_set_rgb(
|
|||||||
green: Color,
|
green: Color,
|
||||||
blue: Color,
|
blue: Color,
|
||||||
) {
|
) {
|
||||||
nc::channel_set_rgb8(&mut palette.chans[idx as usize], red, green, blue)
|
channel_set_rgb8(&mut palette.chans[idx as usize], red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as `palette256_set_rgb()` but set an assembled 24 bit channel at once.
|
/// Same as `palette256_set_rgb()` but set an assembled 24 bit channel at once.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn palette256_set(palette: &mut Palette, idx: PaletteIndex, rgb: Rgb) {
|
pub fn palette256_set(palette: &mut Palette, idx: PaletteIndex, rgb: Rgb) {
|
||||||
nc::channel_set(&mut palette.chans[idx as usize], rgb);
|
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.
|
/// Extract the three 8-bit R/G/B components from an entry inside a palette store.
|
||||||
@ -47,7 +49,7 @@ pub fn palette256_get_rgb(
|
|||||||
green: &mut Color,
|
green: &mut Color,
|
||||||
blue: &mut Color,
|
blue: &mut Color,
|
||||||
) -> Channel {
|
) -> Channel {
|
||||||
nc::channel_rgb8(palette.chans[idx as usize], red, green, blue)
|
channel_rgb8(palette.chans[idx as usize], red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
//+ ncpixel_set_r
|
//+ ncpixel_set_r
|
||||||
//+ ncpixel_set_rgb
|
//+ ncpixel_set_rgb
|
||||||
|
|
||||||
use crate as nc;
|
use crate::types::{Color, Pixel};
|
||||||
use nc::types::{Color, Pixel};
|
|
||||||
|
|
||||||
// Pixel Structure:
|
// Pixel Structure:
|
||||||
//
|
//
|
||||||
|
@ -155,10 +155,19 @@ use core::ptr::null_mut;
|
|||||||
use cstr_core::CString;
|
use cstr_core::CString;
|
||||||
use libc::free;
|
use libc::free;
|
||||||
|
|
||||||
use crate as nc;
|
use crate::{
|
||||||
use nc::types::{
|
bindgen::__va_list_tag,
|
||||||
AlphaBits, Cell, Channel, ChannelPair, Color, EGCBackstop, IntResult, NcAlign, NcPlane,
|
cell_load, cell_release, cells_double_box, cells_rounded_box, channels_bchannel,
|
||||||
StyleMask,
|
channels_bg_alpha, channels_bg_default_p, channels_bg_rgb, channels_bg_rgb8, channels_fchannel,
|
||||||
|
channels_fg_alpha, channels_fg_default_p, channels_fg_rgb, channels_fg_rgb8, ncplane_at_cursor,
|
||||||
|
ncplane_at_yx, ncplane_box, ncplane_channels, ncplane_cursor_move_yx, ncplane_cursor_yx,
|
||||||
|
ncplane_dim_yx, ncplane_gradient, ncplane_hline_interp, ncplane_putc_yx, ncplane_putegc_yx,
|
||||||
|
ncplane_putnstr_yx, ncplane_putstr_yx, ncplane_resize, ncplane_vline_interp,
|
||||||
|
ncplane_vprintf_yx, notcurses_align,
|
||||||
|
types::{
|
||||||
|
AlphaBits, Cell, Channel, Channels, Color, EgcBackstop, IntResult, NcAlign, NcPlane,
|
||||||
|
StyleMask,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Return the column at which 'cols' columns ought start in order to be aligned
|
/// Return the column at which 'cols' columns ought start in order to be aligned
|
||||||
@ -168,18 +177,18 @@ use nc::types::{
|
|||||||
// NOTE: [leave cols as i32](https://github.com/dankamongmen/notcurses/issues/904)
|
// NOTE: [leave cols as i32](https://github.com/dankamongmen/notcurses/issues/904)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: i32) -> i32 {
|
pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: i32) -> i32 {
|
||||||
nc::notcurses_align(nc::ncplane_dim_x(plane), align, cols)
|
notcurses_align(ncplane_dim_x(plane), align, cols)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve the current contents of the cell under the cursor into 'cell'.
|
/// Retrieve the current contents of the cell under the cursor into 'cell'.
|
||||||
/// This cell is invalidated if the associated plane is destroyed.
|
/// This cell is invalidated if the associated plane is destroyed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn nplane_at_cursor_cell(plane: &mut NcPlane, cell: &mut Cell) -> IntResult {
|
pub fn nplane_at_cursor_cell(plane: &mut NcPlane, cell: &mut Cell) -> IntResult {
|
||||||
let mut egc = unsafe { nc::ncplane_at_cursor(plane, &mut cell.stylemask, &mut cell.channels) };
|
let mut egc = unsafe { ncplane_at_cursor(plane, &mut cell.stylemask, &mut cell.channels) };
|
||||||
if egc.is_null() {
|
if egc.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let result: IntResult = unsafe { nc::cell_load(plane, cell, egc) };
|
let result: IntResult = unsafe { cell_load(plane, cell, egc) };
|
||||||
if result < 0 {
|
if result < 0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
free(&mut egc as *mut _ as *mut c_void);
|
free(&mut egc as *mut _ as *mut c_void);
|
||||||
@ -192,13 +201,12 @@ pub fn nplane_at_cursor_cell(plane: &mut NcPlane, cell: &mut Cell) -> IntResult
|
|||||||
/// This cell is invalidated if the associated plane is destroyed.
|
/// This cell is invalidated if the associated plane is destroyed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_at_yx_cell(plane: &mut NcPlane, y: i32, x: i32, cell: &mut Cell) -> IntResult {
|
pub fn ncplane_at_yx_cell(plane: &mut NcPlane, y: i32, x: i32, cell: &mut Cell) -> IntResult {
|
||||||
let mut egc =
|
let mut egc = unsafe { ncplane_at_yx(plane, y, x, &mut cell.stylemask, &mut cell.channels) };
|
||||||
unsafe { nc::ncplane_at_yx(plane, y, x, &mut cell.stylemask, &mut cell.channels) };
|
|
||||||
if egc.is_null() {
|
if egc.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let channels = cell.channels; // need to preserve wide flag
|
let channels = cell.channels; // need to preserve wide flag
|
||||||
let result: IntResult = unsafe { nc::cell_load(plane, cell, egc) };
|
let result: IntResult = unsafe { cell_load(plane, cell, egc) };
|
||||||
cell.channels = channels;
|
cell.channels = channels;
|
||||||
unsafe {
|
unsafe {
|
||||||
free(&mut egc as *mut _ as *mut c_void);
|
free(&mut egc as *mut _ as *mut c_void);
|
||||||
@ -224,8 +232,8 @@ pub fn ncplane_box_sized(
|
|||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
let (mut y, mut x) = (0, 0);
|
let (mut y, mut x) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_cursor_yx(plane, &mut y, &mut x);
|
ncplane_cursor_yx(plane, &mut y, &mut x);
|
||||||
nc::ncplane_box(
|
ncplane_box(
|
||||||
plane,
|
plane,
|
||||||
ul,
|
ul,
|
||||||
ur,
|
ur,
|
||||||
@ -245,7 +253,7 @@ pub fn ncplane_box_sized(
|
|||||||
pub fn ncplane_dim_x(plane: &NcPlane) -> i32 {
|
pub fn ncplane_dim_x(plane: &NcPlane) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
nc::ncplane_dim_yx(plane, null_mut(), &mut x);
|
ncplane_dim_yx(plane, null_mut(), &mut x);
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +263,7 @@ pub fn ncplane_dim_x(plane: &NcPlane) -> i32 {
|
|||||||
pub fn ncplane_dim_y(plane: &NcPlane) -> i32 {
|
pub fn ncplane_dim_y(plane: &NcPlane) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
nc::ncplane_dim_yx(plane, &mut y, null_mut());
|
ncplane_dim_yx(plane, &mut y, null_mut());
|
||||||
y
|
y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,7 +273,7 @@ pub fn ncplane_dim_y(plane: &NcPlane) -> i32 {
|
|||||||
pub fn ncplane_double_box(
|
pub fn ncplane_double_box(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ystop: i32,
|
ystop: i32,
|
||||||
xstop: i32,
|
xstop: i32,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
@ -281,7 +289,7 @@ pub fn ncplane_double_box(
|
|||||||
let mut vl = cell_trivial_initializer![];
|
let mut vl = cell_trivial_initializer![];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ret = nc::cells_double_box(
|
ret = cells_double_box(
|
||||||
plane,
|
plane,
|
||||||
stylemask as u32,
|
stylemask as u32,
|
||||||
channels,
|
channels,
|
||||||
@ -293,15 +301,15 @@ pub fn ncplane_double_box(
|
|||||||
&mut vl,
|
&mut vl,
|
||||||
);
|
);
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
ret = nc::ncplane_box(plane, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
|
ret = ncplane_box(plane, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc::cell_release(plane, &mut ul);
|
cell_release(plane, &mut ul);
|
||||||
nc::cell_release(plane, &mut ur);
|
cell_release(plane, &mut ur);
|
||||||
nc::cell_release(plane, &mut ll);
|
cell_release(plane, &mut ll);
|
||||||
nc::cell_release(plane, &mut lr);
|
cell_release(plane, &mut lr);
|
||||||
nc::cell_release(plane, &mut hl);
|
cell_release(plane, &mut hl);
|
||||||
nc::cell_release(plane, &mut vl);
|
cell_release(plane, &mut vl);
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@ -311,14 +319,14 @@ pub fn ncplane_double_box(
|
|||||||
pub fn ncplane_double_box_sized(
|
pub fn ncplane_double_box_sized(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ylen: i32,
|
ylen: i32,
|
||||||
xlen: i32,
|
xlen: i32,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
let (mut y, mut x) = (0, 0);
|
let (mut y, mut x) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_cursor_yx(plane, &mut y, &mut x);
|
ncplane_cursor_yx(plane, &mut y, &mut x);
|
||||||
}
|
}
|
||||||
ncplane_double_box(
|
ncplane_double_box(
|
||||||
plane,
|
plane,
|
||||||
@ -333,7 +341,7 @@ pub fn ncplane_double_box_sized(
|
|||||||
/// On error, return the negative number of cells drawn.
|
/// On error, return the negative number of cells drawn.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_hline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
pub fn ncplane_hline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
||||||
unsafe { nc::ncplane_hline_interp(plane, cell, len, cell.channels, cell.channels) }
|
unsafe { ncplane_hline_interp(plane, cell, len, cell.channels, cell.channels) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -349,9 +357,9 @@ pub fn ncplane_perimeter(
|
|||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_cursor_move_yx(plane, 0, 0);
|
ncplane_cursor_move_yx(plane, 0, 0);
|
||||||
let (mut dimy, mut dimx) = (0, 0);
|
let (mut dimy, mut dimx) = (0, 0);
|
||||||
nc::ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
||||||
ncplane_box_sized(plane, ul, ur, ll, lr, hline, vline, dimy, dimx, ctlword)
|
ncplane_box_sized(plane, ul, ur, ll, lr, hline, vline, dimy, dimx, ctlword)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,15 +369,15 @@ pub fn ncplane_perimeter(
|
|||||||
pub fn ncplane_perimeter_double(
|
pub fn ncplane_perimeter_double(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
if unsafe { nc::ncplane_cursor_move_yx(plane, 0, 0) } != 0 {
|
if unsafe { ncplane_cursor_move_yx(plane, 0, 0) } != 0 {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let (mut dimy, mut dimx) = (0, 0);
|
let (mut dimy, mut dimx) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
||||||
}
|
}
|
||||||
let mut ul = cell_trivial_initializer![];
|
let mut ul = cell_trivial_initializer![];
|
||||||
let mut ur = cell_trivial_initializer![];
|
let mut ur = cell_trivial_initializer![];
|
||||||
@ -378,7 +386,7 @@ pub fn ncplane_perimeter_double(
|
|||||||
let mut hl = cell_trivial_initializer![];
|
let mut hl = cell_trivial_initializer![];
|
||||||
let mut vl = cell_trivial_initializer![];
|
let mut vl = cell_trivial_initializer![];
|
||||||
if unsafe {
|
if unsafe {
|
||||||
nc::cells_double_box(
|
cells_double_box(
|
||||||
plane,
|
plane,
|
||||||
stylemask as u32,
|
stylemask as u32,
|
||||||
channels,
|
channels,
|
||||||
@ -395,12 +403,12 @@ pub fn ncplane_perimeter_double(
|
|||||||
}
|
}
|
||||||
let ret = ncplane_box_sized(plane, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
|
let ret = ncplane_box_sized(plane, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, &mut ul);
|
cell_release(plane, &mut ul);
|
||||||
nc::cell_release(plane, &mut ur);
|
cell_release(plane, &mut ur);
|
||||||
nc::cell_release(plane, &mut ll);
|
cell_release(plane, &mut ll);
|
||||||
nc::cell_release(plane, &mut lr);
|
cell_release(plane, &mut lr);
|
||||||
nc::cell_release(plane, &mut hl);
|
cell_release(plane, &mut hl);
|
||||||
nc::cell_release(plane, &mut vl);
|
cell_release(plane, &mut vl);
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@ -410,15 +418,15 @@ pub fn ncplane_perimeter_double(
|
|||||||
pub fn ncplane_perimeter_rounded(
|
pub fn ncplane_perimeter_rounded(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
if unsafe { nc::ncplane_cursor_move_yx(plane, 0, 0) } != 0 {
|
if unsafe { ncplane_cursor_move_yx(plane, 0, 0) } != 0 {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let (mut dimy, mut dimx) = (0, 0);
|
let (mut dimy, mut dimx) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
ncplane_dim_yx(plane, &mut dimy, &mut dimx);
|
||||||
}
|
}
|
||||||
let mut ul = cell_trivial_initializer![];
|
let mut ul = cell_trivial_initializer![];
|
||||||
let mut ur = cell_trivial_initializer![];
|
let mut ur = cell_trivial_initializer![];
|
||||||
@ -427,7 +435,7 @@ pub fn ncplane_perimeter_rounded(
|
|||||||
let mut hl = cell_trivial_initializer![];
|
let mut hl = cell_trivial_initializer![];
|
||||||
let mut vl = cell_trivial_initializer![];
|
let mut vl = cell_trivial_initializer![];
|
||||||
if unsafe {
|
if unsafe {
|
||||||
nc::cells_rounded_box(
|
cells_rounded_box(
|
||||||
plane,
|
plane,
|
||||||
stylemask as u32,
|
stylemask as u32,
|
||||||
channels,
|
channels,
|
||||||
@ -444,12 +452,12 @@ pub fn ncplane_perimeter_rounded(
|
|||||||
}
|
}
|
||||||
let ret = ncplane_box_sized(plane, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
|
let ret = ncplane_box_sized(plane, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, ctlword);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, &mut ul);
|
cell_release(plane, &mut ul);
|
||||||
nc::cell_release(plane, &mut ur);
|
cell_release(plane, &mut ur);
|
||||||
nc::cell_release(plane, &mut ll);
|
cell_release(plane, &mut ll);
|
||||||
nc::cell_release(plane, &mut lr);
|
cell_release(plane, &mut lr);
|
||||||
nc::cell_release(plane, &mut hl);
|
cell_release(plane, &mut hl);
|
||||||
nc::cell_release(plane, &mut vl);
|
cell_release(plane, &mut vl);
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@ -457,20 +465,20 @@ pub fn ncplane_perimeter_rounded(
|
|||||||
/// Call ncplane_putc_yx() for the current cursor location.
|
/// Call ncplane_putc_yx() for the current cursor location.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putc(plane: &mut NcPlane, cell: &Cell) -> IntResult {
|
pub fn ncplane_putc(plane: &mut NcPlane, cell: &Cell) -> IntResult {
|
||||||
unsafe { nc::ncplane_putc_yx(plane, -1, -1, cell) }
|
unsafe { ncplane_putc_yx(plane, -1, -1, cell) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Call ncplane_putegc() at the current cursor location.
|
/// Call ncplane_putegc() at the current cursor location.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putegc(plane: &mut NcPlane, gcluster: i8, sbytes: &mut i32) -> IntResult {
|
pub fn ncplane_putegc(plane: &mut NcPlane, gcluster: i8, sbytes: &mut i32) -> IntResult {
|
||||||
unsafe { nc::ncplane_putegc_yx(plane, -1, -1, &gcluster, sbytes) }
|
unsafe { ncplane_putegc_yx(plane, -1, -1, &gcluster, sbytes) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putstr(plane: &mut NcPlane, gclustarr: &[u8]) -> IntResult {
|
pub fn ncplane_putstr(plane: &mut NcPlane, gclustarr: &[u8]) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_putstr_yx(
|
ncplane_putstr_yx(
|
||||||
plane,
|
plane,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
@ -483,7 +491,7 @@ pub fn ncplane_putstr(plane: &mut NcPlane, gclustarr: &[u8]) -> IntResult {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putnstr(plane: &mut NcPlane, size: u64, gclustarr: &[u8]) -> IntResult {
|
pub fn ncplane_putnstr(plane: &mut NcPlane, size: u64, gclustarr: &[u8]) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_putnstr_yx(
|
ncplane_putnstr_yx(
|
||||||
plane,
|
plane,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
@ -499,7 +507,7 @@ pub fn ncplane_putnstr(plane: &mut NcPlane, size: u64, gclustarr: &[u8]) -> IntR
|
|||||||
pub fn ncplane_resize_simple(plane: &mut NcPlane, ylen: i32, xlen: i32) -> IntResult {
|
pub fn ncplane_resize_simple(plane: &mut NcPlane, ylen: i32, xlen: i32) -> IntResult {
|
||||||
let (mut oldy, mut oldx) = (0, 0);
|
let (mut oldy, mut oldx) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(plane, &mut oldy, &mut oldx);
|
ncplane_dim_yx(plane, &mut oldy, &mut oldx);
|
||||||
}
|
}
|
||||||
let keepleny = {
|
let keepleny = {
|
||||||
if oldy > ylen {
|
if oldy > ylen {
|
||||||
@ -515,21 +523,21 @@ pub fn ncplane_resize_simple(plane: &mut NcPlane, ylen: i32, xlen: i32) -> IntRe
|
|||||||
oldx
|
oldx
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
unsafe { nc::ncplane_resize(plane, 0, 0, keepleny, keeplenx, 0, 0, ylen, xlen) }
|
unsafe { ncplane_resize(plane, 0, 0, keepleny, keeplenx, 0, 0, ylen, xlen) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// On error, return the negative number of cells drawn.
|
/// On error, return the negative number of cells drawn.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_vline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
pub fn ncplane_vline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
||||||
unsafe { nc::ncplane_vline_interp(plane, cell, len, cell.channels, cell.channels) }
|
unsafe { ncplane_vline_interp(plane, cell, len, cell.channels, cell.channels) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_vprintf(plane: &mut NcPlane, format: &str, ap: &mut nc::__va_list_tag) -> IntResult {
|
pub fn ncplane_vprintf(plane: &mut NcPlane, format: &str, ap: &mut __va_list_tag) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_vprintf_yx(
|
ncplane_vprintf_yx(
|
||||||
plane,
|
plane,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
@ -560,8 +568,8 @@ pub fn ncplane_gradient_sized(
|
|||||||
}
|
}
|
||||||
let (mut y, mut x) = (0, 0);
|
let (mut y, mut x) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_cursor_yx(plane, &mut y, &mut x);
|
ncplane_cursor_yx(plane, &mut y, &mut x);
|
||||||
nc::ncplane_gradient(
|
ncplane_gradient(
|
||||||
plane,
|
plane,
|
||||||
CString::new(egc).expect("Bad EGC").as_ptr(),
|
CString::new(egc).expect("Bad EGC").as_ptr(),
|
||||||
stylemask as u32,
|
stylemask as u32,
|
||||||
@ -578,49 +586,49 @@ pub fn ncplane_gradient_sized(
|
|||||||
/// Extract the 32-bit working foreground channel from an ncplane.
|
/// Extract the 32-bit working foreground channel from an ncplane.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fchannel(plane: &NcPlane) -> Channel {
|
pub fn ncplane_fchannel(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_fchannel(unsafe { nc::ncplane_channels(plane) })
|
channels_fchannel(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 32-bit working background channel from an ncplane.
|
/// Extract the 32-bit working background channel from an ncplane.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bchannel(plane: &NcPlane) -> Channel {
|
pub fn ncplane_bchannel(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_bchannel(unsafe { nc::ncplane_channels(plane) })
|
channels_bchannel(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs.
|
/// Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_rgb(plane: &NcPlane) -> Channel {
|
pub fn ncplane_fg_rgb(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_fg_rgb(unsafe { nc::ncplane_channels(plane) })
|
channels_fg_rgb(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of working background RGB from an ncplane, shifted to LSBs.
|
/// Extract 24 bits of working background RGB from an ncplane, shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_rgb(plane: &NcPlane) -> Channel {
|
pub fn ncplane_bg_rgb(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_bg_rgb(unsafe { nc::ncplane_channels(plane) })
|
channels_bg_rgb(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs.
|
/// Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_alpha(plane: &NcPlane) -> AlphaBits {
|
pub fn ncplane_fg_alpha(plane: &NcPlane) -> AlphaBits {
|
||||||
nc::channels_fg_alpha(unsafe { nc::ncplane_channels(plane) })
|
channels_fg_alpha(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of background alpha from 'struct ncplane', shifted to LSBs.
|
/// Extract 2 bits of background alpha from 'struct ncplane', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_alpha(plane: &NcPlane) -> AlphaBits {
|
pub fn ncplane_bg_alpha(plane: &NcPlane) -> AlphaBits {
|
||||||
nc::channels_bg_alpha(unsafe { nc::ncplane_channels(plane) })
|
channels_bg_alpha(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the plane's foreground using the "default foreground color"?
|
/// Is the plane's foreground using the "default foreground color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_default_p(plane: &NcPlane) -> bool {
|
pub fn ncplane_fg_default_p(plane: &NcPlane) -> bool {
|
||||||
nc::channels_fg_default_p(unsafe { nc::ncplane_channels(plane) })
|
channels_fg_default_p(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the plane's background using the "default background color"?
|
/// Is the plane's background using the "default background color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_default_p(plane: &NcPlane) -> bool {
|
pub fn ncplane_bg_default_p(plane: &NcPlane) -> bool {
|
||||||
nc::channels_bg_default_p(unsafe { nc::ncplane_channels(plane) })
|
channels_bg_default_p(unsafe { ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from a plane, split into components.
|
/// Extract 24 bits of foreground RGB from a plane, split into components.
|
||||||
@ -631,7 +639,7 @@ pub fn ncplane_fg_rgb8(
|
|||||||
green: &mut Color,
|
green: &mut Color,
|
||||||
blue: &mut Color,
|
blue: &mut Color,
|
||||||
) -> Channel {
|
) -> Channel {
|
||||||
nc::channels_fg_rgb8(unsafe { nc::ncplane_channels(plane) }, red, green, blue)
|
channels_fg_rgb8(unsafe { ncplane_channels(plane) }, red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of background RGB from a plane, split into components.
|
/// Extract 24 bits of background RGB from a plane, split into components.
|
||||||
@ -642,7 +650,7 @@ pub fn ncplane_bg_rgb8(
|
|||||||
green: &mut Color,
|
green: &mut Color,
|
||||||
blue: &mut Color,
|
blue: &mut Color,
|
||||||
) -> Channel {
|
) -> Channel {
|
||||||
nc::channels_bg_rgb8(unsafe { nc::ncplane_channels(plane) }, red, green, blue)
|
channels_bg_rgb8(unsafe { ncplane_channels(plane) }, red, green, blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -650,7 +658,7 @@ pub fn ncplane_bg_rgb8(
|
|||||||
pub fn ncplane_rounded_box(
|
pub fn ncplane_rounded_box(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ystop: i32,
|
ystop: i32,
|
||||||
xstop: i32,
|
xstop: i32,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
@ -666,7 +674,7 @@ pub fn ncplane_rounded_box(
|
|||||||
let mut vl = cell_trivial_initializer![];
|
let mut vl = cell_trivial_initializer![];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ret = nc::cells_rounded_box(
|
ret = cells_rounded_box(
|
||||||
plane,
|
plane,
|
||||||
stylemask as u32,
|
stylemask as u32,
|
||||||
channels,
|
channels,
|
||||||
@ -678,15 +686,15 @@ pub fn ncplane_rounded_box(
|
|||||||
&mut vl,
|
&mut vl,
|
||||||
);
|
);
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
ret = nc::ncplane_box(plane, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
|
ret = ncplane_box(plane, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
|
||||||
}
|
}
|
||||||
|
|
||||||
nc::cell_release(plane, &mut ul);
|
cell_release(plane, &mut ul);
|
||||||
nc::cell_release(plane, &mut ur);
|
cell_release(plane, &mut ur);
|
||||||
nc::cell_release(plane, &mut ll);
|
cell_release(plane, &mut ll);
|
||||||
nc::cell_release(plane, &mut lr);
|
cell_release(plane, &mut lr);
|
||||||
nc::cell_release(plane, &mut hl);
|
cell_release(plane, &mut hl);
|
||||||
nc::cell_release(plane, &mut vl);
|
cell_release(plane, &mut vl);
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@ -696,14 +704,14 @@ pub fn ncplane_rounded_box(
|
|||||||
pub fn ncplane_rounded_box_sized(
|
pub fn ncplane_rounded_box_sized(
|
||||||
plane: &mut NcPlane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: Channels,
|
||||||
ylen: i32,
|
ylen: i32,
|
||||||
xlen: i32,
|
xlen: i32,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
) -> IntResult {
|
) -> IntResult {
|
||||||
let (mut y, mut x) = (0, 0);
|
let (mut y, mut x) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_cursor_yx(plane, &mut y, &mut x);
|
ncplane_cursor_yx(plane, &mut y, &mut x);
|
||||||
}
|
}
|
||||||
ncplane_rounded_box(
|
ncplane_rounded_box(
|
||||||
plane,
|
plane,
|
||||||
|
@ -1,57 +1,76 @@
|
|||||||
//! The notcurses types are defined and/or explained here
|
//! Idiomatic Rust Type Aliases
|
||||||
//!
|
//!
|
||||||
//! Existing types are wrapped to make them follow the Rust API Guidelines
|
//! These types wrap the ones used in the C library, including structs,
|
||||||
//! and to enforce type check whenever possible
|
//! constants, and primitives when used as parameters or return values.
|
||||||
|
//!
|
||||||
|
//! This is in order to enforce type checking when possible and also to follow
|
||||||
|
//! the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/naming.html)
|
||||||
//!
|
//!
|
||||||
//! See: [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/naming.html)
|
|
||||||
|
|
||||||
use crate as nc;
|
// Rgb
|
||||||
|
//
|
||||||
/// RGB: 24 bits broken into 3x 8bpp channels.
|
/// 24 bits broken into 3x 8bpp channels.
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// -------- RRRRRRRR GGGGGGGG BBBBBBBB
|
/// -------- RRRRRRRR GGGGGGGG BBBBBBBB
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// type in C: no data type
|
/// `type in C: no data type`
|
||||||
///
|
///
|
||||||
pub type Rgb = u32;
|
pub type Rgb = u32;
|
||||||
|
|
||||||
|
// Color
|
||||||
|
//
|
||||||
/// 8 bpp channel
|
/// 8 bpp channel
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// CCCCCCCC (1 Byte)
|
/// CCCCCCCC (1 Byte)
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// Used both for R/G/B color and 8 bit alpha
|
/// Used both for R/G/B color and 8 bit alpha
|
||||||
///
|
///
|
||||||
/// type in C: no data type
|
/// `type in C: no data type`
|
||||||
///
|
///
|
||||||
pub type Color = u8;
|
pub type Color = u8;
|
||||||
|
|
||||||
/// Channel: 32 bits of context-dependent info
|
// Channel
|
||||||
|
//
|
||||||
|
/// 32 bits of context-dependent info
|
||||||
/// containing RGB + 2 bits of alpha + crap
|
/// containing RGB + 2 bits of alpha + crap
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB
|
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// It is:
|
/// It is:
|
||||||
/// - an RGB value
|
/// - an RGB value
|
||||||
/// - plus 2 bits of alpha
|
/// - plus 2 bits of alpha
|
||||||
/// - plus context-dependent info
|
/// - plus context-dependent info
|
||||||
///
|
///
|
||||||
/// The context details are documented in ChannelPair,
|
/// The context details are documented in [`Channels`](type.Channels.html)
|
||||||
///
|
///
|
||||||
/// type in C: channel (uint32_t)
|
/// `type in C: channel (uint32_t)`
|
||||||
///
|
///
|
||||||
pub type Channel = u32;
|
pub type Channel = u32;
|
||||||
|
|
||||||
|
// AlphaBits
|
||||||
|
//
|
||||||
/// 2 bits of alpha (surrounded by context dependent bits).
|
/// 2 bits of alpha (surrounded by context dependent bits).
|
||||||
/// It is part of a Channel.
|
/// It is part of a Channel.
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// ~~AA~~~~ -------- -------- --------
|
/// ~~AA~~~~ -------- -------- --------
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// type in C: no data type
|
/// `type in C: no data type`
|
||||||
///
|
///
|
||||||
pub type AlphaBits = u32;
|
pub type AlphaBits = u32;
|
||||||
|
|
||||||
/// Channels: 64 bits containing a foreground and background channel
|
// Channels
|
||||||
|
//
|
||||||
|
/// 64 bits containing a foreground and background channel
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// ~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB|~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
|
/// ~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB|~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
|
||||||
/// ↑↑↑↑↑↑↑↑↑↑↑↑ foreground ↑↑↑↑↑↑↑↑↑↑↑|↑↑↑↑↑↑↑↑↑↑↑↑ background ↑↑↑↑↑↑↑↑↑↑↑
|
/// ↑↑↑↑↑↑↑↑↑↑↑↑ foreground ↑↑↑↑↑↑↑↑↑↑↑|↑↑↑↑↑↑↑↑↑↑↑↑ background ↑↑↑↑↑↑↑↑↑↑↑
|
||||||
///
|
///
|
||||||
@ -97,7 +116,7 @@ pub type AlphaBits = u32;
|
|||||||
///
|
///
|
||||||
/// background in 3x8 RGB (rrggbb):
|
/// background in 3x8 RGB (rrggbb):
|
||||||
/// 0········ ········ ········ ········ ········11111111 11111111 11111111 = ········ ··FFFFFF
|
/// 0········ ········ ········ ········ ········11111111 11111111 11111111 = ········ ··FFFFFF
|
||||||
///
|
/// ```
|
||||||
///
|
///
|
||||||
/// At render time, these 24-bit values are quantized down to terminal
|
/// At render time, these 24-bit values are quantized down to terminal
|
||||||
/// capabilities, if necessary. There's a clear path to 10-bit support should
|
/// capabilities, if necessary. There's a clear path to 10-bit support should
|
||||||
@ -105,13 +124,16 @@ pub type AlphaBits = u32;
|
|||||||
/// best explained by color(3NCURSES). ours is the same concept. until the
|
/// best explained by color(3NCURSES). ours is the same concept. until the
|
||||||
/// "not default color" bit is set, any color you load will be ignored.
|
/// "not default color" bit is set, any color you load will be ignored.
|
||||||
///
|
///
|
||||||
/// type in C: channels (uint64_t)
|
/// `type in C: channels (uint64_t)`
|
||||||
///
|
///
|
||||||
pub type ChannelPair = u64;
|
pub type Channels = u64;
|
||||||
|
|
||||||
/// Pixel (RGBA): 32 bits broken into RGB + 8-bit alpha
|
// Pixel (RGBA)
|
||||||
|
/// 32 bits broken into RGB + 8-bit alpha
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// AAAAAAAA GGGGGGGG BBBBBBBB RRRRRRRR
|
/// AAAAAAAA GGGGGGGG BBBBBBBB RRRRRRRR
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// ncpixel has 8 bits of alpha, more or less linear, contributing
|
/// ncpixel has 8 bits of alpha, more or less linear, contributing
|
||||||
/// directly to the usual alpha blending equation
|
/// directly to the usual alpha blending equation
|
||||||
@ -119,40 +141,86 @@ pub type ChannelPair = u64;
|
|||||||
/// we map the 8 bits of alpha to 2 bits of alpha via a level function:
|
/// we map the 8 bits of alpha to 2 bits of alpha via a level function:
|
||||||
/// https://nick-black.com/dankwiki/index.php?title=Notcurses#Transparency.2FContrasting
|
/// https://nick-black.com/dankwiki/index.php?title=Notcurses#Transparency.2FContrasting
|
||||||
///
|
///
|
||||||
/// type in C: ncpixel (uint32_t)
|
/// `type in C: ncpixel (uint32_t)`
|
||||||
///
|
///
|
||||||
// NOTE: the order of the colors is different than channel. Why.
|
// NOTE: the order of the colors is different than channel. Why.
|
||||||
pub type Pixel = u32;
|
pub type Pixel = u32;
|
||||||
|
|
||||||
// Cell: 128 bits tying together a:
|
// Cell
|
||||||
//
|
/// A coordinate on an [`NcPlane`](type.NcPlane.html)
|
||||||
// 1. GCluster, 32b, either or:
|
///
|
||||||
// UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU
|
/// ```txt
|
||||||
// 00000001 IIIIIIII IIIIIIII IIIIIIII
|
/// Cell: 128 bits tying together a:
|
||||||
//
|
///
|
||||||
// 2. GCluster backstop, 8b, (zero)
|
/// 1. GCluster, 32b, either or:
|
||||||
// 00000000
|
/// UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU
|
||||||
//
|
/// 00000001 IIIIIIII IIIIIIII IIIIIIII
|
||||||
// 3. reserved, 8b (ought to be zero)
|
///
|
||||||
// ~~~~~~~~
|
/// 2. GCluster backstop, 8b, (zero)
|
||||||
//
|
/// 00000000
|
||||||
// 4. Stylemask, 16b
|
///
|
||||||
// 11111111 11111111
|
/// 3. reserved, 8b (ought to be zero)
|
||||||
//
|
/// ~~~~~~~~
|
||||||
// 5. Channels (64b)
|
///
|
||||||
// ~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB|~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
|
/// 4. Stylemask, 16b
|
||||||
//
|
/// 11111111 11111111
|
||||||
// type in C: cell (struct)
|
///
|
||||||
pub type Cell = nc::cell;
|
/// 5. Channels (64b)
|
||||||
|
/// ~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB|~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// A Cell corresponds to a single character cell on some plane, which can be occupied by a single grapheme cluster (some root spacing glyph, along with possible combining characters, which might span multiple columns). At any cell, we can have a theoretically arbitrarily long UTF-8 string, a foreground color, a background color, and an attribute set. Valid grapheme cluster contents include:
|
||||||
|
///
|
||||||
|
/// - A NUL terminator,
|
||||||
|
/// - A single control character, followed by a NUL terminator,
|
||||||
|
/// - At most one spacing character, followed by zero or more nonspacing
|
||||||
|
/// characters, followed by a NUL terminator.
|
||||||
|
///
|
||||||
|
/// Multi-column characters can only have a single style/color throughout.
|
||||||
|
/// wcwidth() is not reliable. It's just quoting whether or not the Egc
|
||||||
|
/// contains a "Wide Asian" double-width character.
|
||||||
|
/// This is set for some things, like most emoji, and not set for
|
||||||
|
/// other things, like cuneiform.
|
||||||
|
///
|
||||||
|
/// Each cell occupies 16 static bytes (128 bits). The surface is thus ~1.6MB
|
||||||
|
/// for a (pretty large) 500x200 terminal. At 80x43, it's less than 64KB.
|
||||||
|
/// Dynamic requirements (the egcpool) can add up to 16MB to an ncplane, but
|
||||||
|
/// such large pools are unlikely in common use.
|
||||||
|
///
|
||||||
|
/// We implement some small alpha compositing. Foreground and background both
|
||||||
|
/// have two bits of inverted alpha. The actual grapheme written to a cell is
|
||||||
|
/// the topmost non-zero grapheme. If its alpha is 00, its foreground color is
|
||||||
|
/// used unchanged. If its alpha is 10, its foreground color is derived entirely
|
||||||
|
/// from cells underneath it. Otherwise, the result will be a composite.
|
||||||
|
/// Likewise for the background. If the bottom of a coordinate's zbuffer is
|
||||||
|
/// reached with a cumulative alpha of zero, the default is used. In this way,
|
||||||
|
/// a terminal configured with transparent background can be supported through
|
||||||
|
/// multiple occluding ncplanes. A foreground alpha of 11 requests high-contrast
|
||||||
|
/// text (relative to the computed background). A background alpha of 11 is
|
||||||
|
/// currently forbidden.
|
||||||
|
///
|
||||||
|
/// Default color takes precedence over palette or RGB, and cannot be used with
|
||||||
|
/// transparency. Indexed palette takes precedence over RGB. It cannot
|
||||||
|
/// meaningfully set transparency, but it can be mixed into a cascading color.
|
||||||
|
/// RGB is used if neither default terminal colors nor palette indexing are in
|
||||||
|
/// play, and fully supports all transparency options.
|
||||||
|
///
|
||||||
|
/// `type in C: cell (struct)`
|
||||||
|
///
|
||||||
|
pub type Cell = crate::cell;
|
||||||
|
|
||||||
/// EGC (Extended Grapheme Cluster)
|
// Egc
|
||||||
|
//
|
||||||
|
/// 32-bit Char, Extended Grapheme Cluster
|
||||||
///
|
///
|
||||||
/// This 32 bit char, together with the associated plane's associated egcpool,
|
/// This 32 bit char, together with the associated plane's associated egcpool,
|
||||||
/// completely define this cell's EGC. Unless the EGC requires more than four
|
/// completely define this cell's `Egc`. Unless the `Egc` requires more than
|
||||||
/// bytes to encode as UTF-8, it will be inlined here:
|
/// four bytes to encode as UTF-8, it will be inlined here:
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU
|
/// UUUUUUUU UUUUUUUU UUUUUUUU UUUUUUUU
|
||||||
/// extended grapheme cluster <= 4bytes
|
/// extended grapheme cluster <= 4bytes
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// If more than four bytes are required, it will be spilled into the egcpool.
|
/// If more than four bytes are required, it will be spilled into the egcpool.
|
||||||
/// In either case, there's a NUL-terminated string available without copying,
|
/// In either case, there's a NUL-terminated string available without copying,
|
||||||
@ -160,64 +228,90 @@ pub type Cell = nc::cell;
|
|||||||
/// byte of this struct (the GClusterBackStop field, see below) is
|
/// byte of this struct (the GClusterBackStop field, see below) is
|
||||||
/// guaranteed to be zero, as are any unused bytes in gcluster.
|
/// guaranteed to be zero, as are any unused bytes in gcluster.
|
||||||
///
|
///
|
||||||
/// A spilled EGC is indicated by the value 0x01iiiiii. This cannot alias a
|
/// A spilled Egc is indicated by the value `0x01iiiiii`. This cannot alias a
|
||||||
/// true supra-ASCII EGC, because UTF-8 only encodes bytes <= 0x80 when they
|
/// true supra-ASCII Egc, because UTF-8 only encodes bytes <= 0x80 when they
|
||||||
/// are single-byte ASCII-derived values. The iiiiii is interpreted as a 24-bit
|
/// are single-byte ASCII-derived values. The `iiiiii` is interpreted as a 24-bit
|
||||||
/// index into the egcpool (which may thus be up to 16MB):
|
/// index into the egcpool (which may thus be up to 16MB):
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// 00000001 iiiiiiii iiiiiiii iiiiiiii
|
/// 00000001 iiiiiiii iiiiiiii iiiiiiii
|
||||||
/// sign 24bit index to egpool
|
/// sign 24bit index to egcpool
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// The cost of this scheme is that the character 0x01 (SOH) cannot be encoded
|
/// The cost of this scheme is that the character 0x01 (SOH) cannot be encoded
|
||||||
/// in a cell, and therefore it must not be allowed through the API.
|
/// in a cell, and therefore it must not be allowed through the API.
|
||||||
///
|
///
|
||||||
/// -----
|
/// -----
|
||||||
/// NOTE that even if the EGC is <= 4 bytes and inlined, is still interpreted a
|
/// NOTE that even if the `Egc` is <= 4 bytes and inlined, is still interpreted
|
||||||
/// a NUL-terminated char * (technically, &cell->gcluster is treated as a char*).
|
/// a NUL-terminated char * (technically, &cell->gcluster is treated as a char*).
|
||||||
/// If it is more than 4 bytes, cell->gcluster has a first byte of 0x01,
|
/// If it is more than 4 bytes, cell->gcluster has a first byte of 0x01,
|
||||||
/// and the remaining 24 bits are an index into the plane's egcpool,
|
/// and the remaining 24 bits are an index into the plane's egcpool,
|
||||||
/// which is carved into NUL-terminated chunks of arbitrary length.
|
/// which is carved into NUL-terminated chunks of arbitrary length.
|
||||||
///
|
///
|
||||||
/// type in C: gcluster (uint32_t)
|
/// `type in C: gcluster (uint32_t)`
|
||||||
///
|
///
|
||||||
// WIP towards a safe abstraction for Cell & functions receiving
|
// WIP towards a safe abstraction for Cell & functions receiving
|
||||||
pub type EGC = char;
|
pub type Egc = char;
|
||||||
// pub type EGCPool<'a> = &'a[u8];
|
// pub type EgcPool<'a> = &'a[u8];
|
||||||
|
|
||||||
pub type CellGcluster = u32; // the type cell.gcluster expects the EGB to be
|
pub type CellGcluster = u32; // the type cell.gcluster expects the EGB to be
|
||||||
|
|
||||||
/// EGC BackStop
|
/// Egc BackStop
|
||||||
///
|
///
|
||||||
/// type in C: cell.gcluster_backstop
|
/// `type in C: cell.gcluster_backstop`
|
||||||
pub type EGCBackstop = u8;
|
///
|
||||||
|
pub type EgcBackstop = u8;
|
||||||
|
|
||||||
/// StyleMask
|
// StyleMask
|
||||||
///
|
///
|
||||||
/// 16 bits NCSTYLE_* of boolean styling attributes:
|
/// 16 bits `NCSTYLE_*` of boolean styling attributes:
|
||||||
///
|
///
|
||||||
|
/// ```txt
|
||||||
/// 11111111 11111111
|
/// 11111111 11111111
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// type in C: stylemask (uint16_t)
|
/// `type in C: stylemask (uint16_t)`
|
||||||
///
|
///
|
||||||
pub type StyleMask = u16;
|
pub type StyleMask = u16;
|
||||||
|
|
||||||
/// Type alias of ncplane
|
// NcPlane
|
||||||
// Plane: fundamental drawing surface. unites a:
|
/// Fundamental drawing surface.
|
||||||
//
|
///
|
||||||
// - CellMatrix
|
/// Unites a:
|
||||||
// - EGCPool
|
///
|
||||||
//
|
/// - CellMatrix
|
||||||
// type in C: ncplane (struct)
|
/// - EgcPool
|
||||||
pub type NcPlane = nc::ncplane;
|
///
|
||||||
|
/// `type in C: ncplane (struct)`
|
||||||
|
pub type NcPlane = crate::ncplane;
|
||||||
|
|
||||||
// EGCPool: contiguous region chopped up into NUL-terminated UTF8 EGCs, one per plane
|
/// I/O wrapper to dump file descriptor to [`NcPlane`](type.NcPlane.html)
|
||||||
|
pub type NcFdPlane = crate::ncfdplane;
|
||||||
|
|
||||||
|
/// Options struct for [`NcFdPlane`](type.NcFdPlane.html)
|
||||||
|
///
|
||||||
|
/// `type in C: ncplane_options (struct)`
|
||||||
|
pub type NcFdPlaneOptions = crate::ncfdplane_options;
|
||||||
|
|
||||||
|
// EGCPool:
|
||||||
//
|
//
|
||||||
// type in C: egcpool (struct)
|
// Contiguous region chopped up into NUL-terminated UTF8 EGCs, one per plane
|
||||||
|
//
|
||||||
|
// `type in C: egcpool (struct)`
|
||||||
|
// TODO
|
||||||
|
|
||||||
// CellMatrix: rectilinear array of Cells
|
// CellMatrix: rectilinear array of Cells
|
||||||
// one -- fb per plane, and transients show up ?
|
// one -- fb per plane, and transients show up ?
|
||||||
|
|
||||||
/// Typle alias of palette256
|
/// Palette structure consisting of an array of 256 [`Channel`](type.Channel.html)s
|
||||||
pub type Palette = nc::palette256;
|
///
|
||||||
|
/// Some terminals only support 256 colors, but allow the full
|
||||||
|
/// palette to be specified with arbitrary RGB colors. In all cases, it's more
|
||||||
|
/// performant to use indexed colors, since it's much less data to write to the
|
||||||
|
/// terminal. If you can limit yourself to 256 colors, that's probably best.
|
||||||
|
///
|
||||||
|
/// `type in C: ncpalette256 (struct)`
|
||||||
|
pub type Palette = crate::palette256;
|
||||||
|
|
||||||
/// 8-bit value used for indexing into a palette
|
/// 8-bit value used for indexing into a palette
|
||||||
///
|
///
|
||||||
@ -227,81 +321,159 @@ pub type PaletteIndex = u8;
|
|||||||
///
|
///
|
||||||
pub type IntResult = i32;
|
pub type IntResult = i32;
|
||||||
|
|
||||||
/// Type alias of ncalign_e
|
/// the [`Egc`](type.Egc.html)s which form the various levels
|
||||||
pub type NcAlign = nc::ncalign_e;
|
/// of a given geometry.
|
||||||
pub const NCALIGN_LEFT: NcAlign = nc::ncalign_e_NCALIGN_LEFT;
|
///
|
||||||
pub const NCALIGN_RIGHT: NcAlign = nc::ncalign_e_NCALIGN_RIGHT;
|
/// If the geometry is wide, things are arranged with the rightmost side
|
||||||
pub const NCALIGN_CENTER: NcAlign = nc::ncalign_e_NCALIGN_CENTER;
|
/// increasing most quickly, i.e. it can be indexed as height arrays of
|
||||||
|
/// 1 + height glyphs.
|
||||||
|
/// i.e. The first five braille EGCs are all 0 on the left,
|
||||||
|
/// [0..4] on the right.
|
||||||
|
///
|
||||||
|
/// `type in C: blitset (struct)`
|
||||||
|
pub type BlitSet = crate::blitset;
|
||||||
|
|
||||||
/// Type alias of ncblitter_e
|
/// Alignment within a plane or terminal.
|
||||||
pub type NcBlitter = nc::ncblitter_e;
|
/// Left/right-justified, or centered.
|
||||||
|
pub type NcAlign = crate::ncalign_e;
|
||||||
|
/// Align an NcPlane or NcTerm
|
||||||
|
pub const NCALIGN_LEFT: NcAlign = crate::ncalign_e_NCALIGN_LEFT;
|
||||||
|
///
|
||||||
|
pub const NCALIGN_RIGHT: NcAlign = crate::ncalign_e_NCALIGN_RIGHT;
|
||||||
|
///
|
||||||
|
pub const NCALIGN_CENTER: NcAlign = crate::ncalign_e_NCALIGN_CENTER;
|
||||||
|
///
|
||||||
|
pub const NCALIGN_UNALIGNED: NcAlign = crate::ncalign_e_NCALIGN_UNALIGNED;
|
||||||
|
|
||||||
|
/// Blitter Mode (`NCBLIT_*`)
|
||||||
|
///
|
||||||
|
/// We never blit full blocks, but instead spaces (more efficient) with the
|
||||||
|
/// background set to the desired foreground.
|
||||||
|
pub type NcBlitter = crate::ncblitter_e;
|
||||||
/// space, compatible with ASCII
|
/// space, compatible with ASCII
|
||||||
pub const NCBLIT_1x1: NcBlitter = nc::ncblitter_e_NCBLIT_1x1;
|
pub const NCBLIT_1x1: NcBlitter = crate::ncblitter_e_NCBLIT_1x1;
|
||||||
|
|
||||||
/// halves + 1x1 (space)
|
/// halves + 1x1 (space)
|
||||||
/// ▄▀
|
/// ▄▀
|
||||||
pub const NCBLIT_2x1: NcBlitter = nc::ncblitter_e_NCBLIT_2x1;
|
pub const NCBLIT_2x1: NcBlitter = crate::ncblitter_e_NCBLIT_2x1;
|
||||||
|
|
||||||
/// quadrants + 2x1
|
/// quadrants + 2x1
|
||||||
/// ▗▐ ▖▀▟▌▙
|
/// ▗▐ ▖▀▟▌▙
|
||||||
pub const NCBLIT_2x2: NcBlitter = nc::ncblitter_e_NCBLIT_2x2;
|
pub const NCBLIT_2x2: NcBlitter = crate::ncblitter_e_NCBLIT_2x2;
|
||||||
|
|
||||||
/// sextants (NOT 2x2)
|
/// sextants (NOT 2x2)
|
||||||
/// 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻
|
/// 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻
|
||||||
pub const NCBLIT_3x2: NcBlitter = nc::ncblitter_e_NCBLIT_3x2;
|
pub const NCBLIT_3x2: NcBlitter = crate::ncblitter_e_NCBLIT_3x2;
|
||||||
|
|
||||||
/// four vertical levels
|
/// four vertical levels
|
||||||
/// █▆▄▂
|
/// █▆▄▂
|
||||||
pub const NCBLIT_4x1: NcBlitter = nc::ncblitter_e_NCBLIT_4x1;
|
pub const NCBLIT_4x1: NcBlitter = crate::ncblitter_e_NCBLIT_4x1;
|
||||||
|
|
||||||
/// eight vertical levels
|
/// eight vertical levels
|
||||||
/// █▇▆▅▄▃▂▁
|
/// █▇▆▅▄▃▂▁
|
||||||
pub const NCBLIT_8x1: NcBlitter = nc::ncblitter_e_NCBLIT_8x1;
|
pub const NCBLIT_8x1: NcBlitter = crate::ncblitter_e_NCBLIT_8x1;
|
||||||
|
|
||||||
/// 4 rows, 2 cols (braille)
|
/// 4 rows, 2 cols (braille)
|
||||||
/// ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
|
/// ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
|
||||||
pub const NCBLIT_BRAILLE: NcBlitter = nc::ncblitter_e_NCBLIT_BRAILLE;
|
pub const NCBLIT_BRAILLE: NcBlitter = crate::ncblitter_e_NCBLIT_BRAILLE;
|
||||||
|
|
||||||
/// the blitter is automatically chosen
|
/// the blitter is automatically chosen
|
||||||
pub const NCBLIT_DEFAULT: NcBlitter = nc::ncblitter_e_NCBLIT_DEFAULT;
|
pub const NCBLIT_DEFAULT: NcBlitter = crate::ncblitter_e_NCBLIT_DEFAULT;
|
||||||
|
|
||||||
/// 6 rows, 1 col (RGB), spotty support among terminals
|
/// 6 rows, 1 col (RGB), spotty support among terminals
|
||||||
pub const NCBLIT_SIXEL: NcBlitter = nc::ncblitter_e_NCBLIT_SIXEL;
|
pub const NCBLIT_SIXEL: NcBlitter = crate::ncblitter_e_NCBLIT_SIXEL;
|
||||||
|
|
||||||
/// Type alias of ncscale_e
|
/// Log level for [`NotcursesOptions`](type.NotcursesOptions.html)
|
||||||
pub type NcScale = nc::ncscale_e;
|
pub type NcLogLevel = crate::ncloglevel_e;
|
||||||
|
|
||||||
/// Maintain original size
|
|
||||||
pub const NCSCALE_NONE: NcScale = nc::ncscale_e_NCSCALE_NONE;
|
|
||||||
|
|
||||||
/// Maintain aspect ratio
|
|
||||||
pub const NCSCALE_SCALE: NcScale = nc::ncscale_e_NCSCALE_SCALE;
|
|
||||||
|
|
||||||
/// Throw away aspect ratio
|
|
||||||
pub const NCSCALE_STRETCH: NcScale = nc::ncscale_e_NCSCALE_STRETCH;
|
|
||||||
|
|
||||||
/// Type alias of ncdirect (direct mode)
|
|
||||||
pub type NcDirect = nc::ncdirect;
|
|
||||||
|
|
||||||
/// Type alias of
|
|
||||||
pub type NcDirectFlags = u64;
|
|
||||||
|
|
||||||
/// Avoids placing the terminal into cbreak mode (disabling echo and line buffering)
|
|
||||||
pub const NCDIRECT_INHIBIT_CBREAK: NcDirectFlags =
|
|
||||||
nc::NCDIRECT_OPTION_INHIBIT_CBREAK as NcDirectFlags;
|
|
||||||
|
|
||||||
/// Avoids calling setlocale(LC_ALL, NULL).
|
|
||||||
///
|
///
|
||||||
/// If the result is either "C" or "POSIX", it will print a diagnostic to stderr,
|
pub const NCLOGLEVEL_DEBUG: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_DEBUG;
|
||||||
/// and then call setlocale(LC_ALL, ""). This will attempt to set the locale based
|
pub const NCLOGLEVEL_ERROR: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_ERROR;
|
||||||
/// off the LANG environment variable. Your program should call setlocale(3) itself,
|
pub const NCLOGLEVEL_FATAL: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_FATAL;
|
||||||
/// usually as one of the first lines.
|
pub const NCLOGLEVEL_INFO: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_INFO;
|
||||||
pub const NCDIRECT_INHIBIT_SETLOCALE: NcDirectFlags =
|
pub const NCLOGLEVEL_PANIC: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_PANIC;
|
||||||
nc::NCDIRECT_OPTION_INHIBIT_SETLOCALE as NcDirectFlags;
|
pub const NCLOGLEVEL_SILENT: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_SILENT;
|
||||||
|
pub const NCLOGLEVEL_TRACE: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_TRACE;
|
||||||
|
pub const NCLOGLEVEL_VERBOSE: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_VERBOSE;
|
||||||
|
pub const NCLOGLEVEL_WARNING: NcLogLevel = crate::ncloglevel_e_NCLOGLEVEL_WARNING;
|
||||||
|
|
||||||
/// Type alias of notcurses (full mode)
|
/// How to scale an [`NcVisual`](type.NcVisual.html) during rendering
|
||||||
pub type Notcurses = nc::bindings::notcurses;
|
///
|
||||||
|
/// - NCSCALE_NONE will apply no scaling.
|
||||||
|
/// - NCSCALE_SCALE scales a visual to the plane's size,
|
||||||
|
/// maintaining aspect ratio.
|
||||||
|
/// - NCSCALE_STRETCH stretches and scales the image in an
|
||||||
|
/// attempt to fill the entirety of the plane.
|
||||||
|
pub type NcScale = crate::ncscale_e;
|
||||||
|
/// Maintain original size
|
||||||
|
pub const NCSCALE_NONE: NcScale = crate::ncscale_e_NCSCALE_NONE;
|
||||||
|
/// Maintain aspect ratio
|
||||||
|
pub const NCSCALE_SCALE: NcScale = crate::ncscale_e_NCSCALE_SCALE;
|
||||||
|
/// Throw away aspect ratio
|
||||||
|
pub const NCSCALE_STRETCH: NcScale = crate::ncscale_e_NCSCALE_STRETCH;
|
||||||
|
|
||||||
/// Type alias of ncinput
|
/// Reads and decodes input events
|
||||||
pub type NcInput = nc::ncinput;
|
///
|
||||||
|
/// Reads from stdin and decodes the input to stdout,
|
||||||
|
/// including synthesized events and mouse events.
|
||||||
|
///
|
||||||
|
/// To exit, generate EOF (usually Ctrl+‘d’).
|
||||||
|
pub type NcInput = crate::ncinput;
|
||||||
|
|
||||||
|
/// A visual bit of multimedia opened with LibAV|OIIO
|
||||||
|
pub type NcVisual = crate::ncvisual;
|
||||||
|
/// Options struct for [`NcVisual`](type.NcVisual.html)
|
||||||
|
pub type NcVisualOptions = crate::ncvisual_options;
|
||||||
|
|
||||||
|
// Terminal --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// Minimal notcurses instances for styling text
|
||||||
|
pub type NcDirect = crate::ncdirect;
|
||||||
|
|
||||||
|
/// Flags for NcDirect
|
||||||
|
pub type NcDirectFlags = u64;
|
||||||
|
/// Flag that avoids placing the terminal into cbreak mode
|
||||||
|
/// (disabling echo and line buffering)
|
||||||
|
pub const NCDIRECT_OPTION_INHIBIT_CBREAK: NcDirectFlags =
|
||||||
|
crate::bindings::NCDIRECT_OPTION_INHIBIT_CBREAK as NcDirectFlags;
|
||||||
|
/// Flag that avoids calling setlocale(LC_ALL, NULL)
|
||||||
|
///
|
||||||
|
/// If the result is either "C" or "POSIX", it will print a
|
||||||
|
/// diagnostic to stderr, and then call setlocale(LC_ALL, "").
|
||||||
|
/// This will attempt to set the locale based off the LANG
|
||||||
|
/// environment variable. Your program should call setlocale(3)
|
||||||
|
/// itself, usually as one of the first lines.
|
||||||
|
pub const NCDIRECT_OPTION_INHIBIT_SETLOCALE: NcDirectFlags =
|
||||||
|
crate::bindings::NCDIRECT_OPTION_INHIBIT_SETLOCALE as NcDirectFlags;
|
||||||
|
|
||||||
|
/// TUI library for modern terminal emulators
|
||||||
|
///
|
||||||
|
/// Notcurses builds atop the terminfo abstraction layer to
|
||||||
|
/// provide reasonably portable vivid character displays.
|
||||||
|
pub type Notcurses = crate::bindings::notcurses;
|
||||||
|
/// Options struct for [`Notcurses`](type.Notcurses.html)
|
||||||
|
pub type NotcursesOptions = crate::bindings::notcurses_options;
|
||||||
|
|
||||||
|
/// Context for a palette fade operation
|
||||||
|
pub type NcFadeCtx = crate::ncfadectx;
|
||||||
|
|
||||||
|
|
||||||
|
// Widgets
|
||||||
|
|
||||||
|
pub type NcMenu = crate::ncmenu;
|
||||||
|
pub type NcMenuItem = crate::ncmenu_item;
|
||||||
|
pub type NcMenuOptions = crate::ncmenu_options;
|
||||||
|
pub type NcMenuSection = crate::ncmenu_section;
|
||||||
|
|
||||||
|
pub type NcReader = crate::ncreader;
|
||||||
|
pub type NcReaderOptions = crate::ncreader_options;
|
||||||
|
|
||||||
|
pub type NcReel = crate::ncreel;
|
||||||
|
pub type NcReelOptions = crate::ncreel_options;
|
||||||
|
|
||||||
|
pub type NcPlotF64 = crate::ncdplot;
|
||||||
|
pub type NcPlotU64 = crate::ncuplot;
|
||||||
|
pub type NcPlotOptions = crate::ncplot_options;
|
||||||
|
|
||||||
|
pub type NcSelector = crate::ncselector;
|
||||||
|
pub type NcSelectorItem = crate::ncselector_item;
|
||||||
|
pub type NcSelectorOptions = crate::ncselector_options;
|
||||||
|
|
||||||
|
pub type NcStats = crate::ncstats;
|
||||||
|
|
||||||
|
pub type NcTablet = crate::nctablet;
|
||||||
|
|
||||||
|
pub type NcMultiSelector = crate::ncmultiselector;
|
||||||
|
pub type NcMultiSelectorItem = crate::ncmselector_item;
|
||||||
|
pub type NcMultiSelectorOptions = crate::ncmultiselector_options;
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
// ncvisual_default_blitter
|
// ncvisual_default_blitter
|
||||||
|
|
||||||
use crate as nc;
|
use crate::types::{NCBLIT_1x1, NCBLIT_2x1, NCBLIT_2x2, NcBlitter, NcScale, NCSCALE_STRETCH};
|
||||||
use nc::types::{NCBLIT_1x1, NCBLIT_2x1, NCBLIT_2x2, NcBlitter, NcScale, NCSCALE_STRETCH};
|
|
||||||
|
|
||||||
/// Returns the best default blitter available
|
/// Returns the best default blitter available
|
||||||
///
|
///
|
||||||
|
@ -23,7 +23,7 @@ fn get_notcurses_version() {
|
|||||||
fn create_notcurses_context() {
|
fn create_notcurses_context() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr());
|
let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr());
|
||||||
let opts = nc::notcurses_options {
|
let opts = nc::NotcursesOptions {
|
||||||
loglevel: 0,
|
loglevel: 0,
|
||||||
termtype: null(),
|
termtype: null(),
|
||||||
renderfp: null_mut(),
|
renderfp: null_mut(),
|
||||||
|
Loading…
Reference in New Issue
Block a user