From 0b825c619edb5b002f56f375159f3af8b06ac18c Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 19 Oct 2020 01:37:31 -0400 Subject: [PATCH] add notcurses_stddim_yx_const() --- NEWS.md | 1 + USAGE.md | 8 ++++++++ doc/man/man3/notcurses_stdplane.3.md | 2 ++ include/notcurses/notcurses.h | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/NEWS.md b/NEWS.md index 6035354cf..91ff1a6e7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ rearrangements of Notcurses. * Add `ncinput_equal_p()` for comparison of `ncinput` structure data. * `ncmenu_offer_input()` now recognizes the shortcuts for registered sections, and will unroll the appropriate section when given input. + * Added `notcurses_stddim_yx_const()` (`notcurses_stddim_yx()` `const` form). * 2.0.0 (2020-10-12) "Stankonia" * **API STABILITY!** The API expressed in 2.0.0 will be maintained throughout diff --git a/USAGE.md b/USAGE.md index 88552cf91..a5d14ca60 100644 --- a/USAGE.md +++ b/USAGE.md @@ -207,6 +207,14 @@ notcurses_stddim_yx(struct notcurses* nc, int* restrict y, int* restrict x){ ncplane_dim_yx(s, y, x); // accepts NULL return s; } + +static inline const struct ncplane* +notcurses_stddim_yx_const(const struct notcurses* nc, int* restrict y, int* restrict x){ + const struct ncplane* s = notcurses_stdplane_const(nc); // can't fail + ncplane_dim_yx(s, y, x); // accepts NULL + return s; +} + ``` A reference to the standard plane *is* persistent across a screen resize, as are diff --git a/doc/man/man3/notcurses_stdplane.3.md b/doc/man/man3/notcurses_stdplane.3.md index 87161ff95..7d36ae9a6 100644 --- a/doc/man/man3/notcurses_stdplane.3.md +++ b/doc/man/man3/notcurses_stdplane.3.md @@ -16,6 +16,8 @@ notcurses_stdplane - acquire the standard ncplane **static inline struct ncplane* notcurses_stddim_yx(struct notcurses* nc, int* restrict y, int* restrict x);** +**static inline const struct ncplane* notcurses_stddim_yx_const(const struct notcurses* nc, int* restrict y, int* restrict x);** + # DESCRIPTION **notcurses_stdplane** returns a handle to the standard ncplane for the context diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 3ec0a1803..f9e72b271 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -991,6 +991,13 @@ notcurses_stddim_yx(struct notcurses* nc, int* RESTRICT y, int* RESTRICT x){ return s; } +static inline const struct ncplane* +notcurses_stddim_yx_const(const struct notcurses* nc, int* RESTRICT y, int* RESTRICT x){ + const struct ncplane* s = notcurses_stdplane_const(nc); // can't fail + ncplane_dim_yx(s, y, x); // accepts NULL + return s; +} + static inline int ncplane_dim_y(const struct ncplane* n){ int dimy;