notcurses_*_default_prep()

This commit is contained in:
nick black 2019-12-05 03:54:41 -05:00
parent 56cad83a4b
commit 3c93030177
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 20 additions and 2 deletions

View File

@ -628,6 +628,16 @@ notcurses_bg_prep(uint64_t* channels, int r, int g, int b){
return notcurses_channel_prep(channels, CELL_BG_MASK, 0, r, g, b, CELL_BGDEFAULT_MASK); return notcurses_channel_prep(channels, CELL_BG_MASK, 0, r, g, b, CELL_BGDEFAULT_MASK);
} }
static inline void
notcurses_fg_default_prep(uint64_t* channels){
*channels &= ~(CELL_FGDEFAULT_MASK);
}
static inline void
notcurses_bg_default_prep(uint64_t* channels){
*channels &= ~(CELL_BGDEFAULT_MASK);
}
static inline void static inline void
cell_set_fg(cell* c, unsigned r, unsigned g, unsigned b){ cell_set_fg(cell* c, unsigned r, unsigned g, unsigned b){
notcurses_fg_prep(&c->channels, r, g, b); notcurses_fg_prep(&c->channels, r, g, b);
@ -661,7 +671,7 @@ cell_inherits_style(const cell* c){
// use the default color for the foreground // use the default color for the foreground
static inline void static inline void
cell_fg_default(cell* c){ cell_fg_default(cell* c){
c->channels &= ~CELL_FGDEFAULT_MASK; notcurses_fg_default_prep(&c->channels);
} }
// is the cell using the terminal's default foreground color for its foreground? // is the cell using the terminal's default foreground color for its foreground?
@ -673,7 +683,7 @@ cell_fg_default_p(const cell* c){
// use the default color for the background // use the default color for the background
static inline void static inline void
cell_bg_default(cell* c){ cell_bg_default(cell* c){
c->channels &= ~CELL_BGDEFAULT_MASK; notcurses_bg_default_prep(&c->channels);
} }
// is the cell using the terminal's default background color for its background? // is the cell using the terminal's default background color for its background?

View File

@ -109,9 +109,17 @@ int unicodeblocks_demo(struct notcurses* nc){
return -1; return -1;
} }
++xstart; ++xstart;
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
cells_rounded_box(n, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl);
cell_set_bg(&hl, 0, 0, 0);
cell_set_bg(&vl, 0, 0, 0);
if(ncplane_rounded_box_sized(n, 0, 0, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 0)){ if(ncplane_rounded_box_sized(n, 0, 0, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 0)){
return -1; return -1;
} }
cell_release(n, &ul); cell_release(n, &ur); cell_release(n, &hl);
cell_release(n, &ll); cell_release(n, &lr); cell_release(n, &vl);
for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){ for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){
if(ncplane_cursor_move_yx(n, 4 + chunk, xstart)){ if(ncplane_cursor_move_yx(n, 4 + chunk, xstart)){
return -1; return -1;