export ncplane_putstr_yx() as static inline

This commit is contained in:
nick black 2020-04-06 01:15:20 -04:00
parent 5bfae54b04
commit 5c44416426
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
7 changed files with 46 additions and 47 deletions

View File

@ -2,31 +2,32 @@ This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses.
* 1.2.6 (not yet released)
* ncplane_putsimple_yx() has been exported as a static inline function.
* ncplane_set_scrolling() has been added, allowing control over whether a
* `ncplane_putsimple_yx()` and `ncplane_putstr_yx()` has been exported as a
static inline function.
* `ncplane_set_scrolling()` has been added, allowing control over whether a
plane scrolls. All planes, including the standard plane, do not scroll by
default. If scrolling is enabled, text output via the `*put*` family of
functions continues onto the next line when encountering the end of a row.
This does not apply to e.g. boxes or lines.
* ncplane_putstr_yx() now always returns the inverse of the number of columns
advanced on an error (it used to return the positive short count so long as
the error was due to plane geometry, not bad input).
* `ncplane_putstr_yx()` now always returns the inverse of the number of
columns advanced on an error (it used to return the positive short count so
long as the error was due to plane geometry, not bad input).
* 1.2.5
* Add ncplot, with support for sliding-windowed horizontal histograms.
* gradient, polyfill, ncplane_format() and ncplane_stain() all now return the
number of cells written on success. Failure still sees -1 returned.
* gradient, polyfill, `ncplane_format()` and `ncplane_stain()` all now return
the number of cells written on success. Failure still sees -1 returned.
* `ncvisual_render()` now returns the number of cells emitted on success, as
opposed to 0. Failure still sees -1 returned.
* `ncvisual_render()` now interprets length parameters of -1 to mean "to the
end along this axis", and no longer interprets 0 to mean this. 0 now means
end along this axis", and no longer interprets 0 to mean this. 0 now means
"a length of 0", resulting in a zero-area rendering.
* `notcurses_at_yx()` no longer accepts a `cell*` as its last parameter.
Instead, it accepts a `uint32_t*` and a `uint64_t*`, and writes the
attribute and channels to these parameters. This was done because the
`gcluster` field of the `cell*` was always set to 0, which was surprising
and a source of blunders. The EGC is returned via the `char*` return
value. https://github.com/dankamongmen/notcurses/issues/410
Instead, it accepts a `uint32_t*` and a `uint64_t*`, and writes the
attribute and channels to these parameters. This was done because the
`gcluster` field of the `cell*` was always set to 0, which was surprising
and a source of blunders. The EGC is returned via the `char*` return
value. https://github.com/dankamongmen/notcurses/issues/410
* 1.2.4 2020-03-24
* Add ncmultiselector

View File

@ -145,12 +145,12 @@ output of `pkg-config --cflags notcurses`. If using CMake, a support file is
provided, and can be accessed as `notcurses`.
Before calling into notcurses—and usually as one of the first calls of the
program—be sure to call `setlocale(3)` with an appropriate UTF-8 `LC_ALL`
locale. It is usually appropriate to use `setlocale(LC_ALL, "")`, relying on
the user to properly set the `LANG` environment variable. notcurses will
refuse to start if `nl_langinfo(3)` doesn't indicate `ANSI_X3.4-1968` or
`UTF-8`. In addition, it is wise to mask most signals early in the program,
before any threads are spawned (this is particularly critical for `SIGWINCH`).
program—be sure to call `setlocale(3)` with an appropriate UTF-8 locale. It is
usually appropriate to use `setlocale(LC_ALL, "")`, relying on the user to
properly set the `LANG` environment variable. notcurses will refuse to start if
`nl_langinfo(3)` doesn't indicate `ANSI_X3.4-1968` or `UTF-8`. In addition, it
is wise to mask most signals early in the program, before any threads are
spawned (this is particularly critical for `SIGWINCH`).
notcurses requires an available `terminfo(5)` definition appropriate for the
terminal. It is usually appropriate to pass `NULL` in the `termtype` field of a
@ -955,7 +955,8 @@ int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sby
// (though not beyond the end of the plane); this number is returned on success.
// On error, a non-positive number is returned, indicating the number of cells
// which were written before the error.
int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);
static inline int
ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclusters);
static inline int
ncplane_putstr(struct ncplane* n, const char* gclustarr){

View File

@ -73,9 +73,7 @@ libnotcurses.so.1 libnotcurses1 #MINVER#
ncplane_putegc_stainable@Base 1.2.1
ncplane_putegc_yx@Base 1.2.1
ncplane_putsimple_stainable@Base 1.2.1
ncplane_putsimple_yx@Base 1.2.1
ncplane_putstr_aligned@Base 1.2.1
ncplane_putstr_yx@Base 1.2.1
ncplane_putwegc_stainable@Base 1.2.1
ncplane_reparent@Base 1.2.5
ncplane_resize@Base 1.2.1

View File

@ -43,7 +43,8 @@ ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust, int*
**int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes);**
**int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);**
**static inline int
ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);**
**static inline int
ncplane_putstr(struct ncplane* n, const char* gclustarr);**

View File

@ -1223,7 +1223,28 @@ API int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int*
// (though not beyond the end of the plane); this number is returned on success.
// On error, a non-positive number is returned, indicating the number of cells
// which were written before the error.
API int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);
static inline int
ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclusters){
int ret = 0;
// FIXME speed up this blissfully naive solution
while(*gclusters){
int wcs;
int cols = ncplane_putegc_yx(n, y, x, gclusters, &wcs);
if(cols < 0){
return -ret; // return -ret in case of error
}
if(wcs == 0){
break;
}
// after the first iteration, just let the cursor code control where we
// print, so that scrolling is taken into account
y = -1;
x = -1;
gclusters += wcs;
ret += wcs;
}
return ret;
}
static inline int
ncplane_putstr(struct ncplane* n, const char* gclustarr){

View File

@ -192,7 +192,6 @@ int ncplane_pulse(struct ncplane* n, const struct timespec* ts, fadecb fader, vo
int ncplane_putwc_yx(struct ncplane* n, int y, int x, wchar_t w);
int ncplane_putwc(struct ncplane* n, wchar_t w);
int ncplane_putegc_yx(struct ncplane* n, int y, int x, const char* gclust, int* sbytes);
int ncplane_putstr_yx(struct ncplane* n, int y, int x, const char* gclustarr);
int ncplane_putstr_aligned(struct ncplane* n, int y, ncalign_e align, const char* s);
void cell_init(cell* c);
int cell_load(struct ncplane* n, cell* c, const char* gcluster);

View File

@ -1467,28 +1467,6 @@ int cell_load(ncplane* n, cell* c, const char* gcluster){
return bytes;
}
int ncplane_putstr_yx(ncplane* n, int y, int x, const char* gclusters){
int ret = 0;
// FIXME speed up this blissfully naive solution
while(*gclusters){
int wcs;
int cols = ncplane_putegc_yx(n, y, x, gclusters, &wcs);
if(cols < 0){
return -ret; // return -ret in case of error
}
if(wcs == 0){
break;
}
// after the first iteration, just let the cursor code control where we
// print, so that scrolling is taken into account
y = -1;
x = -1;
gclusters += wcs;
ret += wcs;
}
return ret;
}
unsigned notcurses_supported_styles(const notcurses* nc){
unsigned styles = 0;
styles |= nc->standout ? NCSTYLE_STANDOUT : 0;