diff --git a/USAGE.md b/USAGE.md index 2e645d8a5..e31a34b97 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1850,13 +1850,6 @@ typedef struct nccell { uint64_t channels; // + 8B == 16B } nccell; -#define CELL_BGDEFAULT_MASK 0x0000000040000000ull -#define CELL_FGDEFAULT_MASK (CELL_BGDEFAULT_MASK << 32u) -#define CELL_BG_RGB_MASK 0x0000000000ffffffull -#define CELL_FG_RGB_MASK (CELL_BG_MASK << 32u) -#define CELL_BG_PALETTE 0x0000000008000000ull -#define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u) -#define NCCHANNEL_ALPHA_MASK 0x30000000ull #define NCALPHA_HIGHCONTRAST 0x30000000ull #define NCALPHA_TRANSPARENT 0x20000000ull #define NCALPHA_BLEND 0x10000000ull @@ -2881,8 +2874,8 @@ channel_set_rgb8(unsigned* channel, int r, int g, int b){ return -1; } unsigned c = (r << 16u) | (g << 8u) | b; - c |= CELL_BGDEFAULT_MASK; - const uint64_t mask = CELL_BGDEFAULT_MASK | CELL_BG_MASK; + c |= NC_BGDEFAULT_MASK; + const uint64_t mask = NC_BGDEFAULT_MASK | NC_BG_MASK; *channel = (*channel & ~mask) | c; return 0; } @@ -2893,25 +2886,25 @@ channel_set(unsigned* channel, unsigned rgb){ if(rgb > 0xffffffu){ return -1; } - *channel = (*channel & ~CELL_BG_MASK) | CELL_BGDEFAULT_MASK | rgb; + *channel = (*channel & ~NC_BG_MASK) | NC_BGDEFAULT_MASK | rgb; return 0; } // Extract the 2-bit alpha component from a 32-bit channel. static inline unsigned channel_alpha(unsigned channel){ - return channel & CELL_BG_ALPHA_MASK; + return channel & NC_BG_ALPHA_MASK; } // Set the 2-bit alpha component of the 32-bit channel. static inline int channel_set_alpha(unsigned* channel, unsigned alpha){ - if(alpha & ~CELL_BG_ALPHA_MASK){ + if(alpha & ~NC_BG_ALPHA_MASK){ return -1; } *channel = alpha | (*channel & ~CHANNEL_ALPHA_MASK); if(alpha != NCALPHA_OPAQUE){ - *channel |= CELL_BGDEFAULT_MASK; + *channel |= NC_BGDEFAULT_MASK; } return 0; } @@ -2919,13 +2912,13 @@ channel_set_alpha(unsigned* channel, unsigned alpha){ // Is this channel using the "default color" rather than its RGB? static inline bool channel_default_p(unsigned channel){ - return !(channel & CELL_BGDEFAULT_MASK); + return !(channel & NC_BGDEFAULT_MASK); } // Mark the channel as using its default color. static inline unsigned channel_set_default(unsigned* channel){ - return *channel &= ~CELL_BGDEFAULT_MASK; + return *channel &= ~NC_BGDEFAULT_MASK; } // Extract the 32-bit background channel from a channel pair. @@ -2946,8 +2939,8 @@ static inline uint64_t ncchannels_reverse(uint64_t channels){ const uint64_t raw = ((uint64_t)ncchannels_bchannel(channels) << 32u) + ncchannels_fchannel(channels); - const uint64_t statemask = (CELL_NOBACKGROUND_MASK | CELL_FG_ALPHA_MASK | - CELL_BG_ALPHA_MASK | (CELL_NOBACKGROUND_MASK >> 32u)); + const uint64_t statemask = (NC_NOBACKGROUND_MASK | NC_FG_ALPHA_MASK | + NC_BG_ALPHA_MASK | (NC_NOBACKGROUND_MASK >> 32u)); uint64_t ret = raw & ~statemask; ret |= channels & statemask; return ret; @@ -2956,13 +2949,13 @@ ncchannels_reverse(uint64_t channels){ // Extract 24 bits of foreground RGB from 'channels', shifted to LSBs. static inline unsigned ncchannels_fg_rgb(uint64_t channels){ - return ncchannels_fchannel(channels) & CELL_BG_MASK; + return ncchannels_fchannel(channels) & NC_BG_MASK; } // Extract 24 bits of background RGB from 'channels', shifted to LSBs. static inline unsigned ncchannels_bg_rgb(uint64_t channels){ - return ncchannels_bchannel(channels) & CELL_BG_MASK; + return ncchannels_bchannel(channels) & NC_BG_MASK; } // Extract 2 bits of foreground alpha from 'channels', shifted to LSBs. diff --git a/cffi/src/notcurses/notcurses.py b/cffi/src/notcurses/notcurses.py index 6450441c1..ebf9afde4 100755 --- a/cffi/src/notcurses/notcurses.py +++ b/cffi/src/notcurses/notcurses.py @@ -20,7 +20,7 @@ def channel_rgb8(channel): def channel_set_rgb8(channel, r, g, b): checkRGB(r, g, b) c = (r << 16) | (g << 8) | b - return (channel & ~lib.CELL_BG_RGB_MASK) | lib.CELL_BGDEFAULT_MASK | c + return (channel & ~lib.NC_BG_RGB_MASK) | lib.NC_BGDEFAULT_MASK | c def channels_fchannel(channels): return channels & 0xffffffff00000000 diff --git a/doc/man/man3/notcurses_cell.3.md b/doc/man/man3/notcurses_cell.3.md index 7f32a4fed..a5dc59200 100644 --- a/doc/man/man3/notcurses_cell.3.md +++ b/doc/man/man3/notcurses_cell.3.md @@ -27,13 +27,6 @@ typedef struct nccell { #define CELL_INITIALIZER(c, s, chan) \ { .gcluster = (c), .stylemask = (s), .channels = (chan), } -#define CELL_BGDEFAULT_MASK 0x0000000040000000ull -#define CELL_FGDEFAULT_MASK (CELL_BGDEFAULT_MASK << 32u) -#define CELL_BG_RGB_MASK 0x0000000000ffffffull -#define CELL_FG_RGB_MASK (CELL_BG_MASK << 32u) -#define CELL_BG_PALETTE 0x0000000008000000ull -#define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u) -#define CHANNEL_ALPHA_MASK 0x30000000ull #define NCALPHA_HIGHCONTRAST 0x30000000ull #define NCALPHA_TRANSPARENT 0x20000000ull #define NCALPHA_BLEND 0x10000000ull diff --git a/doc/man/man3/notcurses_channels.3.md b/doc/man/man3/notcurses_channels.3.md index cfe3634a4..078ee6d1f 100644 --- a/doc/man/man3/notcurses_channels.3.md +++ b/doc/man/man3/notcurses_channels.3.md @@ -13,10 +13,10 @@ notcurses_channels - operations on notcurses channels ```c #define NCCHANNELS_INITIALIZER(fr, fg, fb, br, bg, bb) \ (((((uint64_t)(fr) << 16u) + ((uint64_t)(fg) << 8u) + (uint64_t)(fb)) << 32ull) + \ - (((br) << 16u) + ((bg) << 8u) + (bb)) + CELL_BGDEFAULT_MASK + CELL_FGDEFAULT_MASK) + (((br) << 16u) + ((bg) << 8u) + (bb)) + NC_BGDEFAULT_MASK + NC_FGDEFAULT_MASK) #define CHANNEL_INITIALIZER(r, g, b) \ - (((uint32_t)r << 16u) + ((uint32_t)g << 8u) + (b) + CELL_BGDEFAULT_MASK) + (((uint32_t)r << 16u) + ((uint32_t)g << 8u) + (b) + NC_BGDEFAULT_MASK) ``` **uint32_t ncchannel_r(uint32_t ***channel***);** diff --git a/python/notcurses/main.c b/python/notcurses/main.c index 6d1c9ac1d..a406d2335 100644 --- a/python/notcurses/main.c +++ b/python/notcurses/main.c @@ -54,30 +54,30 @@ PyInit_notcurses(void) GNU_PY_MODULE_ADD_OBJECT(py_module, (PyObject *)&NcPlane_Type, "NcPlane"); // background cannot be highcontrast, only foreground - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_ALPHA_HIGHCONTRAST)); - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_ALPHA_TRANSPARENT)); - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_ALPHA_BLEND)); - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_ALPHA_OPAQUE)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NCALPHA_HIGHCONTRAST)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NCALPHA_TRANSPARENT)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NCALPHA_BLEND)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NCALPHA_OPAQUE)); // if this bit is set, we are *not* using the default background color - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_BGDEFAULT_MASK)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_BGDEFAULT_MASK)); // if this bit is set, we are *not* using the default foreground color - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_FGDEFAULT_MASK)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_FGDEFAULT_MASK)); // extract these bits to get the background RGB value - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_BG_RGB_MASK)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_BG_RGB_MASK)); // extract these bits to get the foreground RGB value - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_FG_RGB_MASK)); - // if this bit *and* CELL_BGDEFAULT_MASK are set, we're using a + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_FG_RGB_MASK)); + // if this bit *and* NC_BGDEFAULT_MASK are set, we're using a // palette-indexed background color - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_BG_PALETTE)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_BG_PALETTE)); GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NCPALETTESIZE)); // if this bit *and* CELL_FGDEFAULT_MASK are set, we're using a // palette-indexed foreground color - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_FG_PALETTE)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_FG_PALETTE)); // extract these bits to get the background alpha mask - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_BG_ALPHA_MASK)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_BG_ALPHA_MASK)); // extract these bits to get the foreground alpha mask - GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, CELL_FG_ALPHA_MASK)); + GNU_PY_CHECK_INT(PyModule_AddIntMacro(py_module, NC_FG_ALPHA_MASK)); PyObject *traceback_module CLEANUP_PY_OBJ = GNU_PY_CHECK(PyImport_ImportModule("traceback")); traceback_format_exception = GNU_PY_CHECK(PyObject_GetAttrString(traceback_module, "format_exception")); @@ -85,4 +85,4 @@ PyInit_notcurses(void) Py_INCREF(py_module); return py_module; -} \ No newline at end of file +} diff --git a/rust/src/bindings.rs b/rust/src/bindings.rs index 983e6b398..9e337fb43 100644 --- a/rust/src/bindings.rs +++ b/rust/src/bindings.rs @@ -47,14 +47,14 @@ pub use ffi::{ // NCALPHA_HIGHCONTRAST, // NCALPHA_OPAQUE, // NCALPHA_TRANSPARENT, -// CELL_BGDEFAULT_MASK, -// CELL_BG_ALPHA_MASK, -// CELL_BG_PALETTE, -// CELL_BG_RGB_MASK, -// CELL_FGDEFAULT_MASK, -// CELL_FG_ALPHA_MASK, -// CELL_FG_PALETTE, -// CELL_FG_RGB_MASK, +// NC_BGDEFAULT_MASK, +// NC_BG_ALPHA_MASK, +// NC_BG_PALETTE, +// NC_BG_RGB_MASK, +// NC_FGDEFAULT_MASK, +// NC_FG_ALPHA_MASK, +// NC_FG_PALETTE, +// NC_FG_RGB_MASK, #[doc(inline)] pub use ffi::{ diff --git a/rust/src/channel/mod.rs b/rust/src/channel/mod.rs index 4e9a45bae..3ea6c938a 100644 --- a/rust/src/channel/mod.rs +++ b/rust/src/channel/mod.rs @@ -100,7 +100,7 @@ pub use reimplemented::*; pub type NcChannel = u32; /// Extract these bits to get a channel's alpha value -pub const NCCHANNEL_ALPHA_MASK: u32 = crate::bindings::ffi::CELL_BG_ALPHA_MASK; +pub const NCCHANNEL_ALPHA_MASK: u32 = crate::bindings::ffi::NC_BG_ALPHA_MASK; // NcAlphaBits // @@ -140,7 +140,7 @@ pub const NCALPHA_TRANSPARENT: u32 = crate::bindings::ffi::NCALPHA_TRANSPARENT; /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: This can also be used against a single [`NcChannel`] -pub const NCALPHA_BGDEFAULT_MASK: u32 = crate::bindings::ffi::CELL_BGDEFAULT_MASK; +pub const NCALPHA_BGDEFAULT_MASK: u32 = crate::bindings::ffi::NC_BGDEFAULT_MASK; /// Extract these bits to get the background alpha mask /// ([`NcAlphaBits`]) @@ -148,7 +148,7 @@ pub const NCALPHA_BGDEFAULT_MASK: u32 = crate::bindings::ffi::CELL_BGDEFAULT_MAS /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: This can also be used against a single [`NcChannel`] -pub const NCALPHA_BG_ALPHA_MASK: u32 = crate::bindings::ffi::CELL_BG_ALPHA_MASK; +pub const NCALPHA_BG_ALPHA_MASK: u32 = crate::bindings::ffi::NC_BG_ALPHA_MASK; /// If this bit *and* [`NCALPHA_BGDEFAULT_MASK`] are set, we're using a /// palette-indexed background color @@ -156,21 +156,21 @@ pub const NCALPHA_BG_ALPHA_MASK: u32 = crate::bindings::ffi::CELL_BG_ALPHA_MASK; /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: This can also be used against a single [`NcChannel`] -pub const NCALPHA_BG_PALETTE: u32 = crate::bindings::ffi::CELL_BG_PALETTE; +pub const NCALPHA_BG_PALETTE: u32 = crate::bindings::ffi::NC_BG_PALETTE; /// Extract these bits to get the background [`NcRgb`][crate::NcRgb] value /// /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: This can also be used against a single [`NcChannel`] -pub const NCALPHA_BG_RGB_MASK: u32 = crate::bindings::ffi::CELL_BG_RGB_MASK; +pub const NCALPHA_BG_RGB_MASK: u32 = crate::bindings::ffi::NC_BG_RGB_MASK; /// If this bit is set, we are *not* using the default foreground color /// /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: When working with a single [`NcChannel`] use [`NCALPHA_BGDEFAULT_MASK`]; -pub const NCALPHA_FGDEFAULT_MASK: u64 = crate::bindings::ffi::CELL_FGDEFAULT_MASK; +pub const NCALPHA_FGDEFAULT_MASK: u64 = crate::bindings::ffi::NC_FGDEFAULT_MASK; /// Extract these bits to get the foreground alpha mask /// ([`NcAlphaBits`]) @@ -178,7 +178,7 @@ pub const NCALPHA_FGDEFAULT_MASK: u64 = crate::bindings::ffi::CELL_FGDEFAULT_MAS /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_ALPHA_MASK`]; -pub const NCALPHA_FG_ALPHA_MASK: u64 = crate::bindings::ffi::CELL_FG_ALPHA_MASK; +pub const NCALPHA_FG_ALPHA_MASK: u64 = crate::bindings::ffi::NC_FG_ALPHA_MASK; /// If this bit *and* [`NCALPHA_FGDEFAULT_MASK`] are set, we're using a /// palette-indexed background color @@ -186,14 +186,14 @@ pub const NCALPHA_FG_ALPHA_MASK: u64 = crate::bindings::ffi::CELL_FG_ALPHA_MASK; /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_PALETTE`]; -pub const NCALPHA_FG_PALETTE: u64 = crate::bindings::ffi::CELL_FG_PALETTE; +pub const NCALPHA_FG_PALETTE: u64 = crate::bindings::ffi::NC_FG_PALETTE; /// Extract these bits to get the foreground [`NcRgb`][crate::NcRgb] value /// /// See the detailed diagram at [`NcChannels`][crate::NcChannels] /// /// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_RGB_MASK`]; -pub const NCALPHA_FG_RGB_MASK: u64 = crate::bindings::ffi::CELL_FG_RGB_MASK; +pub const NCALPHA_FG_RGB_MASK: u64 = crate::bindings::ffi::NC_FG_RGB_MASK; // NcChannels //