Skip to content

Commit

Permalink
tree PoC: supply indentcols, offer input #1164
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Feb 22, 2021
1 parent 27a971c commit ebcef33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ draw_tree_item(nctree* n, nctree_int_item* nii, const unsigned* path,
ymin = 0;
ymax = *frontiert;
}
//fprintf(stderr, "x: %d y: %d\n", startx, ymin);
struct ncplane_options nopts = {
.x = startx,
.y = ymin,
Expand Down
20 changes: 16 additions & 4 deletions src/poc/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ callback(struct ncplane* ncp, void* curry, int dizzy){
return 0;
}

static void
static int
tree_ui(struct notcurses* nc, struct nctree* tree){
ncinput ni;
while(notcurses_getc_blocking(nc, &ni) != (char32_t)-1){
fprintf(stderr, "ni: 0x%04x\n", ni.id);
(void)tree; // FIXME
if(nctree_offer_input(tree, &ni)){
if(nctree_redraw(tree)){
return -1;
}
continue;
}
if(ni.id == 'q'){
return 0;
}
}
return -1;
}

static struct nctree*
Expand All @@ -123,6 +131,7 @@ create_tree(struct notcurses* nc){
.items = &rads,
.count = 1,
.nctreecb = callback,
.indentcols = 2,
.flags = 0,
};
struct nctree* tree = nctree_create(notcurses_stdplane(nc), &topts);
Expand All @@ -145,8 +154,11 @@ int main(void){
notcurses_stop(nc);
return EXIT_FAILURE;
}
tree_ui(nc, tree);
int r = tree_ui(nc, tree);
nctree_destroy(tree);
notcurses_stop(nc);
if(r){
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

0 comments on commit ebcef33

Please sign in to comment.