From 238ba10f3288f538fd5f85b4939b52621d2037af Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 1 Jul 2020 03:18:23 -0400 Subject: [PATCH] ncneofetch: default background on palette --- src/fetch/main.c | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/fetch/main.c b/src/fetch/main.c index 448324d297..27416973e7 100644 --- a/src/fetch/main.c +++ b/src/fetch/main.c @@ -257,7 +257,7 @@ drawpalette(struct ncdirect* nc){ return -1; } } - if(ncdirect_bg_palindex(nc, 0)){ + if(ncdirect_bg_default(nc)){ return -1; } if(putchar('\n') == EOF){ @@ -267,29 +267,28 @@ drawpalette(struct ncdirect* nc){ return 0; } -static int +/*static int infoplane(struct ncdirect* nc, const fetched_info* fi){ + // FIXME look for an area without background logo in it. pick the one + // closest to the center horizontally, and lowest vertically. if none + // can be found, just center it on the bottom as we do now + const int dimy = ncdirect_dim_y(nc); + const int planeheight = 8; const int planewidth = 60; - const int infox = (ncdirect_dim_x(nc) - planewidth) / 2; - if(infox < 0){ - return -1; - } - printf("\n"); - ncdirect_fg_rgb(nc, 0xd0, 0xd0, 0xd0); - ncdirect_bg_rgb(nc, 0x50, 0x50, 0x50); - ncdirect_styles_set(nc, NCSTYLE_UNDERLINE); - if(ncdirect_cursor_move_yx(nc, -1, infox) < 0){ - return -1; - } - int r = printf(" %s %s", fi->kernel, fi->kernver); - if(r < 0){ + struct ncplane* infop = ncplane_aligned(notcurses_stdplane(nc), + planeheight, planewidth, + dimy - (planeheight + 1), + NCALIGN_CENTER, NULL); + if(infop == NULL){ return -1; } + ncplane_set_fg_rgb(infop, 0xd0, 0xd0, 0xd0); + ncplane_set_attr(infop, NCSTYLE_UNDERLINE); + ncplane_printf_aligned(infop, 1, NCALIGN_LEFT, " %s %s", fi->kernel, fi->kernver); if(fi->distro_pretty){ - printf("%*s ", planewidth - r, fi->distro_pretty); + ncplane_printf_aligned(infop, 1, NCALIGN_RIGHT, "%s ", fi->distro_pretty); } - ncdirect_styles_set(nc, NCSTYLE_NONE); - /* + ncplane_set_attr(infop, NCSTYLE_NONE); #ifdef __linux__ struct sysinfo sinfo; sysinfo(&sinfo); @@ -350,14 +349,11 @@ infoplane(struct ncdirect* nc, const fetched_info* fi){ fi->username, fi->hostname) < 0){ return -1; } - */ - ncdirect_fg_default(nc); - ncdirect_bg_default(nc); - if(printf("\n") < 0){ - return -1; - } + channels_set_fg_rgb(&channels, 0, 0, 0); + channels_set_bg_rgb(&channels, 0x50, 0x50, 0x50); + ncplane_set_base(infop, " ", 0, channels); return 0; -} +}*/ struct marshal { struct ncdirect* nc; @@ -413,9 +409,12 @@ ncneofetch(struct ncdirect* nc){ fetch_x_props(&fi); fetch_cpu_info(&fi); sem_wait(&display_marshal.sem); - if(infoplane(nc, &fi)){ + /*if(infoplane(nc, &fi)){ return -1; } + if(notcurses_render(nc)){ + return -1; + }*/ return 0; }