From 8bd73378cf4b1bb9581a2fbf50183cb848ea1da4 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 12 May 2021 13:07:23 -0400 Subject: [PATCH] add NCSCALE_INFLATE --- NEWS.md | 3 +++ USAGE.md | 6 +++++- doc/man/man3/notcurses_visual.3.md | 5 +++-- include/notcurses/notcurses.h | 13 ++++++++----- src/lib/notcurses.c | 4 ++++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index dcaba8d8d..6ef5e8a03 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.3.1 (not yet released) + * Add `NCSCALE_INFLATE`. + * 2.3.0 (2021-05-09) **"Triumph"** * No user-visible changes. diff --git a/USAGE.md b/USAGE.md index 0862144eb..e148a5110 100644 --- a/USAGE.md +++ b/USAGE.md @@ -3203,9 +3203,13 @@ typedef enum { NCSCALE_NONE, NCSCALE_SCALE, NCSCALE_STRETCH, + NCSCALE_SCALE_HIRES, + NCSCALE_NONE_HIRES, + NCSCALE_INFLATE, } ncscale_e; -// Lex a scaling mode (one of "none", "stretch", "scale", "hires", or "scalehi"). +// Lex a scaling mode (one of "none", "stretch", "scale", "hires", +// "inflate", or "scalehi"). int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode); // Get the name of a scaling mode. diff --git a/doc/man/man3/notcurses_visual.3.md b/doc/man/man3/notcurses_visual.3.md index 14dffb46e..913aae3c0 100644 --- a/doc/man/man3/notcurses_visual.3.md +++ b/doc/man/man3/notcurses_visual.3.md @@ -16,6 +16,7 @@ typedef enum { NCSCALE_STRETCH, NCSCALE_NONE_HIRES, NCSCALE_SCALE_HIRES, + NCSCALE_INFLATE, } ncscale_e; typedef enum { @@ -225,8 +226,8 @@ instance **NCSCALE_SCALE_HIRES** and a large image), more rows and columns will result in more effective resolution. A string can be transformed to a scaling mode with **notcurses_lex_scalemode**, -recognizing **stretch**, **scalehi**, **hires**, **scale**, and **none**. -Conversion in the opposite direction is performed with +recognizing **stretch**, **scalehi**, **hires**, **scale**, **inflate**, and +**none**. Conversion in the opposite direction is performed with **notcurses_str_scalemode**. Assuming a cell is twice as tall as it is wide, **NCBLIT_1x1** (and indeed diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index adfa776ee..30e292ba4 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -86,16 +86,18 @@ typedef enum { // How to scale an ncvisual during rendering. NCSCALE_NONE will apply no // scaling. NCSCALE_SCALE scales a visual to the plane's size, maintaining -// aspect ratio. NCSCALE_STRETCH stretches and scales the image in an -// attempt to fill the entirety of the plane. NCSCALE_NONE_HIRES and -// NCSCALE_SCALE_HIRES behave like their counterparts, but admit blitters -// which don't preserve aspect ratio. +// aspect ratio. NCSCALE_INFLATE does the same, but without interpolation. +// NCSCALE_STRETCH stretches and scales the image in an attempt to fill the +// entirety of the plane. NCSCALE_NONE_HIRES and NCSCALE_SCALE_HIRES behave +// like their counterparts, but admit blitters which don't preserve aspect +// ratio. typedef enum { NCSCALE_NONE, NCSCALE_SCALE, NCSCALE_STRETCH, NCSCALE_NONE_HIRES, NCSCALE_SCALE_HIRES, + NCSCALE_INFLATE, } ncscale_e; // Returns the number of columns occupied by a multibyte (UTF-8) string, or @@ -905,7 +907,8 @@ API int notcurses_lex_blitter(const char* op, ncblitter_e* blitter); // Get the name of a blitter. API const char* notcurses_str_blitter(ncblitter_e blitter); -// Lex a scaling mode (one of "none", "stretch", "scale", "hires", or "scalehi"). +// Lex a scaling mode (one of "none", "stretch", "scale", "hires", +// "scalehi", or "inflate"). API int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode); // Get the name of a scaling mode. diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index ed1c11121..f102e15bf 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -2533,6 +2533,8 @@ lex_long(const char* op, int* i, char** endptr){ int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode){ if(strcasecmp(op, "stretch") == 0){ *scalemode = NCSCALE_STRETCH; + }else if(strcasecmp(op, "inflate") == 0){ + *scalemode = NCSCALE_INFLATE; }else if(strcasecmp(op, "scalehi") == 0){ *scalemode = NCSCALE_SCALE_HIRES; }else if(strcasecmp(op, "hires") == 0){ @@ -2550,6 +2552,8 @@ int notcurses_lex_scalemode(const char* op, ncscale_e* scalemode){ const char* notcurses_str_scalemode(ncscale_e scalemode){ if(scalemode == NCSCALE_STRETCH){ return "stretch"; + }else if(scalemode == NCSCALE_INFLATE){ + return "inflate"; }else if(scalemode == NCSCALE_SCALE){ return "scale"; }else if(scalemode == NCSCALE_NONE){