@ -346,16 +346,24 @@ draw_focused_tablet(const panelreel* pr){
int dontcarex ;
int dontcarex ;
ncplane_yx ( pr - > tablets - > p , & fulcrum , & dontcarex ) ;
ncplane_yx ( pr - > tablets - > p , & fulcrum , & dontcarex ) ;
// FIXME ugh can't we just remember the previous fulcrum?
// FIXME ugh can't we just remember the previous fulcrum?
if ( pr - > last_traveled_direction > 0 ) {
if ( pr - > tablets - > prev - > p ) {
int prevfulcrum ;
int prevfulcrum ;
ncplane_yx ( pr - > tablets - > prev - > p , & prevfulcrum , & dontcarex ) ;
ncplane_yx ( pr - > tablets - > prev - > p , & prevfulcrum , & dontcarex ) ;
if ( fulcrum < prevfulcrum ) {
fulcrum = pleny + pbegy - ! ( pr - > popts . bordermask & BORDERMASK_BOTTOM ) ;
}
}
} else if ( pr - > last_traveled_direction < 0 ) {
if ( pr - > tablets - > next - > p ) {
int nextfulcrum ;
int nextfulcrum ;
ncplane_yx ( pr - > tablets - > next - > p , & nextfulcrum , & dontcarex ) ;
ncplane_yx ( pr - > tablets - > next - > p , & nextfulcrum , & dontcarex ) ;
if ( pr - > last_traveled_direction > 0 & & fulcrum < prevfulcrum ) {
if ( fulcrum > nextfulcrum ) {
fulcrum = pleny + pbegy - ! ( pr - > popts . bordermask & BORDERMASK_BOTTOM ) ;
} else if ( pr - > last_traveled_direction < 0 & & fulcrum > nextfulcrum ) {
fulcrum = pbegy + ! ( pr - > popts . bordermask & BORDERMASK_TOP ) ;
fulcrum = pbegy + ! ( pr - > popts . bordermask & BORDERMASK_TOP ) ;
}
}
}
}
}
}
//fprintf(stderr, "PR dims: %d/%d + %d/%d fulcrum: %d\n", pbegy, pbegx, pleny, plenx, fulcrum);
//fprintf(stderr, "PR dims: %d/%d + %d/%d fulcrum: %d\n", pbegy, pbegx, pleny, plenx, fulcrum);
panelreel_draw_tablet ( pr , pr - > tablets , fulcrum , 0 ) ;
panelreel_draw_tablet ( pr , pr - > tablets , fulcrum , 0 ) ;
return 0 ;
return 0 ;
@ -393,14 +401,16 @@ draw_previous_tablets(const panelreel* pr, const tablet* otherend){
int frontiery ;
int frontiery ;
while ( upworking - > prev ! = otherend | | otherend - > p = = NULL ) {
while ( upworking - > prev ! = otherend | | otherend - > p = = NULL ) {
window_coordinates ( upworking - > p , & wbegy , & wbegx , & wleny , & wlenx ) ;
window_coordinates ( upworking - > p , & wbegy , & wbegx , & wleny , & wlenx ) ;
//fprintf(stderr, "MOVIN' ON UP: %d %d\n", frontiery, wbegy - 2);
frontiery = wbegy - 2 ;
frontiery = wbegy - 2 ;
//fprintf(stderr, "MOVIN' ON UP: %d %d\n", frontiery, wbegy - 2);
upworking = upworking - > prev ;
upworking = upworking - > prev ;
panelreel_draw_tablet ( pr , upworking , frontiery , - 1 ) ;
panelreel_draw_tablet ( pr , upworking , frontiery , - 1 ) ;
if ( upworking - > p ) {
if ( upworking - > p ) {
window_coordinates ( upworking - > p , & wbegy , & wbegx , & wleny , & wlenx ) ;
window_coordinates ( upworking - > p , & wbegy , & wbegx , & wleny , & wlenx ) ;
//fprintf(stderr, "new up coords: %d/%d + %d/%d, %d\n", wbegy, wbegx, wleny, wlenx, frontiery);
//fprintf(stderr, "new up coords: %d/%d + %d/%d, %d\n", wbegy, wbegx, wleny, wlenx, frontiery);
frontiery = wbegy - 2 ;
frontiery = wbegy - 2 ;
} else {
break ;
}
}
if ( upworking = = otherend ) {
if ( upworking = = otherend ) {
otherend = otherend - > prev ;
otherend = otherend - > prev ;
@ -435,6 +445,7 @@ find_topmost(panelreel* pr){
// good god almighty, this is some fucking garbage.
// good god almighty, this is some fucking garbage.
static int
static int
panelreel_arrange_denormalized ( panelreel * pr ) {
panelreel_arrange_denormalized ( panelreel * pr ) {
//fprintf(stderr, "denormalized devolution (are we men?)\n");
// we'll need the starting line of the tablet which just lost focus, and the
// we'll need the starting line of the tablet which just lost focus, and the
// starting line of the tablet which just gained focus.
// starting line of the tablet which just gained focus.
int fromline , nowline ;
int fromline , nowline ;
@ -490,12 +501,17 @@ panelreel_arrange_denormalized(panelreel* pr){
// focus, if we're not filling out the reel.
// focus, if we're not filling out the reel.
//
//
// This can still leave a gap plus a partially-onscreen tablet FIXME
// This can still leave a gap plus a partially-onscreen tablet FIXME
static int
int panelreel_redraw ( panelreel * pr ) {
panelreel_arrange ( panelreel * pr ) {
//fprintf(stderr, "--------> BEGIN REDRAW <--------\n");
if ( draw_panelreel_borders ( pr ) ) {
return - 1 ; // enforces specified dimensional minima
}
tablet * focused = pr - > tablets ;
tablet * focused = pr - > tablets ;
if ( focused = = NULL ) {
if ( focused = = NULL ) {
//fprintf(stderr, "no focus!\n");
return 0 ; // if none are focused, none exist
return 0 ; // if none are focused, none exist
}
}
//fprintf(stderr, "focused %p!\n", focused);
// FIXME we special-cased this because i'm dumb and couldn't think of a more
// FIXME we special-cased this because i'm dumb and couldn't think of a more
// elegant way to do this. we keep 'all_visible' as boolean state to avoid
// elegant way to do this. we keep 'all_visible' as boolean state to avoid
// having to do an o(n) iteration each round, but this is still grotesque, and
// having to do an o(n) iteration each round, but this is still grotesque, and
@ -503,7 +519,9 @@ panelreel_arrange(panelreel* pr){
if ( pr - > all_visible ) {
if ( pr - > all_visible ) {
return panelreel_arrange_denormalized ( pr ) ;
return panelreel_arrange_denormalized ( pr ) ;
}
}
//fprintf(stderr, "drawing focused tablet %p dir: %d!\n", focused, pr->last_traveled_direction);
draw_focused_tablet ( pr ) ;
draw_focused_tablet ( pr ) ;
//fprintf(stderr, "drew focused tablet %p dir: %d!\n", focused, pr->last_traveled_direction);
tablet * otherend = focused ;
tablet * otherend = focused ;
if ( pr - > last_traveled_direction > = 0 ) {
if ( pr - > last_traveled_direction > = 0 ) {
otherend = draw_previous_tablets ( pr , otherend ) ;
otherend = draw_previous_tablets ( pr , otherend ) ;
@ -517,16 +535,6 @@ panelreel_arrange(panelreel* pr){
return 0 ;
return 0 ;
}
}
int panelreel_redraw ( panelreel * pr ) {
//fprintf(stderr, "--------> BEGIN REDRAW <--------\n");
int ret = 0 ;
if ( draw_panelreel_borders ( pr ) ) {
return - 1 ; // enforces specified dimensional minima
}
ret | = panelreel_arrange ( pr ) ;
return ret ;
}
static bool
static bool
validate_panelreel_opts ( ncplane * w , const panelreel_options * popts ) {
validate_panelreel_opts ( ncplane * w , const panelreel_options * popts ) {
if ( w = = NULL ) {
if ( w = = NULL ) {