Skip to content

Commit

Permalink
[ncpalette] add ncpalette_get() for orthogonality #2565
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jan 21, 2022
1 parent 815bd9f commit 7267883
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/man/man3/notcurses_palette.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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***);**
Expand Down
8 changes: 8 additions & 0 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down

0 comments on commit 7267883

Please sign in to comment.