/* Move down one page. */ void do_page_down(void) { int i, mustmove; /* If the cursor is less than a page away from the bottom of the file, * put it at the end of the last line. */ if (openfile->current->lineno + maxrows - 2 >= openfile->filebot->lineno) { do_last_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 = (maxrows < 3) ? 1 : maxrows - 2; for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) { openfile->current = openfile->current->next; #ifdef DEBUG fprintf(stderr, "paging down: moving to line %lu\n", (unsigned long)openfile->current->lineno); #endif } openfile->current_x = actual_x(openfile->current->data, openfile->placewewant); /* Scroll the edit window down a page. */ adjust_viewport(STATIONARY); refresh_needed = TRUE; }
/* Make sure that the current line, when it is partially scrolled off the * screen in softwrap mode, is scrolled fully into view. */ void ensure_line_is_visible(void) { #ifndef NANO_TINY if (ISSET(SOFTWRAP) && strlenpt(openfile->current->data) / editwincols + openfile->current_y >= editwinrows) { adjust_viewport(ISSET(SMOOTH_SCROLL) ? FLOWING : CENTERING); refresh_needed = TRUE; } #endif }
/* 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; }
static void resize_callback(GLFWwindow *window, int width, int height) { adjust_viewport(window, width, height); cam3_on_window_resize(width, height); }