Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
selector.c File Reference
#include "internal.h"
Include dependency graph for selector.c:

Go to the source code of this file.

Data Structures

struct  ncselector_int
 
struct  ncmselector_int
 
struct  ncselector
 
struct  ncmultiselector
 

Typedefs

typedef struct ncselector ncselector
 
typedef struct ncmultiselector ncmultiselector
 

Functions

void ncselector_destroy (ncselector *n, char **item)
 
ncselectorncselector_create (ncplane *n, const ncselector_options *opts)
 
int ncselector_additem (ncselector *n, const struct ncselector_item *item)
 
int ncselector_delitem (ncselector *n, const char *item)
 
ncplanencselector_plane (ncselector *n)
 
const char * ncselector_selected (const ncselector *n)
 
const char * ncselector_previtem (ncselector *n)
 
const char * ncselector_nextitem (ncselector *n)
 
bool ncselector_offer_input (ncselector *n, const ncinput *nc)
 
ncplanencmultiselector_plane (ncmultiselector *n)
 
const char * ncmultiselector_previtem (ncmultiselector *n)
 
const char * ncmultiselector_nextitem (ncmultiselector *n)
 
bool ncmultiselector_offer_input (ncmultiselector *n, const ncinput *nc)
 
ncmultiselectorncmultiselector_create (ncplane *n, const ncmultiselector_options *opts)
 
void ncmultiselector_destroy (ncmultiselector *n)
 
int ncmultiselector_selected (ncmultiselector *n, bool *selected, unsigned count)
 

Typedef Documentation

◆ ncmultiselector

◆ ncselector

typedef struct ncselector ncselector

Function Documentation

◆ ncmultiselector_create()

ncmultiselector * ncmultiselector_create ( ncplane n,
const ncmultiselector_options opts 
)

Definition at line 885 of file selector.c.

885 {
887 logerror("won't use the standard plane"); // would fail later on resize
888 return NULL;
889 }
890 ncmultiselector_options zeroed = {0};
891 if(!opts){
892 opts = &zeroed;
893 }
894 if(opts->flags > 0){
895 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
896 }
897 unsigned itemcount = 0;
898 if(opts->items){
899 for(const struct ncmselector_item* i = opts->items ; i->option ; ++i){
900 ++itemcount;
901 }
902 }
903 ncmultiselector* ns = malloc(sizeof(*ns));
904 if(ns == NULL){
905 return NULL;
906 }
907 memset(ns, 0, sizeof(*ns));
908 ns->title = opts->title ? strdup(opts->title) : NULL;
909 ns->titlecols = opts->title ? ncstrwidth(opts->title, NULL, NULL) : 0;
910 ns->secondary = opts->secondary ? strdup(opts->secondary) : NULL;
911 ns->secondarycols = opts->secondary ? ncstrwidth(opts->secondary, NULL, NULL) : 0;
912 ns->footer = opts->footer ? strdup(opts->footer) : NULL;
913 ns->footercols = opts->footer ? ncstrwidth(opts->footer, NULL, NULL) : 0;
914 ns->current = 0;
915 ns->startdisp = 0;
916 ns->longitem = 0;
917 ns->maxdisplay = opts->maxdisplay;
918 ns->opchannels = opts->opchannels;
919 ns->boxchannels = opts->boxchannels;
920 ns->descchannels = opts->descchannels;
921 ns->titlechannels = opts->titlechannels;
922 ns->footchannels = opts->footchannels;
923 ns->boxchannels = opts->boxchannels;
924 ns->darrowy = ns->uarrowy = ns->arrowx = -1;
925 if(itemcount){
926 if(!(ns->items = malloc(sizeof(*ns->items) * itemcount))){
927 goto freeitems;
928 }
929 }else{
930 ns->items = NULL;
931 }
932 for(ns->itemcount = 0 ; ns->itemcount < itemcount ; ++ns->itemcount){
933 const struct ncmselector_item* src = &opts->items[ns->itemcount];
934 int unsafe = ncstrwidth(src->option, NULL, NULL);
935 if(unsafe < 0){
936 goto freeitems;
937 }
938 unsigned cols = unsafe;
939 if(cols > ns->longitem){
940 ns->longitem = cols;
941 }
942 unsafe = ncstrwidth(src->desc, NULL, NULL);
943 if(unsafe < 0){
944 goto freeitems;
945 }
946 unsigned cols2 = unsafe;
947 if(cols + cols2 > ns->longitem){
948 ns->longitem = cols + cols2;
949 }
950 ns->items[ns->itemcount].option = strdup(src->option);
951 ns->items[ns->itemcount].desc = strdup(src->desc);
952 ns->items[ns->itemcount].selected = src->selected;
953 if(!(ns->items[ns->itemcount].desc && ns->items[ns->itemcount].option)){
954 free(ns->items[ns->itemcount].option);
955 free(ns->items[ns->itemcount].desc);
956 goto freeitems;
957 }
958 }
959 unsigned dimy, dimx;
960 ns->ncp = n;
961 if(ncmultiselector_dim_yx(ns, &dimy, &dimx)){
962 goto freeitems;
963 }
964 if(ncplane_resize_simple(ns->ncp, dimy, dimx)){
965 goto freeitems;
966 }
967 if(ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncmultiselector_destroy)){
968 goto freeitems;
969 }
970 ncmultiselector_draw(ns); // deal with error here?
971 return ns;
972
973freeitems:
974 while(ns->itemcount--){
975 free(ns->items[ns->itemcount].option);
976 free(ns->items[ns->itemcount].desc);
977 }
978 free(ns->items);
979 free(ns->title); free(ns->secondary); free(ns->footer);
980 free(ns);
982 return NULL;
983}
free(duplicated)
#define logerror(fmt,...)
Definition logging.h:32
#define logwarn(fmt,...)
Definition logging.h:37
ncplane * notcurses_stdplane(notcurses *nc)
Definition notcurses.c:699
int ncplane_destroy(ncplane *ncp)
Definition notcurses.c:1018
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
Definition notcurses.c:3309
notcurses * ncplane_notcurses(const ncplane *n)
Definition notcurses.c:2626
const struct ncplane_options * opts
Definition notcurses.h:3483
vopts n
Definition notcurses.h:3502
void ncmultiselector_destroy(ncmultiselector *n)
Definition selector.c:985
char * option
Definition selector.c:12
const char * option
Definition notcurses.h:3968
const char * desc
Definition notcurses.h:3969
char * secondary
Definition selector.c:50
unsigned maxdisplay
Definition selector.c:44
ncplane * ncp
Definition selector.c:41
uint64_t footchannels
Definition selector.c:57
unsigned longitem
Definition selector.c:45
unsigned startdisp
Definition selector.c:43
uint64_t descchannels
Definition selector.c:55
uint64_t titlechannels
Definition selector.c:56
unsigned itemcount
Definition selector.c:47
unsigned titlecols
Definition selector.c:49
uint64_t boxchannels
Definition selector.c:58
unsigned current
Definition selector.c:42
unsigned secondarycols
Definition selector.c:51
struct ncmselector_int * items
Definition selector.c:46
unsigned footercols
Definition selector.c:53
char * footer
Definition selector.c:52
uint64_t opchannels
Definition selector.c:54
return NULL
Definition termdesc.h:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_destroy()

void ncmultiselector_destroy ( ncmultiselector n)

Definition at line 985 of file selector.c.

985 {
986 if(n){
987 while(n->itemcount--){
988 free(n->items[n->itemcount].option);
989 free(n->items[n->itemcount].desc);
990 }
991 if(ncplane_set_widget(n->ncp, NULL, NULL) == 0){
992 ncplane_destroy(n->ncp);
993 }
994 free(n->items);
995 free(n->title);
996 free(n->secondary);
997 free(n->footer);
998 free(n);
999 }
1000}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_nextitem()

const char * ncmultiselector_nextitem ( ncmultiselector n)

Definition at line 762 of file selector.c.

762 {
763 const char* ret = NULL;
764 if(n->itemcount == 0){
765 return NULL;
766 }
767 unsigned lastdisp = n->startdisp;
768 lastdisp += n->maxdisplay && n->maxdisplay < n->itemcount ? n->maxdisplay : n->itemcount;
769 --lastdisp;
770 lastdisp %= n->itemcount;
771 if(lastdisp == n->current){
772 if(++n->startdisp == n->itemcount){
773 n->startdisp = 0;
774 }
775 }
776 ++n->current;
777 if(n->current == n->itemcount){
778 n->current = 0;
779 }
780 ret = n->items[n->current].option;
781 ncmultiselector_draw(n);
782 return ret;
783}
Here is the caller graph for this function:

◆ ncmultiselector_offer_input()

bool ncmultiselector_offer_input ( ncmultiselector n,
const ncinput nc 
)

Definition at line 785 of file selector.c.

785 {
786 const int items_shown = ncplane_dim_y(n->ncp) - 4 - (n->title ? 2 : 0);
787 if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
788 int y = nc->y, x = nc->x;
789 if(!ncplane_translate_abs(n->ncp, &y, &x)){
790 return false;
791 }
792 if(y == n->uarrowy && x == n->arrowx){
794 return true;
795 }else if(y == n->darrowy && x == n->arrowx){
797 return true;
798 }else if(n->uarrowy < y && y < n->darrowy){
799 // FIXME we probably only want to consider it a click if both the release
800 // and the depress happened to be on us. for now, just check release.
801 // FIXME verify that we're within the body walls!
802 // FIXME verify we're on the left of the split?
803 // FIXME verify that we're on a visible glyph?
804 int cury = (n->current + n->itemcount - n->startdisp) % n->itemcount;
805 int click = y - n->uarrowy - 1;
806 while(click > cury){
808 ++cury;
809 }
810 while(click < cury){
812 --cury;
813 }
814 return true;
815 }
816 }else if(nc->evtype != NCTYPE_RELEASE){
817 if(nc->id == ' '){
818 n->items[n->current].selected = !n->items[n->current].selected;
819 ncmultiselector_draw(n);
820 return true;
821 }else if(nc->id == NCKEY_UP){
823 return true;
824 }else if(nc->id == NCKEY_DOWN){
826 return true;
827 }else if(nc->id == NCKEY_PGDOWN){
828 if(items_shown > 0){
829 for(int i = 0 ; i < items_shown ; ++i){
831 }
832 }
833 return true;
834 }else if(nc->id == NCKEY_PGUP){
835 if(items_shown > 0){
836 for(int i = 0 ; i < items_shown ; ++i){
838 }
839 }
840 return true;
841 }else if(nc->id == NCKEY_SCROLL_UP){
843 return true;
844 }else if(nc->id == NCKEY_SCROLL_DOWN){
846 return true;
847 }
848 }
849 return false;
850}
#define NCKEY_SCROLL_UP
Definition nckeys.h:192
#define NCKEY_SCROLL_DOWN
Definition nckeys.h:193
#define NCKEY_UP
Definition nckeys.h:37
#define NCKEY_DOWN
Definition nckeys.h:39
#define NCKEY_PGUP
Definition nckeys.h:45
#define NCKEY_BUTTON1
Definition nckeys.h:166
#define NCKEY_PGDOWN
Definition nckeys.h:44
bool ncplane_translate_abs(const ncplane *n, int *restrict y, int *restrict x)
Definition notcurses.c:2590
int y
Definition notcurses.h:1905
@ NCTYPE_RELEASE
Definition notcurses.h:1198
int int x
Definition notcurses.h:1905
const char * ncmultiselector_nextitem(ncmultiselector *n)
Definition selector.c:762
const char * ncmultiselector_previtem(ncmultiselector *n)
Definition selector.c:743
ncintype_e evtype
Definition notcurses.h:1218
uint32_t id
Definition notcurses.h:1210
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_plane()

ncplane * ncmultiselector_plane ( ncmultiselector n)

Definition at line 586 of file selector.c.

586 {
587 return n->ncp;
588}

◆ ncmultiselector_previtem()

const char * ncmultiselector_previtem ( ncmultiselector n)

Definition at line 743 of file selector.c.

743 {
744 const char* ret = NULL;
745 if(n->itemcount == 0){
746 return ret;
747 }
748 if(n->current == n->startdisp){
749 if(n->startdisp-- == 0){
750 n->startdisp = n->itemcount - 1;
751 }
752 }
753 if(n->current == 0){
754 n->current = n->itemcount;
755 }
756 --n->current;
757 ret = n->items[n->current].option;
758 ncmultiselector_draw(n);
759 return ret;
760}
Here is the caller graph for this function:

◆ ncmultiselector_selected()

int ncmultiselector_selected ( ncmultiselector n,
bool *  selected,
unsigned  count 
)

Definition at line 1002 of file selector.c.

1002 {
1003 if(n->itemcount != count || n->itemcount < 1){
1004 return -1;
1005 }
1006 while(--count){
1007 selected[count] = n->items[count].selected;
1008 }
1009 return 0;
1010}
Here is the caller graph for this function:

◆ ncselector_additem()

int ncselector_additem ( ncselector n,
const struct ncselector_item item 
)

Definition at line 392 of file selector.c.

392 {
393 unsigned origdimy, origdimx;
394 ncselector_dim_yx(n, &origdimy, &origdimx);
395 size_t newsize = sizeof(*n->items) * (n->itemcount + 1);
396 struct ncselector_int* items = realloc(n->items, newsize);
397 if(!items){
398 return -1;
399 }
400 n->items = items;
401 n->items[n->itemcount].option = strdup(item->option);
402 const char *desc = item->desc ? item->desc : "";
403 n->items[n->itemcount].desc = strdup(desc);
404 int usafecols = ncstrwidth(item->option, NULL, NULL);
405 if(usafecols < 0){
406 return -1;
407 }
408 unsigned cols = usafecols;
409 n->items[n->itemcount].opcolumns = cols;
410 if(cols > n->longop){
411 n->longop = cols;
412 }
413 cols = ncstrwidth(desc, NULL, NULL);
414 n->items[n->itemcount].desccolumns = cols;
415 if(cols > n->longdesc){
416 n->longdesc = cols;
417 }
418 ++n->itemcount;
419 unsigned dimy, dimx;
420 ncselector_dim_yx(n, &dimy, &dimx);
421 if(origdimx < dimx || origdimy < dimy){ // resize if too small
422 ncplane_resize_simple(n->ncp, dimy, dimx);
423 }
424 return ncselector_draw(n);
425}
char * desc
Definition selector.c:6
char * option
Definition selector.c:5
const char * option
Definition notcurses.h:3908
const char * desc
Definition notcurses.h:3909
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_create()

ncselector * ncselector_create ( ncplane n,
const ncselector_options opts 
)

Definition at line 280 of file selector.c.

280 {
282 logerror("won't use the standard plane"); // would fail later on resize
283 return NULL;
284 }
285 ncselector_options zeroed = {0};
286 if(!opts){
287 opts = &zeroed;
288 }
289 unsigned itemcount = 0;
290 if(opts->flags > 0){
291 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
292 }
293 if(opts->items){
294 for(const struct ncselector_item* i = opts->items ; i->option ; ++i){
295 ++itemcount;
296 }
297 }
298 ncselector* ns = malloc(sizeof(*ns));
299 if(ns == NULL){
300 return NULL;
301 }
302 memset(ns, 0, sizeof(*ns));
303 if(opts->defidx && opts->defidx >= itemcount){
304 logerror("default index %u too large (%u items)", opts->defidx, itemcount);
305 goto freeitems;
306 }
307 ns->title = opts->title ? strdup(opts->title) : NULL;
308 ns->titlecols = opts->title ? ncstrwidth(opts->title, NULL, NULL) : 0;
309 ns->secondary = opts->secondary ? strdup(opts->secondary) : NULL;
310 ns->secondarycols = opts->secondary ? ncstrwidth(opts->secondary, NULL, NULL) : 0;
311 ns->footer = opts->footer ? strdup(opts->footer) : NULL;
312 ns->footercols = opts->footer ? ncstrwidth(opts->footer, NULL, NULL) : 0;
313 ns->selected = opts->defidx;
314 ns->longop = 0;
315 if( (ns->maxdisplay = opts->maxdisplay) ){
316 if(opts->defidx >= ns->maxdisplay){
317 ns->startdisp = opts->defidx - ns->maxdisplay + 1;
318 }else{
319 ns->startdisp = 0;
320 }
321 }else{
322 ns->startdisp = 0;
323 }
324 ns->longdesc = 0;
325 ns->opchannels = opts->opchannels;
326 ns->boxchannels = opts->boxchannels;
327 ns->descchannels = opts->descchannels;
328 ns->titlechannels = opts->titlechannels;
329 ns->footchannels = opts->footchannels;
330 ns->boxchannels = opts->boxchannels;
331 ns->darrowy = ns->uarrowy = ns->arrowx = -1;
332 if(itemcount){
333 if(!(ns->items = malloc(sizeof(*ns->items) * itemcount))){
334 goto freeitems;
335 }
336 }else{
337 ns->items = NULL;
338 }
339 for(ns->itemcount = 0 ; ns->itemcount < itemcount ; ++ns->itemcount){
340 const struct ncselector_item* src = &opts->items[ns->itemcount];
341 int unsafe = ncstrwidth(src->option, NULL, NULL);
342 if(unsafe < 0){
343 goto freeitems;
344 }
345 unsigned cols = unsafe;
346 ns->items[ns->itemcount].opcolumns = cols;
347 if(cols > ns->longop){
348 ns->longop = cols;
349 }
350 const char *desc = src->desc ? src->desc : "";
351 unsafe = ncstrwidth(desc, NULL, NULL);
352 if(unsafe < 0){
353 goto freeitems;
354 }
355 cols = unsafe;
356 ns->items[ns->itemcount].desccolumns = cols;
357 if(cols > ns->longdesc){
358 ns->longdesc = cols;
359 }
360 ns->items[ns->itemcount].option = strdup(src->option);
361 ns->items[ns->itemcount].desc = strdup(desc);
362 if(!(ns->items[ns->itemcount].desc && ns->items[ns->itemcount].option)){
363 free(ns->items[ns->itemcount].option);
364 free(ns->items[ns->itemcount].desc);
365 goto freeitems;
366 }
367 }
368 unsigned dimy, dimx;
369 ns->ncp = n;
370 ncselector_dim_yx(ns, &dimy, &dimx);
371 if(ncplane_resize_simple(n, dimy, dimx)){
372 goto freeitems;
373 }
374 if(ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncselector_destroy_internal)){
375 goto freeitems;
376 }
377 ncselector_draw(ns); // deal with error here?
378 return ns;
379
380freeitems:
381 while(ns->itemcount--){
382 free(ns->items[ns->itemcount].option);
383 free(ns->items[ns->itemcount].desc);
384 }
385 free(ns->items);
386 free(ns->title); free(ns->secondary); free(ns->footer);
387 free(ns);
389 return NULL;
390}
size_t desccolumns
Definition selector.c:8
size_t opcolumns
Definition selector.c:7
char * secondary
Definition selector.c:28
unsigned maxdisplay
Definition selector.c:21
ncplane * ncp
Definition selector.c:18
uint64_t footchannels
Definition selector.c:35
unsigned longdesc
Definition selector.c:23
int darrowy
Definition selector.c:37
unsigned startdisp
Definition selector.c:20
uint64_t descchannels
Definition selector.c:33
uint64_t titlechannels
Definition selector.c:34
unsigned itemcount
Definition selector.c:25
unsigned titlecols
Definition selector.c:27
uint64_t boxchannels
Definition selector.c:36
int arrowx
Definition selector.c:37
unsigned secondarycols
Definition selector.c:29
unsigned longop
Definition selector.c:22
int uarrowy
Definition selector.c:37
unsigned footercols
Definition selector.c:31
char * footer
Definition selector.c:30
struct ncselector_int * items
Definition selector.c:24
unsigned selected
Definition selector.c:19
char * title
Definition selector.c:26
uint64_t opchannels
Definition selector.c:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_delitem()

int ncselector_delitem ( ncselector n,
const char *  item 
)

Definition at line 427 of file selector.c.

427 {
428 unsigned origdimy, origdimx;
429 ncselector_dim_yx(n, &origdimy, &origdimx);
430 bool found = false;
431 int maxop = 0, maxdesc = 0;
432 for(unsigned idx = 0 ; idx < n->itemcount ; ++idx){
433 if(strcmp(n->items[idx].option, item) == 0){ // found it
434 free(n->items[idx].option);
435 free(n->items[idx].desc);
436 if(idx < n->itemcount - 1){
437 memmove(n->items + idx, n->items + idx + 1, sizeof(*n->items) * (n->itemcount - idx - 1));
438 }else{
439 if(idx){
440 --n->selected;
441 }
442 }
443 --n->itemcount;
444 found = true;
445 --idx;
446 }else{
447 int cols = ncstrwidth(n->items[idx].option, NULL, NULL);
448 if(cols > maxop){
449 maxop = cols;
450 }
451 cols = ncstrwidth(n->items[idx].desc, NULL, NULL);
452 if(cols > maxdesc){
453 maxdesc = cols;
454 }
455 }
456 }
457 if(found){
458 n->longop = maxop;
459 n->longdesc = maxdesc;
460 unsigned dimy, dimx;
461 ncselector_dim_yx(n, &dimy, &dimx);
462 if(origdimx > dimx || origdimy > dimy){ // resize if too big
463 ncplane_resize_simple(n->ncp, dimy, dimx);
464 }
465 return ncselector_draw(n);
466 }
467 return -1; // wasn't found
468}
uint32_t idx
Definition egcpool.h:298
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_destroy()

void ncselector_destroy ( ncselector n,
char **  item 
)

Definition at line 270 of file selector.c.

270 {
271 if(n){
272 if(item){
273 *item = n->items[n->selected].option;
274 n->items[n->selected].option = NULL;
275 }
276 ncselector_destroy_internal(n);
277 }
278}
Here is the caller graph for this function:

◆ ncselector_nextitem()

const char * ncselector_nextitem ( ncselector n)

Definition at line 500 of file selector.c.

500 {
501 const char* ret = NULL;
502 if(n->itemcount == 0){
503 return NULL;
504 }
505 unsigned lastdisp = n->startdisp;
506 lastdisp += n->maxdisplay && n->maxdisplay < n->itemcount ? n->maxdisplay : n->itemcount;
507 --lastdisp;
508 lastdisp %= n->itemcount;
509 if(lastdisp == n->selected){
510 if(++n->startdisp == n->itemcount){
511 n->startdisp = 0;
512 }
513 }
514 ++n->selected;
515 if(n->selected == n->itemcount){
516 n->selected = 0;
517 }
518 ret = n->items[n->selected].option;
519 ncselector_draw(n);
520 return ret;
521}
Here is the caller graph for this function:

◆ ncselector_offer_input()

bool ncselector_offer_input ( ncselector n,
const ncinput nc 
)

Definition at line 523 of file selector.c.

523 {
524 const int items_shown = ncplane_dim_y(n->ncp) - 4 - (n->title ? 2 : 0);
525 if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
526 int y = nc->y, x = nc->x;
527 if(!ncplane_translate_abs(n->ncp, &y, &x)){
528 return false;
529 }
530 if(y == n->uarrowy && x == n->arrowx){
532 return true;
533 }else if(y == n->darrowy && x == n->arrowx){
535 return true;
536 }else if(n->uarrowy < y && y < n->darrowy){
537 // FIXME we probably only want to consider it a click if both the release
538 // and the depress happened to be on us. for now, just check release.
539 // FIXME verify that we're within the body walls!
540 // FIXME verify we're on the left of the split?
541 // FIXME verify that we're on a visible glyph?
542 int cury = (n->selected + n->itemcount - n->startdisp) % n->itemcount;
543 int click = y - n->uarrowy - 1;
544 while(click > cury){
546 ++cury;
547 }
548 while(click < cury){
550 --cury;
551 }
552 return true;
553 }
554 }else if(nc->evtype != NCTYPE_RELEASE){
555 if(nc->id == NCKEY_UP){
557 return true;
558 }else if(nc->id == NCKEY_DOWN){
560 return true;
561 }else if(nc->id == NCKEY_SCROLL_UP){
563 return true;
564 }else if(nc->id == NCKEY_SCROLL_DOWN){
566 return true;
567 }else if(nc->id == NCKEY_PGDOWN){
568 if(items_shown > 0){
569 for(int i = 0 ; i < items_shown ; ++i){
571 }
572 }
573 return true;
574 }else if(nc->id == NCKEY_PGUP){
575 if(items_shown > 0){
576 for(int i = 0 ; i < items_shown ; ++i){
578 }
579 }
580 return true;
581 }
582 }
583 return false;
584}
const char * ncselector_nextitem(ncselector *n)
Definition selector.c:500
const char * ncselector_previtem(ncselector *n)
Definition selector.c:481
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_plane()

ncplane * ncselector_plane ( ncselector n)

Definition at line 470 of file selector.c.

470 {
471 return n->ncp;
472}

◆ ncselector_previtem()

const char * ncselector_previtem ( ncselector n)

Definition at line 481 of file selector.c.

481 {
482 const char* ret = NULL;
483 if(n->itemcount == 0){
484 return ret;
485 }
486 if(n->selected == n->startdisp){
487 if(n->startdisp-- == 0){
488 n->startdisp = n->itemcount - 1;
489 }
490 }
491 if(n->selected == 0){
492 n->selected = n->itemcount;
493 }
494 --n->selected;
495 ret = n->items[n->selected].option;
496 ncselector_draw(n);
497 return ret;
498}
Here is the caller graph for this function:

◆ ncselector_selected()

const char * ncselector_selected ( const ncselector n)

Definition at line 474 of file selector.c.

474 {
475 if(n->itemcount == 0){
476 return NULL;
477 }
478 return n->items[n->selected].option;
479}
Here is the caller graph for this function: