This diff gives the commands beginning-of-buffer and end-of-buffer the
ability to take a numeric argument and move n/10th of the way from the
top or bottom of the current buffer respectively.
Any comments/testers/oks?
Mark
Index: basic.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.47
diff -u -p -u -p -r1.47 basic.c
--- basic.c 10 Oct 2015 09:13:14 -0000 1.47
+++ basic.c 31 May 2019 11:16:58 -0000
@@ -21,6 +21,8 @@
#include "def.h"
+#define percint(n1, n2) ((n1 * (int) n2) * 0.1)
+
/*
* Go to beginning of line.
*/
@@ -127,6 +129,12 @@ gotobob(int f, int n)
curwp->w_doto = 0;
curwp->w_rflag |= WFFULL;
curwp->w_dotline = 1;
+ if (f & FFOTHARG && n > 0) {
+ if (n > 9)
+ gotoeob(0, 0);
+ else
+ forwline(f, percint(curwp->w_bufp->b_lines, n) - 1);
+ }
return (TRUE);
}
@@ -138,6 +146,7 @@ gotobob(int f, int n)
int
gotoeob(int f, int n)
{
+ int ln;
struct line *lp;
(void) setmark(f, n);
@@ -146,15 +155,22 @@ gotoeob(int f, int n)
curwp->w_dotline = curwp->w_bufp->b_lines;
lp = curwp->w_dotp;
- n = curwp->w_ntrows - 3;
+ ln = curwp->w_ntrows - 3;
- if (n < curwp->w_bufp->b_lines && n >= 3) {
- while (n--)
+ if (ln < curwp->w_bufp->b_lines && ln >= 3) {
+ while (ln--)
curwp->w_dotp = lback(curwp->w_dotp);
curwp->w_linep = curwp->w_dotp;
curwp->w_dotp = lp;
}
+ if (f & FFOTHARG && n > 1) {
+ if (n > 9)
+ gotobob(0, 0);
+ else
+ backline(f, percint(curwp->w_bufp->b_lines, n));
+ }
+
curwp->w_rflag |= WFFULL;
return (TRUE);
}
Index: mg.1
===================================================================
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.112
diff -u -p -u -p -r1.112 mg.1
--- mg.1 26 Dec 2018 07:01:22 -0000 1.112
+++ mg.1 31 May 2019 11:16:58 -0000
@@ -405,6 +405,9 @@ Paragraphs are delimited by <NL><NL> or
Move cursor backwards by the specified number of words.
.It beginning-of-buffer
Move cursor to the top of the buffer.
+A numeric argument
+.Va n ,
+will move n/10th of the way from the top.
.It beginning-of-line
Move cursor to the beginning of the line.
.It blink-and-insert
@@ -526,6 +529,9 @@ version string.
Stop defining a keyboard macro.
.It end-of-buffer
Move cursor to the end of the buffer.
+A numeric argument
+.Va n ,
+will move n/10th of the way from the end.
.It end-of-line
Move cursor to the end of the line.
.It enlarge-window