mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
add ncdirect_canopen_images() and ncdirect_canutf8() #753
This commit is contained in:
parent
c783244185
commit
96c6dc8e16
7
USAGE.md
7
USAGE.md
@ -364,6 +364,13 @@ nc_err_e ncdirect_render_image(struct ncdirect* nc, const char* filename,
|
||||
ncblitter_e blitter, ncscale_e scale);
|
||||
```
|
||||
|
||||
Several of the Notcurses capability predicates have `ncdirect` analogues:
|
||||
|
||||
```c
|
||||
bool ncdirect_canopen_images(const struct ncdirect* n);
|
||||
bool ncdirect_canutf8(const struct ncdirect* n);
|
||||
```
|
||||
|
||||
## Alignment
|
||||
|
||||
Most functions that generate output can be aligned relative to an ncplane.
|
||||
|
@ -56,6 +56,10 @@ ncdirect_init - minimal notcurses instances for styling text
|
||||
|
||||
**int ncdirect_putstr(struct ncdirect* nc, uint64_t channels, const char* utf8);**
|
||||
|
||||
**bool ncdirect_canopen_images(const struct ncdirect* n);**
|
||||
|
||||
**bool ncdirect_canutf8(const struct ncdirect* n);**
|
||||
|
||||
**nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename, ncblitter_e blitter, ncscale_e scale);**
|
||||
|
||||
# DESCRIPTION
|
||||
|
@ -96,8 +96,11 @@ API nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename,
|
||||
// Clear the screen.
|
||||
API int ncdirect_clear(struct ncdirect* nc);
|
||||
|
||||
// Release 'nc' and any associated resources. 0 on success, non-0 on failure.
|
||||
API int ncdirect_stop(struct ncdirect* nc);
|
||||
// Can we load images? This requires being built against FFmpeg/OIIO.
|
||||
API bool ncdirect_canopen_images(const struct ncdirect* n);
|
||||
|
||||
// Is our encoding UTF-8? Requires LANG being set to a UTF8 locale.
|
||||
API bool ncdirect_canutf8(const struct ncdirect* n);
|
||||
|
||||
// Draw horizontal/vertical lines using the specified channels, interpolating
|
||||
// between them as we go. The EGC may not use more than one column. For a
|
||||
@ -109,6 +112,9 @@ API int ncdirect_hline_interp(struct ncdirect* n, const char* egc, int len,
|
||||
API int ncdirect_vline_interp(struct ncdirect* n, const char* egc, int len,
|
||||
uint64_t h1, uint64_t h2);
|
||||
|
||||
// Release 'nc' and any associated resources. 0 on success, non-0 on failure.
|
||||
API int ncdirect_stop(struct ncdirect* nc);
|
||||
|
||||
#undef API
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -503,6 +503,8 @@ int ncdirect_cursor_right(struct ncdirect* nc, int num);
|
||||
int ncdirect_cursor_down(struct ncdirect* nc, int num);
|
||||
int ncdirect_hline_interp(struct ncdirect* n, const char* egc, int len, uint64_t h1, uint64_t h2);
|
||||
int ncdirect_vline_interp(struct ncdirect* n, const char* egc, int len, uint64_t h1, uint64_t h2);
|
||||
bool ncdirect_canopen_images(const struct ncdirect* n);
|
||||
bool ncdirect_canutf8(const struct ncdirect* n);
|
||||
nc_err_e ncdirect_render_image(struct ncdirect* n, const char* filename, ncalign_e align, ncblitter_e blitter, ncscale_e scale);
|
||||
""")
|
||||
|
||||
|
@ -651,3 +651,21 @@ int ncdirect_vline_interp(ncdirect* n, const char* egc, int len,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Can we load images? This requires being built against FFmpeg/OIIO.
|
||||
bool ncdirect_canopen_images(const ncdirect* n){
|
||||
(void)n;
|
||||
#ifdef USE_FFMPEG
|
||||
return true;
|
||||
#else
|
||||
#ifdef USE_OIIO
|
||||
return true;
|
||||
#endif
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is our encoding UTF-8? Requires LANG being set to a UTF8 locale.
|
||||
bool ncdirect_canutf8(const ncdirect* n){
|
||||
return n->utf8;
|
||||
}
|
||||
|
@ -12,6 +12,10 @@ int main(void){
|
||||
if((n = ncdirect_init(NULL, stdout)) == NULL){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!ncdirect_canopen_images(n)){
|
||||
fprintf(stderr, "This notcurses was not build with multimedia support.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(ncdirect_render_image(n, "../data/normal.png", NCALIGN_LEFT,
|
||||
NCBLIT_DEFAULT, NCSCALE_STRETCH) != NCERR_SUCCESS){
|
||||
return EXIT_FAILURE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user