diff --git a/USAGE.md b/USAGE.md index 153d1fcde6..28f96b0bdd 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1104,8 +1104,17 @@ int ncplane_base(struct ncplane* ncp, nccell* c); ```c // Splice ncplane 'n' out of the z-buffer, and reinsert it at the top or bottom. -void ncplane_move_top(struct ncplane* n); -void ncplane_move_bottom(struct ncplane* n); +__attribute__ ((nonnull (1))) +static inline void +ncplane_move_top(struct ncplane* n){ + ncplane_move_below(n, NULL); +} + +__attribute__ ((nonnull (1))) +static inline void +ncplane_move_bottom(struct ncplane* n){ + ncplane_move_above(n, NULL); +} // Splice ncplane 'n' and its bound planes out of the z-buffer, and reinsert // them at the top or bottom. Relative order will be maintained between the diff --git a/doc/man/man3/notcurses_plane.3.md b/doc/man/man3/notcurses_plane.3.md index 36fc2b44d7..8bfef83d27 100644 --- a/doc/man/man3/notcurses_plane.3.md +++ b/doc/man/man3/notcurses_plane.3.md @@ -95,9 +95,9 @@ typedef struct ncplane_options { **int ncplane_base(struct ncplane* ***ncp***, nccell* ***c***);** -**void ncplane_move_top(struct ncplane* ***n***);** +**static inline void ncplane_move_top(struct ncplane* ***n***);** -**void ncplane_move_bottom(struct ncplane* ***n***);** +**static inline void ncplane_move_bottom(struct ncplane* ***n***);** **void ncplane_move_family_top(struct ncplane* ***n***);** diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 89132749ee..ea7619686a 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1667,13 +1667,18 @@ API int ncplane_move_below(struct ncplane* RESTRICT n, struct ncplane* RESTRICT below) __attribute__ ((nonnull (1))); -// Splice ncplane 'n' out of the z-buffer, and reinsert it at the top or -// bottom. FIXME these both become static inline wrappers around -// ncplane_move_below() and ncplane_move_above() in ABI3. -API void ncplane_move_top(struct ncplane* n) - __attribute__ ((nonnull (1))); -API void ncplane_move_bottom(struct ncplane* n) - __attribute__ ((nonnull (1))); +// Splice ncplane 'n' out of the z-buffer; reinsert it at the top or bottom. +__attribute__ ((nonnull (1))) +static inline void +ncplane_move_top(struct ncplane* n){ + ncplane_move_below(n, NULL); +} + +__attribute__ ((nonnull (1))) +static inline void +ncplane_move_bottom(struct ncplane* n){ + ncplane_move_above(n, NULL); +} // Splice ncplane 'n' and its bound planes out of the z-buffer, and reinsert // them above or below 'targ'. Relative order will be maintained between the diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 47011b6d98..ccc8891de6 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1409,36 +1409,6 @@ int ncplane_move_below(ncplane* restrict n, ncplane* restrict below){ return 0; } -void ncplane_move_top(ncplane* n){ - if(n->above){ - if( (n->above->below = n->below) ){ - n->below->above = n->above; - }else{ - ncplane_pile(n)->bottom = n->above; - } - n->above = NULL; - if( (n->below = ncplane_pile(n)->top) ){ - n->below->above = n; - } - ncplane_pile(n)->top = n; - } -} - -void ncplane_move_bottom(ncplane* n){ - if(n->below){ - if( (n->below->above = n->above) ){ - n->above->below = n->below; - }else{ - ncplane_pile(n)->top = n->below; - } - n->below = NULL; - if( (n->above = ncplane_pile(n)->bottom) ){ - n->above->below = n; - } - ncplane_pile(n)->bottom = n; - } -} - // if above is NULL, we're moving to the bottom int ncplane_move_family_above(ncplane* restrict n, ncplane* restrict bpoint){ ncplane* above = ncplane_above(n);