diff options
author | lum <lum@cvs.openbsd.org> | 2013-05-19 10:27:12 +0000 |
---|---|---|
committer | lum <lum@cvs.openbsd.org> | 2013-05-19 10:27:12 +0000 |
commit | c6e7ecac59964b5830cb80fdc8bf7fbf75e55d74 (patch) | |
tree | 5e1fb776391407a4000d574f7f71c4568fcc639a /usr.bin/mg | |
parent | 49de8c6608340f68b529d8edc0806ed564cc0112 (diff) |
Make the cursor position when moving backwards by paragraph behave the
same as emacs: move to line above paragraph. ok florian@
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/paragraph.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c index 16d84ce49e7..2cde33b90e0 100644 --- a/usr.bin/mg/paragraph.c +++ b/usr.bin/mg/paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paragraph.c,v 1.23 2013/02/17 15:42:21 lum Exp $ */ +/* $OpenBSD: paragraph.c,v 1.24 2013/05/19 10:27:11 lum Exp $ */ /* This file is in the public domain. */ @@ -7,6 +7,8 @@ * and GNU-ified by mwm@ucbvax. Several bug fixes by blarson@usc-oberon. */ +#include <ctype.h> + #include "def.h" static int fillcol = 70; @@ -22,36 +24,30 @@ static int fillcol = 70; int gotobop(int f, int n) { + int col; + int nospace = 0; + /* the other way... */ if (n < 0) return (gotoeop(f, -n)); while (n-- > 0) { - /* first scan back until we are in a word */ - while (backchar(FFRAND, 1) && inword() == 0); + while (lback(curwp->w_dotp) != curbp->b_headp) { + curwp->w_dotp = lback(curwp->w_dotp); + curwp->w_dotline--; + curwp->w_doto = 0; + col = 0; - /* and go to the B-O-Line */ - curwp->w_doto = 0; + while (col < llength(curwp->w_dotp) && + (isspace(lgetc(curwp->w_dotp, col)))) + col++; - /* - * and scan back until we hit a <NL><SP> <NL><TAB> or - * <NL><NL> - */ - while (lback(curwp->w_dotp) != curbp->b_headp) - if (llength(lback(curwp->w_dotp)) && - lgetc(curwp->w_dotp, 0) != ' ' && - lgetc(curwp->w_dotp, 0) != '.' && - lgetc(curwp->w_dotp, 0) != '\t') { - curwp->w_dotp = lback(curwp->w_dotp); - curwp->w_dotline--; - } else { - if (llength(lback(curwp->w_dotp)) && - lgetc(curwp->w_dotp, 0) == '.') { - curwp->w_dotp = lforw(curwp->w_dotp); - curwp->w_dotline++; - } - break; - } + if (col >= llength(curwp->w_dotp)) { + if (nospace) + break; + } else + nospace = 1; + } } /* force screen update */ curwp->w_rflag |= WFMOVE; |