[ncpalette] add ncpalette_get() for orthogonality #2565

pull/2569/head
nick black 2 years ago
parent 815bd9f7f2
commit 72678835f2
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -11,6 +11,7 @@ rearrangements of Notcurses.
shortucts using `modifiers`. Setting any of `alt`, `shift`, or
`ctrl` will see `ncmenu_create()` fail.
* `ncinput_equal_p()` considers `NCTYPE_UNKNOWN` equal to `NCTYPE_PRESS`.
* Added `ncpalette_get()` for orthogonality's sake.
* 3.0.4 (2022-01-08)
* We now use level 2 of `XTMODKEYS`, providing better differentiation

@ -27,6 +27,8 @@ typedef struct ncpalette {
**int ncpalette_set(ncpalette* ***p***, int ***idx***, unsigned ***rgb***);**
**uint32_t ncpalette_get(const ncpalette* ***p***, int ***idx***);**
**int ncpalette_get_rgb8(const ncpalette* ***p***, int ***idx***, int* restrict ***r***, int* restrict ***g***, int* restrict ***b***);**
**void ncpalette_free(ncpalette* ***p***);**

@ -1550,6 +1550,14 @@ ncpalette_set(ncpalette* p, int idx, unsigned rgb){
return ncchannel_set(&p->chans[idx], rgb);
}
static inline uint32_t
ncpalette_get(const ncpalette* p, int idx){
if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){
return -1;
}
return ncchannel_rgb(p->chans[idx]);
}
static inline int
ncpalette_get_rgb8(const ncpalette* p, int idx, unsigned* RESTRICT r, unsigned* RESTRICT g, unsigned* RESTRICT b){
if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){

Loading…
Cancel
Save