Skip to content

Commit

Permalink
correct drawtop/drawbot calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Nov 20, 2020
1 parent 5a6704d commit 8badfc1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/notcurses/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -1492,29 +1492,27 @@ fprintf(stderr, "%s %p [%d:%d/%d] sel: %p selline: %d\n", as->c->name, cur, line
cur = as->selected->next;
}else{
cur = as->bobjs;
fprintf(stderr, "none selected, starting with %p\n", cur);
fprintf(stderr, "none selected, starting with %p for %d rows\n", cur, rows);
// if nothing was selected, we might have to clip at the top. check to see
// if we're moving up. if so, run through all devices to get a total length,
// and then move forward until we find the first visible one. begin
// printing, in this case, at line 0. you've been clipped!
line = drawfromtop;
int totallines = 0;
const blockobj* iter = cur;
line = rows - 1;
line = rows - 1; // optimistic (we hope to draw last line, might not)
while(iter){
totallines += device_lines(as->expansion, iter);
line -= device_lines(as->expansion, iter);
iter = iter->next;
}
fprintf(stderr, "total lines: %d line: %d rows: %d\n", totallines, line, rows);
if(line > 0){ // they'll all fit, huzzah
fprintf(stderr, "line: %d rows: %d drawfromtop: %u\n", line, rows, drawfromtop);
if(line >= 0){ // everything fits, huzzah
line = 1;
}else{
if(drawfromtop){
drawbottom = false;
}else{
drawtop = false;
}
++line; // we get one back for tossing a border
while(cur && (line + device_lines(as->expansion, cur) < 0)){
line += device_lines(as->expansion, cur);
cur = cur->next;
Expand Down

0 comments on commit 8badfc1

Please sign in to comment.