|
|
|
@ -457,33 +457,7 @@ const char* ncselector_nextitem(ncselector* n){
|
|
|
|
|
|
|
|
|
|
bool ncselector_offer_input(ncselector* n, const ncinput* nc){
|
|
|
|
|
const int items_shown = ncplane_dim_y(n->ncp) - 4 - (n->title ? 2 : 0);
|
|
|
|
|
if(nc->id == NCKEY_UP){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_DOWN){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_SCROLL_UP){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_SCROLL_DOWN){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_PGDOWN){
|
|
|
|
|
if(items_shown > 0){
|
|
|
|
|
for(int i = 0 ; i < items_shown ; ++i){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_PGUP){
|
|
|
|
|
if(items_shown > 0){
|
|
|
|
|
for(int i = 0 ; i < items_shown ; ++i){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
|
|
|
|
|
if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
|
|
|
|
|
int y = nc->y, x = nc->x;
|
|
|
|
|
if(!ncplane_translate_abs(n->ncp, &y, &x)){
|
|
|
|
|
return false;
|
|
|
|
@ -512,6 +486,34 @@ bool ncselector_offer_input(ncselector* n, const ncinput* nc){
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}else if(nc->evtype != NCTYPE_RELEASE){
|
|
|
|
|
if(nc->id == NCKEY_UP){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_DOWN){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_SCROLL_UP){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_SCROLL_DOWN){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_PGDOWN){
|
|
|
|
|
if(items_shown > 0){
|
|
|
|
|
for(int i = 0 ; i < items_shown ; ++i){
|
|
|
|
|
ncselector_nextitem(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_PGUP){
|
|
|
|
|
if(items_shown > 0){
|
|
|
|
|
for(int i = 0 ; i < items_shown ; ++i){
|
|
|
|
|
ncselector_previtem(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -732,6 +734,36 @@ 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 == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
|
|
|
|
|
int y = nc->y, x = nc->x;
|
|
|
|
|
if(!ncplane_translate_abs(n->ncp, &y, &x)){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(y == n->uarrowy && x == n->arrowx){
|
|
|
|
|
ncmultiselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(y == n->darrowy && x == n->arrowx){
|
|
|
|
|
ncmultiselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(n->uarrowy < y && y < n->darrowy){
|
|
|
|
|
// FIXME we probably only want to consider it a click if both the release
|
|
|
|
|
// and the depress happened to be on us. for now, just check release.
|
|
|
|
|
// FIXME verify that we're within the body walls!
|
|
|
|
|
// FIXME verify we're on the left of the split?
|
|
|
|
|
// FIXME verify that we're on a visible glyph?
|
|
|
|
|
int cury = (n->current + n->itemcount - n->startdisp) % n->itemcount;
|
|
|
|
|
int click = y - n->uarrowy - 1;
|
|
|
|
|
while(click > cury){
|
|
|
|
|
ncmultiselector_nextitem(n);
|
|
|
|
|
++cury;
|
|
|
|
|
}
|
|
|
|
|
while(click < cury){
|
|
|
|
|
ncmultiselector_previtem(n);
|
|
|
|
|
--cury;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}else if(nc->evtype != NCTYPE_RELEASE){
|
|
|
|
|
if(nc->id == ' '){
|
|
|
|
|
n->items[n->current].selected = !n->items[n->current].selected;
|
|
|
|
|
ncmultiselector_draw(n);
|
|
|
|
@ -762,34 +794,6 @@ bool ncmultiselector_offer_input(ncmultiselector* n, const ncinput* nc){
|
|
|
|
|
}else if(nc->id == NCKEY_SCROLL_DOWN){
|
|
|
|
|
ncmultiselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
|
|
|
|
|
int y = nc->y, x = nc->x;
|
|
|
|
|
if(!ncplane_translate_abs(n->ncp, &y, &x)){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(y == n->uarrowy && x == n->arrowx){
|
|
|
|
|
ncmultiselector_previtem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(y == n->darrowy && x == n->arrowx){
|
|
|
|
|
ncmultiselector_nextitem(n);
|
|
|
|
|
return true;
|
|
|
|
|
}else if(n->uarrowy < y && y < n->darrowy){
|
|
|
|
|
// FIXME we probably only want to consider it a click if both the release
|
|
|
|
|
// and the depress happened to be on us. for now, just check release.
|
|
|
|
|
// FIXME verify that we're within the body walls!
|
|
|
|
|
// FIXME verify we're on the left of the split?
|
|
|
|
|
// FIXME verify that we're on a visible glyph?
|
|
|
|
|
int cury = (n->current + n->itemcount - n->startdisp) % n->itemcount;
|
|
|
|
|
int click = y - n->uarrowy - 1;
|
|
|
|
|
while(click > cury){
|
|
|
|
|
ncmultiselector_nextitem(n);
|
|
|
|
|
++cury;
|
|
|
|
|
}
|
|
|
|
|
while(click < cury){
|
|
|
|
|
ncmultiselector_previtem(n);
|
|
|
|
|
--cury;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|