diff options
author | 2018-12-18 20:35:34 +0000 | |
---|---|---|
committer | 2018-12-18 20:35:34 +0000 | |
commit | cd7356ca687e77999021667098d592a480412b49 (patch) | |
tree | d6727ee6f9d184991086f11786e0b38b60b5e48b | |
parent | Rework how socket fds are passed around internally. This will allow (diff) | |
download | wireguard-openbsd-cd7356ca687e77999021667098d592a480412b49.tar.xz wireguard-openbsd-cd7356ca687e77999021667098d592a480412b49.zip |
Make mg kill a region if the 'delete' or 'backspace' keys are pressed
and a region is selected. The contents of the region are then placed
into the kill buffer. Like emacs.
-rw-r--r-- | usr.bin/mg/mg.1 | 8 | ||||
-rw-r--r-- | usr.bin/mg/util.c | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1 index 6d4f22ff1f2..b40151ee29d 100644 --- a/usr.bin/mg/mg.1 +++ b/usr.bin/mg/mg.1 @@ -1,7 +1,7 @@ -.\" $OpenBSD: mg.1,v 1.109 2018/12/13 14:59:16 lum Exp $ +.\" $OpenBSD: mg.1,v 1.110 2018/12/18 20:35:34 lum Exp $ .\" This file is in the public domain. .\" -.Dd $Mdocdate: December 13 2018 $ +.Dd $Mdocdate: December 18 2018 $ .Dt MG 1 .Os .Sh NAME @@ -475,6 +475,8 @@ Delete backwards characters. Like delete-char, this actually does a kill if presented with an argument. +If the cursor is in a region, the region is removed and placed +in to the kill buffer. .It delete-blank-lines Delete blank lines around dot. If dot is sitting on a blank line, this command @@ -486,6 +488,8 @@ Delete characters forward. If any argument is present, it kills rather than deletes, saving the result in the kill buffer. +If the cursor is in a region, the region is removed and placed +in to the kill buffer. .It delete-horizontal-space Delete any whitespace around the dot. .It delete-leading-space diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index 9357d4d2fea..a35bc5edd25 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.38 2015/11/18 18:21:06 jasper Exp $ */ +/* $OpenBSD: util.c,v 1.39 2018/12/18 20:35:34 lum Exp $ */ /* This file is in the public domain. */ @@ -411,7 +411,8 @@ indent(int f, int n) * Delete forward. This is real easy, because the basic delete routine does * all of the work. Watches for negative arguments, and does the right thing. * If any argument is present, it kills rather than deletes, to prevent loss - * of text if typed with a big argument. Normally bound to "C-D". + * of text if typed with a big argument. Normally bound to "C-d". + * If the cursor is in a region, kill the region. */ /* ARGSUSED */ int @@ -420,6 +421,9 @@ forwdel(int f, int n) if (n < 0) return (backdel(f | FFRAND, -n)); + if (curwp->w_markp != NULL) + return(killregion(FFRAND, 1)); + /* really a kill */ if (f & FFARG) { if ((lastflag & CFKILL) == 0) @@ -434,6 +438,7 @@ forwdel(int f, int n) * Delete backwards. This is quite easy too, because it's all done with * other functions. Just move the cursor back, and delete forwards. Like * delete forward, this actually does a kill if presented with an argument. + * If the cursor is in a region, kill the region. */ /* ARGSUSED */ int @@ -444,6 +449,9 @@ backdel(int f, int n) if (n < 0) return (forwdel(f | FFRAND, -n)); + if (curwp->w_markp != NULL) + return (killregion(FFRAND, 1)); + /* really a kill */ if (f & FFARG) { if ((lastflag & CFKILL) == 0) |