/* ARGSUSED */ int forwline(int f, int n) { struct line *dlp; if (n < 0) return (backline(f | FFRAND, -n)); if ((dlp = curwp->w_dotp) == curbp->b_headp) return(TRUE); if ((lastflag & CFCPCN) == 0) /* Fix goal. */ setgoal(); thisflag |= CFCPCN; if (n == 0) return (TRUE); while (n--) { dlp = lforw(dlp); if (dlp == curbp->b_headp) { curwp->w_dotp = lback(dlp); curwp->w_doto = llength(curwp->w_dotp); curwp->w_rflag |= WFMOVE; return (TRUE); } curwp->w_dotline++; } curwp->w_rflag |= WFMOVE; curwp->w_dotp = dlp; curwp->w_doto = getgoal(dlp); return (TRUE); }
/* * Implements the vi "k" command. * * This function is like "forwline", but goes backwards. */ int backline(int f, int n) { int rc; LINE *dlp; n = need_a_count(f, n, 1); if (n < 0) { rc = forwline(f, -n); } else if (is_first_line(DOT, curbp)) { /* cannot move up */ rc = FALSE; } else { /* set the "goal" column if necessary */ if (curgoal < 0) curgoal = getccol(FALSE); /* loop upwards */ dlp = DOT.l; while (n-- && lback(dlp) != buf_head(curbp)) dlp = lback(dlp); /* set dot */ DOT.l = dlp; DOT.o = getgoal(dlp); curwp->w_flag |= WFMOVE; rc = TRUE; } return rc; }
/* ARGSUSED */ int backline(int f, int n) { struct line *dlp; if (n < 0) return (forwline(f | FFRAND, -n)); if ((lastflag & CFCPCN) == 0) /* Fix goal. */ setgoal(); thisflag |= CFCPCN; dlp = curwp->w_dotp; if (lback(dlp) == curbp->b_headp) { if (!(f & FFRAND)) { dobeep(); ewprintf("Beginning of buffer"); } return(TRUE); } while (n-- && lback(dlp) != curbp->b_headp) { dlp = lback(dlp); curwp->w_dotline--; } if (n > 0 && !(f & FFRAND)) { dobeep(); ewprintf("Beginning of buffer"); } curwp->w_dotp = dlp; curwp->w_doto = getgoal(dlp); curwp->w_rflag |= WFMOVE; return (TRUE); }
static void move_dot_to(int row, int col) { LINE *lp; int i; lp = curwp->w_linep; i = row - ((Pmaster) ? ComposerTopLine : 2); while(i-- && lp != curbp->b_linep) /* count from top */ lp = lforw(lp); curgoal = col; curwp->w_dotp = lp; /* to new dot. */ curwp->w_doto = getgoal(lp); curwp->w_flag |= WFMOVE; }
/* * This function is like "forwline", but goes backwards. The scheme is exactly * the same. Check for arguments that are less than zero and call your * alternate. Figure out the new line and call "movedot" to perform the * motion. No errors are possible. Bound to "C-P". */ int backline (int f, int n) { LINE *dlp; if (n < 0) return (forwline (f, -n)); if ((lastflag & CFCPCN) == 0)/* Reset goal if the */ curgoal = getccol (FALSE); /* last isn't C-P, C-N */ thisflag |= CFCPCN; dlp = curwp->w_dotp; while (n-- && lback (dlp) != curbp->b_linep) dlp = lback (dlp); curwp->w_dotp = dlp; curwp->w_doto = getgoal (dlp); curwp->w_flag |= WFMOVE; return (TRUE); }
/* * Move forward by full lines. If the number of lines to move is less than * zero, call the backward line function to actually do it. The last command * controls how the goal column is set. Bound to "C-N". No errors are possible. */ int forwline (int f, int n) { LINE *dlp; if (n < 0) return (backline (f, -n)); if ((lastflag & CFCPCN) == 0)/* Reset goal if last */ curgoal = getccol (FALSE); /* not C-P or C-N */ thisflag |= CFCPCN; dlp = curwp->w_dotp; while (n-- && dlp != curbp->b_linep) dlp = lforw (dlp); curwp->w_dotp = dlp; curwp->w_doto = getgoal (dlp); curwp->w_flag |= WFMOVE; return (TRUE); }
/* * This function is like "forwline", but goes backwards. The scheme is exactly * the same. Check for arguments that are less than zero and call your * alternate. Figure out the new line and call "movedot" to perform the * motion. No errors are possible. Bound to "C-P". * If raw is TRUE then enter folds, else skip them. MJB: 13-Oct-89 */ PASCAL NEAR backline( int f, int n, int raw ) /* argument falg and num */ { register LINE *dlp; if (n < 0) return(forwline(f, -n, raw)); /* if we are on the last line as we start....fail the command */ if (lback(curwp->w_dotp) == curbp->b_linep) return(FALSE); /* if the last command was not note a line move, reset the goal column */ if ((lastflag&CFCPCN) == 0) curgoal = getccol(FALSE); /* flag this command as a line move */ thisflag |= CFCPCN; /* and move the point up */ dlp = curwp->w_dotp; while (n-- && lback(dlp)!=curbp->b_linep) if (raw) /* raw mode */ dlp = dlp->l_bp; else /* it's cooked */ dlp = lback(dlp); /* reseting the current position */ curwp->w_dotp = dlp; curwp->w_doto = getgoal(dlp); curwp->w_flag |= WFMOVE; if (raw) /* may have entered folds */ openoutfolds(); #if DBCS return(stopback()); #else return(TRUE); #endif }
/* ARGSUSED */ int backline(int f, int n) { struct line *dlp; if (n < 0) return (forwline(f | FFRAND, -n)); if ((lastflag & CFCPCN) == 0) /* Fix goal. */ setgoal(); thisflag |= CFCPCN; dlp = curwp->w_dotp; while (n-- && lback(dlp) != curbp->b_headp) { dlp = lback(dlp); curwp->w_dotline--; } curwp->w_dotp = dlp; curwp->w_doto = getgoal(dlp); curwp->w_rflag |= WFMOVE; return (TRUE); }
/* * Implements the vi "j" command. * * Move forward by full lines. If the number of lines to move is less than * zero, call the backward line function to actually do it. The last command * controls how the goal column is set. */ int forwline(int f, int n) { int rc; LINE *dlp; n = need_a_count(f, n, 1); if (n < 0) { rc = backline(f, -n); } else if (n == 0) { rc = TRUE; } else { /* set the "goal" column if necessary */ if (curgoal < 0) curgoal = getccol(FALSE); /* loop downwards */ dlp = DOT.l; rc = TRUE; do { LINE *nlp = lforw(dlp); if (nlp == buf_head(curbp)) { rc = FALSE; break; } dlp = nlp; } while (--n != 0); if (rc) { /* set dot */ DOT.l = dlp; DOT.o = getgoal(dlp); curwp->w_flag |= WFMOVE; } } return rc; }