diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 66c78de45..8e776e855 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -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 diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 9da81874b..042f26033 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -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;