add notcurses_lex_blitter()

This commit is contained in:
nick black 2020-07-19 21:53:01 -04:00
parent 5d6df94187
commit 104bbfef50
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
6 changed files with 45 additions and 0 deletions

View File

@ -1,6 +1,11 @@
This document attempts to list user-visible changes and any major internal This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses. rearrangements of Notcurses.
* 1.6.6 (2020-07-19)
* `notcurses-pydemo` is now only installed alongside the Python module,
using setuptools. CMake no longer installs it.
* Added `notcurses_lex_blitter()` and `notcurses_str_scalemode()`.
* 1.6.5 (2020-07-19) * 1.6.5 (2020-07-19)
* No user-visible changes. * No user-visible changes.

View File

@ -2639,6 +2639,9 @@ typedef enum {
NCBLIT_SIXEL, // 6 rows, 1 col (RGB), spotty support among terminals NCBLIT_SIXEL, // 6 rows, 1 col (RGB), spotty support among terminals
} ncblitter_e; } ncblitter_e;
// Lex a blitter.
int notcurses_lex_blitter(const char* op, ncblitter_e* blitter);
// Get the name of a blitter. // Get the name of a blitter.
const char* notcurses_str_blitter(ncblitter_e blitter); const char* notcurses_str_blitter(ncblitter_e blitter);
@ -2671,6 +2674,12 @@ typedef enum {
NCSCALE_STRETCH, NCSCALE_STRETCH,
} ncscale_e; } ncscale_e;
// Lex a visual scaling mode (one of "none", "stretch", or "scale").
int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);
// Get the name of a scaling mode.
const char* notcurses_str_scalemode(ncscale_e scalemode);
// the streaming operation ceases immediately, and that value is propagated out. // the streaming operation ceases immediately, and that value is propagated out.
// The recommended absolute display time target is passed in 'tspec'. // The recommended absolute display time target is passed in 'tspec'.
typedef int (*streamcb)(struct ncplane*, struct ncvisual*, typedef int (*streamcb)(struct ncplane*, struct ncvisual*,

View File

@ -82,6 +82,12 @@ typedef int (*streamcb)(struct notcurses*, struct ncvisual*, void*);
**char* ncvisual_subtitle(const struct ncvisual* ncv);** **char* ncvisual_subtitle(const struct ncvisual* ncv);**
**int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);**
**const char* notcurses_str_scalemode(ncscale_e scalemode);**
**int notcurses_lex_blitter(const char* op, ncblitter_e* blitter);**
**const char* notcurses_str_blitter(ncblitter_e blitter);** **const char* notcurses_str_blitter(ncblitter_e blitter);**
# DESCRIPTION # DESCRIPTION

View File

@ -895,12 +895,18 @@ typedef struct notcurses_options {
// there can be four numbers separated by commas. // there can be four numbers separated by commas.
API int notcurses_lex_margins(const char* op, notcurses_options* opts); API int notcurses_lex_margins(const char* op, notcurses_options* opts);
// Lex a blitter.
API int notcurses_lex_blitter(const char* op, ncblitter_e* blitter);
// Get the name of a blitter. // Get the name of a blitter.
API const char* notcurses_str_blitter(ncblitter_e blitter); API const char* notcurses_str_blitter(ncblitter_e blitter);
// Lex a visual scaling mode (one of "none", "stretch", or "scale"). // Lex a visual scaling mode (one of "none", "stretch", or "scale").
API int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode); API int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);
// Get the name of a scaling mode.
API const char* notcurses_str_scalemode(ncscale_e scalemode);
// Initialize a notcurses context on the connected terminal at 'fp'. 'fp' must // Initialize a notcurses context on the connected terminal at 'fp'. 'fp' must
// be a tty. You'll usually want stdout. NULL can be supplied for 'fp', in // be a tty. You'll usually want stdout. NULL can be supplied for 'fp', in
// which case /dev/tty will be opened. Returns NULL on error, including any // which case /dev/tty will be opened. Returns NULL on error, including any

View File

@ -146,6 +146,7 @@ typedef enum {
NCBLIT_SIXEL, // 6 rows, 1 col (RGB) NCBLIT_SIXEL, // 6 rows, 1 col (RGB)
} ncblitter_e; } ncblitter_e;
const char* notcurses_str_blitter(ncblitter_e blitter); const char* notcurses_str_blitter(ncblitter_e blitter);
int notcurses_lex_blitter(const char* op, ncblitter_e* blitter);
uint32_t* ncplane_rgba(const struct ncplane* nc, ncblitter_e blit, int begy, int begx, int leny, int lenx); uint32_t* ncplane_rgba(const struct ncplane* nc, ncblitter_e blit, int begy, int begx, int leny, int lenx);
char* ncplane_contents(const struct ncplane* nc, int begy, int begx, int leny, int lenx); char* ncplane_contents(const struct ncplane* nc, int begy, int begx, int leny, int lenx);
void* ncplane_set_userptr(struct ncplane* n, void* opaque); void* ncplane_set_userptr(struct ncplane* n, void* opaque);
@ -273,6 +274,8 @@ typedef enum {
NCSCALE_SCALE, NCSCALE_SCALE,
NCSCALE_STRETCH, NCSCALE_STRETCH,
} ncscale_e; } ncscale_e;
int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode);
const char* notcurses_str_scalemode(ncscale_e scalemode);
struct ncvisual* ncvisual_from_file(const char* file, nc_err_e* ncerr); struct ncvisual* ncvisual_from_file(const char* file, nc_err_e* ncerr);
struct ncvisual* ncvisual_from_rgba(const void* rgba, int rows, int rowstride, int cols); struct ncvisual* ncvisual_from_rgba(const void* rgba, int rows, int rowstride, int cols);
struct ncvisual* ncvisual_from_bgra(const void* rgba, int rows, int rowstride, int cols); struct ncvisual* ncvisual_from_bgra(const void* rgba, int rows, int rowstride, int cols);

View File

@ -499,6 +499,22 @@ const struct blitset notcurses_blitters[] = {
.blit = NULL, .name = NULL, .fill = false, }, .blit = NULL, .name = NULL, .fill = false, },
}; };
int notcurses_lex_blitter(const char* op, ncblitter_e* blitter){
const struct blitset* bset = notcurses_blitters;
while(bset->name){
if(strcasecmp(bset->name, op) == 0){
*blitter = bset->geom;
return 0;
}
++bset;
}
if(strcasecmp("default", op) == 0){
*blitter = NCBLIT_DEFAULT;
return 0;
}
return -1;
}
const char* notcurses_str_blitter(ncblitter_e blitter){ const char* notcurses_str_blitter(ncblitter_e blitter){
if(blitter == NCBLIT_DEFAULT){ if(blitter == NCBLIT_DEFAULT){
return "default"; return "default";