ncdirect: set_ on rgb functions #1261

This commit is contained in:
nick black 2020-12-28 13:52:58 -05:00
parent 5d99b440e7
commit f1253560ad
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
11 changed files with 114 additions and 81 deletions

View File

@ -5,8 +5,8 @@ rearrangements of Notcurses.
* `ncdirect_styles_{set, on, off}()` have been deprecated in favor of
`ncdirect_{set, on, off}_styles()`, to match `ncplane_` equivalents.
* `ncdirect_raster_frame()` no longer requires `blitter` nor `scale`.
* `ncdirect_{fg, bg}_default()` have been deprecated in favor of
`ncdirect_set_{fg, bg}_default()`, to match `ncplane`.
* `ncdirect_{fg, bg}_{default, rgb}()` have been deprecated in favor of
`ncdirect_set_{fg, bg}_{default, rgb}()`, to match `ncplane`.
* 2.1.2 (2020-12-25)
* Add `notcurses_linesigs_enable()` and `notcurses_linesigs_disable()`.

View File

@ -14,17 +14,17 @@ ncdirect_init - minimal notcurses instances for styling text
**unsigned ncdirect_palette_size(const struct ncdirect* ***nc***);**
**int ncdirect_bg_rgb8(struct ncdirect* ***nc***, unsigned ***r***, unsigned ***g***, unsigned ***b***);**
**int ncdirect_set_bg_rgb8(struct ncdirect* ***nc***, unsigned ***r***, unsigned ***g***, unsigned ***b***);**
**int ncdirect_fg_rgb8(struct ncdirect* ***nc***, unsigned ***r***, unsigned ***g***, unsigned ***b***);**
**int ncdirect_set_fg_rgb8(struct ncdirect* ***nc***, unsigned ***r***, unsigned ***g***, unsigned ***b***);**
**int ncdirect_fg_rgb(struct ncdirect* ***nc***, unsigned ***rgb***);**
**int ncdirect_set_fg_rgb(struct ncdirect* ***nc***, unsigned ***rgb***);**
**int ncdirect_bg_rgb(struct ncdirect* ***nc***, unsigned ***rgb***);**
**int ncdirect_set_bg_rgb(struct ncdirect* ***nc***, unsigned ***rgb***);**
**int ncdirect_fg_default(struct ncdirect* ***nc***);**
**int ncdirect_set_fg_default(struct ncdirect* ***nc***);**
**int ncdirect_bg_default(struct ncdirect* ***nc***);**
**int ncdirect_set_bg_default(struct ncdirect* ***nc***);**
**int ncdirect_dim_x(const struct ncdirect* ***nc***);**

View File

@ -40,12 +40,12 @@ namespace ncpp
bool set_fg_rgb (unsigned rgb) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_fg_rgb (direct, rgb), -1);
return error_guard (ncdirect_set_fg_rgb (direct, rgb), -1);
}
bool set_fg_rgb (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_fg_rgb8 (direct, r, g, b), -1);
return error_guard (ncdirect_set_fg_rgb8 (direct, r, g, b), -1);
}
bool fg_palindex (int pidx) const NOEXCEPT_MAYBE
@ -60,12 +60,12 @@ namespace ncpp
bool set_bg_rgb (unsigned rgb) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_bg_rgb (direct, rgb), -1);
return error_guard (ncdirect_set_bg_rgb (direct, rgb), -1);
}
bool set_bg_rgb (unsigned r, unsigned g, unsigned b) const NOEXCEPT_MAYBE
{
return error_guard (ncdirect_bg_rgb8 (direct, r, g, b), -1);
return error_guard (ncdirect_set_bg_rgb8 (direct, r, g, b), -1);
}
bool bg_palindex (int pidx) const NOEXCEPT_MAYBE

View File

@ -37,8 +37,23 @@ 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_rgb(struct ncdirect* nc, unsigned rgb);
API int ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb);
API int ncdirect_set_fg_rgb(struct ncdirect* nc, unsigned rgb);
API int ncdirect_set_bg_rgb(struct ncdirect* nc, unsigned rgb);
static inline int
ncdirect_fg_rgb(struct ncdirect* nc, unsigned rgb){
return ncdirect_set_fg_rgb(nc, rgb);
}
static inline int
ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb){
return ncdirect_set_bg_rgb(nc, rgb);
}
API int ncdirect_fg_rgb(struct ncdirect* nc, unsigned rgb)
__attribute__ ((deprecated));
API int ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb)
__attribute__ ((deprecated));
API int ncdirect_fg_palindex(struct ncdirect* nc, int pidx);
API int ncdirect_bg_palindex(struct ncdirect* nc, int pidx);
@ -63,21 +78,39 @@ API int ncdirect_printf_aligned(struct ncdirect* n, int y, ncalign_e align,
API int ncdirect_flush(const struct ncdirect* nc);
static inline int
ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
ncdirect_set_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){
return -1;
}
return ncdirect_bg_rgb(nc, (r << 16u) + (g << 8u) + b);
return ncdirect_set_bg_rgb(nc, (r << 16u) + (g << 8u) + b);
}
static inline int
ncdirect_set_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){
return -1;
}
return ncdirect_set_fg_rgb(nc, (r << 16u) + (g << 8u) + b);
}
static inline int
ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){
return -1;
}
return ncdirect_fg_rgb(nc, (r << 16u) + (g << 8u) + b);
return ncdirect_set_fg_rgb8(nc, r, g, b);
}
static inline int
ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
return ncdirect_set_bg_rgb8(nc, r, g, b);
}
static inline int
ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b)
__attribute__ ((deprecated));
static inline int
ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b)
__attribute__ ((deprecated));
API int ncdirect_set_fg_default(struct ncdirect* nc);
API int ncdirect_set_bg_default(struct ncdirect* nc);

View File

@ -104,20 +104,20 @@ static struct {
static void
usage_option(FILE* out, struct ncdirect* n, const char* op){
if(n) ncdirect_fg_rgb8(n, 0x80, 0x80, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0x80, 0x80, 0x80);
fprintf(out, " [ ");
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, "%s", op);
if(n) ncdirect_fg_rgb8(n, 0x80, 0x80, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0x80, 0x80, 0x80);
fprintf(out, " ] ");
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_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_rgb8(n, 0xff, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " %s: ", op);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_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_rgb8(n, 0x00, 0xc0, 0xc0);
if(n) ncdirect_set_fg_rgb8(n, 0x00, 0xc0, 0xc0);
fprintf(out, "usage: ");
if(n) ncdirect_fg_rgb8(n, 0x80, 0xff, 0x80);
if(n) ncdirect_set_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_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_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_rgb8(n, 0xff, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " -l:");
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, " logging level (%d: silent..%d: manic)\n", NCLOGLEVEL_SILENT, NCLOGLEVEL_TRACE);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, " -p:");
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_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_rgb8(n, 0x80, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0x80, 0xff, 0x80);
fprintf(out, " default spec: %s\n\n", DEFAULT_DEMO);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_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_rgb8(n, 0xff, 0xff, 0x80);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0x80);
fprintf(out, "%lc ", *demos[i].name - 'a' + 0x24d0);
if(n) ncdirect_fg_rgb8(n, 0xff, 0xff, 0xff);
if(n) ncdirect_set_fg_rgb8(n, 0xff, 0xff, 0xff);
fprintf(out, "%-*.*s", 8, 8, demos[i].name + 1);
if(++printed % 5 == 0){
fprintf(out, "\n");
@ -359,9 +359,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_rgb(nc, color);
ncdirect_set_fg_rgb(nc, color);
fputs(str, stdout);
ncdirect_fg_rgb8(nc, 178, 102, 255);
ncdirect_set_fg_rgb8(nc, 178, 102, 255);
fputs(delim, stdout);
return 0;
}
@ -373,12 +373,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_rgb8(nc, 0xD4, 0xAF, 0x37);
ncdirect_set_fg_rgb8(nc, 0xD4, 0xAF, 0x37);
va_list va;
va_start(va, fmt);
vfprintf(stdout, fmt, va);
va_end(va);
ncdirect_fg_rgb8(nc, 178, 102, 255);
ncdirect_set_fg_rgb8(nc, 178, 102, 255);
fputs(delim, stdout);
return 0;
}
@ -443,13 +443,13 @@ summary_table(struct ncdirect* nc, const char* spec, bool canimage, bool canvide
}else{
rescolor = 0x32CD32;
}
ncdirect_fg_rgb(nc, rescolor);
ncdirect_set_fg_rgb(nc, rescolor);
printf("%2zu", i + 1);
ncdirect_fg_rgb8(nc, 178, 102, 255);
ncdirect_set_fg_rgb8(nc, 178, 102, 255);
printf("");
ncdirect_fg_rgb(nc, rescolor);
ncdirect_set_fg_rgb(nc, rescolor);
printf("%8s", demos[results[i].selector - 'a'].name);
ncdirect_fg_rgb8(nc, 178, 102, 255);
ncdirect_set_fg_rgb8(nc, 178, 102, 255);
printf("│%*ss│%7ju│%*s│ %*ss│%7.1f│%2jd│%2jd│%*s║",
PREFIXFMT(timebuf), (uintmax_t)(results[i].stats.renders),
BPREFIXFMT(totalbuf), PREFIXFMT(rtimebuf),
@ -460,7 +460,7 @@ summary_table(struct ncdirect* nc, const char* spec, bool canimage, bool canvide
(uintmax_t)(results[i].timens ?
results[i].stats.writeout_ns * 100 / results[i].timens : 0),
PREFIXFMT(tfpsbuf));
ncdirect_fg_rgb(nc, rescolor);
ncdirect_set_fg_rgb(nc, rescolor);
printf("%s\n", results[i].result < 0 ? "FAILED" :
results[i].result > 0 ? "ABORTED" :
!results[i].stats.renders ? "SKIPPED" : "");
@ -483,12 +483,12 @@ summary_table(struct ncdirect* nc, const char* spec, bool canimage, bool canvide
table_printf(nc, "", " %*ss", PREFIXFMT(rtimebuf));
table_printf(nc, "", "%7.1f", nsdelta ? totalframes / ((double)nsdelta / GIG) : 0);
printf("\n");
ncdirect_fg_rgb8(nc, 0xff, 0xb0, 0xb0);
ncdirect_set_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);
}
ncdirect_fg_rgb8(nc, 0xfe, 0x20, 0x76); // PANTONE Strong Red C + 3x0x20
ncdirect_set_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
#ifdef DFSG_BUILD
fprintf(stderr, "\nDFSG version. Some demos are unavailable.\n");

View File

@ -29,14 +29,14 @@ int ncdirect_putstr(ncdirect* nc, uint64_t channels, const char* utf8){
if(ncdirect_fg_default_p(nc)){
return -1;
}
}else if(ncdirect_fg_rgb(nc, channels_fg_rgb(channels))){
}else if(ncdirect_set_fg_rgb(nc, channels_fg_rgb(channels))){
return -1;
}
if(channels_bg_default_p(channels)){
if(ncdirect_set_bg_default(nc)){
return -1;
}
}else if(ncdirect_bg_rgb(nc, channels_bg_rgb(channels))){
}else if(ncdirect_set_bg_rgb(nc, channels_bg_rgb(channels))){
return -1;
}
return fprintf(nc->ttyfp, "%s", utf8);
@ -407,12 +407,12 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
if(channels_fg_alpha(channels) == CELL_ALPHA_TRANSPARENT){
ncdirect_set_fg_default(n);
}else{
ncdirect_fg_rgb(n, channels_fg_rgb(channels));
ncdirect_set_fg_rgb(n, channels_fg_rgb(channels));
}
if(channels_bg_alpha(channels) == CELL_ALPHA_TRANSPARENT){
ncdirect_set_bg_default(n);
}else{
ncdirect_bg_rgb(n, channels_bg_rgb(channels));
ncdirect_set_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){
@ -440,12 +440,12 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
if(fgdefault){
ncdirect_set_fg_default(n);
}else{
ncdirect_fg_rgb(n, fgrgb);
ncdirect_set_fg_rgb(n, fgrgb);
}
if(bgdefault){
ncdirect_set_bg_default(n);
}else{
ncdirect_bg_rgb(n, bgrgb);
ncdirect_set_bg_rgb(n, bgrgb);
}
return 0;
}
@ -687,10 +687,10 @@ ncdirect_style_emit(ncdirect* n, unsigned stylebits, FILE* out){
if(r == 0){
// FIXME need to handle palette-indexed colors
if(!ncdirect_fg_default_p(n)){
r |= ncdirect_fg_rgb(n, channels_fg_rgb(n->channels));
r |= ncdirect_set_fg_rgb(n, channels_fg_rgb(n->channels));
}
if(!ncdirect_bg_default_p(n)){
r |= ncdirect_bg_rgb(n, channels_bg_rgb(n->channels));
r |= ncdirect_set_bg_rgb(n, channels_bg_rgb(n->channels));
}
}
return r;
@ -777,7 +777,7 @@ int ncdirect_set_fg_default(ncdirect* nc){
}
}else if(term_emit("op", nc->tcache.op, nc->ttyfp, false) == 0){
if(!ncdirect_bg_default_p(nc)){
if(ncdirect_bg_rgb(nc, channels_bg_rgb(nc->channels))){
if(ncdirect_set_bg_rgb(nc, channels_bg_rgb(nc->channels))){
return -1;
}
}
@ -796,7 +796,7 @@ int ncdirect_set_bg_default(ncdirect* nc){
}
}else if(term_emit("op", nc->tcache.op, nc->ttyfp, false) == 0){
if(!ncdirect_fg_default_p(nc)){
if(ncdirect_fg_rgb(nc, channels_fg_rgb(nc->channels))){
if(ncdirect_set_fg_rgb(nc, channels_fg_rgb(nc->channels))){
return -1;
}
}
@ -840,10 +840,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_rgb8(n, r, g, b);
ncdirect_set_fg_rgb8(n, r, g, b);
}
if(!bgdef){
ncdirect_bg_rgb8(n, br, bg, bb);
ncdirect_set_bg_rgb8(n, br, bg, bb);
}
if(fprintf(n->ttyfp, "%s", egc) < 0){
break;
@ -918,8 +918,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_rgb(n, channels_fg_rgb(ul));
ncdirect_bg_rgb(n, channels_bg_rgb(ul));
ncdirect_set_fg_rgb(n, channels_fg_rgb(ul));
ncdirect_set_bg_rgb(n, channels_bg_rgb(ul));
if(fprintf(n->ttyfp, "%lc", wchars[0]) < 0){
return -1;
}
@ -948,8 +948,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_rgb(n, channels_fg_rgb(ur));
ncdirect_bg_rgb(n, channels_bg_rgb(ur));
ncdirect_set_fg_rgb(n, channels_fg_rgb(ur));
ncdirect_set_bg_rgb(n, channels_bg_rgb(ur));
if(fprintf(n->ttyfp, "%lc", wchars[1]) < 0){
return -1;
}
@ -982,8 +982,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_rgb(n, channels_fg_rgb(ll));
ncdirect_bg_rgb(n, channels_bg_rgb(ll));
ncdirect_set_fg_rgb(n, channels_fg_rgb(ll));
ncdirect_set_bg_rgb(n, channels_bg_rgb(ll));
if(fprintf(n->ttyfp, "%lc", wchars[2]) < 0){
return -1;
}
@ -1001,8 +1001,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_rgb(n, channels_fg_rgb(lr));
ncdirect_bg_rgb(n, channels_bg_rgb(lr));
ncdirect_set_fg_rgb(n, channels_fg_rgb(lr));
ncdirect_set_bg_rgb(n, channels_bg_rgb(lr));
if(fprintf(n->ttyfp, "%lc", wchars[3]) < 0){
return -1;
}

View File

@ -1232,7 +1232,7 @@ char* notcurses_at_yx(notcurses* nc, int yoff, int xoff, uint16_t* stylemask, ui
return egc;
}
int ncdirect_bg_rgb(ncdirect* nc, unsigned rgb){
int ncdirect_set_bg_rgb(ncdirect* nc, unsigned rgb){
if(rgb > 0xffffffu){
return -1;
}
@ -1245,7 +1245,7 @@ int ncdirect_bg_rgb(ncdirect* nc, unsigned rgb){
return 0;
}
int ncdirect_fg_rgb(ncdirect* nc, unsigned rgb){
int ncdirect_set_fg_rgb(ncdirect* nc, unsigned rgb){
if(rgb > 0xffffffu){
return -1;
}

View File

@ -26,14 +26,14 @@ int main(void){
}
fflush(stdout);
int ret = 0;
ret |= ncdirect_fg_rgb(n, 0xff8080);
ret |= ncdirect_set_fg_rgb(n, 0xff8080);
ret |= ncdirect_on_styles(n, NCSTYLE_STANDOUT);
printf(" erp erp \n");
ret |= ncdirect_fg_rgb(n, 0x80ff80);
ret |= ncdirect_set_fg_rgb(n, 0x80ff80);
printf(" erp erp \n");
ret |= ncdirect_off_styles(n, NCSTYLE_STANDOUT);
printf(" erp erp \n");
ret |= ncdirect_fg_rgb(n, 0xff8080);
ret |= ncdirect_set_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_rgb8(nc, r, g, b);
int ret = ncdirect_set_fg_rgb8(nc, r, g, b);
if(ret){
return -1;
}

View File

@ -5,18 +5,18 @@ int main(void){
if(!n){
return EXIT_FAILURE;
}
ncdirect_fg_rgb8(n, 100, 100, 100);
ncdirect_bg_rgb8(n, 0xff, 0xff, 0xff);
ncdirect_set_fg_rgb8(n, 100, 100, 100);
ncdirect_set_bg_rgb8(n, 0xff, 0xff, 0xff);
printf("a");
ncdirect_bg_rgb8(n, 0, 0, 0);
ncdirect_set_bg_rgb8(n, 0, 0, 0);
printf("b");
printf(" ");
printf(" ");
ncdirect_bg_rgb8(n, 0, 0, 1);
ncdirect_set_bg_rgb8(n, 0, 0, 1);
printf("c");
printf(" ");
printf(" ");
ncdirect_bg_rgb8(n, 0xff, 0xff, 0xff);
ncdirect_set_bg_rgb8(n, 0xff, 0xff, 0xff);
printf("d");
printf("\n");
ncdirect_stop(n);

View File

@ -16,8 +16,8 @@ int main(void){
fprintf(stderr, "This notcurses was not build with multimedia support.\n");
return EXIT_FAILURE;
}
ncdirect_fg_rgb8(n, 0xff, 0, 0xff);
ncdirect_bg_rgb8(n, 0, 0xff, 0);
ncdirect_set_fg_rgb8(n, 0xff, 0, 0xff);
ncdirect_set_bg_rgb8(n, 0, 0xff, 0);
ncdirect_printf_aligned(n, -1, NCALIGN_CENTER, "let's play!");
if(ncdirect_render_image(n, "../data/normal.png", NCALIGN_LEFT,
NCBLIT_DEFAULT, NCSCALE_STRETCH)){