_stainable() -> _stained() #985

This commit is contained in:
nick black 2020-09-18 01:50:48 -04:00 committed by Nick Black
parent c5c608b22e
commit e42dbdfd60
10 changed files with 72 additions and 63 deletions

View File

@ -26,6 +26,10 @@ rearrangements of Notcurses.
`channels_set_fg()` and `channels_set_fchannel()` were indistinguishable on `channels_set_fg()` and `channels_set_fchannel()` were indistinguishable on
sight. Failure to make the necessary conversions will result in compiler sight. Failure to make the necessary conversions will result in compiler
errors. See https://github.com/dankamongmen/notcurses/issues/985. errors. See https://github.com/dankamongmen/notcurses/issues/985.
* Functions ending in `_stainable()` now end in `_stained()`.
* `ncplane_putwc_stained()` and `ncplane_putwstr_stained()` have been
added in the interest of orthogonality.
* 1.7.2 (2020-09-09) * 1.7.2 (2020-09-09)
* Exported `ncvisual_default_blitter()`, so that the effective value of * Exported `ncvisual_default_blitter()`, so that the effective value of

View File

@ -923,7 +923,7 @@ ncplane_putchar(struct ncplane* n, char c){
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
int ncplane_putchar_stainable(struct ncplane* n, char c); int ncplane_putchar_stained(struct ncplane* n, char c);
// Replace the cell at the specified coordinates with the provided wide char // Replace the cell at the specified coordinates with the provided wide char
// 'w'. Advance the cursor by the character's width as reported by wcwidth(). // 'w'. Advance the cursor by the character's width as reported by wcwidth().
@ -955,7 +955,7 @@ ncplane_putegc(struct ncplane* n, const char* gclust, int* sbytes){
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
int ncplane_putegc_stainable(struct ncplane* n, const char* gclust, int* sbytes); int ncplane_putegc_stained(struct ncplane* n, const char* gclust, int* sbytes);
#define WCHAR_MAX_UTF8BYTES 6 #define WCHAR_MAX_UTF8BYTES 6
@ -990,7 +990,7 @@ ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust,
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes); int ncplane_putwegc_stained(struct ncplane* n, const wchar_t* gclust, int* sbytes);
// Write a series of EGCs to the current location, using the current style. // Write a series of EGCs to the current location, using the current style.
// They will be interpreted as a series of columns (according to the definition // They will be interpreted as a series of columns (according to the definition
@ -1009,7 +1009,7 @@ int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char
// Replace a string's worth of glyphs at the current cursor location, but // Replace a string's worth of glyphs at the current cursor location, but
// retain the styling. The current styling of the plane will not be changed. // retain the styling. The current styling of the plane will not be changed.
int ncplane_putstr_stainable(struct ncplane* n, const char* s); int ncplane_putstr_stained(struct ncplane* n, const char* s);
// ncplane_putstr(), but following a conversion from wchar_t to UTF-8 multibyte. // ncplane_putstr(), but following a conversion from wchar_t to UTF-8 multibyte.
static inline int static inline int

View File

@ -18,23 +18,25 @@ notcurses_output - output to ncplanes
**static inline int ncplane_putchar_yx(struct ncplane* n, int y, int x, char c);** **static inline int ncplane_putchar_yx(struct ncplane* n, int y, int x, char c);**
**int ncplane_putchar_stainable(struct ncplane* n, char c);** **int ncplane_putchar_stained(struct ncplane* n, char c);**
**static inline int ncplane_putwc(struct ncplane* n, wchar_t w);** **static inline int ncplane_putwc(struct ncplane* n, wchar_t w);**
**int ncplane_putwc_yx(struct ncplane* n, int y, int x, wchar_t w);** **int ncplane_putwc_yx(struct ncplane* n, int y, int x, wchar_t w);**
**static inline int ncplane_putwc_stained(struct ncplane* n, wchar_t w);**
**static inline int ncplane_putegc(struct ncplane* n, const char* gclust, int* sbytes);** **static inline int ncplane_putegc(struct ncplane* n, const char* gclust, int* sbytes);**
**int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes);** **int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes);**
**int ncplane_putegc_stainable(struct ncplane* n, const char* gclust, int* sbytes);** **int ncplane_putegc_stained(struct ncplane* n, const char* gclust, int* sbytes);**
**static inline int ncplane_putwegc(struct ncplane* n, const wchar_t* gclust, int* sbytes);** **static inline int ncplane_putwegc(struct ncplane* n, const wchar_t* gclust, int* sbytes);**
**static inline int ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust, int* sbytes);** **static inline int ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust, int* sbytes);**
**int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes);** **int ncplane_putwegc_stained(struct ncplane* n, const wchar_t* gclust, int* sbytes);**
**int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);** **int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);**
@ -42,18 +44,20 @@ notcurses_output - output to ncplanes
**int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char* s);** **int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char* s);**
**int ncplane_putstr_stainable(struct ncplane* n, const char* s);** **int ncplane_putstr_stained(struct ncplane* n, const char* s);**
**static inline int ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr);**
**int ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr);** **int ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr);**
**static inline int ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align, const wchar_t* gclustarr);** **static inline int ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align, const wchar_t* gclustarr);**
**static inline int ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr);** **int ncplane_putwstr_stained(struct ncplane* n, const wchar_t* gclustarr);**
**int ncplane_putnstr_yx(struct ncplane* n, int y, int x, size_t s, const char* gclusters);**
**static inline int ncplane_putnstr(struct ncplane* n, size_t s, const char* gclustarr);** **static inline int ncplane_putnstr(struct ncplane* n, size_t s, const char* gclustarr);**
**int ncplane_putnstr_yx(struct ncplane* n, int y, int x, size_t s, const char* gclusters);**
**int ncplane_putnstr_aligned(struct ncplane* n, int y, ncalign_e align, size_t s, const char* s);** **int ncplane_putnstr_aligned(struct ncplane* n, int y, ncalign_e align, size_t s, const char* s);**
**int ncplane_vprintf_aligned(struct ncplane* n, int y, ncalign_e align, const char* format, va_list ap);** **int ncplane_vprintf_aligned(struct ncplane* n, int y, ncalign_e align, const char* format, va_list ap);**

View File

@ -389,7 +389,7 @@ namespace ncpp
{ {
int ret; int ret;
if (retain_styling) { if (retain_styling) {
ret = ncplane_putchar_stainable (plane, c); ret = ncplane_putchar_stained (plane, c);
} else { } else {
ret = ncplane_putchar (plane, c); ret = ncplane_putchar (plane, c);
} }
@ -406,7 +406,7 @@ namespace ncpp
{ {
int ret; int ret;
if (retain_styling) { if (retain_styling) {
ret = ncplane_putegc_stainable (plane, gclust, sbytes); ret = ncplane_putegc_stained (plane, gclust, sbytes);
} else { } else {
ret = ncplane_putegc (plane, gclust, sbytes); ret = ncplane_putegc (plane, gclust, sbytes);
} }
@ -423,7 +423,7 @@ namespace ncpp
{ {
int ret; int ret;
if (retain_styling) { if (retain_styling) {
ret = ncplane_putwegc_stainable (plane, gclust, sbytes); ret = ncplane_putwegc_stained (plane, gclust, sbytes);
} else { } else {
ret = ncplane_putwegc (plane, gclust, sbytes); ret = ncplane_putwegc (plane, gclust, sbytes);
} }
@ -481,19 +481,19 @@ namespace ncpp
return error_guard<int> (ncplane_putwstr_aligned (plane, y, static_cast<ncalign_e>(atype), gcluststyles), -1); return error_guard<int> (ncplane_putwstr_aligned (plane, y, static_cast<ncalign_e>(atype), gcluststyles), -1);
} }
int putstr_stainable (const char* s) const NOEXCEPT_MAYBE int putstr_stained (const char* s) const NOEXCEPT_MAYBE
{ {
int ret = ncplane_putstr_stainable (plane, s); int ret = ncplane_putstr_stained (plane, s);
return error_guard_cond<int> (ret, ret < 0); return error_guard_cond<int> (ret, ret < 0);
} }
int printf_stainable (const char* format, ...) const NOEXCEPT_MAYBE int printf_stained (const char* format, ...) const NOEXCEPT_MAYBE
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
{ {
va_list va; va_list va;
va_start (va, format); va_start (va, format);
int ret = ncplane_vprintf_stainable (plane, format, va); int ret = ncplane_vprintf_stained (plane, format, va);
va_end (va); va_end (va);
return error_guard<int> (ret, -1); return error_guard<int> (ret, -1);
@ -535,9 +535,9 @@ namespace ncpp
return error_guard<int> (ret, -1); return error_guard<int> (ret, -1);
} }
int vprintf_stainable (const char* format, va_list ap) const NOEXCEPT_MAYBE int vprintf_stained (const char* format, va_list ap) const NOEXCEPT_MAYBE
{ {
return error_guard<int> (ncplane_vprintf_stainable (plane, format, ap), -1); return error_guard<int> (ncplane_vprintf_stained (plane, format, ap), -1);
} }
int vprintf (const char* format, va_list ap) const NOEXCEPT_MAYBE int vprintf (const char* format, va_list ap) const NOEXCEPT_MAYBE

View File

@ -1339,7 +1339,7 @@ ncplane_putchar(struct ncplane* n, char c){
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
API int ncplane_putchar_stainable(struct ncplane* n, char c); API int ncplane_putchar_stained(struct ncplane* n, char c);
// Replace the cell at the specified coordinates with the provided EGC, and // Replace the cell at the specified coordinates with the provided EGC, and
// advance the cursor by the width of the cluster (but not past the end of the // advance the cursor by the width of the cluster (but not past the end of the
@ -1356,7 +1356,7 @@ ncplane_putegc(struct ncplane* n, const char* gclust, int* sbytes){
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
API int ncplane_putegc_stainable(struct ncplane* n, const char* gclust, int* sbytes); API int ncplane_putegc_stained(struct ncplane* n, const char* gclust, int* sbytes);
// 0x0--0x10ffff can be UTF-8-encoded with only 4 bytes...but we aren't // 0x0--0x10ffff can be UTF-8-encoded with only 4 bytes...but we aren't
// yet actively guarding against higher values getting into wcstombs FIXME // yet actively guarding against higher values getting into wcstombs FIXME
@ -1393,7 +1393,7 @@ ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust,
// Replace the EGC underneath us, but retain the styling. The current styling // Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed. // of the plane will not be changed.
API int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes); API int ncplane_putwegc_stained(struct ncplane* n, const wchar_t* gclust, int* sbytes);
// Write a series of EGCs to the current location, using the current style. // Write a series of EGCs to the current location, using the current style.
// They will be interpreted as a series of columns (according to the definition // They will be interpreted as a series of columns (according to the definition
@ -1413,7 +1413,7 @@ API int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align,
// Replace a string's worth of glyphs at the current cursor location, but // Replace a string's worth of glyphs at the current cursor location, but
// retain the styling. The current styling of the plane will not be changed. // retain the styling. The current styling of the plane will not be changed.
API int ncplane_putstr_stainable(struct ncplane* n, const char* s); API int ncplane_putstr_stained(struct ncplane* n, const char* s);
// Write a series of EGCs to the current location, using the current style. // Write a series of EGCs to the current location, using the current style.
// They will be interpreted as a series of columns (according to the definition // They will be interpreted as a series of columns (according to the definition
@ -1458,7 +1458,7 @@ ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
return ncplane_putwstr_yx(n, y, xpos, gclustarr); return ncplane_putwstr_yx(n, y, xpos, gclustarr);
} }
API int ncplane_putwstr_stainable(struct ncplane* n, const wchar_t* gclustarr); API int ncplane_putwstr_stained(struct ncplane* n, const wchar_t* gclustarr);
static inline int static inline int
ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr){ ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr){
@ -1483,9 +1483,9 @@ ncplane_putwc(struct ncplane* n, wchar_t w){
// Write 'w' at the current cursor position, using any preexisting styling // Write 'w' at the current cursor position, using any preexisting styling
// at that cell. // at that cell.
static inline int static inline int
ncplane_putwc_stainable(struct ncplane* n, wchar_t w){ ncplane_putwc_stained(struct ncplane* n, wchar_t w){
wchar_t warr[2] = { w, L'\0' }; wchar_t warr[2] = { w, L'\0' };
return ncplane_putwstr_stainable(n, warr); return ncplane_putwstr_stained(n, warr);
} }
// The ncplane equivalents of printf(3) and vprintf(3). // The ncplane equivalents of printf(3) and vprintf(3).
@ -1500,7 +1500,7 @@ ncplane_vprintf(struct ncplane* n, const char* format, va_list ap){
return ncplane_vprintf_yx(n, -1, -1, format, ap); return ncplane_vprintf_yx(n, -1, -1, format, ap);
} }
API int ncplane_vprintf_stainable(struct ncplane* n, const char* format, va_list ap); API int ncplane_vprintf_stained(struct ncplane* n, const char* format, va_list ap);
static inline int static inline int
ncplane_printf(struct ncplane* n, const char* format, ...) ncplane_printf(struct ncplane* n, const char* format, ...)
@ -1543,14 +1543,14 @@ ncplane_printf_aligned(struct ncplane* n, int y, ncalign_e align, const char* fo
} }
static inline int static inline int
ncplane_printf_stainable(struct ncplane* n, const char* format, ...) ncplane_printf_stained(struct ncplane* n, const char* format, ...)
__attribute__ ((format (printf, 2, 3))); __attribute__ ((format (printf, 2, 3)));
static inline int static inline int
ncplane_printf_stainable(struct ncplane* n, const char* format, ...){ ncplane_printf_stained(struct ncplane* n, const char* format, ...){
va_list va; va_list va;
va_start(va, format); va_start(va, format);
int ret = ncplane_vprintf_stainable(n, format, va); int ret = ncplane_vprintf_stained(n, format, va);
va_end(va); va_end(va);
return ret; return ret;
} }

View File

@ -177,7 +177,8 @@ int ncplane_fadein(struct ncplane* n, const struct timespec* ts, fadecb fader, v
int ncplane_pulse(struct ncplane* n, const struct timespec* ts, fadecb fader, void* curry); int ncplane_pulse(struct ncplane* n, const struct timespec* ts, fadecb fader, void* curry);
int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes); int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes);
int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char* s); int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char* s);
int ncplane_putstr_stainable(struct ncplane* n, const char* s); int ncplane_putstr_stained(struct ncplane* n, const char* s);
int ncplane_putwstr_stained(struct ncplane* n, const wchar_t* gclustarr);
struct ncplane* ncplane_dup(const struct ncplane* n, void* opaque); struct ncplane* ncplane_dup(const struct ncplane* n, void* opaque);
int cell_load(struct ncplane* n, cell* c, const char* gcluster); int cell_load(struct ncplane* n, cell* c, const char* gcluster);
int cell_duplicate(struct ncplane* n, cell* targ, const cell* c); int cell_duplicate(struct ncplane* n, cell* targ, const cell* c);
@ -335,9 +336,9 @@ int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const cell* c);
int ncplane_gradient(struct ncplane* n, const char* egc, uint32_t styles, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ystop, int xstop); int ncplane_gradient(struct ncplane* n, const char* egc, uint32_t styles, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ystop, int xstop);
int ncplane_highgradient(struct ncplane* n, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ystop, int xstop); int ncplane_highgradient(struct ncplane* n, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ystop, int xstop);
int ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen); int ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen);
int ncplane_putchar_stainable(struct ncplane* n, char c); int ncplane_putchar_stained(struct ncplane* n, char c);
int ncplane_putegc_stainable(struct ncplane* n, const char* gclust, int* sbytes); int ncplane_putegc_stained(struct ncplane* n, const char* gclust, int* sbytes);
int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes); int ncplane_putwegc_stained(struct ncplane* n, const wchar_t* gclust, int* sbytes);
int ncplane_format(struct ncplane* n, int ystop, int xstop, uint32_t styles); int ncplane_format(struct ncplane* n, int ystop, int xstop, uint32_t styles);
int ncplane_stain(struct ncplane* n, int ystop, int xstop, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr); int ncplane_stain(struct ncplane* n, int ystop, int xstop, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr);
int ncplane_rotate_cw(struct ncplane* n); int ncplane_rotate_cw(struct ncplane* n);

View File

@ -40,16 +40,16 @@
// ncplane_polyfill_yx // ncplane_polyfill_yx
// ncplane_pulse // ncplane_pulse
// ncplane_putc_yx // ncplane_putc_yx
// ncplane_putegc_stainable // ncplane_putegc_stained
// ncplane_putegc_yx // ncplane_putegc_yx
// ncplane_putnstr_aligned // ncplane_putnstr_aligned
// ncplane_putnstr_yx // ncplane_putnstr_yx
// ncplane_putsimple_stainable // ncplane_putsimple_stained
// ncplane_putstr_aligned // ncplane_putstr_aligned
// ncplane_putstr_stainable // ncplane_putstr_stained
// ncplane_putstr_yx // ncplane_putstr_yx
// ncplane_puttext // ncplane_puttext
// ncplane_putwegc_stainable // ncplane_putwegc_stained
// ncplane_qrcode // ncplane_qrcode
// ncplane_reparent // ncplane_reparent
// ncplane_resize // ncplane_resize
@ -83,7 +83,7 @@
// ncplane_userptr // ncplane_userptr
// ncplane_vline_interp // ncplane_vline_interp
// ncplane_vprintf_aligned // ncplane_vprintf_aligned
// ncplane_vprintf_stainable // ncplane_vprintf_stained
// ncplane_vprintf_yx // ncplane_vprintf_yx
// ncplane_yx // ncplane_yx
// //
@ -789,14 +789,14 @@ pub fn ncplane_rounded_box_sized(
// } // }
// static inline int // static inline int
// ncplane_printf_stainable(struct ncplane* n, const char* format, ...) // ncplane_printf_stained(struct ncplane* n, const char* format, ...)
// __attribute__ ((format (printf, 2, 3))); // __attribute__ ((format (printf, 2, 3)));
// static inline int // static inline int
// ncplane_printf_stainable(struct ncplane* n, const char* format, ...){ // ncplane_printf_stained(struct ncplane* n, const char* format, ...){
// va_list va; // va_list va;
// va_start(va, format); // va_start(va, format);
// int ret = ncplane_vprintf_stainable(n, format, va); // int ret = ncplane_vprintf_stained(n, format, va);
// va_end(va); // va_end(va);
// return ret; // return ret;
// } // }

View File

@ -1421,7 +1421,7 @@ int ncplane_putegc_yx(ncplane* n, int y, int x, const char* gclust, int* sbytes)
return ncplane_put(n, y, x, gclust, cols, n->stylemask, n->channels, bytes); return ncplane_put(n, y, x, gclust, cols, n->stylemask, n->channels, bytes);
} }
int ncplane_putchar_stainable(ncplane* n, char c){ int ncplane_putchar_stained(ncplane* n, char c){
uint64_t channels = n->channels; uint64_t channels = n->channels;
uint32_t stylemask = n->stylemask; uint32_t stylemask = n->stylemask;
const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)]; const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)];
@ -1433,7 +1433,7 @@ int ncplane_putchar_stainable(ncplane* n, char c){
return ret; return ret;
} }
int ncplane_putwegc_stainable(ncplane* n, const wchar_t* gclust, int* sbytes){ int ncplane_putwegc_stained(ncplane* n, const wchar_t* gclust, int* sbytes){
uint64_t channels = n->channels; uint64_t channels = n->channels;
uint32_t stylemask = n->stylemask; uint32_t stylemask = n->stylemask;
const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)]; const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)];
@ -1445,7 +1445,7 @@ int ncplane_putwegc_stainable(ncplane* n, const wchar_t* gclust, int* sbytes){
return ret; return ret;
} }
int ncplane_putegc_stainable(ncplane* n, const char* gclust, int* sbytes){ int ncplane_putegc_stained(ncplane* n, const char* gclust, int* sbytes){
uint64_t channels = n->channels; uint64_t channels = n->channels;
uint32_t stylemask = n->stylemask; uint32_t stylemask = n->stylemask;
const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)]; const cell* targ = &n->fb[nfbcellidx(n, n->y, n->x)];
@ -1562,12 +1562,12 @@ int ncplane_vprintf_aligned(ncplane* n, int y, ncalign_e align,
return ret; return ret;
} }
int ncplane_vprintf_stainable(struct ncplane* n, const char* format, va_list ap){ int ncplane_vprintf_stained(struct ncplane* n, const char* format, va_list ap){
char* r = ncplane_vprintf_prep(format, ap); char* r = ncplane_vprintf_prep(format, ap);
if(r == NULL){ if(r == NULL){
return -1; return -1;
} }
int ret = ncplane_putstr_stainable(n, r); int ret = ncplane_putstr_stained(n, r);
free(r); free(r);
return ret; return ret;
} }
@ -2300,12 +2300,12 @@ int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclusters){
return ret; return ret;
} }
int ncplane_putstr_stainable(struct ncplane* n, const char* gclusters){ int ncplane_putstr_stained(struct ncplane* n, const char* gclusters){
int ret = 0; int ret = 0;
// FIXME speed up this blissfully naive solution // FIXME speed up this blissfully naive solution
while(*gclusters){ while(*gclusters){
int wcs; int wcs;
int cols = ncplane_putegc_stainable(n, gclusters, &wcs); int cols = ncplane_putegc_stained(n, gclusters, &wcs);
if(cols < 0){ if(cols < 0){
return -ret; return -ret;
} }
@ -2318,7 +2318,7 @@ int ncplane_putstr_stainable(struct ncplane* n, const char* gclusters){
return ret; return ret;
} }
int ncplane_putwstr_stainable(ncplane* n, const wchar_t* gclustarr){ int ncplane_putwstr_stained(ncplane* n, const wchar_t* gclustarr){
// maximum of six UTF8-encoded bytes per wchar_t // maximum of six UTF8-encoded bytes per wchar_t
const size_t mbytes = (wcslen(gclustarr) * WCHAR_MAX_UTF8BYTES) + 1; const size_t mbytes = (wcslen(gclustarr) * WCHAR_MAX_UTF8BYTES) + 1;
char* mbstr = malloc(mbytes); // need cast for c++ callers char* mbstr = malloc(mbytes); // need cast for c++ callers
@ -2330,7 +2330,7 @@ int ncplane_putwstr_stainable(ncplane* n, const wchar_t* gclustarr){
free(mbstr); free(mbstr);
return -1; return -1;
} }
int r = ncplane_putstr_stainable(n, mbstr); int r = ncplane_putstr_stained(n, mbstr);
free(mbstr); free(mbstr);
return r; return r;
} }

View File

@ -711,7 +711,7 @@ TEST_CASE("NCPlane") {
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
} }
SUBCASE("EGCStainable") { SUBCASE("EGCStained") {
cell c = CELL_TRIVIAL_INITIALIZER; cell c = CELL_TRIVIAL_INITIALIZER;
int sbytes; int sbytes;
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444)); CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
@ -722,8 +722,8 @@ TEST_CASE("NCPlane") {
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
// EGC should change, but not the color // EGC should change, but not the color
CHECK(0 == ncplane_set_fg_rgb(n_, 0x222222)); CHECK(0 == ncplane_set_fg_rgb(n_, 0x222222));
CHECK(1 == ncplane_putegc_stainable(n_, "C", &sbytes)); CHECK(1 == ncplane_putegc_stained(n_, "C", &sbytes));
CHECK(1 == ncplane_putegc_stainable(n_, "D", &sbytes)); CHECK(1 == ncplane_putegc_stained(n_, "D", &sbytes));
uint64_t channels = 0; uint64_t channels = 0;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &c)); CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &c));
CHECK(cell_simple_p(&c)); CHECK(cell_simple_p(&c));

View File

@ -955,34 +955,34 @@ TEST_CASE("Wide") {
SUBCASE("Putwc") { SUBCASE("Putwc") {
wchar_t w = L'\u2658'; wchar_t w = L'\u2658';
CHECK(0 == ncplane_set_fg(n_, 0xff00ff)); CHECK(0 == ncplane_set_fg_rgb(n_, 0xff00ff));
CHECK(0 < ncplane_putwc(n_, w)); CHECK(0 < ncplane_putwc(n_, w));
CHECK(0 == ncplane_set_fg(n_, 0x00ff00)); CHECK(0 == ncplane_set_fg_rgb(n_, 0x00ff00));
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
uint16_t stylemask; uint16_t stylemask;
uint64_t channels; uint64_t channels;
char* egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels); char* egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels);
REQUIRE(egc); REQUIRE(egc);
CHECK(0 == stylemask); CHECK(0 == stylemask);
CHECK(0xff00ff == channels_fg(channels)); CHECK(0xff00ff == channels_fg_rgb(channels));
CHECK(0 == strcmp("\u2658", egc)); CHECK(0 == strcmp("\u2658", egc));
free(egc); free(egc);
} }
SUBCASE("PutwcStainable") { SUBCASE("Putwcstained") {
wchar_t w = L'\u2658'; wchar_t w = L'\u2658';
CHECK(0 == ncplane_set_fg(n_, 0xff00ff)); CHECK(0 == ncplane_set_fg_rgb(n_, 0xff00ff));
CHECK(0 < ncplane_putwc(n_, w)); CHECK(0 < ncplane_putwc(n_, w));
CHECK(0 == ncplane_set_fg(n_, 0x00ff00)); CHECK(0 == ncplane_set_fg_rgb(n_, 0x00ff00));
ncplane_home(n_); ncplane_home(n_);
CHECK(0 < ncplane_putwc_stainable(n_, w)); CHECK(0 < ncplane_putwc_stained(n_, w));
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
uint16_t stylemask; uint16_t stylemask;
uint64_t channels; uint64_t channels;
char* egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels); char* egc = notcurses_at_yx(nc_, 0, 0, &stylemask, &channels);
REQUIRE(egc); REQUIRE(egc);
CHECK(0 == stylemask); CHECK(0 == stylemask);
CHECK(0xff00ff == channels_fg(channels)); CHECK(0xff00ff == channels_fg_rgb(channels));
CHECK(0 == strcmp("\u2658", egc)); CHECK(0 == strcmp("\u2658", egc));
free(egc); free(egc);
} }