mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
[ncpalette] add ncpalette_get() for orthogonality #2565
This commit is contained in:
parent
815bd9f7f2
commit
72678835f2
1
NEWS.md
1
NEWS.md
@ -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…
x
Reference in New Issue
Block a user