From 4bfc0f4657dbef45d8fe05e7f3d9ac94a491bdc1 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 10 Oct 2021 21:51:19 -0400 Subject: [PATCH] ncplane_pixelgeom -> ncplane_pixel_geom() #1777 --- NEWS.md | 10 ++++++++++ USAGE.md | 6 +++--- doc/man/man3/notcurses_plane.3.md | 4 ++-- include/notcurses/notcurses.h | 6 +++--- python/notcurses/notcurses.py | 2 +- python/notcurses/plane.c | 6 +++--- src/demo/boxdemo.c | 2 +- src/demo/intro.c | 4 ++-- src/info/main.c | 2 +- src/input/input.cpp | 2 +- src/lib/notcurses.c | 6 +++--- src/lib/render.c | 2 +- src/poc/bitmapstates.c | 4 ++-- src/poc/grid.c | 2 +- src/poc/interp.c | 2 +- src/tests/bitmap.cpp | 2 +- 16 files changed, 36 insertions(+), 26 deletions(-) diff --git a/NEWS.md b/NEWS.md index ed439866ea..c08173b308 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,16 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 3.0.0 (not yet released) + * Made the ABI changes that have been planned/collected during 2.x + development. This primarily involved removing deprecated functions, + and making some `static inline` (and thus no longer linkable symbols). + There have been a few small renamings (i.e. `ncplane_pixelgeom()` to + `ncplane_pixel_geom()`) for purposes of regularity. The only thing removed + without an obvious replacement is the `renderfp` field of + `notcurses_options`, for which I make no apology. If you've been avoiding + deprecated functionality, ABI3 ought require small changes, if any. + * 2.4.6 (not yet released) * Features 1, 2, and 8 of the Kitty keyboard protocol are now supported. This provides much more detailed and fine-grained keyboard reports, including diff --git a/USAGE.md b/USAGE.md index f43439e7ca..1f8f037161 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1045,9 +1045,9 @@ ncplane_dim_x(const struct ncplane* n){ // ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy', // 'maxbmapx'). If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will // be 0. Any of the geometry arguments may be NULL. -void ncplane_pixelgeom(struct ncplane* n, int* restrict pxy, int* restrict pxx, - int* restrict celldimy, int* restrict celldimx, - int* restrict maxbmapy, int* restrict maxbmapx); +void ncplane_pixel_geom(struct ncplane* n, int* restrict pxy, int* restrict pxx, + int* restrict celldimy, int* restrict celldimx, + int* restrict maxbmapy, int* restrict maxbmapx); // provided a coordinate relative to the origin of 'src', map it to the same // absolute coordinate relative to the origin of 'dst'. either or both of 'y' diff --git a/doc/man/man3/notcurses_plane.3.md b/doc/man/man3/notcurses_plane.3.md index 113ce625c8..959f10898a 100644 --- a/doc/man/man3/notcurses_plane.3.md +++ b/doc/man/man3/notcurses_plane.3.md @@ -225,7 +225,7 @@ typedef struct ncplane_options { **int ncplane_rotate_ccw(struct ncplane* ***n***);** -**void ncplane_pixelgeom(struct notcurses* ***n***, int* restrict ***pxy***, int* restrict ***pxx***, int* restrict ***celldimy***, int* restrict ***celldimx***, int* restrict ***maxbmapy***, int* restrict ***maxbmapx***);** +**void ncplane_pixel_geom(struct notcurses* ***n***, int* restrict ***pxy***, int* restrict ***pxx***, int* restrict ***celldimy***, int* restrict ***celldimx***, int* restrict ***maxbmapy***, int* restrict ***maxbmapx***);** **int ncplane_set_name(struct ncplane* ***n***, const char* ***name***);** @@ -433,7 +433,7 @@ they intersect the plane. This can be disabled with the ## Bitmaps -**ncplane_pixelgeom** retrieves pixel geometry details. **pxy** and **pxx** +**ncplane_pixel_geom** retrieves pixel geometry details. **pxy** and **pxx** return the size of the plane in pixels. **celldimy** and **celldimx** return the size of a cell in pixels (these ought be the same across planes). **maxbmapy** and **maxbmapx** describe the largest bitmap which can be diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 6a91a15f05..bb17c63c8f 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1208,9 +1208,9 @@ API const struct notcurses* ncplane_notcurses_const(const struct ncplane* n) // 'maxbmapx'). If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will // be 0. Any of the geometry arguments may be NULL. These results are // invalidated by a terminal resize. -API void ncplane_pixelgeom(const struct ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx, - int* RESTRICT celldimy, int* RESTRICT celldimx, - int* RESTRICT maxbmapy, int* RESTRICT maxbmapx) +API void ncplane_pixel_geom(const struct ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx, + int* RESTRICT celldimy, int* RESTRICT celldimx, + int* RESTRICT maxbmapy, int* RESTRICT maxbmapx) __attribute__ ((nonnull (1))); // Return our current idea of the terminal dimensions in rows and cols. diff --git a/python/notcurses/notcurses.py b/python/notcurses/notcurses.py index f5f2c97277..41b84a82ab 100644 --- a/python/notcurses/notcurses.py +++ b/python/notcurses/notcurses.py @@ -524,7 +524,7 @@ def dim_y(self) -> int: """Return Y dimension of this NcPlane.""" raise NotImplementedError('Stub') - def pixelgeom(self) -> Tuple[int, int, int, int, int, int]: + def pixel_geom(self) -> Tuple[int, int, int, int, int, int]: """Retrieve pixel geometry for the display region, each cell and the maximum displayable bitmap.""" raise NotImplementedError('Stub') diff --git a/python/notcurses/plane.c b/python/notcurses/plane.c index 3e5c62b936..3c91aa49fc 100644 --- a/python/notcurses/plane.c +++ b/python/notcurses/plane.c @@ -110,10 +110,10 @@ NcPlane_dim_y(NcPlaneObject *self, PyObject *Py_UNUSED(args)) } static PyObject * -NcPlane_pixelgeom(NcPlaneObject *self, PyObject *Py_UNUSED(args)) +NcPlane_pixel_geom(NcPlaneObject *self, PyObject *Py_UNUSED(args)) { int pxy = 0, pxx = 0, celldimy = 0, celldimx = 0, maxbmapy = 0, maxbmapx = 0; - ncplane_pixelgeom(self->ncplane_ptr, &pxy, &pxx, &celldimy, &celldimx, &maxbmapy, &maxbmapx); + ncplane_pixel_geom(self->ncplane_ptr, &pxy, &pxx, &celldimy, &celldimx, &maxbmapy, &maxbmapx); return Py_BuildValue("ii ii ii", pxy, pxx, celldimy, celldimx, maxbmapy, maxbmapx); } @@ -1718,7 +1718,7 @@ static PyMethodDef NcPlane_methods[] = { {"dim_yx", (PyCFunction)NcPlane_dim_yx, METH_NOARGS, PyDoc_STR("Return the dimensions of this ncplane.")}, {"dim_x", (PyCFunction)NcPlane_dim_x, METH_NOARGS, PyDoc_STR("Return X dimension of this ncplane.")}, {"dim_y", (PyCFunction)NcPlane_dim_y, METH_NOARGS, PyDoc_STR("Return Y dimension of this ncplane.")}, - {"pixelgeom", (PyCFunction)NcPlane_pixelgeom, METH_NOARGS, PyDoc_STR("Retrieve pixel geometry for the display region ('pxy', 'pxx'), each cell ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy', 'maxbmapx'). Note that this will call notcurses_check_pixel_support(), possibly leading to an interrogation of the terminal. If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will be 0. Any of the geometry arguments may be NULL.")}, + {"pixel_geom", (PyCFunction)NcPlane_pixel_geom, METH_NOARGS, PyDoc_STR("Retrieve pixel geometry for the display region ('pxy', 'pxx'), each cell ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy', 'maxbmapx'). Note that this will call notcurses_check_pixel_support(), possibly leading to an interrogation of the terminal. If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will be 0. Any of the geometry arguments may be NULL.")}, {"set_resizecb", (PyCFunction)NcPlane_set_resizecb, METH_VARARGS, PyDoc_STR("Replace the ncplane's existing resizecb with 'resizecb' (which may be NULL). The standard plane's resizecb may not be changed.")}, {"reparent", (PyCFunction)NcPlane_reparent, METH_VARARGS, PyDoc_STR("Plane 'n' will be unbound from its parent plane, and will be made a bound child of 'newparent'.")}, diff --git a/src/demo/boxdemo.c b/src/demo/boxdemo.c index 0a9fdb43a5..b4bc5a1e7c 100644 --- a/src/demo/boxdemo.c +++ b/src/demo/boxdemo.c @@ -129,7 +129,7 @@ get_ships(struct notcurses* nc, struct ship* ships, unsigned shipcount){ return -1; } int cdimy, cdimx; - ncplane_pixelgeom(notcurses_stdplane(nc), NULL, NULL, &cdimy, &cdimx, NULL, NULL); + ncplane_pixel_geom(notcurses_stdplane(nc), NULL, NULL, &cdimy, &cdimx, NULL, NULL); if(ncvisual_resize(wmv, cdimy * SHIPHEIGHT, cdimx * SHIPWIDTH)){ ncvisual_destroy(wmv); return -1; diff --git a/src/demo/intro.c b/src/demo/intro.c index 6e88cea860..1df3281ecf 100644 --- a/src/demo/intro.c +++ b/src/demo/intro.c @@ -79,8 +79,8 @@ orcashow(struct notcurses* nc, int dimy, int dimx){ .scaling = NCSCALE_STRETCH, }; int cellpxy, cellpxx; - ncplane_pixelgeom(notcurses_stdplane_const(nc), NULL, NULL, - &cellpxy, &cellpxx, NULL, NULL); + ncplane_pixel_geom(notcurses_stdplane_const(nc), NULL, NULL, + &cellpxy, &cellpxx, NULL, NULL); int odimy, odimx, scaley, scalex; ncvisual_blitter_geom(nc, ncv, &vopts, &odimy, &odimx, &scaley, &scalex, NULL); // even if we can't do pixel output, we want her the same size as if weu diff --git a/src/info/main.c b/src/info/main.c index 9c126c4f50..e4016be4f5 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -308,7 +308,7 @@ unicodedumper(struct ncplane* n, const char* indent){ static int display_logo(struct ncplane* n, const char* path){ int cpixy, cpixx; - ncplane_pixelgeom(n, NULL, NULL, &cpixy, &cpixx, NULL, NULL); + ncplane_pixel_geom(n, NULL, NULL, &cpixy, &cpixx, NULL, NULL); struct ncvisual* ncv = ncvisual_from_file(path); if(ncv == NULL){ return -1; diff --git a/src/input/input.cpp b/src/input/input.cpp index 2826f2ee51..e4467700e5 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -255,7 +255,7 @@ int input_demo(ncpp::NotCurses* nc) { auto n = nc->get_stdplane(&dimy, &dimx); // FIXME no ncpp wrapper for Plane::pixelgeom? int celldimx, maxbmapx; - ncplane_pixelgeom(*n, nullptr, nullptr, nullptr, &celldimx, nullptr, &maxbmapx); + ncplane_pixel_geom(*n, nullptr, nullptr, nullptr, &celldimx, nullptr, &maxbmapx); struct ncplane_options nopts = { .y = dimy - PLOTHEIGHT - 1, .x = NCALIGN_CENTER, diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 23400126b0..25788e6d0c 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -3113,9 +3113,9 @@ int ncstrwidth_valid(const char* egcs, int* validbytes, int* validwidth){ return *validwidth; } -void ncplane_pixelgeom(const ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx, - int* RESTRICT celldimy, int* RESTRICT celldimx, - int* RESTRICT maxbmapy, int* RESTRICT maxbmapx){ +void ncplane_pixel_geom(const ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx, + int* RESTRICT celldimy, int* RESTRICT celldimx, + int* RESTRICT maxbmapy, int* RESTRICT maxbmapx){ notcurses* nc = ncplane_notcurses(n); if(celldimy){ *celldimy = nc->tcache.cellpixy; diff --git a/src/lib/render.c b/src/lib/render.c index 80eec98478..193d6ee141 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -1507,7 +1507,7 @@ int ncpile_render(ncplane* n){ ncpile_render_internal(n, pile->crender, pile->dimy, pile->dimx); clock_gettime(CLOCK_MONOTONIC, &renderdone); pthread_mutex_lock(&nc->stats.lock); - update_raster_stats(&renderdone, &start, &nc->stats.s); + update_render_stats(&renderdone, &start, &nc->stats.s); pthread_mutex_unlock(&nc->stats.lock); return 0; } diff --git a/src/poc/bitmapstates.c b/src/poc/bitmapstates.c index 775c53cb5e..8c63bdd2e5 100644 --- a/src/poc/bitmapstates.c +++ b/src/poc/bitmapstates.c @@ -12,8 +12,8 @@ emit(struct ncplane* n, const char* str){ static int wipebitmap(struct notcurses* nc){ int cellpxy, cellpxx; - ncplane_pixelgeom(notcurses_stdplane(nc), NULL, NULL, - &cellpxy, &cellpxx, NULL, NULL); + ncplane_pixel_geom(notcurses_stdplane(nc), NULL, NULL, + &cellpxy, &cellpxx, NULL, NULL); int pixy = cellpxy * 6; int pixx = cellpxx * 6; uint32_t pixels[pixx * pixy]; diff --git a/src/poc/grid.c b/src/poc/grid.c index 16d8841eb4..c4bc63aa77 100644 --- a/src/poc/grid.c +++ b/src/poc/grid.c @@ -4,7 +4,7 @@ struct ncvisual* draw_grid(struct ncplane* stdn){ int maxby, maxbx; int cellpxy, cellpxx; - ncplane_pixelgeom(stdn, NULL, NULL, &cellpxy, &cellpxx, &maxby, &maxbx); + ncplane_pixel_geom(stdn, NULL, NULL, &cellpxy, &cellpxx, &maxby, &maxbx); if(cellpxy <= 1 || cellpxx <= 1){ fprintf(stderr, "cell-pixel geometry: %d %d\n", cellpxy, cellpxx); return NULL; diff --git a/src/poc/interp.c b/src/poc/interp.c index 91d12c59bb..e435df3c44 100644 --- a/src/poc/interp.c +++ b/src/poc/interp.c @@ -102,7 +102,7 @@ int main(void){ } struct ncplane* stdn = notcurses_stdplane(nc); int cellpixy, cellpixx; - ncplane_pixelgeom(stdn, NULL, NULL, &cellpixy, &cellpixx, NULL, NULL); + ncplane_pixel_geom(stdn, NULL, NULL, &cellpixy, &cellpixx, NULL, NULL); if(interp(nc, cellpixy, cellpixx)){ goto err; } diff --git a/src/tests/bitmap.cpp b/src/tests/bitmap.cpp index ca0758b8dd..cd9e77b517 100644 --- a/src/tests/bitmap.cpp +++ b/src/tests/bitmap.cpp @@ -52,7 +52,7 @@ TEST_CASE("Bitmaps") { vopts.blitter = NCBLIT_PIXEL; vopts.flags = NCVISUAL_OPTION_NODEGRADE; int maxy, maxx; - ncplane_pixelgeom(n_, nullptr, nullptr, nullptr, nullptr, &maxy, &maxx); + ncplane_pixel_geom(n_, nullptr, nullptr, nullptr, nullptr, &maxy, &maxx); CHECK(0 == ncvisual_resize(ncv, maxy, maxx)); auto n = ncvisual_render(nc_, ncv, &vopts); REQUIRE(nn == n);