introduce ncplane_aligned() #237

pull/243/head
nick black 5 years ago
parent 8926fc5879
commit 2ea4f77875
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -16,6 +16,7 @@ for more information, see [my wiki](https://nick-black.com/dankwiki/index.php/No
* [Requirements](#requirements)
* [Building](#building)
* [Use](#use)
* [Alignment](#alignment)
* [Input](#input)
* [Planes](#planes) ([Plane Channels API](#plane-channels-api), [Wide chars](#wide-chars))
* [Cells](#cells) ([Cell Channels API](#cell-channels-api))
@ -255,8 +256,8 @@ int notcurses_refresh(struct notcurses* n);
// and the specified size. The number of rows and columns must both be positive.
// This plane is initially at the top of the z-buffer, as if ncplane_move_top()
// had been called on it. The void* 'opaque' can be retrieved (and reset) later.
struct ncplane* notcurses_newplane(struct notcurses* nc, int rows, int cols,
int yoff, int xoff, void* opaque);
API struct ncplane* ncplane_new(struct notcurses* nc, int rows, int cols,
int yoff, int xoff, void* opaque);
// Returns a 16-bit bitmask in the LSBs of supported curses-style attributes
// (CELL_STYLE_UNDERLINE, CELL_STYLE_BOLD, etc.) The attribute is only
@ -276,6 +277,40 @@ bool notcurses_canfade(const struct notcurses* nc);
bool notcurses_canopen(const struct notcurses* nc);
```
### Alignment
Most functions that generate output can be aligned relative to an ncplane.
Alignment currently comes in three forms: `NCALIGN_LEFT`, `NCALIGN_CENTER`, and
`NCALIGN_RIGHT`.
```c
// Alignment within the ncplane. Left/right-justified, or centered.
typedef enum {
NCALIGN_LEFT,
NCALIGN_CENTER,
NCALIGN_RIGHT,
} ncalign_e;
// Return the column at which 'c' cols ought start in order to be aligned
// according to 'align' within ncplane 'n'. Returns INT_MAX on invalid 'align'.
// Undefined behavior on negative 'c'.
// 'align', negative 'c').
static inline int
ncplane_align(const struct ncplane* n, ncalign_e align, int c){
if(align == NCALIGN_LEFT){
return 0;
}
int cols;
ncplane_dim_yx(n, NULL, &cols);
if(align == NCALIGN_CENTER){
return (cols - c) / 2;
}else if(align == NCALIGN_RIGHT){
return cols - c;
}
return INT_MAX;
}
```
### Input
Input can currently be taken only from `stdin`, but on the plus side, stdin
@ -479,6 +514,10 @@ but is the primary drawing surface of notcurses—there is no object
corresponding to a bare NCURSES `WINDOW`.
```c
// Create a new ncplane aligned relative to 'n'.
struct ncplane* ncplane_aligned(struct ncplane* n, int rows, int cols,
int yoff, ncalign_e align, void* opaque);
// Resize the specified ncplane. The four parameters 'keepy', 'keepx',
// 'keepleny', and 'keeplenx' define a subset of the ncplane to keep,
// unchanged. This may be a section of size 0, though none of these four
@ -696,13 +735,6 @@ ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust,
return ncplane_putwegc(n, gclust, attr, channels, sbytes);
}
// Alignment within the ncplane. Left/right-justified, or centered.
typedef enum {
NCALIGN_LEFT,
NCALIGN_CENTER,
NCALIGN_RIGHT,
} ncalign_e;
// Write a series of EGCs to the current location, using the current style.
// They will be interpreted as a series of columns (according to the definition
// of ncplane_putc()). Advances the cursor by some positive number of cells
@ -737,8 +769,13 @@ ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr){
return ret;
}
int ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
const wchar_t* gclustarr);
static inline int
ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
const wchar_t* gclustarr){
int width = wcswidth(gclustarr, INT_MAX);
int xpos = ncplane_align(n, align, width);
return ncplane_putwstr_yx(n, y, xpos, gclustarr);
}
static inline int
ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr){
@ -940,24 +977,6 @@ int ncplane_fadeout(struct ncplane* n, const struct timespec* ts);
int ncplane_fadein(struct ncplane* n, const struct timespec* ts);
```
Aligned forms are available for `ncplane_putstr()` and `ncplane_putwstr()`.
These forms correctly take double-column glyphs into account.
```c
// Alignment within the ncplane. Left/right-justified, or centered.
typedef enum {
NCALIGN_LEFT,
NCALIGN_CENTER,
NCALIGN_RIGHT,
} ncalign_e;
int ncplane_putstr_aligned(struct ncplane* n, int y, const char* s,
ncalign_e atype);
int ncplane_putwstr_aligned(struct ncplane* n, int y,
const wchar_t* gclustarr, ncalign_e atype);
```
#### Plane channels API
Helpers are provided to manipulate an `ncplane`'s `channels` member. They are

2
debian/control vendored

@ -3,7 +3,7 @@ Priority: optional
Maintainer: Nick Black <dankamongmen@gmail.com>
Build-Depends: debhelper-compat (= 12), cmake (>= 3.13), pkg-config (>= 0.29),
libncurses-dev (>= 6.1), libavformat-dev (>= 57.0), libswscale-dev (>= 5.0),
libavutil-dev (>= 56.0), doctest-dev (>= 1.2.7), ruby-ronn (>= 0.7.3)
libavutil-dev (>= 56.0), ruby-ronn (>= 0.7.3)
Standards-Version: 4.4.1.1
Section: libs
Homepage: https://nick-black.com/dankwiki/index.php/notcurses

@ -11,6 +11,7 @@
#include <stdarg.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <stdbool.h>
#ifdef __cplusplus
@ -313,12 +314,22 @@ API int notcurses_refresh(struct notcurses* n);
API struct ncplane* notcurses_stdplane(struct notcurses* nc);
API const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc);
// Alignment within the ncplane. Left/right-justified, or centered.
typedef enum {
NCALIGN_LEFT,
NCALIGN_CENTER,
NCALIGN_RIGHT,
} ncalign_e;
// Create a new ncplane at the specified offset (relative to the standard plane)
// and the specified size. The number of rows and columns must both be positive.
// This plane is initially at the top of the z-buffer, as if ncplane_move_top()
// had been called on it. The void* 'opaque' can be retrieved (and reset) later.
API struct ncplane* notcurses_newplane(struct notcurses* nc, int rows, int cols,
int yoff, int xoff, void* opaque);
API struct ncplane* ncplane_new(struct notcurses* nc, int rows, int cols,
int yoff, int xoff, void* opaque);
API struct ncplane* ncplane_aligned(struct ncplane* n, int rows, int cols,
int yoff, ncalign_e align, void* opaque);
// Returns a 16-bit bitmask of supported curses-style attributes
// (CELL_STYLE_UNDERLINE, CELL_STYLE_BOLD, etc.) The attribute is only
@ -460,6 +471,25 @@ notcurses_term_dim_yx(const struct notcurses* n, int* RESTRICT rows,
ncplane_dim_yx(notcurses_stdplane_const(n), rows, cols);
}
// Return the column at which 'c' cols ought start in order to be aligned
// according to 'align' within ncplane 'n'. Returns INT_MAX on invalid 'align'.
// Undefined behavior on negative 'c'.
// 'align', negative 'c').
static inline int
ncplane_align(const struct ncplane* n, ncalign_e align, int c){
if(align == NCALIGN_LEFT){
return 0;
}
int cols;
ncplane_dim_yx(n, NULL, &cols);
if(align == NCALIGN_CENTER){
return (cols - c) / 2;
}else if(align == NCALIGN_RIGHT){
return cols - c;
}
return INT_MAX;
}
// Move the cursor to the specified position (the cursor needn't be visible).
// Returns -1 on error, including negative parameters, or ones exceeding the
// plane's dimensions.
@ -562,13 +592,6 @@ ncplane_putwegc_yx(struct ncplane* n, int y, int x, const wchar_t* gclust,
return ncplane_putwegc(n, gclust, attr, channels, sbytes);
}
// Alignment within the ncplane. Left/right-justified, or centered.
typedef enum {
NCALIGN_LEFT,
NCALIGN_CENTER,
NCALIGN_RIGHT,
} ncalign_e;
// Write a series of EGCs to the current location, using the current style.
// They will be interpreted as a series of columns (according to the definition
// of ncplane_putc()). Advances the cursor by some positive number of cells
@ -604,8 +627,13 @@ ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr){
return ret;
}
API int ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
const wchar_t* gclustarr);
static inline int
ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
const wchar_t* gclustarr){
int width = wcswidth(gclustarr, INT_MAX);
int xpos = ncplane_align(n, align, width);
return ncplane_putwstr_yx(n, y, xpos, gclustarr);
}
static inline int
ncplane_putwstr(struct ncplane* n, const wchar_t* gclustarr){

@ -84,7 +84,7 @@ zoom_map(struct notcurses* nc, const char* map){
ncplane_destroy(zncp);
zoomy += delty;
zoomx += deltx;
zncp = notcurses_newplane(nc, zoomy, zoomx, 0, 0, NULL);
zncp = ncplane_new(nc, zoomy, zoomx, 0, 0, NULL);
struct ncvisual* zncv = ncplane_visual_open(zncp, map, &averr);
if(zncv == NULL){
ncvisual_destroy(ncv);
@ -161,7 +161,7 @@ eagles(struct notcurses* nc){
for(size_t i = 0 ; i < sizeof(e) / sizeof(*e) ; ++i){
e[i].xoff = 0;
e[i].yoff = random() % ((truey - height) / 2);
e[i].n = notcurses_newplane(nc, height, width, e[i].yoff, e[i].xoff, NULL);
e[i].n = ncplane_new(nc, height, width, e[i].yoff, e[i].xoff, NULL);
if(e[i].n == NULL){
return -1;
}

@ -59,7 +59,7 @@ struct ncplane* hud_create(struct notcurses* nc){
int xoffset = (dimx - HUD_COLS) / 2;
//int yoffset = (dimy - HUD_ROWS);
int yoffset = 0;
struct ncplane* n = notcurses_newplane(nc, HUD_ROWS, HUD_COLS, yoffset, xoffset, NULL);
struct ncplane* n = ncplane_new(nc, HUD_ROWS, HUD_COLS, yoffset, xoffset, NULL);
if(n == NULL){
return NULL;
}

@ -169,7 +169,7 @@ int luigi_demo(struct notcurses* nc){
int i;
struct ncplane* lastseen = NULL;
for(i = 0 ; i < 3 ; ++i){
lns[i] = notcurses_newplane(nc, height, 16, yoff, 0, NULL);
lns[i] = ncplane_new(nc, height, 16, yoff, 0, NULL);
if(lns[i] == NULL){
while(--i){
ncplane_destroy(lns[i]);

@ -28,8 +28,8 @@ static struct ncplane*
legend(struct notcurses* nc, const char* msg){
int dimx, dimy;
notcurses_term_dim_yx(nc, &dimy, &dimx);
// FIXME replace with notcurses_newplane_aligned()
struct ncplane* n = notcurses_newplane(nc, 3, strlen(msg) + 2, dimy - 4,
// FIXME replace with ncplane_new_aligned()
struct ncplane* n = ncplane_new(nc, 3, strlen(msg) + 2, dimy - 4,
(dimx - ((strlen(msg) + 2))) / 2, NULL);
if(n == NULL){
return NULL;
@ -119,7 +119,7 @@ slidepanel(struct notcurses* nc){
struct ncplane* l;
// First we just create a plane with no styling and no glyphs.
struct ncplane* n = notcurses_newplane(nc, ny, nx, yoff, xoff, NULL);
struct ncplane* n = ncplane_new(nc, ny, nx, yoff, xoff, NULL);
// Zero-initialized channels use the default color, opaquely. Since we have
// no glyph, we should show underlying glyphs in the default colors. The

@ -42,7 +42,7 @@ fadethread(void* vnc){
}
int rows, cols;
notcurses_term_dim_yx(nc, &rows, &cols);
struct ncplane* apiap = notcurses_newplane(nc, 1, cols, rows - 1, 0, NULL);
struct ncplane* apiap = ncplane_new(nc, 1, cols, rows - 1, 0, NULL);
ncplane_set_fg_rgb(apiap, 0xc0, 0x40, 0x80);
ncplane_set_bg_rgb(apiap, 0, 0, 0);
ncplane_putstr_aligned(apiap, 0, NCALIGN_CENTER,
@ -66,7 +66,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
int xs = (*cols - (strlen(str1) + 4)) / 2;
int ystart = *rows - 6;
*cols = xs;
struct ncplane* non = notcurses_newplane(nc, 5, strlen(str1) + 4, ystart, *cols, NULL);
struct ncplane* non = ncplane_new(nc, 5, strlen(str1) + 4, ystart, *cols, NULL);
if(non == NULL){
return NULL;
}

@ -187,7 +187,7 @@ int sliding_puzzle_demo(struct notcurses* nc){
for(cx = 0 ; cx < CHUNKS_HORZ ; ++cx){
const int idx = cy * CHUNKS_HORZ + cx;
chunks[idx] =
notcurses_newplane(nc, chunky, chunkx, cy * chunky + wastey + 1,
ncplane_new(nc, chunky, chunkx, cy * chunky + wastey + 1,
cx * chunkx + wastex + 1, NULL);
if(chunks[idx] == NULL){
goto done;

@ -178,7 +178,7 @@ int unicodeblocks_demo(struct notcurses* nc){
}
int xstart = (maxx - ((CHUNKSIZE * 2) + 3)) / 2;
struct ncplane* nn;
if((nn = notcurses_newplane(nc, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 3, xstart, NULL)) == NULL){
if((nn = ncplane_new(nc, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 3, xstart, NULL)) == NULL){
return -1;
}
if(hud){

@ -40,7 +40,7 @@ view_video_demo(struct notcurses* nc){
static struct ncplane*
legend(struct notcurses* nc, int dimy, int dimx){
struct ncplane* n = notcurses_newplane(nc, 4, 25, dimy * 7 / 8, (dimx - 25) / 2, NULL);
struct ncplane* n = ncplane_new(nc, 4, 25, dimy * 7 / 8, (dimx - 25) / 2, NULL);
ncplane_set_bg_alpha(n, CELL_ALPHA_TRANSPARENT);
uint64_t channels = 0;
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
@ -83,7 +83,7 @@ int view_demo(struct notcurses* nc){
return -1;
}
free(pic);
struct ncplane* dsplane = notcurses_newplane(nc, dimy, dimx, 0, 0, NULL);
struct ncplane* dsplane = ncplane_new(nc, dimy, dimx, 0, 0, NULL);
if(dsplane == NULL){
return -1;
}

@ -644,7 +644,7 @@ int witherworm_demo(struct notcurses* nc){
rgb += step;
}
}while(y < maxy && x < maxx);
struct ncplane* mess = notcurses_newplane(nc, 7, 57, 1, 4, NULL);
struct ncplane* mess = ncplane_new(nc, 7, 57, 1, 4, NULL);
if(mess == NULL){
return -1;
}

@ -27,7 +27,7 @@ perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused)),
ncplane_dim_yx(nstd, &dimy, &dimx);
y = dimy - sizeof(leg) / sizeof(*leg);
// FIXME how will this plane be destroyed?
n = notcurses_newplane(nc, sizeof(leg) / sizeof(*leg), dimx, y, 0, NULL);
n = ncplane_new(nc, sizeof(leg) / sizeof(*leg), dimx, y, 0, NULL);
if(n == NULL){
return -1;
}
@ -92,7 +92,7 @@ int xray_demo(struct notcurses* nc){
int dimx, dimy;
struct ncplane* nstd = notcurses_stdplane(nc);
ncplane_dim_yx(nstd, &dimy, &dimx);
struct ncplane* n = notcurses_newplane(nc, dimy, dimx, 0, 0, NULL);
struct ncplane* n = ncplane_new(nc, dimy, dimx, 0, 0, NULL);
if(n == NULL){
return -1;
}

@ -140,7 +140,7 @@ AVFrame* ncvisual_decode(ncvisual* nc, int* averr){
}
nc->dstwidth = cols;
nc->dstheight = rows * 2;
nc->ncp = notcurses_newplane(nc->ncobj, rows, cols, nc->placey, nc->placex, nc);
nc->ncp = ncplane_new(nc->ncobj, rows, cols, nc->placey, nc->placex, nc);
if(nc->ncp == NULL){
*averr = AVERROR(ENOMEM);
return NULL;

@ -127,29 +127,6 @@ int ncplane_putstr_aligned(ncplane* n, int y, ncalign_e align, const char* s){
return r;
}
int ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
const wchar_t* gclustarr){
int width = wcswidth(gclustarr, INT_MAX);
int cols;
int xpos;
switch(align){
case NCALIGN_LEFT:
xpos = 0;
break;
case NCALIGN_CENTER:
ncplane_dim_yx(n, NULL, &cols);
xpos = (cols - width) / 2;
break;
case NCALIGN_RIGHT:
ncplane_dim_yx(n, NULL, &cols);
xpos = cols - width;
break;
default:
return -1;
}
return ncplane_putwstr_yx(n, y, xpos, gclustarr);
}
static const char NOTCURSES_VERSION[] =
notcurses_VERSION_MAJOR "."
notcurses_VERSION_MINOR "."
@ -316,7 +293,7 @@ const ncplane* notcurses_stdplane_const(const notcurses* nc){
return nc->stdscr;
}
ncplane* notcurses_newplane(notcurses* nc, int rows, int cols,
ncplane* ncplane_new(notcurses* nc, int rows, int cols,
int yoff, int xoff, void* opaque){
ncplane* n = ncplane_create(nc, rows, cols, yoff, xoff);
if(n == NULL){
@ -326,6 +303,11 @@ ncplane* notcurses_newplane(notcurses* nc, int rows, int cols,
return n;
}
struct ncplane* ncplane_aligned(struct ncplane* n, int rows, int cols,
int yoff, ncalign_e align, void* opaque){
return ncplane_new(n->nc, rows, cols, yoff, ncplane_align(n, align, cols), opaque);
}
// can be used on stdscr, unlike ncplane_resize() which prohibits it.
static int
ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,

@ -236,7 +236,7 @@ panelreel_draw_tablet(const panelreel* pr, tablet* t, int frontiery,
//fprintf(stderr, "tplacement: %p:%p base %d/%d len %d/%d\n", t, fp, begx, begy, lenx, leny);
//fprintf(stderr, "DRAWING %p at frontier %d (dir %d) with %d\n", t, frontiery, direction, leny);
if(fp == NULL){ // create a panel for the tablet
t->p = notcurses_newplane(pr->p->nc, leny + 1, lenx, begy, begx, NULL);
t->p = ncplane_new(pr->p->nc, leny + 1, lenx, begy, begx, NULL);
if((fp = t->p) == NULL){
return -1;
}
@ -617,7 +617,7 @@ panelreel* panelreel_create(ncplane* w, const panelreel_options* popts, int efd)
xlen = 0; // FIXME see above...
}
}
if((pr->p = notcurses_newplane(w->nc, ylen, xlen, popts->toff + wy, popts->loff + wx, NULL)) == NULL){
if((pr->p = ncplane_new(w->nc, ylen, xlen, popts->toff + wy, popts->loff + wx, NULL)) == NULL){
free(pr);
return NULL;
}
@ -655,7 +655,7 @@ insert_new_panel(struct notcurses* nc, panelreel* pr, tablet* t){
return t;
}
// fprintf(stderr, "newwin: %d/%d + %d/%d\n", begy, begx, leny, lenx);
if((t->p = notcurses_newplane(nc, leny, lenx, begy, begx, NULL)) == NULL){
if((t->p = ncplane_new(nc, leny, lenx, begy, begx, NULL)) == NULL){
pr->all_visible = false;
return t;
}
@ -673,7 +673,7 @@ insert_new_panel(struct notcurses* nc, panelreel* pr, tablet* t){
return t;
}
// fprintf(stderr, "newwin: %d/%d + %d/%d\n", begy, begx, 2, lenx);
if((t->p = notcurses_newplane(nc, 2, lenx, begy, begx, NULL)) == NULL){
if((t->p = ncplane_new(nc, 2, lenx, begy, begx, NULL)) == NULL){
pr->all_visible = false;
return t;
}

@ -115,7 +115,7 @@ int main(int argc, char** argv){
struct ncplane* nstd = notcurses_stdplane(nc);
int dimy, dimx;
ncplane_dim_yx(nstd, &dimy, &dimx);
struct ncplane* n = notcurses_newplane(nc, dimy - 1, dimx, 1, 0, nullptr);
struct ncplane* n = ncplane_new(nc, dimy - 1, dimx, 1, 0, nullptr);
if(!n){
notcurses_stop(nc);
return EXIT_FAILURE;

@ -74,7 +74,7 @@ int main(int argc, char** argv){
int dimy, dimx;
notcurses_term_dim_yx(nc, &dimy, &dimx);
struct timespec start;
auto ncp = notcurses_newplane(nc, dimy - 1, dimx, 1, 0, &start);
auto ncp = ncplane_new(nc, dimy - 1, dimx, 1, 0, &start);
if(ncp == nullptr){
notcurses_stop(nc);
return EXIT_FAILURE;

@ -377,7 +377,7 @@ TEST_CASE("NCPlane") {
int x, y;
void* sentinel = &x;
notcurses_term_dim_yx(nc_, &y, &x);
struct ncplane* ncp = notcurses_newplane(nc_, y, x, 0, 0, sentinel);
struct ncplane* ncp = ncplane_new(nc_, y, x, 0, 0, sentinel);
REQUIRE(ncp);
CHECK(&x == ncplane_userptr(ncp));
CHECK(sentinel == ncplane_set_userptr(ncp, nullptr));
@ -393,7 +393,7 @@ TEST_CASE("NCPlane") {
SUBCASE("NewPlaneSameSize") {
int x, y;
notcurses_term_dim_yx(nc_, &y, &x);
struct ncplane* ncp = notcurses_newplane(nc_, y, x, 0, 0, nullptr);
struct ncplane* ncp = ncplane_new(nc_, y, x, 0, 0, nullptr);
REQUIRE(ncp);
int px, py;
ncplane_dim_yx(ncp, &py, &px);
@ -410,7 +410,7 @@ TEST_CASE("NCPlane") {
int maxx, maxy;
int x = 0, y = 0;
notcurses_term_dim_yx(nc_, &maxy, &maxx);
struct ncplane* newp = notcurses_newplane(nc_, maxy, maxx, y, x, nullptr);
struct ncplane* newp = ncplane_new(nc_, maxy, maxx, y, x, nullptr);
REQUIRE(newp);
CHECK(0 == notcurses_render(nc_));
while(y > 4 && x > 4){
@ -449,7 +449,7 @@ TEST_CASE("NCPlane") {
notcurses_term_dim_yx(nc_, &dimy, &dimx);
x = dimx / 2 - 1;
y = dimy / 2 - 1;
struct ncplane* newp = notcurses_newplane(nc_, maxy, maxx, y, x, nullptr);
struct ncplane* newp = ncplane_new(nc_, maxy, maxx, y, x, nullptr);
REQUIRE(newp);
while(dimx - maxx > 4 && dimy - maxy > 4){
maxx += 2;
@ -722,7 +722,7 @@ TEST_CASE("NCPlane") {
cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
int y, x;
ncplane_yx(n_, &y, &x);
struct ncplane* ncp = notcurses_newplane(nc_, 2, 2, y, ncols - 3, nullptr);
struct ncplane* ncp = ncplane_new(nc_, 2, 2, y, ncols - 3, nullptr);
REQUIRE(ncp);
REQUIRE(0 == cells_rounded_box(ncp, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl));
CHECK(0 == ncplane_box(ncp, &ul, &ur, &ll, &lr, &hl, &vl, y + 1, x + 1, 0));
@ -736,7 +736,7 @@ TEST_CASE("NCPlane") {
cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
int y, x;
ncplane_yx(n_, &y, &x);
struct ncplane* ncp = notcurses_newplane(nc_, 2, 2, y, x, nullptr);
struct ncplane* ncp = ncplane_new(nc_, 2, 2, y, x, nullptr);
REQUIRE(ncp);
REQUIRE(0 == cells_rounded_box(ncp, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl));
CHECK(0 == ncplane_box(ncp, &ul, &ur, &ll, &lr, &hl, &vl, y + 1, x + 1, 0));

@ -79,7 +79,7 @@ TEST_CASE("NotcursesBase") {
for(int y = 0 ; y < maxy ; ++y){
for(int x = 0 ; x < maxx ; ++x){
const auto idx = y * maxx + x;
planes[idx] = notcurses_newplane(nc_, 1, 1, y, x, &planesecrets[idx]);
planes[idx] = ncplane_new(nc_, 1, 1, y, x, &planesecrets[idx]);
REQUIRE(planes[idx]);
}
}

@ -34,7 +34,7 @@ TEST_CASE("ZAxisTest") {
// you can't place a plane above or below itself, stdplane or otherwise
SUBCASE("NoMoveSelf") {
struct ncplane* np = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* np = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(np);
CHECK(ncplane_move_below(n_, n_));
CHECK(ncplane_move_above(n_, n_));
@ -44,7 +44,7 @@ TEST_CASE("ZAxisTest") {
// new planes ought be on the top
SUBCASE("NewPlaneOnTop") {
struct ncplane* np = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* np = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(np);
struct ncplane* top = notcurses_top(nc_);
CHECK(np == top);
@ -54,7 +54,7 @@ TEST_CASE("ZAxisTest") {
// "move" top plane to top. everything ought remain the same.
SUBCASE("TopToTop") {
struct ncplane* np = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* np = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(np);
struct ncplane* top = notcurses_top(nc_);
CHECK(np == top);
@ -70,7 +70,7 @@ TEST_CASE("ZAxisTest") {
// move top plane to bottom, and verify enumeration
SUBCASE("TopToBottom") {
struct ncplane* np = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* np = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(np);
struct ncplane* top = notcurses_top(nc_);
CHECK(np == top);
@ -95,7 +95,7 @@ TEST_CASE("ZAxisTest") {
REQUIRE(1 == ncplane_at_cursor(n_, &cat));
REQUIRE(cell_simple_p(&cat));
REQUIRE('x' == cat.gcluster);
struct ncplane* n2 = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* n2 = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(1 == cell_load(n2, &c, "y"));
REQUIRE(!cell_set_fg_rgb(&c, 0, 0xff, 0));
REQUIRE(1 == ncplane_putc(n2, &c));
@ -103,7 +103,7 @@ TEST_CASE("ZAxisTest") {
REQUIRE(!ncplane_cursor_move_yx(n2, 0, 0));
REQUIRE(1 == ncplane_at_cursor(n2, &cat));
REQUIRE('y' == cat.gcluster);
struct ncplane* n3 = notcurses_newplane(nc_, 2, 2, 0, 0, nullptr);
struct ncplane* n3 = ncplane_new(nc_, 2, 2, 0, 0, nullptr);
REQUIRE(1 == cell_load(n3, &c, "z"));
REQUIRE(!cell_set_fg_rgb(&c, 0, 0, 0xff));
REQUIRE(1 == ncplane_putc(n3, &c));

Loading…
Cancel
Save