convert all channel rgb calls #985

This commit is contained in:
nick black 2020-09-17 15:34:28 -04:00 committed by Nick Black
parent 0e34bec3fb
commit b7a57eaab7
62 changed files with 633 additions and 633 deletions

View File

@ -121,14 +121,14 @@ namespace ncpp
return cell_fchannel (&_cell);
}
unsigned get_fg () const noexcept
unsigned get_fg_rgb () const noexcept
{
return cell_fg (&_cell);
return cell_fg_rgb (&_cell);
}
unsigned get_bg () const noexcept
unsigned get_bg_rgb () const noexcept
{
return cell_bg (&_cell);
return cell_bg_rgb (&_cell);
}
unsigned get_fg_alpha () const noexcept
@ -156,24 +156,24 @@ namespace ncpp
return cell_set_bg_alpha (&_cell, alpha) != -1;
}
unsigned get_fg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
unsigned get_fg_rgb8 (unsigned *r, unsigned *g, unsigned *b) const noexcept
{
return cell_fg_rgb (&_cell, r, g, b);
return cell_fg_rgb8 (&_cell, r, g, b);
}
bool set_fg_rgb (int r, int g, int b, bool clipped = false) noexcept
bool set_fg_rgb8 (int r, int g, int b, bool clipped = false) noexcept
{
if (clipped) {
cell_set_fg_rgb_clipped (&_cell, r, g, b);
return true;
}
return cell_set_fg_rgb (&_cell, r, g, b) != -1;
return cell_set_fg_rgb8 (&_cell, r, g, b) != -1;
}
void set_fg (uint32_t channel) noexcept
void set_fg_rgb (uint32_t channel) noexcept
{
cell_set_fg (&_cell, channel);
cell_set_fg_rgb (&_cell, channel);
}
void set_fg_default () noexcept
@ -181,24 +181,24 @@ namespace ncpp
cell_set_fg_default (&_cell);
}
unsigned get_bg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
unsigned get_bg_rgb8 (unsigned *r, unsigned *g, unsigned *b) const noexcept
{
return cell_bg_rgb (&_cell, r, g, b);
return cell_bg_rgb8 (&_cell, r, g, b);
}
bool set_bg_rgb (int r, int g, int b, bool clipped = false) noexcept
bool set_bg_rgb8 (int r, int g, int b, bool clipped = false) noexcept
{
if (clipped) {
cell_set_bg_rgb_clipped (&_cell, r, g, b);
return true;
}
return cell_set_bg_rgb (&_cell, r, g, b) != -1;
return cell_set_bg_rgb8 (&_cell, r, g, b) != -1;
}
void set_bg (uint32_t channel) noexcept
void set_bg_rgb (uint32_t channel) noexcept
{
cell_set_bg (&_cell, channel);
cell_set_bg_rgb (&_cell, channel);
}
void set_bg_default () noexcept

View File

@ -38,14 +38,14 @@ namespace ncpp
return error_guard (ncdirect_fg_default (direct), -1);
}
bool set_fg (unsigned rgb) const NOEXCEPT_MAYBE
bool set_fg_rgb (unsigned rgb) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_fg (direct, rgb), -1);
return error_guard (ncdirect_fg_rgb (direct, rgb), -1);
}
bool set_fg (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
bool set_fg_rgb (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_fg_rgb (direct, r, g, b), -1);
return error_guard (ncdirect_fg_rgb8 (direct, r, g, b), -1);
}
bool fg_palindex (int pidx) const NOEXCEPT_MAYBE
@ -58,14 +58,14 @@ namespace ncpp
return error_guard (ncdirect_bg_default (direct), -1);
}
bool set_bg (unsigned rgb) const NOEXCEPT_MAYBE
bool set_bg_rgb (unsigned rgb) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_bg (direct, rgb), -1);
return error_guard (ncdirect_bg_rgb (direct, rgb), -1);
}
bool set_bg (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
bool set_bg_rgb (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_bg_rgb (direct, r, g, b), -1);
return error_guard (ncdirect_bg_rgb8 (direct, r, g, b), -1);
}
bool bg_palindex (int pidx) const NOEXCEPT_MAYBE

View File

@ -36,7 +36,7 @@ namespace ncpp
bool set (int idx, int r, int g, int b) const NOEXCEPT_MAYBE
{
return error_guard (palette256_set_rgb (palette, idx, r, g, b), -1);
return error_guard (palette256_set_rgb8 (palette, idx, r, g, b), -1);
}
bool set (int idx, unsigned rgb) const NOEXCEPT_MAYBE
@ -58,7 +58,7 @@ namespace ncpp
bool get (int idx, unsigned &r, unsigned &g, unsigned &b) const NOEXCEPT_MAYBE
{
return error_guard (palette256_get_rgb (palette, idx, &r, &g, &b), -1);
return error_guard (palette256_get_rgb8 (palette, idx, &r, &g, &b), -1);
}
private:

View File

@ -689,14 +689,14 @@ namespace ncpp
return ncplane_fchannel (plane);
}
unsigned get_fg () const noexcept
unsigned get_fg_rgb () const noexcept
{
return ncplane_fg (plane);
return ncplane_fg_rgb (plane);
}
unsigned get_bg () const noexcept
unsigned get_bg_rgb () const noexcept
{
return ncplane_bg (plane);
return ncplane_bg_rgb (plane);
}
unsigned get_fg_alpha () const noexcept
@ -729,19 +729,19 @@ namespace ncpp
return error_guard (ncplane_set_bg_alpha (plane, alpha), -1);
}
unsigned get_fg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
unsigned get_fg_rgb8 (unsigned *r, unsigned *g, unsigned *b) const noexcept
{
return ncplane_fg_rgb (plane, r, g, b);
return ncplane_fg_rgb8 (plane, r, g, b);
}
bool set_fg_rgb (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
bool set_fg_rgb8 (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
{
if (clipped) {
ncplane_set_fg_rgb_clipped (plane, r, g, b);
return true;
}
return error_guard (ncplane_set_fg_rgb (plane, r, g, b), -1);
return error_guard (ncplane_set_fg_rgb8 (plane, r, g, b), -1);
}
bool set_fg_palindex (int idx) const NOEXCEPT_MAYBE
@ -749,9 +749,9 @@ namespace ncpp
return error_guard (ncplane_set_fg_palindex (plane, idx), -1);
}
bool set_fg (uint32_t channel) const NOEXCEPT_MAYBE
bool set_fg_rgb (uint32_t channel) const NOEXCEPT_MAYBE
{
return error_guard (ncplane_set_fg (plane, channel), -1);
return error_guard (ncplane_set_fg_rgb (plane, channel), -1);
}
void set_fg_default () const noexcept
@ -759,19 +759,19 @@ namespace ncpp
ncplane_set_fg_default (plane);
}
unsigned get_bg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
unsigned get_bg_rgb8 (unsigned *r, unsigned *g, unsigned *b) const noexcept
{
return ncplane_bg_rgb (plane, r, g, b);
return ncplane_bg_rgb8 (plane, r, g, b);
}
bool set_bg_rgb (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
bool set_bg_rgb8 (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
{
if (clipped) {
ncplane_set_fg_rgb_clipped (plane, r, g, b);
return true;
}
return error_guard (ncplane_set_bg_rgb (plane, r, g, b), -1);
return error_guard (ncplane_set_bg_rgb8 (plane, r, g, b), -1);
}
bool set_bg_palindex (int idx) const NOEXCEPT_MAYBE
@ -779,9 +779,9 @@ namespace ncpp
return error_guard (ncplane_set_bg_alpha (plane, idx), -1);
}
bool set_bg (uint32_t channel) const NOEXCEPT_MAYBE
bool set_bg_rgb (uint32_t channel) const NOEXCEPT_MAYBE
{
return error_guard (ncplane_set_bg (plane, channel), -1);
return error_guard (ncplane_set_bg_rgb (plane, channel), -1);
}
void set_bg_default () const noexcept

View File

@ -21,8 +21,8 @@ API struct ncdirect* ncdirect_init(const char* termtype, FILE* fp, uint64_t flag
// Direct mode. This API can be used to colorize and stylize output generated
// outside of notcurses, without ever calling notcurses_render(). These should
// not be intermixed with standard notcurses rendering.
API int ncdirect_fg(struct ncdirect* nc, unsigned rgb);
API int ncdirect_bg(struct ncdirect* nc, unsigned rgb);
API int ncdirect_fg_rgb(struct ncdirect* nc, unsigned rgb);
API int ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb);
API int ncdirect_fg_palindex(struct ncdirect* nc, int pidx);
API int ncdirect_bg_palindex(struct ncdirect* nc, int pidx);
@ -41,19 +41,19 @@ API int ncdirect_putstr(struct ncdirect* nc, uint64_t channels, const char* utf8
API int ncdirect_flush(const struct ncdirect* nc);
static inline int
ncdirect_bg_rgb(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){
return -1;
}
return ncdirect_bg(nc, (r << 16u) + (g << 8u) + b);
return ncdirect_bg_rgb(nc, (r << 16u) + (g << 8u) + b);
}
static inline int
ncdirect_fg_rgb(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){
return -1;
}
return ncdirect_fg(nc, (r << 16u) + (g << 8u) + b);
return ncdirect_fg_rgb(nc, (r << 16u) + (g << 8u) + b);
}
API int ncdirect_fg_default(struct ncdirect* nc);

View File

@ -60,7 +60,7 @@ allglyphs(struct notcurses* nc, struct ncplane* column, int legendy){
}
ncplane_set_attr(std, NCSTYLE_NONE);
DEMO_RENDER(nc);
ncplane_set_fg_rgb(column,
ncplane_set_fg_rgb8(column,
random() % 192 + 64,
random() % 192 + 64,
random() % 192 + 64);
@ -82,15 +82,15 @@ int allglyphs_demo(struct notcurses* nc){
ncplane_erase(n);
ncplane_home(n);
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
channel_set_rgb(&tl, 0, 0, 0);
channel_set_rgb(&tr, 0, 0xff, 0);
channel_set_rgb(&bl, 0, 0, 0xff);
channel_set_rgb(&br, 0, 0xff, 0xff);
channel_set_rgb8(&tl, 0, 0, 0);
channel_set_rgb8(&tr, 0, 0xff, 0);
channel_set_rgb8(&bl, 0, 0, 0xff);
channel_set_rgb8(&br, 0, 0xff, 0xff);
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) < 0){
return -1;
}
ncplane_set_fg(n, 0xf0f0a0);
ncplane_set_bg(n, 0);
ncplane_set_fg_rgb(n, 0xf0f0a0);
ncplane_set_bg_rgb(n, 0);
int width = 40;
if(width > dimx - 8){
if((width = dimx - 8) <= 0){

View File

@ -96,7 +96,7 @@ int box_demo(struct notcurses* nc){
cell_set_bg_default(&c);
ncplane_set_base_cell(n, &c);
cell_release(n, &c);
ncplane_set_fg_rgb(n, 180, 40, 180);
ncplane_set_fg_rgb8(n, 180, 40, 180);
ncplane_set_bg_default(n);
if(notcurses_canutf8(nc)){
if(utf8_target(n, ytargbase)){
@ -107,28 +107,28 @@ int box_demo(struct notcurses* nc){
return -1;
}
}
if(cell_set_fg_rgb(&ul, 0xff, 0, 0)){
if(cell_set_fg_rgb8(&ul, 0xff, 0, 0)){
return -1;
}
if(cell_set_bg_rgb(&ul, 20, 40, 20)){
if(cell_set_bg_rgb8(&ul, 20, 40, 20)){
return -1;
}
if(cell_set_fg_rgb(&ur, 0, 0xff, 0)){
if(cell_set_fg_rgb8(&ur, 0, 0xff, 0)){
return -1;
}
if(cell_set_bg_rgb(&ur, 20, 40, 20)){
if(cell_set_bg_rgb8(&ur, 20, 40, 20)){
return -1;
}
if(cell_set_fg_rgb(&ll, 0, 0, 0xff)){
if(cell_set_fg_rgb8(&ll, 0, 0, 0xff)){
return -1;
}
if(cell_set_bg_rgb(&ll, 20, 40, 20)){
if(cell_set_bg_rgb8(&ll, 20, 40, 20)){
return -1;
}
if(cell_set_fg_rgb(&lr, 0xff, 0xff, 0xff)){
if(cell_set_fg_rgb8(&lr, 0xff, 0xff, 0xff)){
return -1;
}
if(cell_set_bg_rgb(&lr, 20, 40, 20)){
if(cell_set_bg_rgb8(&lr, 20, 40, 20)){
return -1;
}
int y = 1, x = 0;

View File

@ -104,20 +104,20 @@ static struct {
static void
usage_option(FILE* out, struct ncdirect* n, const char* op){
if(n) ncdirect_fg_rgb(n, 0x80, 0x80, 0x80);
if(n) ncdirect_fg_rgb8(n, 0x80, 0x80, 0x80);
fprintf(out, " [ ");
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, "%s", op);
if(n) ncdirect_fg_rgb(n, 0x80, 0x80, 0x80);
if(n) ncdirect_fg_rgb8(n, 0x80, 0x80, 0x80);
fprintf(out, " ] ");
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
}
static void
usage_expo(FILE* out, struct ncdirect* n, const char* op, const char* expo){
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " %s: ", op);
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, "%s\n", expo);
}
@ -126,9 +126,9 @@ static void
usage(const char* exe, int status){
FILE* out = status == EXIT_SUCCESS ? stdout : stderr;
struct ncdirect* n = ncdirect_init(NULL, out, 0);
if(n) ncdirect_fg_rgb(n, 0x00, 0xc0, 0xc0);
if(n) ncdirect_fg_rgb8(n, 0x00, 0xc0, 0xc0);
fprintf(out, "usage: ");
if(n) ncdirect_fg_rgb(n, 0x80, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0x80, 0xff, 0x80);
fprintf(out, "%s ", exe);
const char* options[] = { "-hVikc", "-m margins", "-p path", "-l loglevel",
"-d mult", "-J jsonfile", "-f renderfile", "demospec",
@ -137,7 +137,7 @@ usage(const char* exe, int status){
usage_option(out, n, *op);
}
fprintf(out, "\n\n");
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
const char* optexpo[] = {
"-h", "this message",
"-V", "print program name and version",
@ -154,18 +154,18 @@ usage(const char* exe, int status){
const char* expo = op[1];
usage_expo(out, n, *op, expo);
}
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " -l:");
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, " logging level (%d: silent..%d: manic)\n", NCLOGLEVEL_SILENT, NCLOGLEVEL_TRACE);
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " -p:");
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, " data file path (default: %s)\n", NOTCURSES_SHARE);
fprintf(out, "\nspecify demos via their first letter. repetitions are allowed.\n");
if(n) ncdirect_fg_rgb(n, 0x80, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0x80, 0xff, 0x80);
fprintf(out, " default spec: %s\n\n", DEFAULT_DEMO);
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
int printed = 0;
for(size_t i = 0 ; i < sizeof(demos) / sizeof(*demos) ; ++i){
if(demos[i].name){
@ -173,9 +173,9 @@ usage(const char* exe, int status){
fprintf(out, " ");
}
// U+24D0: CIRCLED LATIN SMALL LETTER A
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0x80);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, "%lc ", *demos[i].name - 'a' + 0x24d0);
if(n) ncdirect_fg_rgb(n, 0xff, 0xff, 0xff);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, "%-*.*s", 8, 8, demos[i].name + 1);
if(++printed % 6 == 0){
fprintf(out, "\n");
@ -219,8 +219,8 @@ ext_demos(struct notcurses* nc, const char* spec, bool ignore_failures){
// erase the plane (we let one demo bleed through to the next, an effect
// we exploit in a few transitions).
cell c = CELL_TRIVIAL_INITIALIZER;
cell_set_fg_rgb(&c, 0, 0, 0);
cell_set_bg_rgb(&c, 0, 0, 0);
cell_set_fg_rgb8(&c, 0, 0, 0);
cell_set_bg_rgb8(&c, 0, 0, 0);
ncplane_set_base_cell(n, &c);
cell_release(n, &c);
@ -356,9 +356,9 @@ handle_opts(int argc, char** argv, notcurses_options* opts,
static int
table_segment_color(struct ncdirect* nc, const char* str, const char* delim, unsigned color){
ncdirect_fg(nc, color);
ncdirect_fg_rgb(nc, color);
fputs(str, stdout);
ncdirect_fg_rgb(nc, 178, 102, 255);
ncdirect_fg_rgb8(nc, 178, 102, 255);
fputs(delim, stdout);
return 0;
}
@ -370,12 +370,12 @@ table_segment(struct ncdirect* nc, const char* str, const char* delim){
static int
table_printf(struct ncdirect* nc, const char* delim, const char* fmt, ...){
ncdirect_fg_rgb(nc, 0xD4, 0xAF, 0x37);
ncdirect_fg_rgb8(nc, 0xD4, 0xAF, 0x37);
va_list va;
va_start(va, fmt);
vfprintf(stdout, fmt, va);
va_end(va);
ncdirect_fg_rgb(nc, 178, 102, 255);
ncdirect_fg_rgb8(nc, 178, 102, 255);
fputs(delim, stdout);
return 0;
}
@ -437,13 +437,13 @@ summary_table(struct ncdirect* nc, const char* spec){
}else{
rescolor = 0x32CD32;
}
ncdirect_fg(nc, rescolor);
ncdirect_fg_rgb(nc, rescolor);
printf("%2zu", i);
ncdirect_fg_rgb(nc, 178, 102, 255);
ncdirect_fg_rgb8(nc, 178, 102, 255);
printf("");
ncdirect_fg(nc, rescolor);
ncdirect_fg_rgb(nc, rescolor);
printf("%8s", demos[results[i].selector - 'a'].name);
ncdirect_fg_rgb(nc, 178, 102, 255);
ncdirect_fg_rgb8(nc, 178, 102, 255);
printf("│%*ss│%7ju│%*s│ %*ss│%3jd│%7.1f│%*s║",
PREFIXFMT(timebuf), (uintmax_t)(results[i].stats.renders),
BPREFIXFMT(totalbuf), PREFIXFMT(rtimebuf),
@ -452,7 +452,7 @@ summary_table(struct ncdirect* nc, const char* spec){
results[i].timens ?
results[i].stats.renders / ((double)results[i].timens / GIG) : 0.0,
PREFIXFMT(tfpsbuf));
ncdirect_fg(nc, rescolor);
ncdirect_fg_rgb(nc, rescolor);
printf("%s\n", results[i].result < 0 ? "FAILED" :
results[i].result > 0 ? "ABORTED" :
!results[i].stats.renders ? "SKIPPED" : "");
@ -475,17 +475,17 @@ summary_table(struct ncdirect* nc, const char* spec){
table_printf(nc, "", "%3ld", nsdelta ? totalrenderns * 100 / nsdelta : 0);
table_printf(nc, "", "%7.1f", nsdelta ? totalframes / ((double)nsdelta / GIG) : 0);
printf("\n");
ncdirect_fg_rgb(nc, 0xff, 0xb0, 0xb0);
ncdirect_fg_rgb8(nc, 0xff, 0xb0, 0xb0);
fflush(stdout); // in case we print to stderr below, we want color from above
if(failed){
fprintf(stderr, "\nError running demo.\nIs \"%s\" the correct data path? Supply it with -p.\n", datadir);
}
#ifdef DFSG_BUILD
ncdirect_fg_rgb(nc, 0xfe, 0x20, 0x76); // PANTONE Strong Red C + 3x0x20
ncdirect_fg_rgb8(nc, 0xfe, 0x20, 0x76); // PANTONE Strong Red C + 3x0x20
fflush(stdout); // in case we print to stderr below, we want color from above
fprintf(stderr, "\nDFSG version. Some demos are unavailable.\n");
#elif !defined(USE_MULTIMEDIA) // don't double-print for DFSG
ncdirect_fg_rgb(nc, 0xfe, 0x20, 0x76); // PANTONE Strong Red C + 3x0x20
ncdirect_fg_rgb8(nc, 0xfe, 0x20, 0x76); // PANTONE Strong Red C + 3x0x20
fflush(stdout); // in case we print to stderr below, we want color from above
fprintf(stderr, "\nNo multimedia support. Some demos are unavailable.\n");
#endif
@ -496,8 +496,8 @@ static int
scrub_stdplane(struct notcurses* nc){
struct ncplane* n = notcurses_stdplane(nc);
uint64_t channels = 0;
channels_set_fg(&channels, 0); // explicit black + opaque
channels_set_bg(&channels, 0);
channels_set_fg_rgb(&channels, 0); // explicit black + opaque
channels_set_bg_rgb(&channels, 0);
if(ncplane_set_base(n, "", 0, channels)){
return -1;
}

View File

@ -120,26 +120,26 @@ draw_eagle(struct ncplane* n, const char* sprite){
case '0':
break;
case '1':
ncplane_set_fg_rgb(n, 0xff, 0xff, 0xff);
ncplane_set_fg_rgb8(n, 0xff, 0xff, 0xff);
break;
case '2':
ncplane_set_fg_rgb(n, 0xe3, 0x9d, 0x25);
ncplane_set_fg_rgb8(n, 0xe3, 0x9d, 0x25);
break;
case '3':
ncplane_set_fg_rgb(n, 0x3a, 0x84, 0x00);
ncplane_set_fg_rgb8(n, 0x3a, 0x84, 0x00);
break;
}
if(sprite[s] != '0'){
unsigned f, b;
f = ncplane_fg(n);
b = ncplane_bg(n);
ncplane_set_fg(n, b);
ncplane_set_bg(n, f);
f = ncplane_fg_rgb(n);
b = ncplane_bg_rgb(n);
ncplane_set_fg_rgb(n, b);
ncplane_set_bg_rgb(n, f);
if(ncplane_putegc_yx(n, s / 16, s % 16, " ", &sbytes) != 1){
return -1;
}
ncplane_set_fg(n, f);
ncplane_set_bg(n, b);
ncplane_set_fg_rgb(n, f);
ncplane_set_bg_rgb(n, b);
}
}
return 0;

View File

@ -3,19 +3,19 @@
// clip and set
static int
ccell_set_fg_rgb(cell* c, int r, int g, int b){
ccell_set_fg_rgb8(cell* c, int r, int g, int b){
if(r < 0) r = 0;
if(g < 0) g = 0;
if(b < 0) b = 0;
return cell_set_fg_rgb(c, r, g, b);
return cell_set_fg_rgb8(c, r, g, b);
}
static int
ccell_set_bg_rgb(cell* c, int r, int g, int b){
ccell_set_bg_rgb8(cell* c, int r, int g, int b){
if(r < 0) r = 0;
if(g < 0) g = 0;
if(b < 0) b = 0;
return cell_set_bg_rgb(c, r, g, b);
return cell_set_bg_rgb8(c, r, g, b);
}
static void
@ -90,7 +90,7 @@ prep_cells(struct ncplane* n,
static int
bgnext(cell* c, int* r, int* g, int* b){
int ret = ccell_set_bg_rgb(c, *r, *g, *b);
int ret = ccell_set_bg_rgb8(c, *r, *g, *b);
if(*g % 2){
if(--*b <= 0){
if(++*g >= 256){
@ -123,46 +123,46 @@ gridinv_demo(struct notcurses* nc, struct ncplane *n){
int x = 0;
int y = 1;
// top line
ccell_set_fg_rgb(&ul, i / 2, i, i / 2);
ccell_set_bg_rgb(&ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&ul, i / 2, i, i / 2);
ccell_set_bg_rgb8(&ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc_yx(n, y, x, &ul);
for(x = 1 ; x < maxx - 1 ; ++x){
ccell_set_fg_rgb(&uc, i / 2, i, i / 2);
ccell_set_bg_rgb(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&uc, i / 2, i, i / 2);
ccell_set_bg_rgb8(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &uc);
}
ccell_set_fg_rgb(&ur, i / 2, i, i / 2);
ccell_set_bg_rgb(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&ur, i / 2, i, i / 2);
ccell_set_bg_rgb8(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &ur);
// center
for(++y ; y < maxy - 1 ; ++y){
x = 0;
ccell_set_fg_rgb(&cl, i / 2, i, i / 2);
ccell_set_bg_rgb(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&cl, i / 2, i, i / 2);
ccell_set_bg_rgb8(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc_yx(n, y, x, &cl);
for(x = 1 ; x < maxx - 1 ; ++x){
ccell_set_fg_rgb(&cc, i / 2, i, i / 2);
ccell_set_bg_rgb(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&cc, i / 2, i, i / 2);
ccell_set_bg_rgb8(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &cc);
}
ccell_set_fg_rgb(&cr, i / 2, i, i / 2);
ccell_set_bg_rgb(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&cr, i / 2, i, i / 2);
ccell_set_bg_rgb8(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &cr);
}
// bottom line
x = 0;
ccell_set_fg_rgb(&ll, i / 2, i, i / 2);
ccell_set_bg_rgb(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&ll, i / 2, i, i / 2);
ccell_set_bg_rgb8(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc_yx(n, y, x, &ll);
for(x = 1 ; x < maxx - 1 ; ++x){
ccell_set_fg_rgb(&lc, i / 2, i, i / 2);
ccell_set_bg_rgb(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&lc, i / 2, i, i / 2);
ccell_set_bg_rgb8(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &lc);
}
ccell_set_fg_rgb(&lr, i / 2, i, i / 2);
ccell_set_bg_rgb(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ccell_set_fg_rgb8(&lr, i / 2, i, i / 2);
ccell_set_bg_rgb8(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &lr);
DEMO_RENDER(nc);
@ -189,19 +189,19 @@ gridswitch_demo(struct notcurses* nc, struct ncplane *n){
int bgg = 0x80;
int bgb = i;
// top line
ret |= ccell_set_fg_rgb(&ul, 255 - rs * y, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_fg_rgb8(&ul, 255 - rs * y, 255 - gs * (x + y), 255 - bs * y);
ret |= bgnext(&ul, &bgr, &bgg, &bgb);
if(ncplane_putc_yx(n, y, x, &ul) <= 0){
return -1;
}
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_fg_rgb(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&uc, &bgr, &bgg, &bgb);
if(ncplane_putc(n, &uc) <= 0){
return -1;
}
}
ret |= ccell_set_fg_rgb(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&ur, &bgr, &bgg, &bgb);
if(ncplane_putc(n, &ur) < 0){
return -1;
@ -210,30 +210,30 @@ gridswitch_demo(struct notcurses* nc, struct ncplane *n){
// center
for(++y ; y < maxy - 1 ; ++y){
x = 0;
ret |= ccell_set_fg_rgb(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&cl, &bgr, &bgg, &bgb);
ncplane_putc_yx(n, y, x, &cl);
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_fg_rgb(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&cc, &bgr, &bgg, &bgb);
ncplane_putc(n, &cc);
}
ret |= ccell_set_fg_rgb(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&cr, &bgr, &bgg, &bgb);
ncplane_putc(n, &cr);
}
// bottom line
x = 0;
ret |= ccell_set_fg_rgb(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&ll, &bgr, &bgg, &bgb);
ncplane_putc_yx(n, y, x, &ll);
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_fg_rgb(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&lc, &bgr, &bgg, &bgb);
ncplane_putc(n, &lc);
}
ret |= ccell_set_fg_rgb(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= ccell_set_fg_rgb8(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * x);
ret |= bgnext(&lr, &bgr, &bgg, &bgb);
ncplane_putc(n, &lr);
@ -264,20 +264,20 @@ int grid_demo(struct notcurses* nc){
// top line
x = 0;
y = 1;
ret |= ccell_set_bg_rgb(&ul, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&ul, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc_yx(n, y, 0, &ul) <= 0){
return -1;
}
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_bg_rgb(&uc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&uc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &uc) <= 0){
return -1;
}
}
ret |= ccell_set_bg_rgb(&ur, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&ur, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &ur) <= 0){
return -1;
}
@ -285,20 +285,20 @@ int grid_demo(struct notcurses* nc){
// center
for(++y ; y < maxy - 1 ; ++y){
x = 0;
ret |= ccell_set_bg_rgb(&cl, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&cl, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc_yx(n, y, x, &cl) <= 0){
return -1;
}
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_bg_rgb(&cc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&cc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &cc) <= 0){
return -1;
}
}
ret |= ccell_set_bg_rgb(&cr, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&cr, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &cr) <= 0){
return -1;
}
@ -306,20 +306,20 @@ int grid_demo(struct notcurses* nc){
// bottom line
x = 0;
ret |= ccell_set_bg_rgb(&ll, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&ll, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc_yx(n, y, x, &ll) <= 0){
return -1;
}
for(x = 1 ; x < maxx - 1 ; ++x){
ret |= ccell_set_bg_rgb(&lc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&lc, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &lc) <= 0){
return -1;
}
}
ret |= ccell_set_bg_rgb(&lr, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ret |= ccell_set_bg_rgb8(&lr, i, x * rs, y * bs);
ret |= ccell_set_fg_rgb8(&lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
if(ncplane_putc(n, &lr) <= 0){
return -1;
}

View File

@ -83,7 +83,7 @@ int highcontrast_demo(struct notcurses* nc){
total = r = g = b = 0;
}
cell_load_char(n, &c, motto[out % strlen(motto)]);
cell_set_bg(&c, scrcolors[out % totcells]);
cell_set_bg_rgb(&c, scrcolors[out % totcells]);
if(ncplane_putc_yx(n, (out + dimx) / dimx, out % dimx, &c) < 0){
free(scrcolors);
goto err;
@ -103,15 +103,15 @@ int highcontrast_demo(struct notcurses* nc){
const int f = offset - 1 + dimx;
const int l = totcells + dimx - offset;
ncplane_at_yx_cell(n, f / dimx, f % dimx, &c);
cell_set_fg(&c, 0x004000 + (16 * offset));
cell_set_bg(&c, 0);
cell_set_fg_rgb(&c, 0x004000 + (16 * offset));
cell_set_bg_rgb(&c, 0);
cell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE);
if(ncplane_putc_yx(n, f / dimx, f % dimx, &c) < 0){
goto err;
}
ncplane_at_yx_cell(n, l / dimx, l % dimx, &c);
cell_set_fg(&c, 0x004000 + (16 * offset));
cell_set_bg(&c, 0);
cell_set_fg_rgb(&c, 0x004000 + (16 * offset));
cell_set_bg_rgb(&c, 0);
cell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE);
if(ncplane_putc_yx(n, l / dimx, l % dimx, &c) < 0){
goto err;

View File

@ -48,12 +48,12 @@ static struct ncplane* about; // "about" modal popup
#define MENUSTR_QUIT "Quit"
static int
hud_standard_bg(struct ncplane* n){
hud_standard_bg_rgb(struct ncplane* n){
uint64_t channels = 0;
channels_set_fg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_fg_rgb(&channels, 0x80, 0x80, 0x80);
channels_set_fg_rgb8(&channels, 0x80, 0x80, 0x80);
channels_set_bg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_bg_rgb(&channels, 0x80, 0x80, 0x80);
channels_set_bg_rgb8(&channels, 0x80, 0x80, 0x80);
if(ncplane_set_base(n, "", 0, channels) >= 0){
return -1;
}
@ -77,12 +77,12 @@ about_toggle(struct notcurses* nc){
// let the glyphs below show through, but only dimly
uint64_t channels = 0;
channels_set_fg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_fg_rgb(&channels, 0x0, 0x0, 0x0);
channels_set_fg_rgb8(&channels, 0x0, 0x0, 0x0);
channels_set_bg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_bg_rgb(&channels, 0x0, 0x0, 0x0);
channels_set_bg_rgb8(&channels, 0x0, 0x0, 0x0);
if(ncplane_set_base(n, "", 0, channels) >= 0){
ncplane_set_fg(n, 0x11ffff);
ncplane_set_bg(n, 0);
ncplane_set_fg_rgb(n, 0x11ffff);
ncplane_set_bg_rgb(n, 0);
ncplane_set_bg_alpha(n, CELL_ALPHA_BLEND);
ncplane_printf_aligned(n, 1, NCALIGN_CENTER, "notcurses-demo %s", notcurses_version());
ncplane_printf_aligned(n, 3, NCALIGN_LEFT, " P toggle plot");
@ -95,8 +95,8 @@ about_toggle(struct notcurses* nc){
cell lr = CELL_TRIVIAL_INITIALIZER, ll = CELL_TRIVIAL_INITIALIZER;
cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
channels = 0;
channels_set_fg(&channels, 0xc020c0);
channels_set_bg(&channels, 0);
channels_set_fg_rgb(&channels, 0xc020c0);
channels_set_bg_rgb(&channels, 0);
if(cells_rounded_box(n, NCSTYLE_NONE, channels, &ul, &ur, &ll, &lr, &hl, &vl) == 0){
if(ncplane_perimeter(n, &ul, &ur, &ll, &lr, &hl, &vl, 0) == 0){
cell_release(n, &ul); cell_release(n, &ur); cell_release(n, &hl);
@ -228,12 +228,12 @@ struct ncmenu* menu_create(struct notcurses* nc){
};
uint64_t headerchannels = 0;
uint64_t sectionchannels = 0;
channels_set_fg(&sectionchannels, 0xffffff);
channels_set_bg(&sectionchannels, 0x000000);
channels_set_fg_rgb(&sectionchannels, 0xffffff);
channels_set_bg_rgb(&sectionchannels, 0x000000);
channels_set_fg_alpha(&sectionchannels, CELL_ALPHA_HIGHCONTRAST);
channels_set_bg_alpha(&sectionchannels, CELL_ALPHA_BLEND);
channels_set_fg(&headerchannels, 0xffffff);
channels_set_bg(&headerchannels, 0x7f347f);
channels_set_fg_rgb(&headerchannels, 0xffffff);
channels_set_bg_rgb(&headerchannels, 0x7f347f);
channels_set_bg_alpha(&headerchannels, CELL_ALPHA_BLEND);
const ncmenu_options mopts = {
.sections = sections,
@ -296,9 +296,9 @@ hud_print_finished(elem* list){
if(hud){
cell c = CELL_TRIVIAL_INITIALIZER;
ncplane_base(hud, &c);
ncplane_set_bg(hud, cell_bg(&c));
ncplane_set_bg_rgb(hud, cell_bg_rgb(&c));
ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND);
ncplane_set_fg(hud, 0xffffff);
ncplane_set_fg_rgb(hud, 0xffffff);
ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE);
cell_release(hud, &c);
if(ncplane_printf_yx(hud, line, 1, "%d", e->frames) < 0){
@ -329,10 +329,10 @@ struct ncplane* hud_create(struct notcurses* nc){
if(n == NULL){
return NULL;
}
hud_standard_bg(n);
hud_standard_bg_rgb(n);
hud_refresh(n);
ncplane_set_fg(n, 0xffffff);
ncplane_set_bg(n, 0);
ncplane_set_fg_rgb(n, 0xffffff);
ncplane_set_bg_rgb(n, 0);
ncplane_set_bg_alpha(n, CELL_ALPHA_BLEND);
if(hud_hidden){
ncplane_move_bottom(n);
@ -386,7 +386,7 @@ int hud_release(void){
}
hud_grab_x = -1;
hud_grab_y = -1;
return hud_standard_bg(hud);
return hud_standard_bg_rgb(hud);
}
int fpsplot_release(void){
@ -397,7 +397,7 @@ int fpsplot_release(void){
return -1;
}
plot_grab_y = -1;
return hud_standard_bg(hud);
return hud_standard_bg_rgb(hud);
}
// currently running demo is always at y = HUD_ROWS-2
@ -497,9 +497,9 @@ int demo_render(struct notcurses* nc){
++elems->frames;
cell c = CELL_TRIVIAL_INITIALIZER;
ncplane_base(hud, &c);
ncplane_set_bg(hud, cell_bg(&c));
ncplane_set_bg_rgb(hud, cell_bg_rgb(&c));
ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND);
ncplane_set_fg(hud, 0x80d0ff);
ncplane_set_fg_rgb(hud, 0x80d0ff);
ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE);
cell_release(hud, &c);
ncplane_styles_on(hud, NCSTYLE_BOLD);
@ -537,20 +537,20 @@ int fpsgraph_init(struct notcurses* nc){
uint32_t style = 0;
uint64_t channels = 0;
channels_set_fg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_fg(&channels, 0x201020);
channels_set_fg_rgb(&channels, 0x201020);
channels_set_bg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_bg(&channels, 0x201020);
channels_set_bg_rgb(&channels, 0x201020);
ncplane_set_base(newp, "", style, channels);
ncplot_options opts;
memset(&opts, 0, sizeof(opts));
opts.flags = NCPLOT_OPTION_LABELTICKSD | NCPLOT_OPTION_EXPONENTIALD;
opts.legendstyle = NCSTYLE_ITALIC;
opts.title = "frames per second";
channels_set_fg_rgb(&opts.minchannels, 0x80, 0x80, 0xff);
channels_set_bg(&opts.minchannels, 0x201020);
channels_set_fg_rgb8(&opts.minchannels, 0x80, 0x80, 0xff);
channels_set_bg_rgb(&opts.minchannels, 0x201020);
channels_set_bg_alpha(&opts.minchannels, CELL_ALPHA_BLEND);
channels_set_fg_rgb(&opts.maxchannels, 0x80, 0xff, 0x80);
channels_set_bg(&opts.maxchannels, 0x201020);
channels_set_fg_rgb8(&opts.maxchannels, 0x80, 0xff, 0x80);
channels_set_bg_rgb(&opts.maxchannels, 0x201020);
channels_set_bg_alpha(&opts.maxchannels, CELL_ALPHA_BLEND);
struct ncuplot* fpsplot = ncuplot_create(newp, &opts, 0, 0);
if(!fpsplot){

View File

@ -6,7 +6,7 @@ fader(struct notcurses* nc, struct ncplane* ncp, void* curry){
int rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
for(int x = 5 ; x < cols - 6 ; ++x){
ncplane_set_fg_rgb(ncp, 0xd0, 0xf0, 0xd0);
ncplane_set_fg_rgb8(ncp, 0xd0, 0xf0, 0xd0);
if(ncplane_putwc_yx(ncp, rows - 5, x, x % 2 == *flipmode % 2 ? L'' : L'') <= 0){
return -1;
}
@ -27,17 +27,17 @@ int intro(struct notcurses* nc){
struct ncplane* ncp = notcurses_stddim_yx(nc, &rows, &cols);
uint32_t ccul, ccur, ccll, cclr;
ccul = ccur = ccll = cclr = 0;
channel_set_rgb(&ccul, 0, 0xd0, 0);
channel_set_rgb(&ccur, 0xff, 0, 0);
channel_set_rgb(&ccll, 0x88, 0, 0xcc);
channel_set_rgb(&cclr, 0, 0, 0);
channel_set_rgb8(&ccul, 0, 0xd0, 0);
channel_set_rgb8(&ccur, 0xff, 0, 0);
channel_set_rgb8(&ccll, 0x88, 0, 0xcc);
channel_set_rgb8(&cclr, 0, 0, 0);
// we use full block rather+fg than space+bg to conflict less with the menu
ncplane_home(ncp);
if(ncplane_highgradient_sized(ncp, ccul, ccur, ccll, cclr, rows, cols) <= 0){
return -1;
}
cell c = CELL_TRIVIAL_INITIALIZER;
cell_set_bg_rgb(&c, 0x20, 0x20, 0x20);
cell_set_bg_rgb8(&c, 0x20, 0x20, 0x20);
ncplane_set_base_cell(ncp, &c);
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
@ -48,10 +48,10 @@ int intro(struct notcurses* nc){
if(cells_rounded_box(ncp, NCSTYLE_BOLD, 0, &ul, &ur, &ll, &lr, &hl, &vl)){
return -1;
}
cell_set_fg(&ul, 0xff0000); cell_set_bg(&ul, 0x002000);
cell_set_fg(&ur, 0x00ff00); cell_set_bg(&ur, 0x002000);
cell_set_fg(&ll, 0x0000ff); cell_set_bg(&ll, 0x002000);
cell_set_fg(&lr, 0xffffff); cell_set_bg(&lr, 0x002000);
cell_set_fg_rgb(&ul, 0xff0000); cell_set_bg_rgb(&ul, 0x002000);
cell_set_fg_rgb(&ur, 0x00ff00); cell_set_bg_rgb(&ur, 0x002000);
cell_set_fg_rgb(&ll, 0x0000ff); cell_set_bg_rgb(&ll, 0x002000);
cell_set_fg_rgb(&lr, 0xffffff); cell_set_bg_rgb(&lr, 0x002000);
if(ncplane_box_sized(ncp, &ul, &ur, &ll, &lr, &hl, &vl, rows - 1, cols,
NCBOXGRAD_TOP | NCBOXGRAD_BOTTOM |
NCBOXGRAD_RIGHT | NCBOXGRAD_LEFT)){
@ -59,10 +59,10 @@ int intro(struct notcurses* nc){
}
uint64_t cul, cur, cll, clr;
cul = cur = cll = clr = 0;
channels_set_fg_rgb(&cul, 200, 0, 200); channels_set_bg_rgb(&cul, 0, 64, 0);
channels_set_fg_rgb(&cur, 200, 0, 200); channels_set_bg_rgb(&cur, 0, 64, 0);
channels_set_fg_rgb(&cll, 200, 0, 200); channels_set_bg_rgb(&cll, 0, 128, 0);
channels_set_fg_rgb(&clr, 200, 0, 200); channels_set_bg_rgb(&clr, 0, 128, 0);
channels_set_fg_rgb8(&cul, 200, 0, 200); channels_set_bg_rgb8(&cul, 0, 64, 0);
channels_set_fg_rgb8(&cur, 200, 0, 200); channels_set_bg_rgb8(&cur, 0, 64, 0);
channels_set_fg_rgb8(&cll, 200, 0, 200); channels_set_bg_rgb8(&cll, 0, 128, 0);
channels_set_fg_rgb8(&clr, 200, 0, 200); channels_set_bg_rgb8(&clr, 0, 128, 0);
int centercols = cols > 80 ? 72 : cols - 8;
if(ncplane_cursor_move_yx(ncp, 5, (cols - centercols) / 2 + 1)){
return -1;
@ -70,10 +70,10 @@ int intro(struct notcurses* nc){
if(ncplane_gradient(ncp, "Δ", 0, cul, cur, cll, clr, rows - 8, cols / 2 + centercols / 2 - 1) <= 0){
return -1;
}
cell_set_fg(&lr, 0xff0000); cell_set_bg(&lr, 0x002000);
cell_set_fg(&ll, 0x00ff00); cell_set_bg(&ll, 0x002000);
cell_set_fg(&ur, 0x0000ff); cell_set_bg(&ur, 0x002000);
cell_set_fg(&ul, 0xffffff); cell_set_bg(&ul, 0x002000);
cell_set_fg_rgb(&lr, 0xff0000); cell_set_bg_rgb(&lr, 0x002000);
cell_set_fg_rgb(&ll, 0x00ff00); cell_set_bg_rgb(&ll, 0x002000);
cell_set_fg_rgb(&ur, 0x0000ff); cell_set_bg_rgb(&ur, 0x002000);
cell_set_fg_rgb(&ul, 0xffffff); cell_set_bg_rgb(&ul, 0x002000);
if(ncplane_cursor_move_yx(ncp, 4, (cols - centercols) / 2)){
return -1;
}
@ -86,10 +86,10 @@ int intro(struct notcurses* nc){
cell_release(ncp, &hl); cell_release(ncp, &vl);
const char s1[] = " Die Welt ist alles, was der Fall ist. ";
const char str[] = " Wovon man nicht sprechen kann, darüber muss man schweigen. ";
if(ncplane_set_fg_rgb(ncp, 192, 192, 192)){
if(ncplane_set_fg_rgb8(ncp, 192, 192, 192)){
return -1;
}
if(ncplane_set_bg_rgb(ncp, 0, 40, 0)){
if(ncplane_set_bg_rgb8(ncp, 0, 40, 0)){
return -1;
}
if(ncplane_putstr_aligned(ncp, rows / 2 - 4, NCALIGN_CENTER, s1) != (int)strlen(s1)){
@ -100,7 +100,7 @@ int intro(struct notcurses* nc){
return -1;
}
ncplane_styles_off(ncp, NCSTYLE_ITALIC);
ncplane_set_fg_rgb(ncp, 0xff, 0xff, 0xff);
ncplane_set_fg_rgb8(ncp, 0xff, 0xff, 0xff);
int major, minor, patch, tweak;
notcurses_version_components(&major, &minor, &patch, &tweak);
if(tweak){
@ -124,8 +124,8 @@ int intro(struct notcurses* nc){
return -1;
}
if(rows < 45){
ncplane_set_fg_rgb(ncp, 0xc0, 0x80, 0x80);
ncplane_set_bg_rgb(ncp, 0x20, 0x20, 0x20);
ncplane_set_fg_rgb8(ncp, 0xc0, 0x80, 0x80);
ncplane_set_bg_rgb8(ncp, 0x20, 0x20, 0x20);
ncplane_styles_on(ncp, NCSTYLE_BLINK); // heh FIXME replace with pulse
if(ncplane_putstr_aligned(ncp, 2, NCALIGN_CENTER, "demo runs best with at least 45 lines") < 0){
return -1;

View File

@ -26499,7 +26499,7 @@ load_palette(struct notcurses* nc, const unsigned char* pal, size_t size){
}
palette256* p256 = palette256_new(nc);
for(int idx = 0 ; idx < NCPALETTESIZE ; ++idx){
if(palette256_set_rgb(p256, idx, pal[idx * 3], pal[idx * 3 + 1], pal[idx * 3 + 2])){
if(palette256_set_rgb8(p256, idx, pal[idx * 3], pal[idx * 3 + 1], pal[idx * 3 + 2])){
palette256_free(p256);
return NULL;
}
@ -26539,16 +26539,16 @@ cycle_palettes(struct notcurses* nc, palette256* p){
for(s = sets ; s->l ; ++s){
unsigned tr, tg, tb;
// first grab the top rgbs (u), for use in bottom (l)
if(palette256_get_rgb(p, s->u, &tr, &tg, &tb) < 0){
if(palette256_get_rgb8(p, s->u, &tr, &tg, &tb) < 0){
return -1;
}
// shift each range up one
for(int i = s->l ; i <= s->u ; ++i){
unsigned r, g, b;
if(palette256_get_rgb(p, i, &r, &g, &b) < 0){
if(palette256_get_rgb8(p, i, &r, &g, &b) < 0){
return -1;
}
if(palette256_set_rgb(p, i, tr, tg, tb)){
if(palette256_set_rgb8(p, i, tr, tg, tb)){
return -1;
}
tr = r;

View File

@ -118,19 +118,19 @@ draw_luigi(struct ncplane* n, const char* sprite){
size_t s;
int sbytes;
// optimization so we can elide more color changes, see README's "#perf"
ncplane_set_bg_rgb(n, 0x00, 0x00, 0x00);
ncplane_set_bg_rgb8(n, 0x00, 0x00, 0x00);
for(s = 0 ; sprite[s] ; ++s){
switch(sprite[s]){
case '0':
break;
case '1':
ncplane_set_bg_rgb(n, 0xff, 0xff, 0xff);
ncplane_set_bg_rgb8(n, 0xff, 0xff, 0xff);
break;
case '2':
ncplane_set_bg_rgb(n, 0xe3, 0x9d, 0x25);
ncplane_set_bg_rgb8(n, 0xe3, 0x9d, 0x25);
break;
case '3':
ncplane_set_bg_rgb(n, 0x3a, 0x84, 0x00);
ncplane_set_bg_rgb8(n, 0x3a, 0x84, 0x00);
break;
}
if(sprite[s] != '0'){

View File

@ -3398,7 +3398,7 @@ mojiplane(struct ncplane* title, int y, int rows, const char* summary){
return NULL;
}
channels = 0;
if(ncplane_set_fg(n, 0x40d0d0)){
if(ncplane_set_fg_rgb(n, 0x40d0d0)){
ncplane_destroy(n);
return NULL;
}
@ -3407,7 +3407,7 @@ mojiplane(struct ncplane* title, int y, int rows, const char* summary){
ncplane_destroy(n);
return NULL;
}
if(ncplane_set_base(n, " ", 0, channels) < 0 || ncplane_set_fg(n, 0x40d040)){
if(ncplane_set_base(n, " ", 0, channels) < 0 || ncplane_set_fg_rgb(n, 0x40d040)){
ncplane_destroy(n);
return NULL;
}
@ -3550,22 +3550,22 @@ maketitle(struct ncplane* std){
return NULL;
}
uint64_t channels = 0;
channels_set_bg(&channels, 0x0);
if(ncplane_set_base(title, " ", 0, channels) < 0 || ncplane_set_bg(title, 0)){
channels_set_bg_rgb(&channels, 0x0);
if(ncplane_set_base(title, " ", 0, channels) < 0 || ncplane_set_bg_rgb(title, 0)){
ncplane_destroy(title);
return NULL;
}
ncplane_set_fg(title, 0xe0b0b0);
ncplane_set_fg_rgb(title, 0xe0b0b0);
if(ncplane_putstr_aligned(title, 0, NCALIGN_CENTER, "mojibake 文字化けmodʑibake (english: \"garbled\")") < 0){
ncplane_destroy(title);
return NULL;
}
ncplane_set_fg(title, 0xa0ffff);
ncplane_set_fg_rgb(title, 0xa0ffff);
if(ncplane_putstr_aligned(title, 1, NCALIGN_CENTER, "Display of emoji depends upon terminal, font, and font rendering engine.") < 0){
ncplane_destroy(title);
return NULL;
}
ncplane_set_fg(title, 0xe0a0a0);
ncplane_set_fg_rgb(title, 0xe0a0a0);
if(ncplane_putstr_aligned(title, 2, NCALIGN_CENTER, "Not all symbols are emoji, and not all emoji map to a single code point.") < 0){
ncplane_destroy(title);
return NULL;

View File

@ -158,8 +158,8 @@ int normal_demo(struct notcurses* nc){
struct ncplane* nstd = notcurses_stddim_yx(nc, &dy, &dx);
ncplane_erase(nstd);
cell c = CELL_TRIVIAL_INITIALIZER;
cell_set_fg_rgb(&c, 0x0, 0x0, 0x0);
cell_set_bg_rgb(&c, 0x0, 0x0, 0x0);
cell_set_fg_rgb8(&c, 0x0, 0x0, 0x0);
cell_set_bg_rgb8(&c, 0x0, 0x0, 0x0);
ncplane_set_base_cell(nstd, &c);
cell_release(nstd, &c);
struct ncplane* n = NULL;
@ -225,10 +225,10 @@ int normal_demo(struct notcurses* nc){
ncplane_home(n);
uint64_t tl, tr, bl, br;
tl = tr = bl = br = 0;
channels_set_fg_rgb(&tl, 0, 0, 0);
channels_set_fg_rgb(&tr, 0, 0xff, 0);
channels_set_fg_rgb(&bl, 0xff, 0, 0xff);
channels_set_fg_rgb(&br, 0, 0, 0);
channels_set_fg_rgb8(&tl, 0, 0, 0);
channels_set_fg_rgb8(&tr, 0, 0xff, 0);
channels_set_fg_rgb8(&bl, 0xff, 0, 0xff);
channels_set_fg_rgb8(&br, 0, 0, 0);
ncplane_dim_yx(n, &dy, &dx);
if(ncplane_stain(n, dy - 1, dx - 1, tl, tr, bl, br) < 0){
goto err;
@ -236,8 +236,8 @@ int normal_demo(struct notcurses* nc){
DEMO_RENDER(nc);
timespec_div(&demodelay, 2, &scaled);
demo_nanosleep(nc, &scaled);
cell_set_fg_rgb(&c, 0, 0, 0);
cell_set_bg_rgb(&c, 0, 0, 0);
cell_set_fg_rgb8(&c, 0, 0, 0);
cell_set_bg_rgb8(&c, 0, 0, 0);
ncplane_set_base_cell(nstd, &c);
cell_release(nstd, &c);
r = rotate_visual(nc, n, dy, dx);

View File

@ -92,8 +92,8 @@ videothread(void* vnc){
channels_set_bg_alpha(&trans_channel, CELL_ALPHA_TRANSPARENT);
channels_set_fg_alpha(&trans_channel, CELL_ALPHA_TRANSPARENT);
ncplane_set_base(apiap, "", 0, trans_channel);
ncplane_set_fg_rgb(apiap, 0xc0, 0x40, 0x80);
ncplane_set_bg_rgb(apiap, 0, 0, 0);
ncplane_set_fg_rgb8(apiap, 0xc0, 0x40, 0x80);
ncplane_set_bg_rgb8(apiap, 0, 0, 0);
ncplane_putstr_aligned(apiap, 0, NCALIGN_CENTER,
"Apia 🡺 Atlanta. Samoa, tula'i ma sisi ia lau fu'a, lou pale lea!");
int canceled = ncvisual_stream(nc, ncv, delaymultiplier, perframe, &ovopts, &three);
@ -120,7 +120,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
int xs;
ncplane_yx(non, NULL, &xs);
uint64_t channels = 0;
channels_set_bg_rgb(&channels, 0x58, 0x36, 0x58);
channels_set_bg_rgb8(&channels, 0x58, 0x36, 0x58);
if(ncplane_set_base(non, " ", 0, channels) < 0){
return NULL;
}
@ -143,10 +143,10 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
if(ncplane_putchar_yx(non, *rows - 1, *cols - 2, ' ') < 0 || ncplane_putchar(non, ' ') < 0){
return NULL;
}
if(ncplane_set_fg_rgb(non, 0, 0, 0)){
if(ncplane_set_fg_rgb8(non, 0, 0, 0)){
return NULL;
}
if(ncplane_set_bg_rgb(non, 0, 180, 180)){
if(ncplane_set_bg_rgb8(non, 0, 180, 180)){
return NULL;
}
if(ncplane_set_bg_alpha(non, CELL_ALPHA_BLEND)){

View File

@ -28,7 +28,7 @@ int qrcode_demo(struct notcurses* nc){
if(qlen > 0){ // FIXME can fail due to being too large for display; distinguish this case
ncplane_move_yx(n, (dimy - y) / 2, (dimx - x) / 2);
ncplane_home(n);
ncplane_set_fg_rgb(n, random() % 255 + 1, random() % 255 + 1, random() % 255 + 1);
ncplane_set_fg_rgb8(n, random() % 255 + 1, random() % 255 + 1, random() % 255 + 1);
DEMO_RENDER(nc);
}
}

View File

@ -72,7 +72,7 @@ tabletdraw(struct ncplane* w, int maxy, tabletctx* tctx, unsigned rgb){
for(y = 0 ; y < maxy ; ++y, rgb += 16){
snprintf(cchbuf, sizeof(cchbuf) / sizeof(*cchbuf), "%x", y % 16);
cell_load(w, &c, cchbuf);
if(cell_set_fg_rgb(&c, (rgb >> 16u) % 0xffu, (rgb >> 8u) % 0xffu, rgb % 0xffu)){
if(cell_set_fg_rgb8(&c, (rgb >> 16u) % 0xffu, (rgb >> 8u) % 0xffu, rgb % 0xffu)){
return -1;
}
int x;
@ -98,7 +98,7 @@ drawcb(struct nctablet* t, bool drawfromtop){
int ll;
int maxy = ncplane_dim_y(p);
ll = tabletdraw(p, maxy, tctx, rgb);
ncplane_set_fg_rgb(p, 242, 242, 242);
ncplane_set_fg_rgb8(p, 242, 242, 242);
if(ll){
const int summaryy = drawfromtop ? 0 : ll - 1;
ncplane_styles_on(p, NCSTYLE_BOLD);
@ -206,12 +206,12 @@ ncreel_demo_core(struct notcurses* nc){
.focusedchan = 0,
.flags = NCREEL_OPTION_INFINITESCROLL | NCREEL_OPTION_CIRCULAR,
};
channels_set_fg_rgb(&popts.focusedchan, 58, 150, 221);
channels_set_bg_rgb(&popts.focusedchan, 97, 214, 214);
channels_set_fg_rgb(&popts.tabletchan, 19, 161, 14);
channels_set_bg_rgb(&popts.borderchan, 0, 0, 0);
channels_set_fg_rgb(&popts.borderchan, 136, 23, 152);
channels_set_bg_rgb(&popts.borderchan, 0, 0, 0);
channels_set_fg_rgb8(&popts.focusedchan, 58, 150, 221);
channels_set_bg_rgb8(&popts.focusedchan, 97, 214, 214);
channels_set_fg_rgb8(&popts.tabletchan, 19, 161, 14);
channels_set_bg_rgb8(&popts.borderchan, 0, 0, 0);
channels_set_fg_rgb8(&popts.borderchan, 136, 23, 152);
channels_set_bg_rgb8(&popts.borderchan, 0, 0, 0);
uint64_t bgchannels = 0;
if(channels_set_fg_alpha(&bgchannels, CELL_ALPHA_TRANSPARENT)){
ncplane_destroy(w);
@ -230,7 +230,7 @@ ncreel_demo_core(struct notcurses* nc){
// Press a for a new nc above the current, c for a new one below the
// current, and b for a new block at arbitrary placement.
ncplane_styles_on(std, NCSTYLE_BOLD | NCSTYLE_ITALIC);
ncplane_set_fg_rgb(std, 58, 150, 221);
ncplane_set_fg_rgb8(std, 58, 150, 221);
ncplane_set_bg_default(std);
ncplane_printf_yx(std, 1, 2, "a, b, c create tablets, DEL deletes.");
ncplane_styles_off(std, NCSTYLE_BOLD | NCSTYLE_ITALIC);
@ -253,13 +253,13 @@ ncreel_demo_core(struct notcurses* nc){
}
do{
ncplane_styles_set(std, NCSTYLE_NONE);
ncplane_set_fg_rgb(std, 197, 15, 31);
ncplane_set_fg_rgb8(std, 197, 15, 31);
int count = ncreel_tabletcount(pr);
ncplane_styles_on(std, NCSTYLE_BOLD);
ncplane_printf_yx(std, 2, 2, "%d tablet%s", count, count == 1 ? "" : "s");
ncplane_styles_off(std, NCSTYLE_BOLD);
// FIXME wclrtoeol(w);
ncplane_set_fg_rgb(std, 0, 55, 218);
ncplane_set_fg_rgb8(std, 0, 55, 218);
wchar_t rw;
ncinput ni;
pthread_mutex_lock(&renderlock);

View File

@ -101,12 +101,12 @@ fill_chunk(struct ncplane* n, int idx){
int r = 64 + hidx * 10;
int b = 64 + vidx * 30;
int g = 225 - ((hidx + vidx) * 12);
channels_set_fg_rgb(&channels, r, g, b);
channels_set_fg_rgb8(&channels, r, g, b);
uint32_t ul = 0, ur = 0, ll = 0, lr = 0;
channel_set_rgb(&ul, r, g, b);
channel_set_rgb(&lr, r, g, b);
channel_set_rgb(&ur, g, b, r);
channel_set_rgb(&ll, b, r, g);
channel_set_rgb8(&ul, r, g, b);
channel_set_rgb8(&lr, r, g, b);
channel_set_rgb8(&ur, g, b, r);
channel_set_rgb8(&ll, b, r, g);
int ret = 0;
if(ncplane_highgradient_sized(n, ul, ur, ll, lr, maxy, maxx) <= 0){
ret = -1;
@ -126,8 +126,8 @@ static int
draw_bounding_box(struct ncplane* n, int yoff, int xoff, int chunky, int chunkx){
int ret;
uint64_t channels = 0;
channels_set_fg_rgb(&channels, 180, 80, 180);
//channels_set_bg_rgb(&channels, 0, 0, 0);
channels_set_fg_rgb8(&channels, 180, 80, 180);
//channels_set_bg_rgb8(&channels, 0, 0, 0);
ncplane_cursor_move_yx(n, yoff, xoff);
ret = ncplane_rounded_box(n, 0, channels,
CHUNKS_VERT * chunky + yoff + 1,

View File

@ -2,7 +2,7 @@
#include "demo.h"
static void
grow_rgb(uint32_t* rgb){
grow_rgb8(uint32_t* rgb){
int r = channel_r(*rgb);
int g = channel_g(*rgb);
int b = channel_b(*rgb);
@ -35,14 +35,14 @@ legend(struct notcurses* nc, const char* msg){
return NULL;
}
cell c = CELL_TRIVIAL_INITIALIZER;
cell_set_fg_rgb(&c, 0, 0, 0); // darken surrounding characters by half
cell_set_fg_rgb8(&c, 0, 0, 0); // darken surrounding characters by half
cell_set_fg_alpha(&c, CELL_ALPHA_BLEND);
cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); // don't touch background
if(ncplane_set_base_cell(n, &c)){
ncplane_destroy(n);
return NULL;
}
if(ncplane_set_fg(n, 0xd78700) || ncplane_set_bg(n, 0)){
if(ncplane_set_fg_rgb(n, 0xd78700) || ncplane_set_bg_rgb(n, 0)){
ncplane_destroy(n);
return NULL;
}
@ -153,7 +153,7 @@ slidepanel(struct notcurses* nc){
// Set the foreground color, setting it to blend. We should get the underlying
// glyphs in a blended color, with the default background color.
cell_set_fg(&c, 0x80c080);
cell_set_fg_rgb(&c, 0x80c080);
cell_set_fg_alpha(&c, CELL_ALPHA_BLEND);
ncplane_set_base_cell(n, &c);
clock_gettime(CLOCK_MONOTONIC, &cur);
@ -168,7 +168,7 @@ slidepanel(struct notcurses* nc){
// Opaque foreground color. This produces underlying glyphs in the specified,
// fixed color, with the default background color.
cell_set_fg(&c, 0x80c080);
cell_set_fg_rgb(&c, 0x80c080);
cell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE);
ncplane_set_base_cell(n, &c);
clock_gettime(CLOCK_MONOTONIC, &cur);
@ -217,8 +217,8 @@ slidepanel(struct notcurses* nc){
// characters. We blend, however, to show the underlying color in our glyphs.
cell_set_fg_alpha(&c, CELL_ALPHA_BLEND);
cell_set_bg_alpha(&c, CELL_ALPHA_BLEND);
cell_set_fg(&c, 0x80c080);
cell_set_bg(&c, 0x204080);
cell_set_fg_rgb(&c, 0x80c080);
cell_set_bg_rgb(&c, 0x204080);
ncplane_set_base_cell(n, &c);
clock_gettime(CLOCK_MONOTONIC, &cur);
l = legend(nc, "all blended, print glyph");
@ -240,10 +240,10 @@ slidepanel(struct notcurses* nc){
int trans_demo(struct notcurses* nc){
int maxx, maxy;
struct ncplane* n = notcurses_stddim_yx(nc, &maxy, &maxx);
ncplane_set_fg_rgb(n, 255, 255, 255);
ncplane_set_fg_rgb8(n, 255, 255, 255);
uint64_t channels = 0;
channels_set_fg_rgb(&channels, 0, 128, 128);
channels_set_bg_rgb(&channels, 90, 0, 90);
channels_set_fg_rgb8(&channels, 0, 128, 128);
channels_set_bg_rgb8(&channels, 90, 0, 90);
int y = 1, x = 0;
ncplane_cursor_move_yx(n, y, x);
if(ncplane_rounded_box_sized(n, 0, channels, maxy - 1, maxx, 0)){
@ -256,10 +256,10 @@ int trans_demo(struct notcurses* nc){
return -1;
}
while(x < maxx - 1){
ncplane_set_fg_rgb(n, (rgb & 0xff0000) >> 16u, (rgb & 0xff00) >> 8u, rgb & 0xff);
ncplane_set_bg_rgb(n, 0, 10, 0);
ncplane_set_fg_rgb8(n, (rgb & 0xff0000) >> 16u, (rgb & 0xff00) >> 8u, rgb & 0xff);
ncplane_set_bg_rgb8(n, 0, 10, 0);
ncplane_putchar(n, x % 10 + '0');
grow_rgb(&rgb);
grow_rgb8(&rgb);
++x;
}
}

View File

@ -32,22 +32,22 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
cell_set_bg_alpha(&ur, CELL_ALPHA_TRANSPARENT);
cell_set_bg_alpha(&ll, CELL_ALPHA_TRANSPARENT);
cell_set_bg_alpha(&lr, CELL_ALPHA_TRANSPARENT);
cell_set_fg_rgb(&ul, 0xea, 0xaa, 0x00);
cell_set_fg_rgb(&ur, 0x00, 0x30, 0x57);
cell_set_fg_rgb(&ll, 0x00, 0x30, 0x57);
cell_set_fg_rgb(&lr, 0xea, 0xaa, 0x00);
cell_set_fg_rgb8(&ul, 0xea, 0xaa, 0x00);
cell_set_fg_rgb8(&ur, 0x00, 0x30, 0x57);
cell_set_fg_rgb8(&ll, 0x00, 0x30, 0x57);
cell_set_fg_rgb8(&lr, 0xea, 0xaa, 0x00);
// see https://github.com/dankamongmen/notcurses/issues/259. we use a random
// (but dark) background for the perimeter to force refreshing on the box,
// when it might otherwise be molested by RTL text. hacky and gross :( FIXME
int rbg = random() % 20;
cell_set_bg(&ul, rbg);
cell_set_bg(&ur, rbg);
cell_set_bg(&ll, rbg);
cell_set_bg(&lr, rbg);
cell_set_fg_rgb(&hl, 255, 255, 255);
cell_set_fg_rgb(&vl, 255, 255, 255);
cell_set_bg_rgb(&hl, 0, 0, 0);
cell_set_bg_rgb(&vl, 0, 0, 0);
cell_set_bg_rgb(&ul, rbg);
cell_set_bg_rgb(&ur, rbg);
cell_set_bg_rgb(&ll, rbg);
cell_set_bg_rgb(&lr, rbg);
cell_set_fg_rgb8(&hl, 255, 255, 255);
cell_set_fg_rgb8(&vl, 255, 255, 255);
cell_set_bg_rgb8(&hl, 0, 0, 0);
cell_set_bg_rgb8(&vl, 0, 0, 0);
ncplane_home(nn);
unsigned control = NCBOXGRAD_TOP | NCBOXGRAD_BOTTOM | NCBOXGRAD_LEFT | NCBOXGRAD_RIGHT;
if(ncplane_box_sized(nn, &ul, &ur, &ll, &lr, &hl, &vl, dimy, dimx, control)){
@ -84,8 +84,8 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
}else{ // don't dump non-printing codepoints
strcpy(utf8arr, " ");
}
ncplane_set_fg_rgb(nn, 0xad + z * 2, 0xff, 0x2f - z * 2);
ncplane_set_bg_rgb(nn, 8 * chunk, 8 * chunk, 8 * chunk);
ncplane_set_fg_rgb8(nn, 0xad + z * 2, 0xff, 0x2f - z * 2);
ncplane_set_bg_rgb8(nn, 8 * chunk, 8 * chunk, 8 * chunk);
if(ncplane_putstr_yx(nn, chunk + 1, z * 2 + 1, utf8arr) < 0){
return -1;
}
@ -194,15 +194,15 @@ int unicodeblocks_demo(struct notcurses* nc){
}
uint64_t channels = 0;
channels_set_fg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_fg(&channels, 0x004000);
channels_set_bg(&channels, 0x0);
channels_set_fg_rgb(&channels, 0x004000);
channels_set_bg_rgb(&channels, 0x0);
ncplane_set_base(header, "", 0, channels);
for(sindex = 0 ; sindex < sizeof(blocks) / sizeof(*blocks) ; ++sindex){
ncplane_set_bg_rgb(n, 0, 0, 0);
ncplane_set_bg_rgb8(n, 0, 0, 0);
uint32_t blockstart = blocks[sindex].start;
const char* description = blocks[sindex].name;
ncplane_set_bg(header, 0);
ncplane_set_fg(header, 0xbde8f6);
ncplane_set_bg_rgb(header, 0);
ncplane_set_fg_rgb(header, 0xbde8f6);
if(ncplane_printf_aligned(header, 1, NCALIGN_CENTER, "Unicode points 0x%05x—0x%05x (%u—%u)",
blockstart, blockstart + BLOCKSIZE,
blockstart, blockstart + BLOCKSIZE) <= 0){
@ -216,7 +216,7 @@ int unicodeblocks_demo(struct notcurses* nc){
if(draw_block(nn, blockstart)){
return -1;
}
if(ncplane_set_fg_rgb(n, 0x40, 0xc0, 0x40)){
if(ncplane_set_fg_rgb8(n, 0x40, 0xc0, 0x40)){
return -1;
}
if(ncplane_cursor_move_yx(n, 6 + BLOCKSIZE / CHUNKSIZE, 0)){

View File

@ -30,13 +30,13 @@ legend(struct notcurses* nc, int dimy, int dimx){
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
ncplane_set_base(n, " ", 0, channels);
ncplane_styles_set(n, NCSTYLE_BOLD);
ncplane_set_fg_rgb(n, 0xff, 0xff, 0xff);
ncplane_set_fg_rgb8(n, 0xff, 0xff, 0xff);
ncplane_set_fg_alpha(n, CELL_ALPHA_HIGHCONTRAST);
if(ncplane_putstr_aligned(n, 0, NCALIGN_CENTER, "target launch") <= 0){
ncplane_destroy(n);
return NULL;
}
ncplane_set_fg_rgb(n, 0, 0, 0);
ncplane_set_fg_rgb8(n, 0, 0, 0);
if(ncplane_putstr_aligned(n, 1, NCALIGN_CENTER, "2003-12-11 FM-6") <= 0){
ncplane_destroy(n);
return NULL;
@ -45,7 +45,7 @@ legend(struct notcurses* nc, int dimy, int dimx){
ncplane_destroy(n);
return NULL;
}
ncplane_set_fg_rgb(n, 0x80, 0xc0, 0x80);
ncplane_set_fg_rgb8(n, 0x80, 0xc0, 0x80);
if(ncplane_putstr_aligned(n, 3, NCALIGN_CENTER, "exo-atmospheric intercept") <= 0){
ncplane_destroy(n);
return NULL;

View File

@ -19,12 +19,12 @@ mathplane(struct notcurses* nc){
const int WIDTH = dimx;
struct ncplane* n = ncplane_new(nc, HEIGHT, WIDTH, dimy - HEIGHT - 1, dimx - WIDTH, NULL);
uint64_t channels = 0;
channels_set_fg(&channels, 0x2b50c8); // metallic gold, inverted
channels_set_fg_rgb(&channels, 0x2b50c8); // metallic gold, inverted
channels_set_fg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
ncplane_set_base(n, "", 0, channels);
ncplane_set_fg(n, 0xd4af37); // metallic gold
ncplane_set_bg(n, 0x0);
ncplane_set_fg_rgb(n, 0xd4af37); // metallic gold
ncplane_set_bg_rgb(n, 0x0);
if(n){
ncplane_printf_aligned(n, 0, NCALIGN_RIGHT, "∮E⋅da=Q,n→∞,∑f(i)=∏g(i)╭╭╭ ╮╮╮");
ncplane_printf_aligned(n, 1, NCALIGN_RIGHT, "│││ 8πG ││⎪");
@ -46,7 +46,7 @@ lighten(struct ncplane* n, cell* c, int distance, int y, int x){
return 0;
}
unsigned r, g, b;
cell_fg_rgb(c, &r, &g, &b);
cell_fg_rgb8(c, &r, &g, &b);
r += rand() % (64 / (2 * distance + 1) + 1);
g += rand() % (64 / (2 * distance + 1) + 1);
b += rand() % (64 / (2 * distance + 1) + 1);
@ -164,11 +164,11 @@ message(struct ncplane* n, int maxy, int maxx, int num, int total,
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
ncplane_set_base(n, "", 0, channels);
ncplane_set_fg_rgb(n, 255, 255, 255);
ncplane_set_bg_rgb(n, 32, 64, 32);
ncplane_set_fg_rgb8(n, 255, 255, 255);
ncplane_set_bg_rgb8(n, 32, 64, 32);
channels = 0;
channels_set_fg_rgb(&channels, 255, 255, 255);
channels_set_bg_rgb(&channels, 32, 64, 32);
channels_set_fg_rgb8(&channels, 255, 255, 255);
channels_set_bg_rgb8(&channels, 32, 64, 32);
ncplane_cursor_move_yx(n, 2, 0);
if(ncplane_rounded_box(n, 0, channels, 4, 56, 0)){
return -1;
@ -179,8 +179,8 @@ message(struct ncplane* n, int maxy, int maxx, int num, int total,
ncplane_putegc_yx(n, 6, 17, "", NULL);
cell hl = CELL_TRIVIAL_INITIALIZER;
cell_load(n, &hl, "");
cell_set_fg_rgb(&hl, 255, 255, 255);
cell_set_bg_rgb(&hl, 32, 64, 32);
cell_set_fg_rgb8(&hl, 255, 255, 255);
cell_set_bg_rgb8(&hl, 32, 64, 32);
ncplane_hline(n, &hl, 57 - 18 - 1);
ncplane_putegc_yx(n, 6, 56, "", NULL);
ncplane_putegc_yx(n, 5, 56, "", NULL);
@ -196,15 +196,15 @@ message(struct ncplane* n, int maxy, int maxx, int num, int total,
ncplane_putegc_yx(n, 0, 19, "", NULL);
ncplane_putegc_yx(n, 1, 19, "", NULL);
ncplane_putegc_yx(n, 2, 19, "", NULL);
ncplane_set_fg_rgb(n, 64, 128, 240);
ncplane_set_bg_rgb(n, 32, 64, 32);
ncplane_set_fg_rgb8(n, 64, 128, 240);
ncplane_set_bg_rgb8(n, 32, 64, 32);
ncplane_styles_on(n, NCSTYLE_ITALIC);
ncplane_printf_yx(n, 5, 18, " bytes: %05d EGCs: %05d cols: %05d ", bytes_out, egs_out, cols_out);
ncplane_printf_yx(n, 1, 4, " %03dx%03d (%d/%d) ", maxx, maxy, num + 1, total);
ncplane_styles_off(n, NCSTYLE_ITALIC);
ncplane_set_fg_rgb(n, 224, 128, 224);
ncplane_set_fg_rgb8(n, 224, 128, 224);
ncplane_putstr_yx(n, 3, 1, " 🔥 unicode 13, resize awareness, 24b truecolor…🔥 ");
ncplane_set_fg_rgb(n, 255, 255, 255);
ncplane_set_fg_rgb8(n, 255, 255, 255);
return 0;
}
@ -473,13 +473,13 @@ int witherworm_demo(struct notcurses* nc){
if(ncplane_cursor_move_yx(n, y, x)){
return -1;
}
ncplane_set_bg_rgb(n, 20, 20, 20);
ncplane_set_bg_rgb8(n, 20, 20, 20);
do{ // we fill up the screen, however large, bouncing around our strtable
s = strs + random() % ((sizeof(strs) / sizeof(*strs)) - 1);
size_t idx = 0;
ncplane_cursor_yx(n, &y, &x);
while((*s)[idx]){ // each multibyte char of string
if(ncplane_set_fg_rgb(n, channel_r(rgb), channel_g(rgb), channel_b(rgb))){
if(ncplane_set_fg_rgb8(n, channel_r(rgb), channel_g(rgb), channel_b(rgb))){
return -1;
}
if(x >= maxx){

View File

@ -34,7 +34,7 @@ make_slider(struct notcurses* nc, int dimy, int dimx){
for(int x = 0 ; x < REPS ; ++x){
for(size_t l = 0 ; l < sizeof(leg) / sizeof(*leg) ; ++l){
ncplane_set_fg_rgb_clipped(n, r + 0x8 * l, g + 0x8 * l, b + 0x8 * l);
if(ncplane_set_bg_rgb(n, (l + 1) * 0x2, 0x20, (l + 1) * 0x2)){
if(ncplane_set_bg_rgb8(n, (l + 1) * 0x2, 0x20, (l + 1) * 0x2)){
ncplane_destroy(n);
return NULL;
}

View File

@ -59,7 +59,7 @@ int yield_demo(struct notcurses* nc){
continue;
}
ncpixel_set_a(&pixel, 0xfe);
ncpixel_set_rgb(&pixel, (random() % 128) + 128, 0, ncpixel_b(pixel) / 4);
ncpixel_set_rgb8(&pixel, (random() % 128) + 128, 0, ncpixel_b(pixel) / 4);
pfilled = ncvisual_polyfill_yx(wmv, y, x, pixel);
if(pfilled < 0){
ncvisual_destroy(wmv);
@ -71,8 +71,8 @@ int yield_demo(struct notcurses* nc){
ncvisual_destroy(wmv);
return -1;
}
ncplane_set_bg_rgb(std, 0x10, 0x10, 0x10);
ncplane_set_fg_rgb(std, 0xf0, 0x20, 0x20);
ncplane_set_bg_rgb8(std, 0x10, 0x10, 0x10);
ncplane_set_fg_rgb8(std, 0xf0, 0x20, 0x20);
ncplane_set_attr(std, NCSTYLE_BOLD);
if(tfilled > threshold_painted){
tfilled = threshold_painted; // don't allow printing of 100.1% etc

View File

@ -324,7 +324,7 @@ infoplane(struct ncdirect* ncd, const fetched_info* fi){
if(infop == NULL){
return -1;
}
ncplane_set_fg_rgb(infop, 0xd0, 0xd0, 0xd0);
ncplane_set_fg_rgb8(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){
@ -346,13 +346,13 @@ infoplane(struct ncdirect* ncd, const fetched_info* fi){
ncplane_printf_aligned(infop, 4, NCALIGN_LEFT, " RGB TERM: %s", fi->term);
cell c = CELL_CHAR_INITIALIZER('R');
cell_styles_set(&c, NCSTYLE_BOLD);
cell_set_fg_rgb(&c, 0xd0, 0, 0);
cell_set_fg_rgb8(&c, 0xd0, 0, 0);
ncplane_putc_yx(infop, 4, 1, &c);
cell_load_char(infop, &c, 'G');
cell_set_fg_rgb(&c, 0, 0xd0, 0);
cell_set_fg_rgb8(&c, 0, 0xd0, 0);
ncplane_putc_yx(infop, 4, 2, &c);
cell_load_char(infop, &c, 'B');
cell_set_fg_rgb(&c, 0, 0, 0xd);
cell_set_fg_rgb8(&c, 0, 0, 0xd);
ncplane_putc_yx(infop, 4, 3, &c);
cell_styles_set(&c, NCSTYLE_NONE);
}else{
@ -369,30 +369,30 @@ infoplane(struct ncdirect* ncd, const fetched_info* fi){
if(cells_rounded_box(infop, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl)){
return -1;
}
cell_set_fg_rgb(&ul, 0x90, 0x90, 0x90);
cell_set_fg_rgb(&ur, 0x90, 0x90, 0x90);
cell_set_fg_rgb(&ll, 0, 0, 0);
cell_set_fg_rgb(&lr, 0, 0, 0);
cell_set_fg_rgb8(&ul, 0x90, 0x90, 0x90);
cell_set_fg_rgb8(&ur, 0x90, 0x90, 0x90);
cell_set_fg_rgb8(&ll, 0, 0, 0);
cell_set_fg_rgb8(&lr, 0, 0, 0);
unsigned ctrlword = NCBOXGRAD_BOTTOM | NCBOXGRAD_LEFT | NCBOXGRAD_RIGHT;
if(ncplane_perimeter(infop, &ul, &ur, &ll, &lr, &hl, &vl, ctrlword)){
return -1;
}
ncplane_home(infop);
uint64_t channels = 0;
channels_set_fg_rgb(&channels, 0, 0xff, 0);
channels_set_fg_rgb8(&channels, 0, 0xff, 0);
ncplane_hline_interp(infop, &hl, planewidth / 2, ul.channels, channels);
ncplane_hline_interp(infop, &hl, planewidth / 2, channels, ur.channels);
cell_release(infop, &ul); cell_release(infop, &ur);
cell_release(infop, &ll); cell_release(infop, &lr);
cell_release(infop, &hl); cell_release(infop, &vl);
ncplane_set_fg_rgb(infop, 0xff, 0xff, 0xff);
ncplane_set_fg_rgb8(infop, 0xff, 0xff, 0xff);
ncplane_set_attr(infop, NCSTYLE_BOLD);
if(ncplane_printf_aligned(infop, 0, NCALIGN_CENTER, "[ %s@%s ]",
fi->username, fi->hostname) < 0){
return -1;
}
channels_set_fg_rgb(&channels, 0, 0, 0);
channels_set_bg_rgb(&channels, 0x50, 0x50, 0x50);
channels_set_fg_rgb8(&channels, 0, 0, 0);
channels_set_bg_rgb8(&channels, 0x50, 0x50, 0x50);
ncplane_set_base(infop, " ", 0, channels);
if(notcurses_render(nc)){
return -1;

View File

@ -161,14 +161,14 @@ dim_rows(const Plane* n){
return false;
}
unsigned r, g, b;
c.get_fg_rgb(&r, &g, &b);
c.get_fg_rgb8(&r, &g, &b);
r -= r / 32;
g -= g / 32;
b -= b / 32;
if(r > 247){ r = 0; }
if(g > 247){ g = 0; }
if(b > 247){ b = 0; }
if(!c.set_fg_rgb(r, g, b)){
if(!c.set_fg_rgb8(r, g, b)){
n->release(c);
return false;
}
@ -211,15 +211,15 @@ int input_demo(ncpp::NotCurses* nc) {
// FIXME would be nice to switch over to exponential at some level
popts.flags = NCPLOT_OPTION_LABELTICKSD;
popts.minchannels = popts.maxchannels = 0;
channels_set_fg_rgb(&popts.minchannels, 0x40, 0x50, 0xb0);
channels_set_fg_rgb(&popts.maxchannels, 0x40, 0xff, 0xd0);
channels_set_fg_rgb8(&popts.minchannels, 0x40, 0x50, 0xb0);
channels_set_fg_rgb8(&popts.maxchannels, 0x40, 0xff, 0xd0);
popts.gridtype = static_cast<ncblitter_e>(NCBLIT_2x2);
plot = ncuplot_create(pplane, &popts, 0, 0);
if(!plot){
return EXIT_FAILURE;
}
n->set_fg_rgb(0x00, 0x00, 0x00);
n->set_bg_rgb(0xbb, 0x64, 0xbb);
n->set_fg_rgb8(0x00, 0x00, 0x00);
n->set_bg_rgb8(0xbb, 0x64, 0xbb);
n->styles_on(CellStyle::Underline);
if(n->putstr(0, NCAlign::Center, "mash keys, yo. give that mouse some waggle! ctrl+d exits.") <= 0){
return -1;
@ -256,18 +256,18 @@ int input_demo(ncpp::NotCurses* nc) {
if(!n->cursor_move(y, 0)){
break;
}
n->set_fg_rgb(0xd0, 0xd0, 0xd0);
n->set_fg_rgb8(0xd0, 0xd0, 0xd0);
n->printf("%c%c%c ", ni.alt ? 'A' : 'a', ni.ctrl ? 'C' : 'c',
ni.shift ? 'S' : 's');
if(r < 0x80){
n->set_fg_rgb(128, 250, 64);
n->set_fg_rgb8(128, 250, 64);
if(n->printf("ASCII: [0x%02x (%03d)] '%lc'", r, r,
(wchar_t)(iswprint(r) ? r : printutf8(r))) < 0){
break;
}
}else{
if(nckey_supppuab_p(r)){
n->set_fg_rgb(250, 64, 128);
n->set_fg_rgb8(250, 64, 128);
if(n->printf("Special: [0x%02x (%02d)] '%s'", r, r, nckeystr(r)) < 0){
break;
}
@ -277,7 +277,7 @@ int input_demo(ncpp::NotCurses* nc) {
}
}
}else{
n->set_fg_rgb(64, 128, 250);
n->set_fg_rgb8(64, 128, 250);
n->printf("Unicode: [0x%08x] '%lc'", r, (wchar_t)r);
}
}

View File

@ -14,14 +14,14 @@ int ncdirect_putstr(ncdirect* nc, uint64_t channels, const char* utf8){
if(ncdirect_fg_default(nc)){
return -1;
}
}else if(ncdirect_fg(nc, channels_fg_rgb(channels))){
}else if(ncdirect_fg_rgb(nc, channels_fg_rgb(channels))){
return -1;
}
if(channels_bg_default_p(channels)){
if(ncdirect_bg_default(nc)){
return -1;
}
}else if(ncdirect_bg(nc, channels_bg_rgb(channels))){
}else if(ncdirect_bg_rgb(nc, channels_bg_rgb(channels))){
return -1;
}
return fprintf(nc->ttyfp, "%s", utf8);
@ -386,8 +386,8 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
if(egc == nullptr){
return -1;
}
ncdirect_fg(n, channels_fg_rgb(channels));
ncdirect_bg(n, channels_bg_rgb(channels));
ncdirect_fg_rgb(n, channels_fg_rgb(channels));
ncdirect_bg_rgb(n, channels_bg_rgb(channels));
//fprintf(stderr, "%03d/%03d [%s] (%03dx%03d)\n", y, x, egc, dimy, dimx);
if(fprintf(n->ttyfp, "%s", strlen(egc) == 0 ? " " : egc) < 0){
free(egc);
@ -610,10 +610,10 @@ ncdirect_style_emit(ncdirect* n, const char* sgr, unsigned stylebits, FILE* out)
// sgr resets colors, so set them back up if not defaults
if(r == 0){
if(!n->fgdefault){
r |= ncdirect_fg(n, n->fgrgb);
r |= ncdirect_fg_rgb(n, n->fgrgb);
}
if(!n->bgdefault){
r |= ncdirect_bg(n, n->bgrgb);
r |= ncdirect_bg_rgb(n, n->bgrgb);
}
}
return r;
@ -667,7 +667,7 @@ int ncdirect_fg_default(ncdirect* nc){
if(nc->bgdefault){
return 0;
}
return ncdirect_bg(nc, nc->bgrgb);
return ncdirect_bg_rgb(nc, nc->bgrgb);
}
return -1;
}
@ -678,7 +678,7 @@ int ncdirect_bg_default(ncdirect* nc){
if(nc->fgdefault){
return 0;
}
return ncdirect_fg(nc, nc->fgrgb);
return ncdirect_fg_rgb(nc, nc->fgrgb);
}
return -1;
}
@ -718,10 +718,10 @@ int ncdirect_hline_interp(ncdirect* n, const char* egc, int len,
int bg = (deltbg * ret) / len + bg1;
int bb = (deltbb * ret) / len + bb1;
if(!fgdef){
ncdirect_fg_rgb(n, r, g, b);
ncdirect_fg_rgb8(n, r, g, b);
}
if(!bgdef){
ncdirect_bg_rgb(n, br, bg, bb);
ncdirect_bg_rgb8(n, br, bg, bb);
}
if(fprintf(n->ttyfp, "%s", egc) < 0){
break;
@ -796,8 +796,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur,
unsigned edges;
edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_LEFT);
if(edges >= box_corner_needs(ctlword)){
ncdirect_fg(n, channels_fg_rgb(ul));
ncdirect_bg(n, channels_bg_rgb(ul));
ncdirect_fg_rgb(n, channels_fg_rgb(ul));
ncdirect_bg_rgb(n, channels_bg_rgb(ul));
if(fprintf(n->ttyfp, "%lc", wchars[0]) < 0){
return -1;
}
@ -826,8 +826,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur,
}
edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_RIGHT);
if(edges >= box_corner_needs(ctlword)){
ncdirect_fg(n, channels_fg_rgb(ur));
ncdirect_bg(n, channels_bg_rgb(ur));
ncdirect_fg_rgb(n, channels_fg_rgb(ur));
ncdirect_bg_rgb(n, channels_bg_rgb(ur));
if(fprintf(n->ttyfp, "%lc", wchars[1]) < 0){
return -1;
}
@ -860,8 +860,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur,
// bottom line
edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_LEFT);
if(edges >= box_corner_needs(ctlword)){
ncdirect_fg(n, channels_fg_rgb(ll));
ncdirect_bg(n, channels_bg_rgb(ll));
ncdirect_fg_rgb(n, channels_fg_rgb(ll));
ncdirect_bg_rgb(n, channels_bg_rgb(ll));
if(fprintf(n->ttyfp, "%lc", wchars[2]) < 0){
return -1;
}
@ -879,8 +879,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur,
}
edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_RIGHT);
if(edges >= box_corner_needs(ctlword)){
ncdirect_fg(n, channels_fg_rgb(lr));
ncdirect_bg(n, channels_bg_rgb(lr));
ncdirect_fg_rgb(n, channels_fg_rgb(lr));
ncdirect_bg_rgb(n, channels_bg_rgb(lr));
if(fprintf(n->ttyfp, "%lc", wchars[3]) < 0){
return -1;
}

View File

@ -1139,24 +1139,24 @@ void ncplane_set_bg_rgb_clipped(ncplane* n, int r, int g, int b){
channels_set_bg_rgb_clipped(&n->channels, r, g, b);
}
int ncplane_set_bg_rgb(ncplane* n, int r, int g, int b){
return channels_set_bg_rgb(&n->channels, r, g, b);
int ncplane_set_bg_rgb8(ncplane* n, int r, int g, int b){
return channels_set_bg_rgb8(&n->channels, r, g, b);
}
void ncplane_set_fg_rgb_clipped(ncplane* n, int r, int g, int b){
channels_set_fg_rgb_clipped(&n->channels, r, g, b);
}
int ncplane_set_fg_rgb(ncplane* n, int r, int g, int b){
return channels_set_fg_rgb(&n->channels, r, g, b);
int ncplane_set_fg_rgb8(ncplane* n, int r, int g, int b){
return channels_set_fg_rgb8(&n->channels, r, g, b);
}
int ncplane_set_fg(ncplane* n, unsigned channel){
return channels_set_fg(&n->channels, channel);
int ncplane_set_fg_rgb(ncplane* n, unsigned channel){
return channels_set_fg_rgb(&n->channels, channel);
}
int ncplane_set_bg(ncplane* n, unsigned channel){
return channels_set_bg(&n->channels, channel);
int ncplane_set_bg_rgb(ncplane* n, unsigned channel){
return channels_set_bg_rgb(&n->channels, channel);
}
int ncplane_set_fg_alpha(ncplane* n, int alpha){
@ -1577,13 +1577,13 @@ int ncplane_hline_interp(ncplane* n, const cell* c, int len,
unsigned ur, ug, ub;
int r1, g1, b1, r2, g2, b2;
int br1, bg1, bb1, br2, bg2, bb2;
channels_fg_rgb(c1, &ur, &ug, &ub);
channels_fg_rgb8(c1, &ur, &ug, &ub);
r1 = ur; g1 = ug; b1 = ub;
channels_fg_rgb(c2, &ur, &ug, &ub);
channels_fg_rgb8(c2, &ur, &ug, &ub);
r2 = ur; g2 = ug; b2 = ub;
channels_bg_rgb(c1, &ur, &ug, &ub);
channels_bg_rgb8(c1, &ur, &ug, &ub);
br1 = ur; bg1 = ug; bb1 = ub;
channels_bg_rgb(c2, &ur, &ug, &ub);
channels_bg_rgb8(c2, &ur, &ug, &ub);
br2 = ur; bg2 = ug; bb2 = ub;
int deltr = r2 - r1;
int deltg = g2 - g1;
@ -1611,10 +1611,10 @@ int ncplane_hline_interp(ncplane* n, const cell* c, int len,
int bg = (deltbg * ret) / len + bg1;
int bb = (deltbb * ret) / len + bb1;
if(!fgdef){
cell_set_fg_rgb(&dupc, r, g, b);
cell_set_fg_rgb8(&dupc, r, g, b);
}
if(!bgdef){
cell_set_bg_rgb(&dupc, br, bg, bb);
cell_set_bg_rgb8(&dupc, br, bg, bb);
}
if(ncplane_putc(n, &dupc) <= 0){
break;
@ -1629,13 +1629,13 @@ int ncplane_vline_interp(ncplane* n, const cell* c, int len,
unsigned ur, ug, ub;
int r1, g1, b1, r2, g2, b2;
int br1, bg1, bb1, br2, bg2, bb2;
channels_fg_rgb(c1, &ur, &ug, &ub);
channels_fg_rgb8(c1, &ur, &ug, &ub);
r1 = ur; g1 = ug; b1 = ub;
channels_fg_rgb(c2, &ur, &ug, &ub);
channels_fg_rgb8(c2, &ur, &ug, &ub);
r2 = ur; g2 = ug; b2 = ub;
channels_bg_rgb(c1, &ur, &ug, &ub);
channels_bg_rgb8(c1, &ur, &ug, &ub);
br1 = ur; bg1 = ug; bb1 = ub;
channels_bg_rgb(c2, &ur, &ug, &ub);
channels_bg_rgb8(c2, &ur, &ug, &ub);
br2 = ur; bg2 = ug; bb2 = ub;
int deltr = (r2 - r1) / (len + 1);
int deltg = (g2 - g1) / (len + 1);
@ -1667,10 +1667,10 @@ int ncplane_vline_interp(ncplane* n, const cell* c, int len,
bg1 += deltbg;
bb1 += deltbb;
if(!fgdef){
cell_set_fg_rgb(&dupc, r1, g1, b1);
cell_set_fg_rgb8(&dupc, r1, g1, b1);
}
if(!bgdef){
cell_set_bg_rgb(&dupc, br1, bg1, bb1);
cell_set_bg_rgb8(&dupc, br1, bg1, bb1);
}
if(ncplane_putc(n, &dupc) <= 0){
break;
@ -2147,8 +2147,8 @@ uint32_t* ncplane_rgba(const ncplane* nc, ncblitter_e blit,
uint32_t* top = &ret[targy * lenx + targx];
uint32_t* bot = &ret[(targy + 1) * lenx + targx];
unsigned fr, fg, fb, br, bg, bb;
channels_fg_rgb(channels, &fr, &fb, &fg);
channels_bg_rgb(channels, &br, &bb, &bg);
channels_fg_rgb8(channels, &fr, &fb, &fg);
channels_bg_rgb8(channels, &br, &bb, &bg);
// FIXME how do we deal with transparency?
uint32_t frgba = (fr) + (fg << 16u) + (fb << 8u) + 0xff000000;
uint32_t brgba = (br) + (bg << 16u) + (bb << 8u) + 0xff000000;

View File

@ -205,7 +205,7 @@ lock_in_highcontrast(cell* targc, struct crender* crender){
hchan = channels_blend(hchan, crender->hcfg, &crender->hcfgblends);
cell_set_fchannel(targc, hchan);
}else{
cell_set_fg(targc, highcontrast(cell_bchannel(targc)));
cell_set_fg_rgb(targc, highcontrast(cell_bchannel(targc)));
}
}
}
@ -674,7 +674,7 @@ update_palette(notcurses* nc, FILE* out){
for(size_t damageidx = 0 ; damageidx < sizeof(nc->palette.chans) / sizeof(*nc->palette.chans) ; ++damageidx){
unsigned r, g, b;
if(nc->palette_damage[damageidx]){
channel_rgb(nc->palette.chans[damageidx], &r, &g, &b);
channel_rgb8(nc->palette.chans[damageidx], &r, &g, &b);
// Need convert RGB values [0..256) to [0..1000], ugh
// FIXME need handle HSL case also
r = r * 1000 / 255;
@ -817,7 +817,7 @@ notcurses_rasterize_inner(notcurses* nc, const struct crender* rvec, FILE* out){
nc->rstate.defaultelidable = false;
nc->rstate.fgelidable = false;
}else if(!cell_fg_default_p(srccell)){ // rgb foreground
cell_fg_rgb(srccell, &r, &g, &b);
cell_fg_rgb8(srccell, &r, &g, &b);
if(nc->rstate.fgelidable && nc->rstate.lastr == r && nc->rstate.lastg == g && nc->rstate.lastb == b){
++nc->stats.fgelisions;
}else{
@ -844,7 +844,7 @@ notcurses_rasterize_inner(notcurses* nc, const struct crender* rvec, FILE* out){
nc->rstate.defaultelidable = false;
nc->rstate.bgelidable = false;
}else if(!cell_bg_default_p(srccell)){ // rgb background
cell_bg_rgb(srccell, &br, &bg, &bb);
cell_bg_rgb8(srccell, &br, &bg, &bb);
if(nc->rstate.bgelidable && nc->rstate.lastbr == br && nc->rstate.lastbg == bg && nc->rstate.lastbb == bb){
++nc->stats.bgelisions;
}else{
@ -1061,7 +1061,7 @@ char* notcurses_at_yx(notcurses* nc, int yoff, int xoff, uint16_t* stylemask, ui
return egc;
}
int ncdirect_bg(ncdirect* nc, unsigned rgb){
int ncdirect_bg_rgb(ncdirect* nc, unsigned rgb){
if(rgb > 0xffffffu){
return -1;
}
@ -1074,7 +1074,7 @@ int ncdirect_bg(ncdirect* nc, unsigned rgb){
return 0;
}
int ncdirect_fg(ncdirect* nc, unsigned rgb){
int ncdirect_fg_rgb(ncdirect* nc, unsigned rgb){
if(rgb > 0xffffffu){
return -1;
}

View File

@ -47,11 +47,11 @@ int tabletfxn(struct nctablet* _t, bool cliptop){
auto tctx = t->get_userptr<TabletCtx>();
p->erase();
Cell c(' ');
c.set_bg(tctx->getRGB());
c.set_bg_rgb(tctx->getRGB());
p->set_base_cell(c);
p->release(c);
p->set_bg(0xffffff);
p->set_fg(0x000000);
p->set_bg_rgb(0xffffff);
p->set_fg_rgb(0x000000);
p->printf(1, 1, "%d %p lines: %d", tctx->getIdx(), _t, tctx->getLines());
return tctx->getLines();
}
@ -111,12 +111,12 @@ void parse_args(int argc, char** argv, struct notcurses_options* opts,
}
int runreels(struct notcurses* nc, struct ncplane* n, ncreel_options* nopts){
if(ncplane_set_fg_rgb(n, 0xb1, 0x1b, 0xb1)){
if(ncplane_set_fg_rgb8(n, 0xb1, 0x1b, 0xb1)){
return -1;
}
channels_set_fg(&nopts->focusedchan, 0xffffff);
channels_set_bg(&nopts->focusedchan, 0x00c080);
channels_set_fg(&nopts->borderchan, 0x00c080);
channels_set_fg_rgb(&nopts->focusedchan, 0xffffff);
channels_set_bg_rgb(&nopts->focusedchan, 0x00c080);
channels_set_fg_rgb(&nopts->borderchan, 0x00c080);
auto nr = ncreel_create(n, nopts);
if(!nr || notcurses_render(nc)){
return -1;

View File

@ -27,8 +27,8 @@ auto main() -> int {
if(!na){
goto err;
}
n->set_fg(0x00ff00);
na->set_fg(0x00ff00);
n->set_fg_rgb(0x00ff00);
na->set_fg_rgb(0x00ff00);
if(!na->cursor_move(0, 0)){
goto err;
}

View File

@ -26,14 +26,14 @@ int main(void){
}
fflush(stdout);
int ret = 0;
ret |= ncdirect_fg(n, 0xff8080);
ret |= ncdirect_fg_rgb(n, 0xff8080);
ret |= ncdirect_styles_on(n, NCSTYLE_STANDOUT);
printf(" erp erp \n");
ret |= ncdirect_fg(n, 0x80ff80);
ret |= ncdirect_fg_rgb(n, 0x80ff80);
printf(" erp erp \n");
ret |= ncdirect_styles_off(n, NCSTYLE_STANDOUT);
printf(" erp erp \n");
ret |= ncdirect_fg(n, 0xff8080);
ret |= ncdirect_fg_rgb(n, 0xff8080);
printf(" erp erp \n");
ret |= ncdirect_cursor_right(n, dimx / 2);
ret |= ncdirect_cursor_up(n, dimy / 2);

View File

@ -11,7 +11,7 @@ print_b(struct ncdirect* nc, int r, int g, int total){
if(b > 255){
return 0;
}
int ret = ncdirect_fg_rgb(nc, r, g, b);
int ret = ncdirect_fg_rgb8(nc, r, g, b);
if(ret){
return -1;
}
@ -32,7 +32,7 @@ print_gb(struct ncdirect* nc, int r, int total){
}
static int
print_rgb(struct ncdirect* nc, int total){
print_rgb8(struct ncdirect* nc, int total){
if(random() % 2){
if(ncdirect_styles_off(nc, NCSTYLE_ITALIC)){
return -1;
@ -61,7 +61,7 @@ int main(void){
return EXIT_FAILURE;
}
for(int t = 0 ; t < 768 ; t += 4){
if(print_rgb(nc, t)){
if(print_rgb8(nc, t)){
goto err;
}
}
@ -73,7 +73,7 @@ int main(void){
goto err;
}
for(int t = 768 ; t ; t -= 4){
if(print_rgb(nc, t)){
if(print_rgb8(nc, t)){
goto err;
}
}
@ -85,7 +85,7 @@ int main(void){
goto err;
}
for(int t = 0 ; t < 768 ; t += 4){
if(print_rgb(nc, t)){
if(print_rgb8(nc, t)){
goto err;
}
}
@ -97,7 +97,7 @@ int main(void){
goto err;
}
for(int t = 768 ; t ; t -= 4){
if(print_rgb(nc, t)){
if(print_rgb8(nc, t)){
goto err;
}
}

View File

@ -10,8 +10,8 @@ int main(void){
putchar('\n');
for(int i = 0 ; i < 15 ; ++i){
uint64_t c1 = 0, c2 = 0;
channels_set_fg_rgb(&c1, 0x0, 0x10 * i, 0xff);
channels_set_fg_rgb(&c2, 0x10 * i, 0x0, 0x0);
channels_set_fg_rgb8(&c1, 0x0, 0x10 * i, 0xff);
channels_set_fg_rgb8(&c2, 0x10 * i, 0x0, 0x0);
if(ncdirect_hline_interp(n, "-", i, c1, c2) < i){
return EXIT_FAILURE;
}
@ -21,8 +21,8 @@ int main(void){
}
for(int i = 0 ; i < 15 ; ++i){
uint64_t c1 = 0, c2 = 0;
channels_set_fg_rgb(&c1, 0x0, 0x10 * i, 0xff);
channels_set_fg_rgb(&c2, 0x10 * i, 0x0, 0x0);
channels_set_fg_rgb8(&c1, 0x0, 0x10 * i, 0xff);
channels_set_fg_rgb8(&c2, 0x10 * i, 0x0, 0x0);
if(ncdirect_vline_interp(n, "|", i, c1, c2) < i){
return EXIT_FAILURE;
}
@ -37,10 +37,10 @@ int main(void){
printf("\n");
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg_rgb(&ul, 0xff, 0x0, 0xff);
channels_set_fg_rgb(&ur, 0x0, 0xff, 0x0);
channels_set_fg_rgb(&ll, 0x0, 0x0, 0xff);
channels_set_fg_rgb(&lr, 0xff, 0x0, 0x0);
channels_set_fg_rgb8(&ul, 0xff, 0x0, 0xff);
channels_set_fg_rgb8(&ur, 0x0, 0xff, 0x0);
channels_set_fg_rgb8(&ll, 0x0, 0x0, 0xff);
channels_set_fg_rgb8(&lr, 0xff, 0x0, 0x0);
if(ncdirect_rounded_box(n, ul, ur, ll, lr, 10, 10, 0) < 0){
return EXIT_FAILURE;
}

View File

@ -9,8 +9,8 @@ using namespace ncpp;
auto mathtext([[maybe_unused]] NotCurses& nc, std::shared_ptr<Plane>& n) -> int {
if(n){
n->set_fg(0xffffff);
n->set_bg(0x008000);
n->set_fg_rgb(0xffffff);
n->set_bg_rgb(0x008000);
n->printf(0, NCAlign::Right, "∮E⋅da=Q,n→∞,∑f(i)=∏g(i)⎧⎡⎛┌─────┐⎞⎤⎫");
n->printf(1, NCAlign::Right, "⎪⎢⎜│a²+b³ ⎟⎥⎪");
n->printf(2, NCAlign::Right, "∀x∈:⌈x⌉=x⌋,α∧¬β=¬(¬α∨β)⎪⎢⎜│───── ⎟⎥⎪");

View File

@ -10,11 +10,11 @@ run_menu(struct notcurses* nc, struct ncmenu* ncm){
if(selplane == NULL){
return -1;
}
ncplane_set_fg(selplane, 0x0);
ncplane_set_bg(selplane, 0xdddddd);
ncplane_set_fg_rgb(selplane, 0x0);
ncplane_set_bg_rgb(selplane, 0xdddddd);
uint64_t channels = 0;
channels_set_fg(&channels, 0x000088);
channels_set_bg(&channels, 0x88aa00);
channels_set_fg_rgb(&channels, 0x000088);
channels_set_bg_rgb(&channels, 0x88aa00);
if(ncplane_set_base(selplane, " ", 0, channels) < 0){
goto err;
}
@ -106,10 +106,10 @@ int main(void){
memset(&mopts, 0, sizeof(mopts));
mopts.sections = sections;
mopts.sectioncount = sizeof(sections) / sizeof(*sections);
channels_set_fg(&mopts.headerchannels, 0x00ff00);
channels_set_bg(&mopts.headerchannels, 0x440000);
channels_set_fg(&mopts.sectionchannels, 0xb0d700);
channels_set_bg(&mopts.sectionchannels, 0x002000);
channels_set_fg_rgb(&mopts.headerchannels, 0x00ff00);
channels_set_bg_rgb(&mopts.headerchannels, 0x440000);
channels_set_fg_rgb(&mopts.sectionchannels, 0xb0d700);
channels_set_bg_rgb(&mopts.sectionchannels, 0x002000);
int dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncmenu* top = ncmenu_create(n, &mopts);
@ -117,14 +117,14 @@ int main(void){
goto err;
}
uint64_t channels = 0;
channels_set_fg(&channels, 0x88aa00);
channels_set_bg(&channels, 0x000088);
channels_set_fg_rgb(&channels, 0x88aa00);
channels_set_bg_rgb(&channels, 0x000088);
if(ncplane_set_base(n, "x", 0, channels) < 0){
return EXIT_FAILURE;
}
notcurses_render(nc);
ncplane_set_fg(n, 0x00dddd);
ncplane_set_fg_rgb(n, 0x00dddd);
if(ncplane_putstr_aligned(n, dimy - 1, NCALIGN_RIGHT, " -=+ menu poc. press q to exit +=- ") < 0){
return EXIT_FAILURE;
}

View File

@ -104,7 +104,7 @@ int main(void){
}
}
ncplane_set_fg(n, 0x40f040);
ncplane_set_fg_rgb(n, 0x40f040);
ncplane_putstr_aligned(n, 0, NCALIGN_RIGHT, "multiselect widget demo");
struct ncplane* mseln = ncplane_new(nc, 1, 1, 3, 0, NULL);
if(mseln == NULL){

View File

@ -40,10 +40,10 @@ int run ()
nc.stop ();
Direct direct (getenv ("TERM"));
direct.set_fg (0xb5, 0x0d, 0xff);
direct.set_fg_rgb (0xb5, 0x0d, 0xff);
std::cout << "notcurses version: ";
direct.set_bg (0x05, 0x6e, 0xee);
direct.set_fg (0xe2, 0xbf, 0x00);
direct.set_bg_rgb (0x05, 0x6e, 0xee);
direct.set_fg_rgb (0xe2, 0xbf, 0x00);
std::cout << ncver << std::endl;
return 0;

View File

@ -39,10 +39,10 @@ int run ()
nc.stop ();
Direct direct (getenv ("TERM"));
direct.set_fg (0xb5, 0x0d, 0xff);
direct.set_fg_rgb (0xb5, 0x0d, 0xff);
std::cout << "notcurses version: ";
direct.set_bg (0x05, 0x6e, 0xee);
direct.set_fg (0xe2, 0xbf, 0x00);
direct.set_bg_rgb (0x05, 0x6e, 0xee);
direct.set_fg_rgb (0xe2, 0xbf, 0x00);
std::cout << ncver << std::endl;
return 0;

View File

@ -22,10 +22,10 @@ int main(void){
r = 0;
g = 0x80;
b = 0;
ncplane_set_bg_rgb(n, 0x40, 0x20, 0x40);
ncplane_set_bg_rgb8(n, 0x40, 0x20, 0x40);
for(y = 0 ; y < dimy ; ++y){
for(x = 0 ; x < dimx ; ++x){
if(ncplane_set_fg_rgb(n, r, g, b)){
if(ncplane_set_fg_rgb8(n, r, g, b)){
goto err;
}
if(ncplane_cursor_move_yx(n, y, x)){

View File

@ -21,10 +21,10 @@ auto main() -> int {
r = 0;
g = 0x80;
b = 0;
ncplane_set_fg_rgb(n, 0x40, 0x20, 0x40);
ncplane_set_fg_rgb8(n, 0x40, 0x20, 0x40);
for(y = 0 ; y < dimy ; ++y){
for(x = 0 ; x < dimx ; ++x){
if(ncplane_set_bg_rgb(n, r, g, b)){
if(ncplane_set_bg_rgb8(n, r, g, b)){
goto err;
}
if(ncplane_cursor_move_yx(n, y, x)){

View File

@ -14,10 +14,10 @@ rotate_grad(struct notcurses* nc){
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_home(n);
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
channel_set_rgb(&tl, 0xff, 0, 0);
channel_set_rgb(&tr, 0, 0, 0xff);
channel_set_rgb(&bl, 0, 0xff, 0);
channel_set_rgb(&br, 0, 0xff, 0xff);
channel_set_rgb8(&tl, 0xff, 0, 0);
channel_set_rgb8(&tr, 0, 0, 0xff);
channel_set_rgb8(&bl, 0, 0xff, 0);
channel_set_rgb8(&br, 0, 0xff, 0xff);
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) <= 0){
return -1;
}
@ -118,10 +118,10 @@ rotate(struct notcurses* nc){
int g = 0;
int b = 0;
for(int x = 0 ; x < XSIZE ; ++x){
if(ncplane_set_fg_rgb(n, r, g, b)){
if(ncplane_set_fg_rgb8(n, r, g, b)){
return -1;
}
if(ncplane_set_bg_rgb(n, b, r, g)){
if(ncplane_set_bg_rgb8(n, b, r, g)){
return -1;
}
if(ncplane_putegc_yx(n, dimy / 2, x, "", NULL) < 0){
@ -133,10 +133,10 @@ rotate(struct notcurses* nc){
g = 0;
b = 255;
for(int x = 0 ; x < XSIZE ; ++x){
if(ncplane_set_fg_rgb(n, r, g, b)){
if(ncplane_set_fg_rgb8(n, r, g, b)){
return -1;
}
if(ncplane_set_bg_rgb(n, b, r, g)){
if(ncplane_set_bg_rgb8(n, b, r, g)){
return -1;
}
if(ncplane_putegc_yx(n, dimy / 2 + 1, x, "", NULL) < 0){

View File

@ -96,7 +96,7 @@ int main(void){
ncvisual_destroy(ncv);
}
ncplane_set_fg(n, 0x40f040);
ncplane_set_fg_rgb(n, 0x40f040);
ncplane_putstr_aligned(n, 0, NCALIGN_RIGHT, "selector widget demo");
struct ncplane* seln = ncplane_new(nc, 1, 1, 3, 0, NULL);
ncplane_set_base(seln, "", 0, bgchannels);

View File

@ -19,7 +19,7 @@ auto main() -> int {
int dimx, dimy;
n->get_dim(&dimy, &dimx);
Cell c;
c.set_bg_rgb(0, 0x80, 0);
c.set_bg_rgb8(0, 0x80, 0);
//n->set_default(c);
if(n->load(c, "🐳") < 0){
goto err;

View File

@ -51,12 +51,12 @@ auto main() -> int {
// first, a 2x1 with "AB"
auto nn = std::make_shared<Plane>(1, 2, 1, 16);
nn->set_fg_rgb(0xc0, 0x80, 0xc0);
nn->set_bg_rgb(0x20, 0x00, 0x20);
nn->set_fg_rgb8(0xc0, 0x80, 0xc0);
nn->set_bg_rgb8(0x20, 0x00, 0x20);
nn->putstr("AB");
n->set_fg_rgb(0x80, 0xc0, 0x80);
n->set_bg_rgb(0x00, 0x40, 0x00);
n->set_fg_rgb8(0x80, 0xc0, 0x80);
n->set_bg_rgb8(0x00, 0x40, 0x00);
n->putstr("\xe5\xbd\xa2\xe5\x85\xa8");
n->putstr(1, 0, "\xe5\xbd\xa2\xe5\x85\xa8");
n->putstr(2, 0, "\xe5\xbd\xa2\xe5\x85\xa8");

View File

@ -18,7 +18,7 @@ void DrawBoard() { // draw all fixed components of the game
board_ = std::make_unique<ncpp::Plane>(BOARD_HEIGHT, BOARD_WIDTH * 2,
board_top_y_, x / 2 - (BOARD_WIDTH + 1));
uint64_t channels = 0;
channels_set_fg(&channels, 0x00b040);
channels_set_fg_rgb(&channels, 0x00b040);
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
board_->double_box(0, channels, BOARD_HEIGHT - 1, BOARD_WIDTH * 2 - 1, NCBOXMASK_TOP);
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
@ -29,9 +29,9 @@ void DrawBoard() { // draw all fixed components of the game
channels_set_fg_alpha(&scorechan, CELL_ALPHA_TRANSPARENT);
scoreplane_->set_base("", 0, scorechan);
scoreplane_->set_bg_alpha(CELL_ALPHA_TRANSPARENT);
scoreplane_->set_fg(0xd040d0);
scoreplane_->set_fg_rgb(0xd040d0);
scoreplane_->printf(0, 1, "%s", getpwuid(geteuid())->pw_name);
scoreplane_->set_fg(0x00d0a0);
scoreplane_->set_fg_rgb(0x00d0a0);
UpdateScore();
nc_.render();
}

View File

@ -21,7 +21,7 @@ std::unique_ptr<ncpp::Plane> NewPiece() {
uint64_t channels = 0;
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
n->set_fg(t->color);
n->set_fg_rgb(t->color);
n->set_bg_alpha(CELL_ALPHA_TRANSPARENT);
n->set_base("", 0, channels);
y = 0; x = 0;

View File

@ -56,7 +56,7 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
std::unique_ptr<Plane> stdn(nc.get_stdplane());
int* framecount = static_cast<int*>(vframecount);
++*framecount;
stdn->set_fg(0x80c080);
stdn->set_fg_rgb(0x80c080);
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
intmax_t ns = timespec_to_ns(&now) - timespec_to_ns(start);
@ -78,7 +78,7 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
ncplane_set_base(subtitle_plane, "", 0, channels);
ncplane_set_fg(subtitle_plane, 0x00ffff);
ncplane_set_fg_rgb(subtitle_plane, 0x00ffff);
ncplane_set_fg_alpha(subtitle_plane, CELL_ALPHA_HIGHCONTRAST);
ncplane_set_bg_alpha(subtitle_plane, CELL_ALPHA_TRANSPARENT);
}else{

View File

@ -65,7 +65,7 @@ TEST_CASE("Cell") {
notcurses_term_dim_yx(nc_, &dimy, &dimx);
cell_styles_set(&c, NCSTYLE_ITALIC);
CHECK(1 == cell_load(n_, &c, "i"));
cell_set_fg_rgb(&c, 255, 255, 255);
cell_set_fg_rgb8(&c, 255, 255, 255);
ncplane_set_base_cell(n_, &c);
cell_release(n_, &c);
CHECK(0 == notcurses_render(nc_));
@ -78,7 +78,7 @@ TEST_CASE("Cell") {
notcurses_term_dim_yx(nc_, &dimy, &dimx);
cell_styles_set(&c, NCSTYLE_BOLD);
CHECK(1 == cell_load(n_, &c, "b"));
cell_set_fg_rgb(&c, 255, 255, 255);
cell_set_fg_rgb8(&c, 255, 255, 255);
ncplane_set_base_cell(n_, &c);
cell_release(n_, &c);
CHECK(0 == notcurses_render(nc_));
@ -91,7 +91,7 @@ TEST_CASE("Cell") {
notcurses_term_dim_yx(nc_, &dimy, &dimx);
cell_styles_set(&c, NCSTYLE_UNDERLINE);
CHECK(1 == cell_load(n_, &c, "u"));
cell_set_fg_rgb(&c, 255, 255, 255);
cell_set_fg_rgb8(&c, 255, 255, 255);
ncplane_set_base_cell(n_, &c);
cell_release(n_, &c);
CHECK(0 == notcurses_render(nc_));
@ -142,14 +142,14 @@ TEST_CASE("Cell") {
// white on a black background ought be unmolested for highcontrast
SUBCASE("HighContrastWhiteOnBlackBackground"){
cell c = CELL_CHAR_INITIALIZER('+');
CHECK(0 == cell_set_fg_rgb(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_fg_rgb8(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT));
auto np = ncplane_new(nc_, 1, 1, 0, 0, nullptr);
REQUIRE(nullptr != np);
CHECK(1 == ncplane_putc(np, &c));
cell_load_char(np, &c, '*');
CHECK(0 == cell_set_bg_rgb(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_bg_rgb8(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE));
CHECK(1 == ncplane_putc(n_, &c));
CHECK(0 == notcurses_render(nc_));
@ -160,8 +160,8 @@ TEST_CASE("Cell") {
REQUIRE(nullptr != negc);
auto topegc = ncplane_at_yx(np, 0, 0, nullptr, &overchannels);
REQUIRE(nullptr != topegc);
CHECK(channels_bg(channels) == channels_bg(underchannels));
CHECK(channels_fg(channels) == channels_fg(overchannels));
CHECK(channels_bg_rgb(channels) == channels_bg_rgb(underchannels));
CHECK(channels_fg_rgb(channels) == channels_fg_rgb(overchannels));
ncplane_destroy(np);
free(topegc);
free(negc);
@ -171,14 +171,14 @@ TEST_CASE("Cell") {
// white on a white background ought be changed for highcontrast
SUBCASE("HighContrastWhiteOnWhiteBackground"){
cell c = CELL_CHAR_INITIALIZER('+');
CHECK(0 == cell_set_fg_rgb(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_fg_rgb8(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT));
auto np = ncplane_new(nc_, 1, 1, 0, 0, nullptr);
REQUIRE(nullptr != np);
CHECK(1 == ncplane_putc(np, &c));
cell_load_char(np, &c, '*');
CHECK(0 == cell_set_bg_rgb(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_bg_rgb8(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE));
CHECK(1 == ncplane_putc(n_, &c));
CHECK(0 == notcurses_render(nc_));
@ -189,8 +189,8 @@ TEST_CASE("Cell") {
REQUIRE(nullptr != negc);
auto topegc = ncplane_at_yx(np, 0, 0, nullptr, &overchannels);
REQUIRE(nullptr != topegc);
CHECK(channels_bg(channels) == channels_bg(underchannels));
CHECK(channels_fg(channels) < channels_fg(overchannels));
CHECK(channels_bg_rgb(channels) == channels_bg_rgb(underchannels));
CHECK(channels_fg_rgb(channels) < channels_fg_rgb(overchannels));
ncplane_destroy(np);
free(topegc);
free(negc);
@ -200,14 +200,14 @@ TEST_CASE("Cell") {
// black on a black background must be changed for highcontrast
SUBCASE("HighContrastBlackOnBlackBackground"){
cell c = CELL_CHAR_INITIALIZER('+');
CHECK(0 == cell_set_fg_rgb(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_fg_rgb8(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT));
auto np = ncplane_new(nc_, 1, 1, 0, 0, nullptr);
REQUIRE(nullptr != np);
CHECK(1 == ncplane_putc(np, &c));
cell_load_char(np, &c, '*');
CHECK(0 == cell_set_bg_rgb(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_bg_rgb8(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE));
CHECK(1 == ncplane_putc(n_, &c));
CHECK(0 == notcurses_render(nc_));
@ -218,8 +218,8 @@ TEST_CASE("Cell") {
REQUIRE(nullptr != negc);
auto topegc = ncplane_at_yx(np, 0, 0, nullptr, &overchannels);
REQUIRE(nullptr != topegc);
CHECK(channels_bg(channels) == channels_bg(underchannels));
CHECK(channels_fg(channels) > channels_fg(overchannels));
CHECK(channels_bg_rgb(channels) == channels_bg_rgb(underchannels));
CHECK(channels_fg_rgb(channels) > channels_fg_rgb(overchannels));
ncplane_destroy(np);
free(topegc);
free(negc);
@ -229,14 +229,14 @@ TEST_CASE("Cell") {
// black on a white background ought be unmolested for highcontrast
SUBCASE("HighContrastBlackOnWhiteBackground"){
cell c = CELL_CHAR_INITIALIZER('+');
CHECK(0 == cell_set_fg_rgb(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_fg_rgb8(&c, 0x0, 0x0, 0x0));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT));
auto np = ncplane_new(nc_, 1, 1, 0, 0, nullptr);
REQUIRE(nullptr != np);
CHECK(1 == ncplane_putc(np, &c));
cell_load_char(np, &c, '*');
CHECK(0 == cell_set_bg_rgb(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_bg_rgb8(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE));
CHECK(1 == ncplane_putc(n_, &c));
CHECK(0 == notcurses_render(nc_));
@ -247,8 +247,8 @@ TEST_CASE("Cell") {
REQUIRE(nullptr != negc);
auto topegc = ncplane_at_yx(np, 0, 0, nullptr, &overchannels);
REQUIRE(nullptr != topegc);
CHECK(channels_bg(channels) == channels_bg(underchannels));
CHECK(channels_fg(channels) == channels_fg(overchannels));
CHECK(channels_bg_rgb(channels) == channels_bg_rgb(underchannels));
CHECK(channels_fg_rgb(channels) == channels_fg_rgb(overchannels));
ncplane_destroy(np);
free(topegc);
free(negc);
@ -260,14 +260,14 @@ TEST_CASE("Cell") {
SUBCASE("HighContrastBelowOnly"){
cell c = CELL_TRIVIAL_INITIALIZER;
// top has a background of white
CHECK(0 == cell_set_bg_rgb(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_bg_rgb8(&c, 0xff, 0xff, 0xff));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT));
auto np = ncplane_new(nc_, 1, 1, 0, 0, nullptr);
REQUIRE(nullptr != np);
CHECK(1 == ncplane_putc(np, &c));
cell_load_char(n_, &c, '*');
// bottom has white foreground + HIGHCONTRAST, should remain white
CHECK(0 == cell_set_fg_rgb(&c, 0xff, 0x0, 0xff));
CHECK(0 == cell_set_fg_rgb8(&c, 0xff, 0x0, 0xff));
CHECK(0 == cell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST));
cell_set_bg_default(&c);
CHECK(1 == ncplane_putc(n_, &c));
@ -279,8 +279,8 @@ TEST_CASE("Cell") {
REQUIRE(nullptr != negc);
auto topegc = ncplane_at_yx(np, 0, 0, nullptr, &overchannels);
REQUIRE(nullptr != topegc);
CHECK(channels_bg(channels) == channels_bg(overchannels));
CHECK(channels_fg(channels) < channels_fg(underchannels));
CHECK(channels_bg_rgb(channels) == channels_bg_rgb(overchannels));
CHECK(channels_fg_rgb(channels) < channels_fg_rgb(underchannels));
free(topegc);
free(negc);
free(egc);

View File

@ -12,7 +12,7 @@ TEST_CASE("ChannelGetRGB") {
};
for(auto i = 0u ; i < sizeof(test) / sizeof(*test) ; ++i){
unsigned r, g, b;
CHECK(test[i].channel == channel_rgb(test[i].channel, &r, &g, &b));
CHECK(test[i].channel == channel_rgb8(test[i].channel, &r, &g, &b));
CHECK(test[i].r == r);
CHECK(test[i].g == g);
CHECK(test[i].b == b);
@ -70,13 +70,13 @@ TEST_CASE("ChannelSetDefault") {
TEST_CASE("ChannelBlend0") {
uint32_t c1 = 0;
uint32_t c2 = 0;
channel_set_rgb(&c1, 0x80, 0x40, 0x20);
channel_set_rgb(&c2, 0x88, 0x44, 0x22);
channel_set_rgb8(&c1, 0x80, 0x40, 0x20);
channel_set_rgb8(&c2, 0x88, 0x44, 0x22);
unsigned blends = 0;
uint32_t c = channels_blend(c1, c2, &blends);
CHECK(!channel_default_p(c));
unsigned r, g, b;
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0x88 == r);
CHECK(0x44 == g);
CHECK(0x22 == b);
@ -87,13 +87,13 @@ TEST_CASE("ChannelBlend0") {
TEST_CASE("ChannelBlend1") {
uint32_t c1 = 0;
uint32_t c2 = 0;
channel_set_rgb(&c1, 0x80, 0x40, 0x20);
channel_set_rgb(&c2, 0x0, 0x0, 0x0);
channel_set_rgb8(&c1, 0x80, 0x40, 0x20);
channel_set_rgb8(&c2, 0x0, 0x0, 0x0);
unsigned blends = 1;
uint32_t c = channels_blend(c1, c2, &blends);
CHECK(!channel_default_p(c));
unsigned r, g, b;
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0x40 == r);
CHECK(0x20 == g);
CHECK(0x10 == b);
@ -104,13 +104,13 @@ TEST_CASE("ChannelBlend1") {
TEST_CASE("ChannelBlend2") {
uint32_t c1 = 0;
uint32_t c2 = 0;
channel_set_rgb(&c1, 0x60, 0x30, 0x0f);
channel_set_rgb(&c2, 0x0, 0x0, 0x0);
channel_set_rgb8(&c1, 0x60, 0x30, 0x0f);
channel_set_rgb8(&c2, 0x0, 0x0, 0x0);
unsigned blends = 2;
uint32_t c = channels_blend(c1, c2, &blends);
CHECK(!channel_default_p(c));
unsigned r, g, b;
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0x40 == r);
CHECK(0x20 == g);
CHECK(0x0a == b);
@ -121,26 +121,26 @@ TEST_CASE("ChannelBlend2") {
TEST_CASE("ChannelBlendDefaultLeft") {
uint32_t c1 = 0;
uint32_t c2 = 0;
channel_set_rgb(&c2, 0x80, 0x40, 0x20);
channel_set_rgb8(&c2, 0x80, 0x40, 0x20);
unsigned blends = 0;
uint32_t c = channels_blend(c1, c2, &blends); // will replace
CHECK(!channel_default_p(c));
unsigned r, g, b;
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0x80 == r);
CHECK(0x40 == g);
CHECK(0x20 == b);
CHECK(1 == blends);
c = channels_blend(c1, c2, &blends); // will not replace
CHECK(channel_default_p(c));
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0 == r);
CHECK(0 == g);
CHECK(0 == b);
CHECK(2 == blends);
c = channels_blend(c1, c2, &blends); // will not replace
CHECK(channel_default_p(c));
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0 == r);
CHECK(0 == g);
CHECK(0 == b);
@ -151,7 +151,7 @@ TEST_CASE("ChannelBlendDefaultLeft") {
TEST_CASE("ChannelBlendDefaultRight") {
uint32_t c1 = 0;
uint32_t c2 = 0;
channel_set_rgb(&c1, 0x80, 0x40, 0x20);
channel_set_rgb8(&c1, 0x80, 0x40, 0x20);
CHECK(!channel_default_p(c1));
CHECK(channel_default_p(c2));
unsigned blends = 0;
@ -161,7 +161,7 @@ TEST_CASE("ChannelBlendDefaultRight") {
c = channels_blend(c1, c2, &blends);
CHECK(!channel_default_p(c));
unsigned r, g, b;
channel_rgb(c, &r, &g, &b);
channel_rgb8(c, &r, &g, &b);
CHECK(0x80 == r);
CHECK(0x40 == g);
CHECK(0x20 == b);

View File

@ -43,7 +43,7 @@ TEST_CASE("Fade") {
ncplane_dim_yx(n_, &dimy, &dimx);
cell c = CELL_TRIVIAL_INITIALIZER;
c.gcluster = '*';
cell_set_fg_rgb(&c, 0xff, 0xff, 0xff);
cell_set_fg_rgb8(&c, 0xff, 0xff, 0xff);
unsigned rgb = 0xffffffu;
CHECK(!ncplane_set_scrolling(n_, true));
for(int y = 0 ; y < dimy ; ++y){
@ -52,8 +52,8 @@ TEST_CASE("Fade") {
if(rgb < 32){
rgb = 0xffffffu;
}
cell_set_fg(&c, rgb);
cell_set_bg_rgb(&c, rgb & 0xff, (rgb >> 16u) & 0xff, (rgb >> 8u) & 0xff);
cell_set_fg_rgb(&c, rgb);
cell_set_bg_rgb8(&c, rgb & 0xff, (rgb >> 16u) & 0xff, (rgb >> 8u) & 0xff);
CHECK(0 < ncplane_putc(n_, &c));
}
}
@ -93,7 +93,7 @@ TEST_CASE("Fade") {
ts.tv_sec = 0;
ts.tv_nsec = 75000000;
ncplane_erase(n_);
ncplane_set_fg(n_, 0xffd700);
ncplane_set_fg_rgb(n_, 0xffd700);
CHECK(0 < ncplane_printf_aligned(n_, dimy - 1, NCALIGN_CENTER, "pulllllllse"));
struct timespec pulsestart;
clock_gettime(CLOCK_MONOTONIC, &pulsestart);

View File

@ -80,15 +80,15 @@ TEST_CASE("Fills") {
SUBCASE("GradientMonochromatic") {
uint64_t c = 0;
channels_set_fg(&c, 0x40f040);
channels_set_bg(&c, 0x40f040);
channels_set_fg_rgb(&c, 0x40f040);
channels_set_bg_rgb(&c, 0x40f040);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "M", 0, c, c, c, c, dimy, dimx));
cell cl = CELL_TRIVIAL_INITIALIZER;
uint64_t channels = 0;
channels_set_fg(&channels, 0x40f040);
channels_set_bg(&channels, 0x40f040);
channels_set_fg_rgb(&channels, 0x40f040);
channels_set_bg_rgb(&channels, 0x40f040);
// check all squares
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
@ -104,21 +104,21 @@ TEST_CASE("Fills") {
SUBCASE("GradientVertical") {
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0x40f040);
channels_set_bg(&ul, 0x40f040);
channels_set_fg(&ll, 0xf040f0);
channels_set_bg(&ll, 0xf040f0);
channels_set_fg(&ur, 0x40f040);
channels_set_bg(&ur, 0x40f040);
channels_set_fg(&lr, 0xf040f0);
channels_set_bg(&lr, 0xf040f0);
channels_set_fg_rgb(&ul, 0x40f040);
channels_set_bg_rgb(&ul, 0x40f040);
channels_set_fg_rgb(&ll, 0xf040f0);
channels_set_bg_rgb(&ll, 0xf040f0);
channels_set_fg_rgb(&ur, 0x40f040);
channels_set_bg_rgb(&ur, 0x40f040);
channels_set_fg_rgb(&lr, 0xf040f0);
channels_set_bg_rgb(&lr, 0xf040f0);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "V", 0, ul, ur, ll, lr, dimy, dimx));
cell c = CELL_TRIVIAL_INITIALIZER;
uint64_t channels = 0;
channels_set_fg(&channels, 0x40f040);
channels_set_bg(&channels, 0x40f040);
channels_set_fg_rgb(&channels, 0x40f040);
channels_set_bg_rgb(&channels, 0x40f040);
// check all squares. all rows ought be the same across their breadth, and
// the components ought be going in the correct direction.
uint64_t lastyrgb, lastxrgb;
@ -155,14 +155,14 @@ TEST_CASE("Fills") {
SUBCASE("GradientHorizontal") {
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0x40f040);
channels_set_bg(&ul, 0x40f040);
channels_set_fg(&ur, 0xf040f0);
channels_set_bg(&ur, 0xf040f0);
channels_set_fg(&ll, 0x40f040);
channels_set_bg(&ll, 0x40f040);
channels_set_fg(&lr, 0xf040f0);
channels_set_bg(&lr, 0xf040f0);
channels_set_fg_rgb(&ul, 0x40f040);
channels_set_bg_rgb(&ul, 0x40f040);
channels_set_fg_rgb(&ur, 0xf040f0);
channels_set_bg_rgb(&ur, 0xf040f0);
channels_set_fg_rgb(&ll, 0x40f040);
channels_set_bg_rgb(&ll, 0x40f040);
channels_set_fg_rgb(&lr, 0xf040f0);
channels_set_bg_rgb(&lr, 0xf040f0);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "H", 0, ul, ur, ll, lr, dimy, dimx));
@ -173,14 +173,14 @@ TEST_CASE("Fills") {
SUBCASE("GradientX") {
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0x000000);
channels_set_bg(&ul, 0xffffff);
channels_set_fg(&ll, 0x40f040);
channels_set_bg(&ll, 0x40f040);
channels_set_fg(&ur, 0xf040f0);
channels_set_bg(&ur, 0xf040f0);
channels_set_fg(&lr, 0xffffff);
channels_set_bg(&lr, 0x000000);
channels_set_fg_rgb(&ul, 0x000000);
channels_set_bg_rgb(&ul, 0xffffff);
channels_set_fg_rgb(&ll, 0x40f040);
channels_set_bg_rgb(&ll, 0x40f040);
channels_set_fg_rgb(&ur, 0xf040f0);
channels_set_bg_rgb(&ur, 0xf040f0);
channels_set_fg_rgb(&lr, 0xffffff);
channels_set_bg_rgb(&lr, 0x000000);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "X", 0, ul, ur, ll, lr, dimy, dimx));
@ -191,14 +191,14 @@ TEST_CASE("Fills") {
SUBCASE("GradientS") {
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0xffffff);
channels_set_bg(&ul, 0xffffff);
channels_set_fg(&lr, 0x000000);
channels_set_bg(&lr, 0x000000);
channels_set_fg(&ll, 0x00ffff);
channels_set_bg(&ll, 0xff0000);
channels_set_fg(&ur, 0xff00ff);
channels_set_bg(&ur, 0x00ff00);
channels_set_fg_rgb(&ul, 0xffffff);
channels_set_bg_rgb(&ul, 0xffffff);
channels_set_fg_rgb(&lr, 0x000000);
channels_set_bg_rgb(&lr, 0x000000);
channels_set_fg_rgb(&ll, 0x00ffff);
channels_set_bg_rgb(&ll, 0xff0000);
channels_set_fg_rgb(&ur, 0xff00ff);
channels_set_bg_rgb(&ur, 0x00ff00);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "S", 0, ul, ur, ll, lr, dimy, dimx));
@ -208,9 +208,9 @@ TEST_CASE("Fills") {
SUBCASE("Ncplane_Format") {
int sbytes;
CHECK(0 == ncplane_set_fg(n_, 0x444444));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc(n_, "A", &sbytes));
CHECK(0 == ncplane_set_fg(n_, 0x888888));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x888888));
CHECK(1 == ncplane_putegc(n_, "B", &sbytes));
CHECK(0 == notcurses_render(nc_));
// attr should change, but not the EGC/color
@ -221,12 +221,12 @@ TEST_CASE("Fills") {
cell d = CELL_TRIVIAL_INITIALIZER;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d));
CHECK(d.stylemask == c.stylemask);
CHECK(0x444444 == cell_fg(&d));
CHECK(0x444444 == cell_fg_rgb(&d));
}
SUBCASE("Ncplane_Stain") {
int sbytes;
CHECK(0 == ncplane_set_fg(n_, 0x444444));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
for(int y = 0 ; y < 8 ; ++y){
for(int x = 0 ; x < 8 ; ++x){
CHECK(1 == ncplane_putegc_yx(n_, y, x, "A", &sbytes));
@ -236,8 +236,8 @@ TEST_CASE("Fills") {
// EGC/color should change, but nothing else
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
uint64_t channels = 0;
channels_set_fg_rgb(&channels, 0x88, 0x99, 0x77);
channels_set_bg(&channels, 0);
channels_set_fg_rgb8(&channels, 0x88, 0x99, 0x77);
channels_set_bg_rgb(&channels, 0);
REQUIRE(0 < ncplane_stain(n_, 7, 7, channels, channels, channels, channels));
CHECK(0 == notcurses_render(nc_));
cell d = CELL_TRIVIAL_INITIALIZER;
@ -254,13 +254,13 @@ TEST_CASE("Fills") {
// test the single-cell (1x1) special case
SUBCASE("GradientSingleCell") {
int sbytes;
CHECK(0 == ncplane_set_fg(n_, 0x444444));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc_yx(n_, 0, 0, "A", &sbytes));
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
uint64_t channels = 0;
channels_set_fg_rgb(&channels, 0x88, 0x99, 0x77);
channels_set_bg(&channels, 0);
channels_set_fg_rgb8(&channels, 0x88, 0x99, 0x77);
channels_set_bg_rgb(&channels, 0);
REQUIRE(0 < ncplane_gradient(n_, "A", 0, channels, channels, channels, channels, 0, 0));
CHECK(0 == notcurses_render(nc_));
cell d = CELL_TRIVIAL_INITIALIZER;
@ -273,15 +273,15 @@ TEST_CASE("Fills") {
// 1d gradients over multiple cells
SUBCASE("Gradient1D") {
int sbytes;
CHECK(0 == ncplane_set_fg(n_, 0x444444));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc_yx(n_, 0, 0, "A", &sbytes));
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
uint64_t chan1 = 0, chan2 = 0;
channels_set_fg_rgb(&chan1, 0x88, 0x99, 0x77);
channels_set_fg_rgb(&chan2, 0x77, 0x99, 0x88);
channels_set_bg(&chan1, 0);
channels_set_bg(&chan2, 0);
channels_set_fg_rgb8(&chan1, 0x88, 0x99, 0x77);
channels_set_fg_rgb8(&chan2, 0x77, 0x99, 0x88);
channels_set_bg_rgb(&chan1, 0);
channels_set_bg_rgb(&chan2, 0);
REQUIRE(0 < ncplane_gradient(n_, "A", 0, chan1, chan2, chan1, chan2, 0, 3));
CHECK(0 == notcurses_render(nc_));
cell d = CELL_TRIVIAL_INITIALIZER;
@ -408,16 +408,16 @@ TEST_CASE("Fills") {
REQUIRE(p1);
cell c1 = CELL_TRIVIAL_INITIALIZER;
CHECK(0 < cell_load(p1, &c1, ""));
CHECK(0 == cell_set_bg(&c1, 0x00ff00));
CHECK(0 == cell_set_fg(&c1, 0x0000ff));
CHECK(0 == cell_set_bg_rgb(&c1, 0x00ff00));
CHECK(0 == cell_set_fg_rgb(&c1, 0x0000ff));
CHECK(0 < ncplane_polyfill_yx(p1, 0, 0, &c1));
CHECK(0 == notcurses_render(nc_));
auto p2 = ncplane_new(nc_, DIMY / 2, DIMX / 2, 3, 3, nullptr); // src, 5x5
REQUIRE(p2);
cell c2 = CELL_TRIVIAL_INITIALIZER;
CHECK(0 < cell_load(p2, &c2, "🞶"));
CHECK(0 == cell_set_bg(&c2, 0x00ffff));
CHECK(0 == cell_set_fg(&c2, 0xff00ff));
CHECK(0 == cell_set_bg_rgb(&c2, 0x00ffff));
CHECK(0 == cell_set_fg_rgb(&c2, 0xff00ff));
CHECK(0 < ncplane_polyfill_yx(p2, 0, 0, &c2));
CHECK(0 == ncplane_mergedown_simple(p2, p1));
CHECK(0 == notcurses_render(nc_));
@ -446,9 +446,9 @@ TEST_CASE("Fills") {
auto p1 = ncplane_new(nc_, DIMY, DIMX, 2, 2, nullptr);
REQUIRE(p1);
uint64_t ul = 0, ur = 0, bl = 0, br = 0;
channels_set_fg(&ur, 0xff0000);
channels_set_fg(&bl, 0x00ff00);
channels_set_fg(&br, 0x0000ff);
channels_set_fg_rgb(&ur, 0xff0000);
channels_set_fg_rgb(&bl, 0x00ff00);
channels_set_fg_rgb(&br, 0x0000ff);
ncplane_highgradient_sized(p1, ul, ur, bl, br, DIMY, DIMX);
CHECK(0 == notcurses_render(nc_));
auto p2 = ncplane_new(nc_, DIMY / 2, DIMX / 2, 3, 3, nullptr);

View File

@ -86,20 +86,20 @@ TEST_CASE("NCPlane") {
}
SUBCASE("SetPlaneRGB") {
CHECK(0 == ncplane_set_fg_rgb(n_, 0, 0, 0));
CHECK(0 == ncplane_set_fg_rgb(n_, 255, 255, 255));
CHECK(0 == ncplane_set_fg_rgb8(n_, 0, 0, 0));
CHECK(0 == ncplane_set_fg_rgb8(n_, 255, 255, 255));
CHECK(0 == notcurses_render(nc_));
}
SUBCASE("RejectBadRGB") {
CHECK(0 > ncplane_set_fg_rgb(n_, -1, 0, 0));
CHECK(0 > ncplane_set_fg_rgb(n_, 0, -1, 0));
CHECK(0 > ncplane_set_fg_rgb(n_, 0, 0, -1));
CHECK(0 > ncplane_set_fg_rgb(n_, -1, -1, -1));
CHECK(0 > ncplane_set_fg_rgb(n_, 256, 255, 255));
CHECK(0 > ncplane_set_fg_rgb(n_, 255, 256, 255));
CHECK(0 > ncplane_set_fg_rgb(n_, 255, 255, 256));
CHECK(0 > ncplane_set_fg_rgb(n_, 256, 256, 256));
CHECK(0 > ncplane_set_fg_rgb8(n_, -1, 0, 0));
CHECK(0 > ncplane_set_fg_rgb8(n_, 0, -1, 0));
CHECK(0 > ncplane_set_fg_rgb8(n_, 0, 0, -1));
CHECK(0 > ncplane_set_fg_rgb8(n_, -1, -1, -1));
CHECK(0 > ncplane_set_fg_rgb8(n_, 256, 255, 255));
CHECK(0 > ncplane_set_fg_rgb8(n_, 255, 256, 255));
CHECK(0 > ncplane_set_fg_rgb8(n_, 255, 255, 256));
CHECK(0 > ncplane_set_fg_rgb8(n_, 256, 256, 256));
}
// Verify we can emit a multibyte character, and it advances the cursor
@ -591,14 +591,14 @@ TEST_CASE("NCPlane") {
REQUIRE(40 < dimx);
cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
REQUIRE(0 == cells_double_box(n_, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl));
CHECK(0 == channels_set_fg_rgb(&ul.channels, 255, 0, 0));
CHECK(0 == channels_set_fg_rgb(&ur.channels, 0, 255, 0));
CHECK(0 == channels_set_fg_rgb(&ll.channels, 0, 0, 255));
CHECK(0 == channels_set_fg_rgb(&lr.channels, 255, 255, 255));
CHECK(0 == channels_set_bg_rgb(&ul.channels, 0, 255, 255));
CHECK(0 == channels_set_bg_rgb(&ur.channels, 255, 0, 255));
CHECK(0 == channels_set_bg_rgb(&ll.channels, 255, 255, 0));
CHECK(0 == channels_set_bg_rgb(&lr.channels, 0, 0, 0));
CHECK(0 == channels_set_fg_rgb8(&ul.channels, 255, 0, 0));
CHECK(0 == channels_set_fg_rgb8(&ur.channels, 0, 255, 0));
CHECK(0 == channels_set_fg_rgb8(&ll.channels, 0, 0, 255));
CHECK(0 == channels_set_fg_rgb8(&lr.channels, 255, 255, 255));
CHECK(0 == channels_set_bg_rgb8(&ul.channels, 0, 255, 255));
CHECK(0 == channels_set_bg_rgb8(&ur.channels, 255, 0, 255));
CHECK(0 == channels_set_bg_rgb8(&ll.channels, 255, 255, 0));
CHECK(0 == channels_set_bg_rgb8(&lr.channels, 0, 0, 0));
// we'll try all 16 gradmasks in sideszXsidesz configs in a 4x4 map
unsigned gradmask = 0;
for(auto y0 = 0 ; y0 < 4 ; ++y0){
@ -630,18 +630,18 @@ TEST_CASE("NCPlane") {
cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
REQUIRE(0 == cells_rounded_box(n_, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl));
// we'll try all 16 boxmasks in sideszXsidesz configurations in a 4x4 map
CHECK(0 == channels_set_fg_rgb(&ul.channels, 255, 0, 0));
CHECK(0 == channels_set_fg_rgb(&ur.channels, 0, 255, 0));
CHECK(0 == channels_set_fg_rgb(&ll.channels, 0, 0, 255));
CHECK(0 == channels_set_fg_rgb(&lr.channels, 0, 0, 0));
CHECK(0 == channels_set_bg_rgb(&ul.channels, 0, 255, 255));
CHECK(0 == channels_set_bg_rgb(&ur.channels, 255, 0, 255));
CHECK(0 == channels_set_bg_rgb(&ll.channels, 255, 255, 0));
CHECK(0 == channels_set_bg_rgb(&lr.channels, 0, 0, 0));
CHECK(0 == channels_set_fg_rgb(&hl.channels, 255, 0, 255));
CHECK(0 == channels_set_fg_rgb(&vl.channels, 255, 255, 255));
CHECK(0 == channels_set_bg_rgb(&hl.channels, 0, 255, 0));
CHECK(0 == channels_set_bg_rgb(&vl.channels, 0, 0, 0));
CHECK(0 == channels_set_fg_rgb8(&ul.channels, 255, 0, 0));
CHECK(0 == channels_set_fg_rgb8(&ur.channels, 0, 255, 0));
CHECK(0 == channels_set_fg_rgb8(&ll.channels, 0, 0, 255));
CHECK(0 == channels_set_fg_rgb8(&lr.channels, 0, 0, 0));
CHECK(0 == channels_set_bg_rgb8(&ul.channels, 0, 255, 255));
CHECK(0 == channels_set_bg_rgb8(&ur.channels, 255, 0, 255));
CHECK(0 == channels_set_bg_rgb8(&ll.channels, 255, 255, 0));
CHECK(0 == channels_set_bg_rgb8(&lr.channels, 0, 0, 0));
CHECK(0 == channels_set_fg_rgb8(&hl.channels, 255, 0, 255));
CHECK(0 == channels_set_fg_rgb8(&vl.channels, 255, 255, 255));
CHECK(0 == channels_set_bg_rgb8(&hl.channels, 0, 255, 0));
CHECK(0 == channels_set_bg_rgb8(&vl.channels, 0, 0, 0));
for(auto y0 = 0 ; y0 < 4 ; ++y0){
for(auto x0 = 0 ; x0 < 4 ; ++x0){
CHECK(0 == ncplane_cursor_move_yx(n_, y0 * sidesz, x0 * (sidesz + 1)));
@ -714,26 +714,26 @@ TEST_CASE("NCPlane") {
SUBCASE("EGCStainable") {
cell c = CELL_TRIVIAL_INITIALIZER;
int sbytes;
CHECK(0 == ncplane_set_fg(n_, 0x444444));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc(n_, "A", &sbytes));
CHECK(0 == ncplane_set_fg(n_, 0x888888));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x888888));
CHECK(1 == ncplane_putegc(n_, "B", &sbytes));
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
CHECK(0 == notcurses_render(nc_));
// EGC should change, but not the color
CHECK(0 == ncplane_set_fg(n_, 0x222222));
CHECK(0 == ncplane_set_fg_rgb(n_, 0x222222));
CHECK(1 == ncplane_putegc_stainable(n_, "C", &sbytes));
CHECK(1 == ncplane_putegc_stainable(n_, "D", &sbytes));
uint64_t channels = 0;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &c));
CHECK(cell_simple_p(&c));
CHECK('C' == c.gcluster);
CHECK(0 == channels_set_fg(&channels, 0x444444));
CHECK(0 == channels_set_fg_rgb(&channels, 0x444444));
CHECK(channels == c.channels);
CHECK(1 == ncplane_at_yx_cell(n_, 0, 1, &c));
CHECK(cell_simple_p(&c));
CHECK('D' == c.gcluster);
CHECK(0 == channels_set_fg(&channels, 0x888888));
CHECK(0 == channels_set_fg_rgb(&channels, 0x888888));
CHECK(channels == c.channels);
CHECK(0 == notcurses_render(nc_));
}

View File

@ -17,9 +17,9 @@ TEST_CASE("Palette256") {
SUBCASE("SetIndexZero") {
palette256* p = palette256_new(nc_);
REQUIRE(nullptr != p);
palette256_set_rgb(p, 0, 0x80, 0x90, 0xa0);
palette256_set_rgb8(p, 0, 0x80, 0x90, 0xa0);
unsigned r, g, b;
palette256_get_rgb(p, 0, &r, &g, &b);
palette256_get_rgb8(p, 0, &r, &g, &b);
CHECK(r == 0x80);
CHECK(g == 0x90);
CHECK(b == 0xa0);
@ -29,9 +29,9 @@ TEST_CASE("Palette256") {
SUBCASE("SetIndex255") {
palette256* p = palette256_new(nc_);
REQUIRE(nullptr != p);
palette256_set_rgb(p, 255, 0xa0, 0x70, 0x50);
palette256_set_rgb8(p, 255, 0xa0, 0x70, 0x50);
unsigned r, g, b;
palette256_get_rgb(p, 255, &r, &g, &b);
palette256_get_rgb8(p, 255, &r, &g, &b);
CHECK(r == 0xa0);
CHECK(g == 0x70);
CHECK(b == 0x50);

View File

@ -10,14 +10,14 @@ TEST_CASE("Resize") {
REQUIRE(n_);
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0x40f040);
channels_set_bg(&ul, 0x40f040);
channels_set_fg(&ll, 0xf040f0);
channels_set_bg(&ll, 0xf040f0);
channels_set_fg(&ur, 0x40f040);
channels_set_bg(&ur, 0x40f040);
channels_set_fg(&lr, 0xf040f0);
channels_set_bg(&lr, 0xf040f0);
channels_set_fg_rgb(&ul, 0x40f040);
channels_set_bg_rgb(&ul, 0x40f040);
channels_set_fg_rgb(&ll, 0xf040f0);
channels_set_bg_rgb(&ll, 0xf040f0);
channels_set_fg_rgb(&ur, 0x40f040);
channels_set_bg_rgb(&ur, 0x40f040);
channels_set_fg_rgb(&lr, 0xf040f0);
channels_set_bg_rgb(&lr, 0xf040f0);
// start at full size, and shrink to a nothing
SUBCASE("ResizeShrink") {

View File

@ -40,14 +40,14 @@ TEST_CASE("Rotate") {
uint64_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
channels_set_fg(&ul, 0x40f040);
channels_set_bg(&ul, 0x40f040);
channels_set_fg(&ll, 0xf040f0);
channels_set_bg(&ll, 0xf040f0);
channels_set_fg(&ur, 0x40f040);
channels_set_bg(&ur, 0x40f040);
channels_set_fg(&lr, 0xf040f0);
channels_set_bg(&lr, 0xf040f0);
channels_set_fg_rgb(&ul, 0x40f040);
channels_set_bg_rgb(&ul, 0x40f040);
channels_set_fg_rgb(&ll, 0xf040f0);
channels_set_bg_rgb(&ll, 0xf040f0);
channels_set_fg_rgb(&ur, 0x40f040);
channels_set_bg_rgb(&ur, 0x40f040);
channels_set_fg_rgb(&lr, 0xf040f0);
channels_set_bg_rgb(&lr, 0xf040f0);
SUBCASE("RotateTransparentCW") {
struct ncplane* testn = ncplane_new(nc_, 8, 16, dimy / 2, dimx / 2, nullptr);
@ -132,11 +132,11 @@ TEST_CASE("Rotate") {
char* c = notcurses_at_yx(nc_, 0, x, &stylemask, &channels);
REQUIRE(c);
CHECK(0 == strcmp(c, " "));
if(channels_fg(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_fg(channels));
if(channels_fg_rgb(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_fg_rgb(channels));
}
if(channels_bg(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_bg(channels));
if(channels_bg_rgb(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_bg_rgb(channels));
}
free(c);
}
@ -183,11 +183,11 @@ TEST_CASE("Rotate") {
char* c = notcurses_at_yx(nc_, 0, x, &stylemask, &channels);
REQUIRE(c);
CHECK(0 == strcmp(c, " "));
if(channels_fg(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_fg(channels));
if(channels_fg_rgb(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_fg_rgb(channels));
}
if(channels_bg(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_bg(channels));
if(channels_bg_rgb(channels) & CELL_BG_RGB_MASK){
CHECK(0xffccbb == channels_bg_rgb(channels));
}
free(c);
}

View File

@ -182,8 +182,8 @@ TEST_CASE("Visual") {
uint64_t channels;
char* egc = notcurses_at_yx(nc_, y, x, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK((rgba[y * 2 * DIMX + x] & 0xffffff) == channels_bg(channels));
CHECK((rgba[(y * 2 + 1) * DIMX + x] & 0xffffff) == channels_fg(channels));
CHECK((rgba[y * 2 * DIMX + x] & 0xffffff) == channels_bg_rgb(channels));
CHECK((rgba[(y * 2 + 1) * DIMX + x] & 0xffffff) == channels_fg_rgb(channels));
free(egc);
}
}
@ -222,8 +222,8 @@ TEST_CASE("Visual") {
uint64_t channels;
char* egc = notcurses_at_yx(nc_, y, x, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK((rgba[(y * 2 * DIMX) + (x * 2)] & 0xffffff) == channels_fg(channels));
CHECK((rgba[(y * 2 + 1) * DIMX + (x * 2) + 1] & 0xffffff) == channels_fg(channels));
CHECK((rgba[(y * 2 * DIMX) + (x * 2)] & 0xffffff) == channels_fg_rgb(channels));
CHECK((rgba[(y * 2 + 1) * DIMX + (x * 2) + 1] & 0xffffff) == channels_fg_rgb(channels));
free(egc);
}
}

View File

@ -379,12 +379,12 @@ TEST_CASE("Wide") {
REQUIRE(nullptr != p);
cell c = CELL_CHAR_INITIALIZER('X');
CHECK(0 == ncplane_perimeter(p, &c, &c, &c, &c, &c, &c, 0));
ncplane_set_bg_rgb(n_, 0x20, 0x20, 0x20);
ncplane_set_bg_rgb8(n_, 0x20, 0x20, 0x20);
int sbytes;
CHECK(2 == ncplane_putegc_yx(n_, 1, 1, "", &sbytes));
uint64_t channels = 0;
channels_set_bg_alpha(&channels, CELL_ALPHA_BLEND);
channels_set_bg_rgb(&channels, 0x80, 0xf0, 0x10);
channels_set_bg_rgb8(&channels, 0x80, 0xf0, 0x10);
CHECK(1 == ncplane_set_base(p, " ", 0, channels));
CHECK(0 == notcurses_render(nc_));
uint16_t stylemask;
@ -412,11 +412,11 @@ TEST_CASE("Wide") {
// drag a plane of narrow chars across a plane of wide glyphs
SUBCASE("NarrowPlaneAtopWide") {
notcurses_cursor_disable(nc_);
CHECK(0 == ncplane_set_fg_rgb(n_, 0xff, 0, 0xff));
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(nc_, 1, 4, 0, 4, nullptr);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb(topp, 0, 0xff, 0));
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(4 == ncplane_putstr(topp, "abcd"));
CHECK(12 == ncplane_putstr(n_, "六六六六"));
CHECK(0 == notcurses_render(nc_));
@ -586,11 +586,11 @@ TEST_CASE("Wide") {
// drag a plane of wide glyphs across a plane of wide glyphs
SUBCASE("WidePlaneAtopWide") {
CHECK(0 == ncplane_set_fg_rgb(n_, 0xff, 0, 0xff));
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(nc_, 1, 4, 0, 4, nullptr);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb(topp, 0, 0xff, 0));
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(6 == ncplane_putstr(topp, "次次"));
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
CHECK(12 == ncplane_putstr(n_, "六六六六"));
@ -731,11 +731,11 @@ TEST_CASE("Wide") {
// drag a plane of wide glyphs across a plane of narrow glyphs
SUBCASE("WidePlaneAtopNarrow") {
CHECK(0 == ncplane_set_fg_rgb(n_, 0xff, 0, 0xff));
CHECK(0 == ncplane_set_fg_rgb8(n_, 0xff, 0, 0xff));
// start the 1x4 top plane at 0, 4
struct ncplane* topp = ncplane_new(nc_, 1, 4, 0, 4, nullptr);
REQUIRE(nullptr != topp);
CHECK(0 == ncplane_set_bg_rgb(topp, 0, 0xff, 0));
CHECK(0 == ncplane_set_bg_rgb8(topp, 0, 0xff, 0));
CHECK(6 == ncplane_putstr(topp, "次次"));
CHECK(8 == ncplane_putstr(n_, "abcdefgh"));
CHECK(0 == notcurses_render(nc_));

View File

@ -82,7 +82,7 @@ TEST_CASE("ZAxis") {
SUBCASE("ZAxisDamage") {
cell cat = CELL_TRIVIAL_INITIALIZER;
cell c = CELL_CHAR_INITIALIZER('x');
REQUIRE(!cell_set_fg_rgb(&c, 0xff, 0, 0));
REQUIRE(!cell_set_fg_rgb8(&c, 0xff, 0, 0));
REQUIRE(1 == ncplane_putc(n_, &c));
CHECK(!notcurses_render(nc_));
REQUIRE(!ncplane_cursor_move_yx(n_, 0, 0));
@ -91,7 +91,7 @@ TEST_CASE("ZAxis") {
REQUIRE(0 == strcmp("x", cell_extended_gcluster(n_, &c)));
struct ncplane* n2 = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(1 == cell_load(n2, &c, "y"));
REQUIRE(!cell_set_fg_rgb(&c, 0, 0xff, 0));
REQUIRE(!cell_set_fg_rgb8(&c, 0, 0xff, 0));
REQUIRE(1 == ncplane_putc(n2, &c));
CHECK_EQ(0, notcurses_render(nc_));
REQUIRE(!ncplane_cursor_move_yx(n2, 0, 0));
@ -99,7 +99,7 @@ TEST_CASE("ZAxis") {
REQUIRE(0 == strcmp("y", cell_extended_gcluster(n_, &c)));
struct ncplane* n3 = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(1 == cell_load(n3, &c, "z"));
REQUIRE(!cell_set_fg_rgb(&c, 0, 0, 0xff));
REQUIRE(!cell_set_fg_rgb8(&c, 0, 0, 0xff));
REQUIRE(1 == ncplane_putc(n3, &c));
CHECK(!notcurses_render(nc_));
REQUIRE(!ncplane_cursor_move_yx(n3, 0, 0));