selector: bind riser to body #309

pull/312/head
nick black 4 years ago
parent 20e4c106a2
commit 4716b5f495
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -44,6 +44,13 @@ ncselector_draw(ncselector* n){
int dimy, dimx;
ncplane_dim_yx(n->ncp, &dimy, &dimx);
ncplane_rounded_box_sized(n->ncp, 0, n->boxchannels, dimy - yoff, bodywidth, 0);
if(n->title){
n->ncp->channels = n->boxchannels;
ncplane_putegc_yx(n->ncp, 2, dimx - 1, "", NULL);
if(bodywidth < dimx){
ncplane_putegc_yx(n->ncp, 2, dimx - bodywidth, "", NULL);
}
}
// There is always at least one space available on the right for the
// secondary title and footer, but we'd prefer to use a few more if we can.
if(n->secondary){

@ -17,6 +17,22 @@ static struct selector_item items[] = {
{ "ten", "stunning and brave", },
};
static void
run_selector(struct notcurses* nc, struct ncselector* ns){
notcurses_render(nc);
char32_t keypress;
while((keypress = notcurses_getc_blocking(nc, NULL)) != (char32_t)-1){
switch(keypress){
case NCKEY_UP: case 'k': ncselector_previtem(ns, NULL); break;
case NCKEY_DOWN: case 'j': ncselector_nextitem(ns, NULL); break;
}
if(keypress == 'q'){
break;
}
notcurses_render(nc);
}
}
int main(void){
if(!setlocale(LC_ALL, "")){
return EXIT_FAILURE;
@ -52,18 +68,12 @@ int main(void){
notcurses_stop(nc);
return EXIT_FAILURE;
}
notcurses_render(nc);
char32_t keypress;
while((keypress = notcurses_getc_blocking(nc, NULL)) != (char32_t)-1){
switch(keypress){
case NCKEY_UP: case 'k': ncselector_previtem(ns, NULL); break;
case NCKEY_DOWN: case 'j': ncselector_nextitem(ns, NULL); break;
}
if(keypress == 'q'){
break;
}
notcurses_render(nc);
}
run_selector(nc, ns);
ncselector_destroy(ns, NULL);
sopts.title = "short round title";
ns = ncselector_create(notcurses_stdplane(nc), 3, 0, &sopts);
run_selector(nc, ns);
ncselector_destroy(ns, NULL);
if(notcurses_stop(nc)){
return EXIT_FAILURE;
}

Loading…
Cancel
Save