122 nccell_init(&
ul); nccell_init(&
ur); nccell_init(&hl);
123 nccell_init(&
ll); nccell_init(&
lr); nccell_init(&vl);
124 if(nccells_rounded_box(
n, 0, channel, &
ul, &
ur, &
ll, &
lr, &hl, &vl)){
134 ncplane_putc(
n, &
ul);
135 ncplane_hline(
n, &hl, lenx - 2);
136 ncplane_putc(
n, &
ur);
145 while(
y <= maxhorizy){
148 ncplane_putc(
n, &vl);
152 ncplane_putc(
n, &vl);
159 ncplane_putc(
n, &
ll);
160 ncplane_hline(
n, &hl, lenx - 2);
161 ncplane_putc(
n, &
lr);
172draw_ncreel_borders(
const ncreel* nr){
184 int* lenx,
int* leny,
int frontiertop,
int frontierbottom,
189 unsigned uleny, ulenx;
199 if(frontierbottom >= *leny){
203 frontierbottom = *leny - 1;
224 *leny -= (frontierbottom - (frontiertop + 1));
226 *begy = frontierbottom;
228 *begy = frontiertop - *leny;
231 if(*leny <= 0 || *lenx <= 0){
241 if(ncplane_set_widget(t->
p,
NULL,
NULL) == 0){
263 nctablet_wipeout(vft);
274nctablet_delete_internal(
struct nctablet* t){
278 if(ncplane_set_widget(t->
p,
NULL,
NULL) == 0){
299 nctablet_delete_internal(t);
319 int lenx, leny, begy, begx;
320 if(tablet_geom(nr, t, &begx, &begy, &lenx, &leny, frontiertop, frontierbottom, direction)){
333 if((t->
p = fp) ==
NULL){
337 ncplane_set_widget(t->
p, t, (
void(*)(
void*))nctablet_delete_internal);
340 int cby = 0, cbx = 0, cbleny = leny, cblenx = lenx;
352 if(cbleny - cby + 1 > 0){
373 logwarn(
"tablet callback returned %d lines, %d allowed",
ll, cbleny);
377 int diff = cbleny -
ll;
380 ncplane_resize_simple(t->
cbp,
ll, cblenx);
387 ncplane_resize_simple(t->
p, leny - diff + 1, lenx);
389 ncplane_resize_simple(t->
p, leny - diff, lenx);
396 if(leny - frontiertop + 1 <
ll){
398 frontiertop += (leny -
ll);
416 draw_borders(fp, mask, channels, direction);
424 int frontiertop,
int* frontierbottom){
428 const int maxx = ncplane_dim_y(nr->
p) - 1 - botborder;
430 while(*frontierbottom <= maxx && (working != otherend || !otherend->
p)){
437 if(ncreel_draw_tablet(nr, working, frontiertop, *frontierbottom,
DIRECTION_DOWN)){
440 if(working == otherend){
441 otherend = otherend->
next;
443 *frontierbottom += ncplane_dim_y(working->
p) + 1;
444 working = working->
next;
454 int* frontiertop,
int frontierbottom){
459 while(*frontiertop >= topborder && (upworking != otherend || !otherend->
p)){
464 if(ncreel_draw_tablet(nr, upworking, *frontiertop, frontierbottom,
DIRECTION_UP)){
467 if(upworking == otherend){
468 otherend = otherend->
prev;
470 *frontiertop -= ncplane_dim_y(upworking->
p) + 1;
471 upworking = upworking->
prev;
482 if(!top || !top->
p || !bottom || !bottom->
p){
490 int boty =
y +
ylen - 1;
498 return trim_reel_overhang(
r, top, bottom);
500 int ynew =
ylen - (miny -
y);
529 const int maxy = ncplane_dim_y(
r->p) - (1 + !(
r->ropts.bordermask &
NCBOXMASK_BOTTOM));
534 if(ncplane_set_widget(bottom->
p,
NULL,
NULL) == 0){
539 bottom = bottom->
prev;
540 return trim_reel_overhang(
r, top, bottom);
542 int ynew =
ylen - (boty - maxy);
572tighten_reel_down(
ncreel*
r,
int ybot){
582 if(cury <= ybot - (
int)
ylen - 1){
586 cury = ybot - (int)
ylen;
589 if((cur = cur->
prev) ==
r->tablets){
631 if(cury != expected){
639 expected +=
ylen + 1;
651 unsigned ylen, rylen;
658 if(yoff + (
int)
ylen + 1 >= ybot){
659 if(tighten_reel_down(
r, ybot)){
667 return trim_reel_overhang(
r, top, bottom);
685 if(!focused || !focused->
p || !nr->
vft){
704 if(!focused || !focused->
p || !nr->
vft){
705 fulcrum = ncplane_dim_y(nr->
p) - 1;
713 fulcrum = ncplane_dim_y(nr->
p) - 1;
724 if(ncreel_draw_tablet(nr, focused, fulcrum, fulcrum,
DIRECTION_DOWN)){
730 int frontiertop, frontierbottom;
732 frontierbottom = frontiertop + ncplane_dim_y(nr->
tablets->
p) + 1;
735 otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
736 if(otherend ==
NULL){
737 logerror(
"error drawing higher tablets");
740 otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
742 otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
743 if(otherend ==
NULL){
744 logerror(
"error drawing higher tablets");
747 otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
749 if(otherend ==
NULL){
750 logerror(
"error drawing following tablets");
754 if(tighten_reel(nr)){
762 if(draw_ncreel_borders(nr)){
763 logerror(
"error drawing reel borders");
775 logwarn(
"provided unsupported flags 0x%016" PRIx64, ropts->
flags);
779 logerror(
"can't set circular without infinitescroll");
813 if(!validate_ncreel_opts(
n, ropts)){
816 if((nr = malloc(
sizeof(*nr))) ==
NULL){
822 memcpy(&nr->
ropts, ropts,
sizeof(*ropts));
842 if(after->
next != before || before->
prev != after){
843 logerror(
"bad before (%p) / after (%p) spec", before, after);
846 }
else if(!after && !before){
853 if((t = malloc(
sizeof(*t))) ==
NULL){
882 if(ncplane_set_widget(nreel->
p,
NULL,
NULL) == 0){
API int API int API int uint64_t uint64_t uint64_t uint64_t lr
API int API int API int uint64_t uint64_t uint64_t ll
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned unsigned xlen
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned ylen
API int API int API int uint64_t ul
API int API int API int uint64_t uint64_t ur
#define logerror(fmt,...)
#define NCKEY_SCROLL_DOWN
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
void ncplane_home(ncplane *n)
int ncplane_destroy(ncplane *ncp)
int ncplane_move_yx(ncplane *n, int y, int x)
void ncplane_yx(const ncplane *n, int *y, int *x)
int ncplane_resize(ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
ncplane * ncplane_create(ncplane *n, const ncplane_options *nopts)
int ncplane_move_above(ncplane *restrict n, ncplane *restrict above)
int ncplane_family_destroy(ncplane *ncp)
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
int(* tabletcb)(struct nctablet *t, bool drawfromtop)
#define NCREEL_OPTION_CIRCULAR
#define NCREEL_OPTION_INFINITESCROLL
nctablet * ncreel_focused(ncreel *nr)
int ncreel_del(ncreel *nr, struct nctablet *t)
bool ncreel_offer_input(ncreel *n, const ncinput *nc)
ncplane * ncreel_plane(ncreel *nr)
void ncreel_destroy(ncreel *nreel)
int ncreel_redraw(ncreel *nr)
nctablet * ncreel_prev(ncreel *nr)
ncreel * ncreel_create(ncplane *n, const ncreel_options *ropts)
nctablet * ncreel_next(ncreel *nr)
void * nctablet_userptr(nctablet *t)
int ncreel_tabletcount(const ncreel *nreel)
nctablet * ncreel_add(ncreel *nr, nctablet *after, nctablet *before, tabletcb cbfxn, void *opaque)
ncplane * nctablet_plane(nctablet *t)
void nccell_release(ncplane *n, nccell *c)
enum ncreel::@1 direction