boxdemo: concentric boxes

pull/39/head
nick black 5 years ago committed by Nick Black
parent 5f053ab220
commit 2f43da2d16

@ -6,12 +6,7 @@ int box_demo(struct notcurses* nc){
int ymax, xmax; int ymax, xmax;
notcurses_term_dimyx(nc, &ymax, &xmax); notcurses_term_dimyx(nc, &ymax, &xmax);
struct ncplane* n = notcurses_stdplane(nc); struct ncplane* n = notcurses_stdplane(nc);
ncplane_cursor_move_yx(n, 0, 0);
cell ul, ll, lr, ur, hl, vl; cell ul, ll, lr, ur, hl, vl;
ncplane_erase(n);
if(notcurses_render(nc)){
return -1;
}
ncplane_fg_rgb8(n, 255, 255, 255); ncplane_fg_rgb8(n, 255, 255, 255);
cell_init(&ul); cell_init(&ul);
cell_init(&ur); cell_init(&ur);
@ -27,19 +22,16 @@ int box_demo(struct notcurses* nc){
cell_load(n, &hl, ""); cell_load(n, &hl, "");
cell_set_fg(&hl, 107, 40, 107); cell_set_fg(&hl, 107, 40, 107);
cell_set_bg(&vl, 107, 40, 107); cell_set_bg(&vl, 107, 40, 107);
if(ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ymax, xmax)){ int y = 0, x = 0;
return -1; while(ymax - y - 1 > 2 && xmax - x - 1 > 2){
} ncplane_cursor_move_yx(n, y, x);
cell_set_bg(&hl, 40, 107, 40); if(ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ymax, xmax)){
ncplane_cursor_move_yx(n, 1, 1); return -1;
if(ncplane_hline(n, &hl, xmax - 2) != xmax - 2){ }
return -1; ymax -= 2;
} xmax -= 2;
cell_set_fg(&hl, 40, 107, 40); ++y;
cell_set_bg(&hl, 0, 0, 0); ++x;
ncplane_cursor_move_yx(n, ymax - 2, 1);
if(ncplane_hline(n, &hl, xmax - 2) != xmax - 2){
return -1;
} }
cell_release(n, &ul); cell_release(n, &ul);
cell_release(n, &ur); cell_release(n, &ur);

Loading…
Cancel
Save