diff options
Diffstat (limited to 'usr.bin/mg/util.c')
-rw-r--r-- | usr.bin/mg/util.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index 3f2a14b09af..d2b9c0108df 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.27 2011/01/17 03:12:06 kjell Exp $ */ +/* $OpenBSD: util.c,v 1.28 2011/01/18 16:25:40 kjell Exp $ */ /* This file is in the public domain. */ @@ -453,3 +453,33 @@ backtoindent(int f, int n) ++curwp->w_doto; return (TRUE); } + +/* + * Join the current line to the previous, or with arg, the next line + * to the current one. If the former line is not empty, leave exactly + * one space at the joint. Otherwise, leave no whitespace. + */ +int +joinline(int f, int n) +{ + int doto; + + undo_boundary_enable(FFRAND, 0); + if (f & FFARG) { + gotoeol(FFRAND, 1); + forwdel(FFRAND, 1); + } else { + gotobol(FFRAND, 1); + backdel(FFRAND, 1); + } + + delwhite(FFRAND, 1); + + if ((doto = curwp->w_doto) > 0) { + linsert(1, ' '); + curwp->w_doto = doto; + } + undo_boundary_enable(FFRAND, 1); + + return (TRUE); +} |