/* Move up one page. */ void do_page_up(void) { int i; /* If there's less than a page of text left on the screen, put the * cursor at the beginning of the first line of the file, and then * update the edit window. */ if (openfile->current->lineno <= editwinrows - 2) { do_first_line(); return; } /* If we're not in smooth scrolling mode, put the cursor at the * beginning of the top line of the edit window, as Pico does. */ #ifndef NANO_TINY if (!ISSET(SMOOTH_SCROLL)) { #endif openfile->current = openfile->edittop; openfile->placewewant = 0; #ifndef NANO_TINY } #endif for (i = editwinrows - 2; i > 0 && openfile->current != openfile->fileage; i--) openfile->current = openfile->current->prev; openfile->current_x = actual_x(openfile->current->data, openfile->placewewant); /* Scroll the edit window up a page. */ edit_scroll(UP_DIR, editwinrows - 2); }
/* Move up one page. */ void do_page_up(void) { int i, skipped = 0; /* If there's less than a page of text left on the screen, put the * cursor at the beginning of the first line of the file, and then * update the edit window. */ if (openfile->current->lineno == 1 || ( #ifndef NANO_TINY !ISSET(SOFTWRAP) && #endif openfile->current->lineno <= editwinrows - 2)) { do_first_line(); return; } /* If we're not in smooth scrolling mode, put the cursor at the * beginning of the top line of the edit window, as Pico does. */ #ifndef NANO_TINY if (!ISSET(SMOOTH_SCROLL)) { #endif openfile->current = openfile->edittop; openfile->placewewant = openfile->current_y = 0; #ifndef NANO_TINY } #endif for (i = editwinrows - 2; i - skipped > 0 && openfile->current != openfile->fileage; i--) { openfile->current = openfile->current->prev; #ifndef NANO_TINY if (ISSET(SOFTWRAP) && openfile->current) { skipped += strlenpt(openfile->current->data) / COLS; #ifdef DEBUG fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %lu\n", i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data)); #endif } #endif } openfile->current_x = actual_x(openfile->current->data, openfile->placewewant); #ifdef DEBUG fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n", (unsigned long)openfile->current->lineno, skipped); #endif /* Scroll the edit window up a page. */ edit_update(NONE); }
/* Move up one page. */ void do_page_up(void) { int i, mustmove, skipped = 0; /* If the cursor is less than a page away from the top of the file, * put it at the beginning of the first line. */ if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) && openfile->current->lineno <= editwinrows - 2)) { do_first_line(); return; } /* If we're not in smooth scrolling mode, put the cursor at the * beginning of the top line of the edit window, as Pico does. */ if (!ISSET(SMOOTH_SCROLL)) { openfile->current = openfile->edittop; openfile->placewewant = openfile->current_y = 0; } mustmove = (editwinrows < 3) ? 1 : editwinrows - 2; for (i = mustmove; i - skipped > 0 && openfile->current != openfile->fileage; i--) { openfile->current = openfile->current->prev; #ifndef NANO_TINY if (ISSET(SOFTWRAP) && openfile->current) { skipped += strlenpt(openfile->current->data) / editwincols; #ifdef DEBUG fprintf(stderr, "paging up: i = %d, skipped = %d based on line %ld len %lu\n", i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data)); #endif } #endif } openfile->current_x = actual_x(openfile->current->data, openfile->placewewant); /* Scroll the edit window up a page. */ adjust_viewport(STATIONARY); refresh_needed = TRUE; }