diff --git a/NEWS.md b/NEWS.md index 04fbd621d..f5d511543 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,7 +10,7 @@ rearrangements of Notcurses. self-documenting `struct ncplane_options` argument. So long as the arguments to `ncplane_new()` do not have side-effects, calls can be mechanically translated to their `ncplane_create()` equivalents. - * Added `nplane_set_resize()`. + * Added `ncplane_set_resizecb()` and `ncplane_resizecb()`. * 2.0.4 (2020-11-10) * Fixed unit tests for non UTF-8 case, brown bagger, alas. diff --git a/USAGE.md b/USAGE.md index 5b76c8575..e6f425bfe 100644 --- a/USAGE.md +++ b/USAGE.md @@ -673,6 +673,9 @@ struct ncplane* ncplane_reparent(struct ncplane* n, struct ncplane* newparent); // Replace the ncplane's existing resizecb with 'resizecb' (which may be NULL). void ncplane_set_resizecb(struct ncplane* n, int(*resizecb)(struct ncplane*)); +// Returns the ncplane's current resize callback. +int (*ncplane_resizecb(const struct ncplane* n))(struct ncplane*); + // Suitable for use as a 'resizecb'. This will realign the plane 'n' against its // parent, using the alignment specified at ncplane_create()-time. int ncplane_resize_realign(struct ncplane* n); diff --git a/doc/man/man3/notcurses_plane.3.md b/doc/man/man3/notcurses_plane.3.md index b7d252591..43d2bb51e 100644 --- a/doc/man/man3/notcurses_plane.3.md +++ b/doc/man/man3/notcurses_plane.3.md @@ -37,6 +37,8 @@ typedef struct ncplane_options { **void ncplane_set_resizecb(struct ncplane* ***n***, int(*resizecb)(struct ncplane*));** +**int (*ncplane_resizecb(const struct ncplane* ***n***))(struct ncplane*);** + **struct ncplane* ncplane_dup(struct ncplane* ***n***, void* ***opaque***);** **int ncplane_resize(struct ncplane* ***n***, int ***keepy***, int ***keepx***, int ***keepleny***, int ***keeplenx***, int ***yoff***, int ***xoff***, int ***ylen***, int ***xlen***);** diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 66dd5bf31..ce9a34db5 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1056,6 +1056,9 @@ API int ncplane_resize_realign(struct ncplane* n); // Replace the ncplane's existing resizecb with 'resizecb' (which may be NULL). API void ncplane_set_resizecb(struct ncplane* n, int(*resizecb)(struct ncplane*)); +// Returns the ncplane's current resize callback. +API int (*ncplane_resizecb(const struct ncplane* n))(struct ncplane*); + // Plane 'n' will be unbound from its parent plane, if it is currently bound, // and will be made a bound child of 'newparent', if 'newparent' is not NULL. API struct ncplane* ncplane_reparent(struct ncplane* n, struct ncplane* newparent); diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 5df61aca3..eccf11297 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -2040,6 +2040,10 @@ void ncplane_set_resizecb(ncplane* n, int(*resizecb)(ncplane*)){ n->resizecb = resizecb; } +int (*ncplane_resizecb(const ncplane* n))(ncplane*){ + return n->resizecb; +} + int ncplane_resize_realign(ncplane* n){ const ncplane* parent = ncplane_parent_const(n); if(parent == n){ // somehow got stdplane, should never get here