ncmultiselector: support pgup/pgdown #862

pull/900/head
nick black 4 years ago
parent cdec910d7e
commit 78803f8c1d
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -56,10 +56,21 @@ typedef struct ncmultiselector_options {
# NOTES
Currently, the **ncplane** **n** provided to **ncmultiselector_create** must
not be **NULL**, though the **ncmultiselector** will always get its own plane,
and this plane will not (currently) be bound to **n**.
Currently, the **ncplane** **n** provided to **ncmultiselector_create**
must not be **NULL**, though the **ncmultiselector** will always get its
own plane, and this plane will not (currently) be bound to **n**.
**ncmultiselector_selected** returns a bitmap corresponding to the
currently-selected options.
**ncmultiselector_plane** will return the **ncplane** on which the widget is
drawn.
While the **ncmultiselector** can be driven entirely by client code,
input can be run through **ncmultiselector_offer_input** to take
advantage of common controls. It will handle the up and down arrows,
along with PageUp and PageDown, and space to select/deselect options.
If the mouse is enabled, the mouse scrollwheel and mouse clicks on the scroll
arrows will be handled.
# RETURN VALUES

@ -697,6 +697,7 @@ const char* ncmultiselector_nextitem(ncmultiselector* n){
}
bool ncmultiselector_offer_input(ncmultiselector* n, const ncinput* nc){
const int items_shown = ncplane_dim_y(n->ncp) - 4 - (n->title ? 2 : 0);
if(nc->id == ' '){
n->items[n->current].selected = !n->items[n->current].selected;
ncmultiselector_draw(n);
@ -708,10 +709,18 @@ bool ncmultiselector_offer_input(ncmultiselector* n, const ncinput* nc){
ncmultiselector_nextitem(n);
return true;
}else if(nc->id == NCKEY_PGDOWN){
ncmultiselector_nextitem(n); // FIXME should be a page's worth, or go to bottom
if(items_shown > 0){
for(int i = 0 ; i < items_shown ; ++i){
ncmultiselector_nextitem(n);
}
}
return true;
}else if(nc->id == NCKEY_PGUP){
ncmultiselector_previtem(n); // FIXME should be a page's worth, or go to top
if(items_shown > 0){
for(int i = 0 ; i < items_shown ; ++i){
ncmultiselector_previtem(n);
}
}
return true;
}else if(nc->id == NCKEY_SCROLL_UP){
ncmultiselector_previtem(n);

Loading…
Cancel
Save