nctree PoC: set backgrounds relative to active #1164

pull/1372/head
nick black 3 years ago committed by Nick Black
parent 4ea2b67061
commit 962ad874e4

@ -196,7 +196,18 @@ nctree_prev_internal(nctree* n, unsigned* newpath){
}
void* nctree_prev(nctree* n){
n->curitem = nctree_prev_internal(n, n->currentpath);
int rows = 0;
if(n->curitem->ncp){
rows = ncplane_dim_y(n->curitem->ncp);
}
nctree_int_item* tmp = nctree_prev_internal(n, n->currentpath);
if(tmp != n->curitem){
n->curitem = tmp;
n->activerow -= rows;
if(n->activerow < 0){
n->activerow = 0;
}
}
return n->curitem->curry;
}
@ -232,8 +243,18 @@ nctree_next_internal(nctree* n, unsigned* newpath){
}
void* nctree_next(nctree* n){
// FIXME update n->activerow, redraw
n->curitem = nctree_next_internal(n, n->currentpath);
int rows = 0;
if(n->curitem->ncp){
rows = ncplane_dim_y(n->curitem->ncp);
}
nctree_int_item* tmp = nctree_next_internal(n, n->currentpath);
if(tmp != n->curitem){
n->curitem = tmp;
n->activerow += rows;
if(n->activerow >= ncplane_dim_y(n->items.ncp)){
n->activerow = ncplane_dim_y(n->items.ncp) - 1;
}
}
return n->curitem->curry;
}
@ -332,7 +353,9 @@ nctree_inner_redraw(nctree* n, unsigned* tmppath){
}
distance = 0;
n->activerow = ncplane_y(n->curitem->ncp);
nii = n->curitem;
// draw items below the current one FIME
memcpy(tmppath, n->currentpath, sizeof(*tmppath) * (n->maxdepth + 1));
while(frontierb < ncplane_dim_y(n->items.ncp)){
if((tmpnii = nctree_next_internal(n, tmppath)) == nii){
break;

@ -369,13 +369,19 @@ callback(struct ncplane* ncp, void* curry, int dizzy){
uint64_t channels = 0;
if(dizzy == 0){
channels_set_bg_rgb(&channels, 0x006060);
ncplane_set_fg_rgb(ncp, 0xffffff);
}else if(dizzy < 0){
channels_set_bg_rgb8(&channels, 0, 60 + dizzy, 0);
float f = -dizzy / 80.0;
channels_set_bg_rgb8(&channels, 0, 60 - 60 * f, 0);
ncplane_set_fg_rgb(ncp, 0xbbbbbb);
}else if(dizzy > 0){
channels_set_bg_rgb8(&channels, 0, 60 - dizzy, 0);
float f = dizzy / 80.0;
channels_set_bg_rgb8(&channels, 0, 60 - 60 * f, 0);
ncplane_set_fg_rgb(ncp, 0xbbbbbb);
}
ncplane_set_base(ncp, " ", 0, channels);
ncplane_set_base(ncp, "", 0, channels);
ncplane_putstr(ncp, curry);
fprintf(stderr, "DIZZY (%s) %d\n", (const char*)curry, dizzy);
return 0;
}
@ -387,6 +393,9 @@ tree_ui(struct notcurses* nc, struct nctree* tree){
if(nctree_redraw(tree)){
return -1;
}
if(notcurses_render(nc)){
return -1;
}
continue;
}
if(ni.id == 'q'){

Loading…
Cancel
Save