Skip to content

Commit

Permalink
ncplane_pixelgeom -> ncplane_pixel_geom() #1777
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Oct 11, 2021
1 parent b70aa5c commit 4bfc0f4
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 26 deletions.
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions doc/man/man3/notcurses_plane.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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***);**
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion python/notcurses/notcurses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions python/notcurses/plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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'.")},
Expand Down
2 changes: 1 addition & 1 deletion src/demo/boxdemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/demo/intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/info/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/poc/bitmapstates.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/poc/grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/poc/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4bfc0f4

Please sign in to comment.