diff options
author | 2019-06-03 16:26:30 +0000 | |
---|---|---|
committer | 2019-06-03 16:26:30 +0000 | |
commit | ed288066173529930a74ebf55f1f8d9853a00552 (patch) | |
tree | 1ff275057cc1b2d14484cfbfefc4bbee1714bb2b | |
parent | Don't close the socket in rsync_socket() itself but after calling it. (diff) | |
download | wireguard-openbsd-ed288066173529930a74ebf55f1f8d9853a00552.tar.xz wireguard-openbsd-ed288066173529930a74ebf55f1f8d9853a00552.zip |
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. A universal argument
of higher than 9 puts the cursor back to the end/start of buffer.
-rw-r--r-- | usr.bin/mg/basic.c | 33 | ||||
-rw-r--r-- | usr.bin/mg/mg.1 | 10 |
2 files changed, 33 insertions, 10 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 85d9f70fce6..a019ff56b9b 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.47 2015/10/10 09:13:14 lum Exp $ */ +/* $OpenBSD: basic.c,v 1.48 2019/06/03 16:26:30 lum Exp $ */ /* This file is in the public domain */ @@ -21,6 +21,8 @@ #include "def.h" +#define percint(n1, n2) ((n1 * (int) n2) * 0.1) + /* * Go to beginning of line. */ @@ -115,9 +117,9 @@ forwchar(int f, int n) } /* - * Go to the beginning of the - * buffer. Setting WFFULL is conservative, - * but almost always the case. + * Go to the beginning of the buffer. Setting WFFULL is conservative, + * but almost always the case. A universal argument of higher than 9 + * puts the cursor back to the end of buffer. */ int gotobob(int f, int n) @@ -127,17 +129,25 @@ 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); } /* * Go to the end of the buffer. Leave dot 3 lines from the bottom of the * window if buffer length is longer than window length; same as emacs. - * Setting WFFULL is conservative, but almost always the case. + * Setting WFFULL is conservative, but almost always the case. A universal + * argument of higher than 9 puts the cursor back to the start of buffer. */ int gotoeob(int f, int n) { + int ln; struct line *lp; (void) setmark(f, n); @@ -146,15 +156,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 > 0) { + if (n > 9) + gotobob(0, 0); + else + backline(f, percint(curwp->w_bufp->b_lines, n)); + } + curwp->w_rflag |= WFFULL; return (TRUE); } diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1 index 59383840d1a..50d76d0e8c7 100644 --- a/usr.bin/mg/mg.1 +++ b/usr.bin/mg/mg.1 @@ -1,7 +1,7 @@ -.\" $OpenBSD: mg.1,v 1.112 2018/12/26 07:01:22 phessler Exp $ +.\" $OpenBSD: mg.1,v 1.113 2019/06/03 16:26:30 lum Exp $ .\" This file is in the public domain. .\" -.Dd $Mdocdate: December 26 2018 $ +.Dd $Mdocdate: June 3 2019 $ .Dt MG 1 .Os .Sh NAME @@ -405,6 +405,9 @@ Paragraphs are delimited by <NL><NL> or <NL><TAB> or <NL><SPACE>. 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 |