Currently, mg's cursor jumps from top to bottom of the screen as you
scroll upwards, I find this behaviour confusing at times. This diff
makes mg's scroll back the same as emacs.
Comments/ok?
mark
Index: basic.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.32
diff -u -p -r1.32 basic.c
--- basic.c 30 May 2012 06:13:32 -0000 1.32
+++ basic.c 31 May 2012 06:57:11 -0000
@@ -301,7 +301,7 @@ forwpage(int f, int n)
int
backpage(int f, int n)
{
- struct line *lp;
+ struct line *lp, *lp2;
if (!(f & FFARG)) {
n = curwp->w_ntrows - 2; /* Default scroll. */
@@ -309,18 +309,24 @@ backpage(int f, int n)
n = 1; /* window is tiny. */
} else if (n < 0)
return (forwpage(f | FFRAND, -n));
- lp = curwp->w_linep;
+
+ lp = lp2 = curwp->w_linep;
+
while (n-- && lback(lp) != curbp->b_headp) {
lp = lback(lp);
}
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 != curwp->w_linep) {
+ while (curwp->w_dotp != lp2) {
curwp->w_dotp = lback(curwp->w_dotp);
curwp->w_dotline--;
}