diff --git a/NEWS.md b/NEWS.md index 4169a8c4a..15e7f5b9f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,9 @@ rearrangements of Notcurses. * `ncdirect_render_image()` has been added, allowing images to be rendered in direct mode. * `ncvisual_geom()` now takes scaling into account. + * **notcurses_cantruecolor()** has been added, allowing clients to + determine whether the full RGB space is available to us. If not, + we only have palette-indexed pseudocolor. * 1.5.1 (2020-07-15) * The semantics of rendering have changed slightly. In 1.5.0 and prior diff --git a/USAGE.md b/USAGE.md index 54eaad38e..fe610717a 100644 --- a/USAGE.md +++ b/USAGE.md @@ -237,6 +237,9 @@ int notcurses_palette_size(const struct notcurses* nc); // Can we fade? Fading requires either the "rgb" or "ccc" terminfo capability. bool notcurses_canfade(const struct notcurses* nc); +// Can we directly specify RGB values per cell, or only use palettes? +bool notcurses_can_truecolor(const struct notcurses* nc); + // Can we load images? This requires being built against FFmpeg/OIIO. bool notcurses_canopen_images(const struct notcurses* nc); diff --git a/doc/man/man3/notcurses.3.md b/doc/man/man3/notcurses.3.md index cb3494ec2..c84d473fd 100644 --- a/doc/man/man3/notcurses.3.md +++ b/doc/man/man3/notcurses.3.md @@ -137,7 +137,8 @@ previous action. **ncurses(3NCURSES)**, **notcurses-demo(1)**, **notcurses-input(1)**, -**notcurses_cell(3)**, **notcurses_channels(3)**, +**notcurses_cell(3)**, +**notcurses_channels(3)**, **notcurses_directmode(3)**, **notcurses_error(3)**, **notcurses_fade(3)**, @@ -157,7 +158,8 @@ previous action. **notcurses_render(3)**, **notcurses_selector(3)**, **notcurses_stats(3)**, -**notcurses_stdplane(3)**, **notcurses_stop(3)**, +**notcurses_stdplane(3)**, +**notcurses_stop(3)**, **notcurses_visual(3)**, **terminfo(5)**, **ascii(7)**, **utf-8(7)**, **unicode(7)** diff --git a/doc/man/man3/notcurses_palette.3.md b/doc/man/man3/notcurses_palette.3.md index ffa33fe0f..f5b476a9a 100644 --- a/doc/man/man3/notcurses_palette.3.md +++ b/doc/man/man3/notcurses_palette.3.md @@ -17,6 +17,8 @@ typedef struct palette256 { } palette256; ``` +**bool notcurses_cantruecolor(const struct notcurses* nc);** + **palette256* palette256_new(struct notcurses* nc);** **int palette256_use(struct notcurses* nc, const palette256* p);** diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 92856a343..61aa5c492 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1148,6 +1148,9 @@ API unsigned notcurses_supported_styles(const struct notcurses* nc); // more colors than they actually support, downsampling internally. API int notcurses_palette_size(const struct notcurses* nc); +// Can we directly specify RGB values per cell, or only use palettes? +API bool notcurses_cantruecolor(const struct notcurses* nc); + // Can we fade? Fading requires either the "rgb" or "ccc" terminfo capability. API bool notcurses_canfade(const struct notcurses* nc); @@ -1163,7 +1166,7 @@ API bool notcurses_canopen_videos(const struct notcurses* nc); // Is our encoding UTF-8? Requires LANG being set to a UTF8 locale. API bool notcurses_canutf8(const struct notcurses* nc); -// Can we blit to Sixel? This requires being built against libsixel. +// Can we blit to Sixel? API bool notcurses_cansixel(const struct notcurses* nc); typedef struct ncstats { diff --git a/python/src/notcurses/build_notcurses.py b/python/src/notcurses/build_notcurses.py index 1d6937702..580bc47d0 100644 --- a/python/src/notcurses/build_notcurses.py +++ b/python/src/notcurses/build_notcurses.py @@ -104,6 +104,7 @@ typedef enum { struct ncplane* ncplane_aligned(struct ncplane* n, int rows, int cols, int yoff, ncalign_e align, void* opaque); unsigned notcurses_supported_styles(const struct notcurses* nc); int notcurses_palette_size(const struct notcurses* nc); +bool notcurses_cantruecolor(const struct notcurses* nc); bool notcurses_canfade(const struct notcurses* nc); bool notcurses_canchangecolor(const struct notcurses* nc); bool notcurses_canopen_images(const struct notcurses* nc); diff --git a/src/fetch/main.c b/src/fetch/main.c index 5d594f753..0688f9d1f 100644 --- a/src/fetch/main.c +++ b/src/fetch/main.c @@ -41,6 +41,10 @@ fetch_env_vars(fetched_info* fi){ static distro_info distros[] = { { + .name = "arch", + // from core/filesystem + .logofile = "/usr/share/pixmaps/archlinux.png", + }, { .name = "debian", // from desktop-base package .logofile = "/usr/share/desktop-base/debian-logos/logo-text-256.png", @@ -116,7 +120,7 @@ fetch_x_props(fetched_info* fi){ } static const distro_info* -getdistro(fetched_info* fi){ +linux_ncneofetch(fetched_info* fi){ FILE* osinfo = fopen("/etc/os-release", "re"); if(osinfo == NULL){ return NULL; @@ -187,17 +191,6 @@ unix_gethostname(fetched_info* fi){ return -1; } -static const distro_info* -linux_ncneofetch(fetched_info* fi){ - const distro_info* dinfo = getdistro(fi); - if(dinfo == NULL){ - return NULL; - } - unix_gethostname(fi); - unix_getusername(fi); - return dinfo; -} - typedef enum { NCNEO_LINUX, NCNEO_FREEBSD, @@ -260,8 +253,7 @@ freebsd_ncneofetch(fetched_info* fi){ .name = "FreeBSD", .logofile = NULL, // FIXME }; - unix_gethostname(fi); - unix_getusername(fi); + (void)fi; // FIXME set up distro_pretty return &fbsd; } @@ -370,7 +362,9 @@ struct marshal { static void* display_thread(void* vmarshal){ struct marshal* m = vmarshal; - display(m->nc, m->dinfo); + if(m->dinfo){ + display(m->nc, m->dinfo); + } drawpalette(m->nc); sem_post(&m->sem); pthread_detach(pthread_self()); @@ -398,14 +392,12 @@ ncneofetch(struct notcurses* nc){ .dinfo = fi.distro, }; sem_init(&display_marshal.sem, 0, 0); - if(fi.distro){ - pthread_t tid; - if(pthread_create(&tid, NULL, display_thread, &display_marshal)){ - sem_post(&display_marshal.sem); - } - }else{ + pthread_t tid; + if(pthread_create(&tid, NULL, display_thread, &display_marshal)){ sem_post(&display_marshal.sem); - } + } + unix_gethostname(&fi); + unix_getusername(&fi); fetch_env_vars(&fi); fetch_x_props(&fi); fetch_cpu_info(&fi); diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 30e3a49c2..4ecf25857 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1366,6 +1366,10 @@ int notcurses_palette_size(const notcurses* nc){ return nc->tcache.colors; } +bool notcurses_cantruecolor(const notcurses* nc){ + return nc->tcache.RGBflag; +} + // turn on any specified stylebits void ncplane_styles_on(ncplane* n, unsigned stylebits){ n->attrword |= (stylebits & NCSTYLE_MASK);