demos: use ncalign_center throughout

pull/138/head
nick black 5 years ago
parent a72bf25907
commit 21c4a9a2eb
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -28,46 +28,25 @@ int box_demo(struct notcurses* nc){
int ytargbase = (ylen - targy) / 2;
ncplane_set_fg_rgb(n, 180, 40, 180);
ncplane_bg_default(n);
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
if(ncplane_putstr_aligned(n, ytargbase++, "┏━━┳━━┓", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_putstr(n, "┏━━┳━━┓") < 0){
if(ncplane_putstr_aligned(n, ytargbase++, "┃┌─╂─┐┃", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
if(ncplane_putstr_aligned(n, ytargbase++, "┃│╲╿╱│┃", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_putstr(n, "┃┌─╂─┐┃") < 0){
if(ncplane_putstr_aligned(n, ytargbase++, "┣┿╾╳╼┿┫", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
if(ncplane_putstr_aligned(n, ytargbase++, "┃│╱╽╲│┃", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_putstr(n, "┃│╲╿╱│┃") < 0){
if(ncplane_putstr_aligned(n, ytargbase++, "┃└─╂─┘┃", NCALIGN_CENTER) < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
return -1;
}
if(ncplane_putstr(n, "┣┿╾╳╼┿┫") < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
return -1;
}
if(ncplane_putstr(n, "┃│╱╽╲│┃") < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
return -1;
}
if(ncplane_putstr(n, "┃└─╂─┘┃") < 0){
return -1;
}
if(ncplane_cursor_move_yx(n, ytargbase++, (xlen - targx) / 2)){
return -1;
}
if(ncplane_putstr(n, "┗━━┻━━┛") < 0){
if(ncplane_putstr_aligned(n, ytargbase++, "┗━━┻━━┛", NCALIGN_CENTER) < 0){
return -1;
}
ncplane_set_fg_rgb(n, 255, 255, 255);

@ -60,22 +60,13 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
if(ncplane_set_bg_rgb(on, 0, 180, 180)){
return NULL;
}
if(ncplane_cursor_move_yx(on, ++ybase, (*cols - strlen(str0)) / 2)){
if(ncplane_putstr_aligned(on, ++ybase, str0, NCALIGN_CENTER) < 0){
return NULL;
}
if(ncplane_putstr(on, str0) < 0){
if(ncplane_putstr_aligned(on, ++ybase, str1, NCALIGN_CENTER) < 0){
return NULL;
}
if(ncplane_cursor_move_yx(on, ++ybase, (*cols - strlen(str1)) / 2)){
return NULL;
}
if(ncplane_putstr(on, str1) < 0){
return NULL;
}
if(ncplane_cursor_move_yx(on, ++ybase, (*cols - (strlen(str2) - 4)) / 2)){
return NULL;
}
if(ncplane_putstr(on, str2) < 0){
if(ncplane_putstr_aligned(on, ++ybase, str2, NCALIGN_CENTER) < 0){
return NULL;
}
if(notcurses_render(nc)){

@ -109,12 +109,9 @@ fill_chunk(struct ncplane* n, int idx){
return -1;
}
if(maxx >= 4 && maxy >= 3){
if(ncplane_cursor_move_yx(n, (maxy - 1) / 2, (maxx - 2) / 2)){
return -1;
}
ncplane_set_fg_rgb(n, 0, 0, 0);
ncplane_set_bg_rgb(n, r, g, b);
if(ncplane_putstr(n, buf) <= 0){
if(ncplane_putstr_aligned(n, (maxy - 1) / 2, buf, NCALIGN_CENTER) <= 0){
return -1;
}
}

Loading…
Cancel
Save