diff --git a/NEWS.md b/NEWS.md index 81730d343..440d927d4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ rearrangements of Notcurses. `ncchannels_set_[fb]channel()`, and `ncchannels_[fb]channel()` now function only on the 28 alpha + coloring bits of their respective channels, which is almost certainly what you wanted in the first place. + * Restore `nccell_set_[fb]channel()` and friends, using these semantics. * 3.0.5 (2022-01-21) * The Hyper and Super modifiers are now supported. CapsLock and NumLock diff --git a/USAGE.md b/USAGE.md index 0f29bbde0..9bb17b3eb 100644 --- a/USAGE.md +++ b/USAGE.md @@ -2245,13 +2245,15 @@ Helpers are provided to manipulate an `nccell`'s `channels` member. They are all implemented in terms of the lower-level [Channels API](#channels). ```c -// Extract the 32-bit background channel from a cell. +// Extract the background alpha and coloring bits from a cell's channels +// as a single 32-bit value. static inline uint32_t nccell_bchannel(const nccell* cl){ return ncchannels_bchannel(cl->channels); } -// Extract the 32-bit foreground channel from a cell. +// Extract the foreground alpha and coloring bits from a cell's channels +// as a single 32-bit value. static inline uint32_t nccell_fchannel(const nccell* cl){ return ncchannels_fchannel(cl->channels); diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index d7e82eeed..c87c723a0 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -821,6 +821,20 @@ nccell_wide_left_p(const nccell* c){ API __attribute__ ((returns_nonnull)) const char* nccell_extended_gcluster(const struct ncplane* n, const nccell* c); +// Extract the background alpha and coloring bits from a cell's channels +// as a single 32-bit value. +static inline uint32_t +nccell_bchannel(const nccell* cl){ + return ncchannels_bchannel(cl->channels); +} + +// Extract the foreground alpha and coloring bits from a cell's channels +// as a single 32-bit value. +static inline uint32_t +nccell_fchannel(const nccell* cl){ + return ncchannels_fchannel(cl->channels); +} + // return the number of columns occupied by 'c'. see ncstrwidth() for an // equivalent for multiple EGCs. static inline unsigned