mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
add notcurses_cantruecolor()
This commit is contained in:
parent
5a466ade18
commit
79d3ae67e4
3
NEWS.md
3
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
|
||||
|
3
USAGE.md
3
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);
|
||||
|
||||
|
@ -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)**
|
||||
|
@ -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);**
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user