[scrolling] call notcurses_render() from scroll_down() #2414

This commit is contained in:
nick black 2022-02-15 06:14:01 -05:00 committed by nick black
parent 37fe78917c
commit ad76543ef1
4 changed files with 27 additions and 5 deletions

View File

@ -1728,13 +1728,19 @@ void scroll_down(ncplane* n){
//fprintf(stderr, "pre-scroll: %d/%d %d/%d log: %d scrolling: %u\n", n->y, n->x, n->leny, n->lenx, n->logrow, n->scrolling);
n->x = 0;
if(n->y == n->leny - 1){
// we're on the last line of the plane
if(n->autogrow){
ncplane_resize_simple(n, n->leny + 1, n->lenx);
ncplane_cursor_move_yx(n, n->leny - 1, 0);
return;
}
// we'll actually be scrolling material up and out, and making a new line.
// if this is the standard plane, that means a "physical" scroll event is
// called for.
if(n == notcurses_stdplane(ncplane_notcurses(n))){
// FIXME likely isn't necessary anymore?
ncplane_pile(n)->scrolls++;
notcurses_render(ncplane_notcurses(n));
}
n->logrow = (n->logrow + 1) % n->leny;
nccell* row = n->fb + nfbcellidx(n, n->y, 0);

View File

@ -943,7 +943,9 @@ clean_sprixels(notcurses* nc, ncpile* p, fbuf* f, int scrolls){
return bytesemitted;
}
// scroll the lastframe data |rows| up, to reflect scrolling reality
// scroll the lastframe data |rows| up, to reflect scrolling reality.
// FIXME we could virtualize this as we do for scrolling planes; this
// method involves a lot of unnecessary copying.
static void
scroll_lastframe(notcurses* nc, unsigned rows){
// the top |rows| rows need be released (though not more than the actual

View File

@ -19,6 +19,7 @@ int main(void){
ncplane_set_styles(n, NCSTYLE_BOLD);
ncplane_putstr(n, "This program is *not* indicative of real scrolling speed.\n");
ncplane_set_styles(n, NCSTYLE_NONE);
unsigned y = ncplane_cursor_y(n);
while(true){
struct timespec req = { .tv_sec = 0, .tv_nsec = 1000000, };
nanosleep(&req, NULL);
@ -28,10 +29,16 @@ int main(void){
if(++wc == 0x9fa5){
wc = 0x4e00;
}
if(notcurses_render(nc)){
break;
unsigned newy = ncplane_cursor_y(n);
if(newy != y){
y = newy;
notcurses_render(nc);
}
}
if(notcurses_render(nc)){
notcurses_stop(nc);
return EXIT_FAILURE;
}
notcurses_stop(nc);
return EXIT_FAILURE;
}

View File

@ -19,6 +19,7 @@ int main(void){
ncplane_set_styles(n, NCSTYLE_BOLD);
ncplane_putstr(n, "This program is *not* indicative of real scrolling speed.\n");
ncplane_set_styles(n, NCSTYLE_NONE);
unsigned y = ncplane_cursor_y(n);
while(true){
struct timespec req = { .tv_sec = 0, .tv_nsec = 1000000, };
nanosleep(&req, NULL);
@ -28,10 +29,16 @@ int main(void){
if(++c == '{'){
c = 'A';
}
if(notcurses_render(nc)){
break;
unsigned newy = ncplane_cursor_y(n);
if(newy != y){
y = newy;
notcurses_render(nc);
}
}
if(notcurses_render(nc)){
notcurses_stop(nc);
return EXIT_FAILURE;
}
notcurses_stop(nc);
return EXIT_SUCCESS;
}