/* ARGSUSED */ int backpage(int f, int n) { struct line *lp; if (!(f & FFARG)) { n = curwp->w_ntrows - 2; /* Default scroll. */ if (n <= 0) /* Don't blow up if the */ n = 1; /* window is tiny. */ } else if (n < 0) return (forwpage(f | FFRAND, -n)); lp = curwp->w_linep; while (n-- && lback(lp) != curbp->b_headp) { lp = lback(lp); } curwp->w_linep = lp; curwp->w_flag |= WFFULL; /* if in current window, don't move dot */ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) if (lp == curwp->w_dotp) return (TRUE); /* Move the dot the slow way, for line nos */ while (curwp->w_dotp != curwp->w_linep) { curwp->w_dotp = lback(curwp->w_dotp); curwp->w_dotline--; } curwp->w_doto = 0; return (TRUE); }
/* * Implements the vi "^B" command. * * This command is like "forwpage", but it goes backwards. */ int backpage(int f, int n) { LINE *lp; int status; if ((n = full_pages(f, n)) < 0) return forwpage(f, -n); lp = curwp->w_line.l; if (lback(lp) != buf_head(curbp)) { while ((n -= line_height(curwp, lp)) >= 0 && lback(lp) != buf_head(curbp)) lp = lback(lp); curwp->w_line.l = lp; (void) gotoeos(FALSE, 1); curwp->w_flag |= WFHARD | WFMODE; status = TRUE; } else if (DOT.l != lp) { DOT.l = lp; curwp->w_flag |= WFHARD | WFMODE; status = TRUE; } else { status = FALSE; } return status; }
/* * These functions are provided for compatibility with Gosling's Emacs. They * are used to scroll the display up (or down) one line at a time. */ int forw1page(int f, int n) { if (!(f & FFARG)) { n = 1; f = FFUNIV; } forwpage(f | FFRAND, n); return (TRUE); }
/* * Page the other window. Check to make sure it exists, then * nextwind, forwpage and restore window pointers. */ int pagenext(int f, int n) { struct mgwin *wp; if (wheadp->w_wndp == NULL) { ewprintf("No other window"); return (FALSE); } wp = curwp; (void) nextwind(f, n); (void) forwpage(f, n); curwp = wp; curbp = wp->w_bufp; return (TRUE); }
/* ARGSUSED */ int backpage(int f, int n) { struct line *lp, *lp2; if (!(f & FFARG)) { n = curwp->w_ntrows - 2; /* Default scroll. */ if (n <= 0) /* Don't blow up if the */ return (backline(f, 1));/* window is tiny. */ } else if (n < 0) return (forwpage(f | FFRAND, -n)); lp = lp2 = curwp->w_linep; while (n-- && lback(lp) != curbp->b_headp) { lp = lback(lp); } if (lp == curwp->w_linep) { dobeep(); ewprintf("Beginning of buffer"); } curwp->w_linep = lp; curwp->w_rflag |= WFFULL; /* if in current window, don't move dot */ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) if (lp == curwp->w_dotp) return (TRUE); lp2 = lforw(lp2); /* Move the dot the slow way, for line nos */ while (curwp->w_dotp != lp2) { if (curwp->w_dotline <= curwp->w_ntrows) goto out; curwp->w_dotp = lback(curwp->w_dotp); curwp->w_dotline--; } out: curwp->w_doto = 0; return (TRUE); }
/* * This command is like "forwpage", but it goes backwards. The "2", like * above, is the overlap between the two windows. The value is from the ITS * EMACS manual. Bound to "M-V". We do a hard update for exactly the same * reason. */ PASCAL NEAR backpage( register int f, register int n ) { register LINE *lp; if (f == FALSE) { n = curwp->w_ntrows - 2; /* Default scroll. */ if (n <= 0) /* Don't blow up if the */ n = 1; /* window is tiny. */ } else if (n < 0) return(forwpage(f, -n)); lp = curwp->w_linep; while (n-- && lback(lp)!=curbp->b_linep) lp = lback(lp); curwp->w_linep = lp; curwp->w_dotp = lp; curwp->w_doto = 0; curwp->w_flag |= WFHARD; return(TRUE); }
/* * This command is like "forwpage", but it goes backwards. The "2", like * above, is the overlap between the two windows. The value is from the ITS * EMACS manual. Bound to "M-V". We do a hard update for exactly the same * reason. */ int backpage (int f, int n) { LINE *lp; if (f == FALSE) { n = curwp->w_ntrows - 2; /* Default scroll */ if (n <= 0) /* Don't blow up if the window is tiny */ n = 1; } else if (n < 0) return (forwpage (f, -n)); else /* Convert from pages to lines */ n *= curwp->w_ntrows; lp = curwp->w_linep; while (n-- && lback (lp) != curbp->b_linep) lp = lback (lp); curwp->w_linep = lp; curwp->w_dotp = lp; curwp->w_doto = 0; curwp->w_flag |= WFHARD; return (TRUE); }