add ncdirect_flush() #926

This commit is contained in:
nick black 2020-08-21 02:27:58 -04:00
parent d110facec1
commit 6bb8f447b5
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,8 @@ rearrangements of Notcurses.
Rewrote `cell_set_fg_palindex()` and `cell_set_bg_palindex()` in terms
of these two. This is possible because the palette index now overlaps the
RGB in a channel (they were originally in the attrword).
* Added `ncdirect_flush()`, mainly for the benefit of FFI that might not
have a native interface to `fflush(3)`.
* 1.6.15 (2020-08-16)
* Styles now work properly with `ncdirect`, which apparently has never

View File

@ -36,6 +36,9 @@ API unsigned ncdirect_palette_size(const struct ncdirect* nc);
// necessarily be immediately visible.
API int ncdirect_putstr(struct ncdirect* nc, uint64_t channels, const char* utf8);
// Force a flush. Returns 0 on success, -1 on failure.
API int ncdirect_flush(struct ncdirect* nc);
static inline int
ncdirect_bg_rgb(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){
if(r > 255 || g > 255 || b > 255){

View File

@ -796,3 +796,10 @@ bool ncdirect_canopen_images(const ncdirect* n){
bool ncdirect_canutf8(const ncdirect* n){
return n->utf8;
}
int ncdirect_flush(const ncdirect* nc){
if(fflush(nc->ttyfp) == EOF){
return -1;
}
return 0;
}