ncplane_printf_stainable() and _vfprintf_stainable() #754

This commit is contained in:
nick black 2020-07-10 23:58:37 -04:00
parent 4a97c139e6
commit 5cf912feb6
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 25 additions and 0 deletions

View File

@ -1519,6 +1519,8 @@ ncplane_vprintf(struct ncplane* n, const char* format, va_list ap){
return ncplane_vprintf_yx(n, -1, -1, format, ap);
}
API int ncplane_vprintf_stainable(struct ncplane* n, const char* format, va_list ap);
static inline int
ncplane_printf(struct ncplane* n, const char* format, ...)
__attribute__ ((format (printf, 2, 3)));
@ -1559,6 +1561,19 @@ ncplane_printf_aligned(struct ncplane* n, int y, ncalign_e align, const char* fo
return ret;
}
static inline int
ncplane_printf_stainable(struct ncplane* n, const char* format, ...)
__attribute__ ((format (printf, 2, 3)));
static inline int
ncplane_printf_stainable(struct ncplane* n, const char* format, ...){
va_list va;
va_start(va, format);
int ret = ncplane_vprintf_stainable(n, format, va);
va_end(va);
return ret;
}
// Write the specified text to the plane, breaking lines sensibly, beginning at
// the specified line. Returns the number of columns written. When breaking a
// line, the line will be cleared to the end of the plane (the last line will

View File

@ -1456,6 +1456,16 @@ int ncplane_vprintf_aligned(ncplane* n, int y, ncalign_e align,
return ret;
}
int ncplane_vprintf_stainable(struct ncplane* n, const char* format, va_list ap){
char* r = ncplane_vprintf_prep(format, ap);
if(r == NULL){
return -1;
}
int ret = ncplane_putstr_stainable(n, r);
free(r);
return ret;
}
int ncplane_hline_interp(ncplane* n, const cell* c, int len,
uint64_t c1, uint64_t c2){
unsigned ur, ug, ub;