Skip to content

Commit

Permalink
ncplane_move{top, bottom} become static inline #1777
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Oct 16, 2021
1 parent 59b64c3 commit 6f0c6a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
13 changes: 11 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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***);**
Expand Down
19 changes: 12 additions & 7 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 0 additions & 30 deletions src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f0c6a8

Please sign in to comment.