ncplane_box: accept ctlword (#42)

This commit is contained in:
nick black 2019-12-04 00:46:38 -05:00 committed by Nick Black
parent eb53f420b1
commit a55e02836b
11 changed files with 91 additions and 72 deletions

View File

@ -331,9 +331,31 @@ API int ncplane_vline(struct ncplane* n, const cell* c, int len);
// Draw a box with its upper-left corner at the current cursor position, and its // Draw a box with its upper-left corner at the current cursor position, and its
// lower-right corner at 'ystop'x'xstop'. The 6 cells provided are used to draw the // lower-right corner at 'ystop'x'xstop'. The 6 cells provided are used to draw the
// upper-left, ur, ll, and lr corners, then the horizontal and vertical lines. // upper-left, ur, ll, and lr corners, then the horizontal and vertical lines.
// 'ctlword' is defined in the least significant byte, where bits [7, 4] are a
// gradient mask, and [3, 0] are a border mask:
// * 7, 3: top
// * 6, 2: right
// * 5, 1: bottom
// * 4, 0: left
// if the gradient bit is not set, the styling from the hl/vl cells is used for
// the horizontal and vertical lines, respectively. if the gradient bit is set,
// the color is linearly interpolated between the two relevant corner cells. if
// the bordermask bit is set, that side of the box is not drawn. iff either edge
// connecting to a corner is drawn, the corner is drawn.
#define NCBOXMASK_TOP 0x01
#define NCBOXMASK_RIGHT 0x02
#define NCBOXMASK_BOTTOM 0x04
#define NCBOXMASK_LEFT 0x08
#define NCBOXGRAD_TOP 0x10
#define NCBOXGRAD_RIGHT 0x20
#define NCBOXGRAD_BOTTOM 0x40
#define NCBOXGRAD_LEFT 0x80
API int ncplane_box(struct ncplane* n, const cell* ul, const cell* ur, API int ncplane_box(struct ncplane* n, const cell* ul, const cell* ur,
const cell* ll, const cell* lr, const cell* hline, const cell* ll, const cell* lr, const cell* hline,
const cell* vline, int ystop, int xstop); const cell* vline, int ystop, int xstop,
unsigned ctlword);
// Draw a box with its upper-left corner at the current cursor position, having // Draw a box with its upper-left corner at the current cursor position, having
// dimensions 'ylen'x'xlen'. See ncplane_box() for more information. The // dimensions 'ylen'x'xlen'. See ncplane_box() for more information. The
@ -341,10 +363,11 @@ API int ncplane_box(struct ncplane* n, const cell* ul, const cell* ur,
static inline int static inline int
ncplane_box_sized(struct ncplane* n, const cell* ul, const cell* ur, ncplane_box_sized(struct ncplane* n, const cell* ul, const cell* ur,
const cell* ll, const cell* lr, const cell* hline, const cell* ll, const cell* lr, const cell* hline,
const cell* vline, int ylen, int xlen){ const cell* vline, int ylen, int xlen, unsigned ctlword){
int y, x; int y, x;
ncplane_cursor_yx(n, &y, &x); ncplane_cursor_yx(n, &y, &x);
return ncplane_box(n, ul, ur, ll, lr, hline, vline, y + ylen - 1, x + xlen - 1); return ncplane_box(n, ul, ur, ll, lr, hline, vline, y + ylen - 1,
x + xlen - 1, ctlword);
} }
// Erase every cell in the ncplane, resetting all attributes to normal, all // Erase every cell in the ncplane, resetting all attributes to normal, all
@ -663,13 +686,13 @@ cells_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
static inline int static inline int
ncplane_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels, ncplane_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
int ystop, int xstop){ int ystop, int xstop, unsigned ctlword){
int ret = 0; int ret = 0;
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER; cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER; cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER; cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
if((ret = cells_rounded_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){ if((ret = cells_rounded_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){
ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop); ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
} }
cell_release(n, &ul); cell_release(n, &ul);
cell_release(n, &ur); cell_release(n, &ur);
@ -682,10 +705,11 @@ ncplane_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
static inline int static inline int
ncplane_rounded_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels, ncplane_rounded_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
int ylen, int xlen){ int ylen, int xlen, unsigned ctlword){
int y, x; int y, x;
ncplane_cursor_yx(n, &y, &x); ncplane_cursor_yx(n, &y, &x);
return ncplane_rounded_box(n, attr, channels, y + ylen - 1, x + xlen - 1); return ncplane_rounded_box(n, attr, channels, y + ylen - 1,
x + xlen - 1, ctlword);
} }
static inline int static inline int
@ -696,13 +720,13 @@ cells_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
static inline int static inline int
ncplane_double_box(struct ncplane* n, uint32_t attr, uint64_t channels, ncplane_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
int ystop, int xstop){ int ystop, int xstop, unsigned ctlword){
int ret = 0; int ret = 0;
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER; cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER; cell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER; cell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
if((ret = cells_double_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){ if((ret = cells_double_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){
ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop); ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
} }
cell_release(n, &ul); cell_release(n, &ul);
cell_release(n, &ur); cell_release(n, &ur);
@ -715,10 +739,11 @@ ncplane_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
static inline int static inline int
ncplane_double_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels, ncplane_double_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
int ylen, int xlen){ int ylen, int xlen, unsigned ctlword){
int y, x; int y, x;
ncplane_cursor_yx(n, &y, &x); ncplane_cursor_yx(n, &y, &x);
return ncplane_double_box(n, attr, channels, y + ylen - 1, x + xlen - 1); return ncplane_double_box(n, attr, channels, y + ylen - 1,
x + xlen - 1, ctlword);
} }
// multimedia functionality // multimedia functionality
@ -757,13 +782,6 @@ API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, int* averr);
// This structure is amenable to line- and page-based navigation via keystrokes, // This structure is amenable to line- and page-based navigation via keystrokes,
// scrolling gestures, trackballs, scrollwheels, touchpads, and verbal commands. // scrolling gestures, trackballs, scrollwheels, touchpads, and verbal commands.
enum bordermaskbits {
BORDERMASK_TOP = 0x1,
BORDERMASK_RIGHT = 0x2,
BORDERMASK_BOTTOM = 0x4,
BORDERMASK_LEFT = 0x8,
};
typedef struct panelreel_options { typedef struct panelreel_options {
// require this many rows and columns (including borders). otherwise, a // require this many rows and columns (including borders). otherwise, a
// message will be displayed stating that a larger terminal is necessary, and // message will be displayed stating that a larger terminal is necessary, and

View File

@ -32,7 +32,7 @@ int box_demo(struct notcurses* nc){
if(ncplane_cursor_move_yx(n, y, x)){ if(ncplane_cursor_move_yx(n, y, x)){
return -1; return -1;
} }
if(ncplane_box_sized(n, &ul, &ur, &ll, &lr, &hl, &vl, ylen, xlen)){ if(ncplane_box_sized(n, &ul, &ur, &ll, &lr, &hl, &vl, ylen, xlen, 0)){
return -1; return -1;
} }
ylen -= 2; ylen -= 2;

View File

@ -142,7 +142,7 @@ intro(struct notcurses* nc){
if(ncplane_cursor_move_yx(ncp, 4, 4)){ if(ncplane_cursor_move_yx(ncp, 4, 4)){
return -1; return -1;
} }
if(ncplane_rounded_box(ncp, 0, channels, rows - 6, cols - 6)){ if(ncplane_rounded_box(ncp, 0, channels, rows - 6, cols - 6, 0)){
return -1; return -1;
} }
const char s1[] = " Die Welt ist alles, was der Fall ist. "; const char s1[] = " Die Welt ist alles, was der Fall ist. ";

View File

@ -38,7 +38,7 @@ int maxcolor_demo(struct notcurses* nc){
notcurses_bg_prep(&channels, 90, 0, 90); notcurses_bg_prep(&channels, 90, 0, 90);
int y = 0, x = 0; int y = 0, x = 0;
ncplane_cursor_move_yx(n, y, x); ncplane_cursor_move_yx(n, y, x);
if(ncplane_rounded_box_sized(n, 0, channels, maxy, maxx)){ if(ncplane_rounded_box_sized(n, 0, channels, maxy, maxx, 0)){
return -1; return -1;
} }
uint32_t rgb = 0; uint32_t rgb = 0;

View File

@ -102,7 +102,7 @@ fill_chunk(struct ncplane* n, int idx){
uint64_t channels = 0; uint64_t channels = 0;
int r = random() % 256, g = random() % 256, b = random() % 256; int r = random() % 256, g = random() % 256, b = random() % 256;
notcurses_fg_prep(&channels, r, g, b); notcurses_fg_prep(&channels, r, g, b);
if(ncplane_double_box(n, 0, channels, maxy - 1, maxx - 1)){ if(ncplane_double_box(n, 0, channels, maxy - 1, maxx - 1, 0)){
return -1; return -1;
} }
if(maxx >= 5 && maxy >= 3){ if(maxx >= 5 && maxy >= 3){
@ -131,7 +131,7 @@ draw_bounding_box(struct ncplane* n, int yoff, int xoff, int chunky, int chunkx)
ncplane_cursor_move_yx(n, yoff, xoff); ncplane_cursor_move_yx(n, yoff, xoff);
ret = ncplane_rounded_box(n, 0, channels, ret = ncplane_rounded_box(n, 0, channels,
CHUNKS_VERT * chunky + yoff + 1, CHUNKS_VERT * chunky + yoff + 1,
CHUNKS_HORZ * chunkx + xoff + 1); CHUNKS_HORZ * chunkx + xoff + 1, 0);
return ret; return ret;
} }

View File

@ -109,7 +109,7 @@ int unicodeblocks_demo(struct notcurses* nc){
return -1; return -1;
} }
++xstart; ++xstart;
if(ncplane_rounded_box_sized(n, 0, 0, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2)){ if(ncplane_rounded_box_sized(n, 0, 0, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 0)){
return -1; return -1;
} }
for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){ for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){

View File

@ -13,7 +13,7 @@ message(struct ncplane* n, int maxy, int maxx, int num, int total){
ncplane_fg_rgb8(n, 0, 0, 0); ncplane_fg_rgb8(n, 0, 0, 0);
ncplane_bg_rgb8(n, 255, 255, 255); ncplane_bg_rgb8(n, 255, 255, 255);
ncplane_styles_on(n, CELL_STYLE_BOLD); ncplane_styles_on(n, CELL_STYLE_BOLD);
if(ncplane_rounded_box(n, 0, 0, 5, 57)){ if(ncplane_rounded_box(n, 0, 0, 5, 57, 0)){
return -1; return -1;
} }
ncplane_cursor_move_yx(n, 3, 4); ncplane_cursor_move_yx(n, 3, 4);

View File

@ -1436,7 +1436,8 @@ int ncplane_vline(ncplane* n, const cell* c, int len){
int ncplane_box(ncplane* n, const cell* ul, const cell* ur, int ncplane_box(ncplane* n, const cell* ul, const cell* ur,
const cell* ll, const cell* lr, const cell* hl, const cell* ll, const cell* lr, const cell* hl,
const cell* vl, int ystop, int xstop){ const cell* vl, int ystop, int xstop,
unsigned ctlword){
int yoff, xoff, ymax, xmax; int yoff, xoff, ymax, xmax;
ncplane_cursor_yx(n, &yoff, &xoff); ncplane_cursor_yx(n, &yoff, &xoff);
if(ystop < yoff + 1){ if(ystop < yoff + 1){

View File

@ -81,17 +81,17 @@ draw_borders(ncplane* w, unsigned nobordermask, const cell* attr,
if(!cliphead){ if(!cliphead){
// lenx - begx + 1 is the number of columns we have, but drop 2 due to // lenx - begx + 1 is the number of columns we have, but drop 2 due to
// corners. we thus want lenx - begx - 1 horizontal lines. // corners. we thus want lenx - begx - 1 horizontal lines.
if(!(nobordermask & BORDERMASK_TOP)){ if(!(nobordermask & NCBOXMASK_TOP)){
ret |= ncplane_cursor_move_yx(w, begy, begx); ret |= ncplane_cursor_move_yx(w, begy, begx);
ncplane_putc(w, &ul); ncplane_putc(w, &ul);
ncplane_hline(w, &hl, lenx - 2); ncplane_hline(w, &hl, lenx - 2);
ncplane_putc(w, &ur); ncplane_putc(w, &ur);
}else{ }else{
if(!(nobordermask & BORDERMASK_LEFT)){ if(!(nobordermask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(w, begy, begx); ret |= ncplane_cursor_move_yx(w, begy, begx);
ncplane_putc(w, &ul); ncplane_putc(w, &ul);
} }
if(!(nobordermask & BORDERMASK_RIGHT)){ if(!(nobordermask & NCBOXMASK_RIGHT)){
ret |= ncplane_cursor_move_yx(w, begy, maxx); ret |= ncplane_cursor_move_yx(w, begy, maxx);
ncplane_putc(w, &ur); ncplane_putc(w, &ur);
} }
@ -99,27 +99,27 @@ draw_borders(ncplane* w, unsigned nobordermask, const cell* attr,
} }
int y; int y;
for(y = begy + !cliphead ; y < maxy + !!clipfoot ; ++y){ for(y = begy + !cliphead ; y < maxy + !!clipfoot ; ++y){
if(!(nobordermask & BORDERMASK_LEFT)){ if(!(nobordermask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(w, y, begx); ret |= ncplane_cursor_move_yx(w, y, begx);
ncplane_putc(w, &vl); ncplane_putc(w, &vl);
} }
if(!(nobordermask & BORDERMASK_RIGHT)){ if(!(nobordermask & NCBOXMASK_RIGHT)){
ret |= ncplane_cursor_move_yx(w, y, maxx); ret |= ncplane_cursor_move_yx(w, y, maxx);
ncplane_putc(w, &vl); ncplane_putc(w, &vl);
} }
} }
if(!clipfoot){ if(!clipfoot){
if(!(nobordermask & BORDERMASK_BOTTOM)){ if(!(nobordermask & NCBOXMASK_BOTTOM)){
ret |= ncplane_cursor_move_yx(w, maxy, begx); ret |= ncplane_cursor_move_yx(w, maxy, begx);
ncplane_putc(w, &ll); ncplane_putc(w, &ll);
ncplane_hline(w, &hl, lenx - 2); ncplane_hline(w, &hl, lenx - 2);
ncplane_putc(w, &lr); ncplane_putc(w, &lr);
}else{ }else{
if(!(nobordermask & BORDERMASK_LEFT)){ if(!(nobordermask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(w, maxy, begx); ret |= ncplane_cursor_move_yx(w, maxy, begx);
ret |= ncplane_putc(w, &ll); ret |= ncplane_putc(w, &ll);
} }
if(!(nobordermask & BORDERMASK_RIGHT)){ if(!(nobordermask & NCBOXMASK_RIGHT)){
// mvwadd_wch returns error if we print to the lowermost+rightmost // mvwadd_wch returns error if we print to the lowermost+rightmost
// character cell. maybe we can make this go away with scrolling controls // character cell. maybe we can make this go away with scrolling controls
// at setup? until then, don't check for error here FIXME. // at setup? until then, don't check for error here FIXME.
@ -164,9 +164,9 @@ tablet_columns(const panelreel* pr, int* begx, int* begy, int* lenx, int* leny,
int frontiery, int direction){ int frontiery, int direction){
window_coordinates(pr->p, begy, begx, leny, lenx); window_coordinates(pr->p, begy, begx, leny, lenx);
int maxy = *leny + *begy - 1; int maxy = *leny + *begy - 1;
int begindraw = *begy + !(pr->popts.bordermask & BORDERMASK_TOP); int begindraw = *begy + !(pr->popts.bordermask & NCBOXMASK_TOP);
// FIXME i think this fails to account for an absent panelreel bottom? // FIXME i think this fails to account for an absent panelreel bottom?
int enddraw = maxy - !(pr->popts.bordermask & BORDERMASK_TOP); int enddraw = maxy - !(pr->popts.bordermask & NCBOXMASK_TOP);
if(direction){ if(direction){
if(frontiery < begindraw){ if(frontiery < begindraw){
return -1; return -1;
@ -177,18 +177,18 @@ tablet_columns(const panelreel* pr, int* begx, int* begy, int* lenx, int* leny,
} }
} }
// account for the panelreel borders // account for the panelreel borders
if(direction <= 0 && !(pr->popts.bordermask & BORDERMASK_TOP)){ if(direction <= 0 && !(pr->popts.bordermask & NCBOXMASK_TOP)){
++*begy; ++*begy;
--*leny; --*leny;
} }
if(direction >= 0 && !(pr->popts.bordermask & BORDERMASK_BOTTOM)){ if(direction >= 0 && !(pr->popts.bordermask & NCBOXMASK_BOTTOM)){
--*leny; --*leny;
} }
if(!(pr->popts.bordermask & BORDERMASK_LEFT)){ if(!(pr->popts.bordermask & NCBOXMASK_LEFT)){
++*begx; ++*begx;
--*lenx; --*lenx;
} }
if(!(pr->popts.bordermask & BORDERMASK_RIGHT)){ if(!(pr->popts.bordermask & NCBOXMASK_RIGHT)){
--*lenx; --*lenx;
} }
// at this point, our coordinates describe the largest possible tablet for // at this point, our coordinates describe the largest possible tablet for
@ -265,16 +265,16 @@ panelreel_draw_tablet(const panelreel* pr, tablet* t, int frontiery,
--cbmaxy; --cbmaxy;
--cbmaxx; --cbmaxx;
// If we're drawing up, we'll always have a bottom border unless it's masked // If we're drawing up, we'll always have a bottom border unless it's masked
if(direction < 0 && !(pr->popts.tabletmask & BORDERMASK_BOTTOM)){ if(direction < 0 && !(pr->popts.tabletmask & NCBOXMASK_BOTTOM)){
--cbmaxy; --cbmaxy;
} }
// If we're drawing down, we'll always have a top border unless it's masked // If we're drawing down, we'll always have a top border unless it's masked
if(direction >= 0 && !(pr->popts.tabletmask & BORDERMASK_TOP)){ if(direction >= 0 && !(pr->popts.tabletmask & NCBOXMASK_TOP)){
++cby; ++cby;
} }
// Adjust the x-bounds for side borders, which we always have if unmasked // Adjust the x-bounds for side borders, which we always have if unmasked
cbmaxx -= !(pr->popts.tabletmask & BORDERMASK_RIGHT); cbmaxx -= !(pr->popts.tabletmask & NCBOXMASK_RIGHT);
cbx += !(pr->popts.tabletmask & BORDERMASK_LEFT); cbx += !(pr->popts.tabletmask & NCBOXMASK_LEFT);
bool cbdir = direction < 0 ? true : false; bool cbdir = direction < 0 ? true : false;
// fprintf(stderr, "calling! lenx/leny: %d/%d cbx/cby: %d/%d cbmaxx/cbmaxy: %d/%d dir: %d\n", // fprintf(stderr, "calling! lenx/leny: %d/%d cbx/cby: %d/%d cbmaxx/cbmaxy: %d/%d dir: %d\n",
// lenx, leny, cbx, cby, cbmaxx, cbmaxy, direction); // lenx, leny, cbx, cby, cbmaxx, cbmaxy, direction);
@ -331,9 +331,9 @@ draw_focused_tablet(const panelreel* pr){
int fulcrum; int fulcrum;
if(pr->tablets->p == NULL){ if(pr->tablets->p == NULL){
if(pr->last_traveled_direction >= 0){ if(pr->last_traveled_direction >= 0){
fulcrum = pleny + pbegy - !(pr->popts.bordermask & BORDERMASK_BOTTOM); fulcrum = pleny + pbegy - !(pr->popts.bordermask & NCBOXMASK_BOTTOM);
}else{ }else{
fulcrum = pbegy + !(pr->popts.bordermask & BORDERMASK_TOP); fulcrum = pbegy + !(pr->popts.bordermask & NCBOXMASK_TOP);
} }
}else{ // focused was already present. want to stay where we are, if possible }else{ // focused was already present. want to stay where we are, if possible
int dontcarex; int dontcarex;
@ -344,7 +344,7 @@ draw_focused_tablet(const panelreel* pr){
int prevfulcrum; int prevfulcrum;
ncplane_yx(pr->tablets->prev->p, &prevfulcrum, &dontcarex); ncplane_yx(pr->tablets->prev->p, &prevfulcrum, &dontcarex);
if(fulcrum < prevfulcrum){ if(fulcrum < prevfulcrum){
fulcrum = pleny + pbegy - !(pr->popts.bordermask & BORDERMASK_BOTTOM); fulcrum = pleny + pbegy - !(pr->popts.bordermask & NCBOXMASK_BOTTOM);
} }
} }
}else if(pr->last_traveled_direction < 0){ }else if(pr->last_traveled_direction < 0){
@ -352,7 +352,7 @@ draw_focused_tablet(const panelreel* pr){
int nextfulcrum; int nextfulcrum;
ncplane_yx(pr->tablets->next->p, &nextfulcrum, &dontcarex); ncplane_yx(pr->tablets->next->p, &nextfulcrum, &dontcarex);
if(fulcrum > nextfulcrum){ if(fulcrum > nextfulcrum){
fulcrum = pbegy + !(pr->popts.bordermask & BORDERMASK_TOP); fulcrum = pbegy + !(pr->popts.bordermask & NCBOXMASK_TOP);
} }
} }
} }
@ -452,7 +452,7 @@ panelreel_arrange_denormalized(panelreel* pr){
tablet* topmost = find_topmost(pr); tablet* topmost = find_topmost(pr);
int wbegy, wbegx, wleny, wlenx; int wbegy, wbegx, wleny, wlenx;
window_coordinates(pr->p, &wbegy, &wbegx, &wleny, &wlenx); window_coordinates(pr->p, &wbegy, &wbegx, &wleny, &wlenx);
int frontiery = wbegy + !(pr->popts.bordermask & BORDERMASK_TOP); int frontiery = wbegy + !(pr->popts.bordermask & NCBOXMASK_TOP);
if(pr->last_traveled_direction >= 0){ if(pr->last_traveled_direction >= 0){
ncplane_yx(pr->tablets->prev->p, &fromline, NULL); ncplane_yx(pr->tablets->prev->p, &fromline, NULL);
if(fromline > nowline){ // keep the order we had if(fromline > nowline){ // keep the order we had
@ -538,10 +538,10 @@ validate_panelreel_opts(ncplane* w, const panelreel_options* popts){
return false; // can't set circular without infinitescroll return false; // can't set circular without infinitescroll
} }
} }
const unsigned fullmask = BORDERMASK_LEFT | const unsigned fullmask = NCBOXMASK_LEFT |
BORDERMASK_RIGHT | NCBOXMASK_RIGHT |
BORDERMASK_TOP | NCBOXMASK_TOP |
BORDERMASK_BOTTOM; NCBOXMASK_BOTTOM;
if(popts->bordermask > fullmask){ if(popts->bordermask > fullmask){
return false; return false;
} }
@ -617,7 +617,7 @@ insert_new_panel(struct notcurses* nc, panelreel* pr, tablet* t){
// are we the only tablet? // are we the only tablet?
int begx, begy, lenx, leny, frontiery; int begx, begy, lenx, leny, frontiery;
if(t->prev == t){ if(t->prev == t){
frontiery = wbegy + !(pr->popts.bordermask & BORDERMASK_TOP); frontiery = wbegy + !(pr->popts.bordermask & NCBOXMASK_TOP);
if(tablet_columns(pr, &begx, &begy, &lenx, &leny, frontiery, 1)){ if(tablet_columns(pr, &begx, &begy, &lenx, &leny, frontiery, 1)){
pr->all_visible = false; pr->all_visible = false;
return t; return t;

View File

@ -176,17 +176,17 @@ TEST_F(NcplaneTest, BadlyPlacedBoxen) {
ASSERT_LT(2, x); ASSERT_LT(2, x);
cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{}; cell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
ASSERT_EQ(0, cells_rounded_box(n_, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl)); ASSERT_EQ(0, cells_rounded_box(n_, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y + 1, x + 1)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y + 1, x + 1, 0));
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 1, 0)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 1, 0));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y, x)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y, x, 0));
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 0, 1)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 0, 1));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y, x)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, y, x, 0));
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 1, x - 1)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 1, x - 1));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2, 0));
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 2, x - 1)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 2, x - 1));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2, 0));
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 1, x - 2)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, y - 1, x - 2));
EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2)); EXPECT_GT(0, ncplane_box(n_, &ul, &ur, &ll, &lr, &hl, &vl, 2, 2, 0));
EXPECT_EQ(0, notcurses_render(nc_)); EXPECT_EQ(0, notcurses_render(nc_));
} }
@ -196,7 +196,7 @@ TEST_F(NcplaneTest, PerimeterRoundedBox) {
ASSERT_LT(2, y); ASSERT_LT(2, y);
ASSERT_LT(2, x); ASSERT_LT(2, x);
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0)); ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));
EXPECT_EQ(0, ncplane_rounded_box(n_, 0, 0, y - 1, x - 1)); EXPECT_EQ(0, ncplane_rounded_box(n_, 0, 0, y - 1, x - 1, 0));
EXPECT_EQ(0, notcurses_render(nc_)); EXPECT_EQ(0, notcurses_render(nc_));
} }
@ -206,7 +206,7 @@ TEST_F(NcplaneTest, PerimeterRoundedBoxSized) {
ASSERT_LT(2, y); ASSERT_LT(2, y);
ASSERT_LT(2, x); ASSERT_LT(2, x);
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0)); ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));
EXPECT_EQ(0, ncplane_rounded_box_sized(n_, 0, 0, y, x)); EXPECT_EQ(0, ncplane_rounded_box_sized(n_, 0, 0, y, x, 0));
EXPECT_EQ(0, notcurses_render(nc_)); EXPECT_EQ(0, notcurses_render(nc_));
} }
@ -216,7 +216,7 @@ TEST_F(NcplaneTest, PerimeterDoubleBox) {
ASSERT_LT(2, y); ASSERT_LT(2, y);
ASSERT_LT(2, x); ASSERT_LT(2, x);
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0)); ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));
EXPECT_EQ(0, ncplane_double_box(n_, 0, 0, y - 1, x - 1)); EXPECT_EQ(0, ncplane_double_box(n_, 0, 0, y - 1, x - 1, 0));
EXPECT_EQ(0, notcurses_render(nc_)); EXPECT_EQ(0, notcurses_render(nc_));
} }
@ -226,7 +226,7 @@ TEST_F(NcplaneTest, PerimeterDoubleBoxSized) {
ASSERT_LT(2, y); ASSERT_LT(2, y);
ASSERT_LT(2, x); ASSERT_LT(2, x);
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0)); ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));
EXPECT_EQ(0, ncplane_double_box_sized(n_, 0, 0, y, x)); EXPECT_EQ(0, ncplane_double_box_sized(n_, 0, 0, y, x, 0));
EXPECT_EQ(0, notcurses_render(nc_)); EXPECT_EQ(0, notcurses_render(nc_));
} }

View File

@ -126,30 +126,30 @@ TEST_F(PanelReelTest, DeleteActiveTablet) {
TEST_F(PanelReelTest, NoBorder) { TEST_F(PanelReelTest, NoBorder) {
panelreel_options p{}; panelreel_options p{};
p.bordermask = BORDERMASK_LEFT | BORDERMASK_RIGHT | p.bordermask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT |
BORDERMASK_TOP | BORDERMASK_BOTTOM; NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
struct panelreel* pr = panelreel_create(n_, &p, -1); struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_NE(nullptr, pr); ASSERT_NE(nullptr, pr);
} }
TEST_F(PanelReelTest, BadBorderBitsRejected) { TEST_F(PanelReelTest, BadBorderBitsRejected) {
panelreel_options p{}; panelreel_options p{};
p.bordermask = BORDERMASK_LEFT * 2; p.bordermask = NCBOXMASK_LEFT * 2;
struct panelreel* pr = panelreel_create(n_, &p, -1); struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_EQ(nullptr, pr); ASSERT_EQ(nullptr, pr);
} }
TEST_F(PanelReelTest, NoTabletBorder) { TEST_F(PanelReelTest, NoTabletBorder) {
panelreel_options p{}; panelreel_options p{};
p.tabletmask = BORDERMASK_LEFT | BORDERMASK_RIGHT | p.tabletmask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT |
BORDERMASK_TOP | BORDERMASK_BOTTOM; NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
struct panelreel* pr = panelreel_create(n_, &p, -1); struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_NE(nullptr, pr); ASSERT_NE(nullptr, pr);
} }
TEST_F(PanelReelTest, BadTabletBorderBitsRejected) { TEST_F(PanelReelTest, BadTabletBorderBitsRejected) {
panelreel_options p{}; panelreel_options p{};
p.tabletmask = BORDERMASK_LEFT * 2; p.tabletmask = NCBOXMASK_LEFT * 2;
struct panelreel* pr = panelreel_create(n_, &p, -1); struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_EQ(nullptr, pr); ASSERT_EQ(nullptr, pr);
} }
@ -201,8 +201,8 @@ TEST_F(PanelReelTest, SubwinNoPanelreelBorders) {
p.roff = 1; p.roff = 1;
p.toff = 1; p.toff = 1;
p.boff = 1; p.boff = 1;
p.bordermask = BORDERMASK_LEFT | BORDERMASK_RIGHT | p.bordermask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT |
BORDERMASK_TOP | BORDERMASK_BOTTOM; NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
EXPECT_EQ(0, clear()); EXPECT_EQ(0, clear());
PANEL* base = make_targwin(n_); PANEL* base = make_targwin(n_);
ASSERT_NE(nullptr, base); ASSERT_NE(nullptr, base);