ncmultiselector_selected() #322

pull/404/head
nick black 4 years ago committed by Nick Black
parent 638be8feb7
commit be089747a7

@ -44,6 +44,8 @@ typedef struct multiselector_options {
**struct ncmultiselector* ncmultiselector_create(struct ncplane* n, int y, int x, const multiselector_options* opts);**
**int ncselector_selected(bool* selected, unsigned n);**
**struct ncplane* ncmultiselector_plane(struct ncmultiselector* n);**
**bool ncmultiselector_offer_input(struct ncmultiselector* n, const struct ncinput* nc);**

@ -2325,6 +2325,10 @@ struct ncmultiselector;
API struct ncmultiselector* ncmultiselector_create(struct ncplane* n, int y, int x,
const multiselector_options* opts);
// Return selected vector. An array of bools must be provided, along with its
// length. If that length doesn't match the itemcount, it is an error.
API int ncmultiselector_selected(struct ncmultiselector* n, bool* selected, unsigned count);
// Return a reference to the ncmultiselector's underlying ncplane.
API struct ncplane* ncmultiselector_plane(struct ncmultiselector* n);

@ -322,6 +322,7 @@ typedef struct multiselector_options {
uint64_t bgchannels; // background channels, used only in body
} multiselector_options;
struct ncmultiselector* ncmultiselector_create(struct ncplane* n, int y, int x, const multiselector_options* opts);
int ncselector_selected(bool* selected, unsigned n);
struct ncplane* ncmultiselector_plane(struct ncmultiselector* n);
bool ncmultiselector_offer_input(struct ncmultiselector* n, const struct ncinput* nc);
void ncmultiselector_destroy(struct ncmultiselector* n, char** item);

@ -745,3 +745,13 @@ void ncmultiselector_destroy(ncmultiselector* n, char** item){
free(n);
}
}
int ncmultiselector_selected(ncmultiselector* n, bool* selected, unsigned count){
if(n->itemcount != count || n->itemcount < 1){
return -1;
}
while(--count){
selected[count] = n->items[count].selected;
}
return 0;
}

Loading…
Cancel
Save