diff --git a/include/notcurses.h b/include/notcurses.h index 6f38bffe6..f018321ce 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -700,6 +700,18 @@ channels_get_fchannel(uint64_t channels){ return channels_get_bchannel(channels >> 32u); } +// Set the 32-bit background channel of a channel pair. +static inline uint64_t +channels_set_bchannel(uint64_t* channels, uint32_t channel){ + return *channels = (*channels & 0xffffffff00000000llu) | channel; +} + +// Set the 32-bit foreground channel of a channel pair. +static inline uint64_t +channels_set_fchannel(uint64_t* channels, uint32_t channel){ + return *channels = (*channels & 0xfffffffflu) | ((uint64_t)channel << 32u); +} + // Extract 24 bits of foreground RGB from 'channels', shifted to LSBs. static inline unsigned channels_get_fg(uint64_t channels){ @@ -847,6 +859,18 @@ cell_get_fchannel(const cell* cl){ return channels_get_fchannel(cl->channels); } +// Set the 32-bit background channel of a cell. +static inline uint64_t +cell_set_bchannel(cell* cl, uint32_t channel){ + return channels_set_bchannel(&cl->channels, channel); +} + +// Set the 32-bit foreground channel of a cell. +static inline uint64_t +cell_set_fchannel(cell* cl, uint32_t channel){ + return channels_set_fchannel(&cl->channels, channel); +} + // Extract 24 bits of foreground RGB from 'cell', shifted to LSBs. static inline unsigned cell_get_fg(const cell* cl){ diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 38a332b4d..10ce3cd7a 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1104,13 +1104,13 @@ dig_visible_cell(cell* c, int y, int x, ncplane* p, int falpha, int balpha){ if( (c->gcluster = vis->gcluster) ){ // index copy only lockedglyph = true; // must return this ncplane for this glyph c->attrword = vis->attrword; - cell_set_fg(c, cell_get_fg(vis)); // FIXME blend it in + cell_set_fchannel(c, cell_get_fchannel(vis)); // FIXME blend it in falpha -= (CELL_ALPHA_TRANS - nalpha); // FIXME blend it in } } } if(balpha > 0 && (nalpha = cell_get_bg_alpha(vis)) < CELL_ALPHA_TRANS){ - cell_set_bg(c, cell_get_bg(vis)); // FIXME blend it in + cell_set_bchannel(c, cell_get_bchannel(vis)); // FIXME blend it in balpha -= (CELL_ALPHA_TRANS - nalpha); } if((falpha > 0 || balpha > 0) && p->z){ // we must go further!