summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2006-06-01 04:17:35 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2006-06-01 04:17:35 +0000
commitd3f11c5fcf8c2b1812a5d1e8e8a05e3ceeb5edd0 (patch)
tree584f2b3090b58f9526b4ebb4b0ebe08ff695c299 /usr.bin/mg
parent3f1928d7d7543e128a88583ececb15de9324d666 (diff)
Make transpose (c-T) undoable.
There is still a bug here, but it lies in undo (cursor position when undo wraps the undo list), and is purely cosmetic for now.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/util.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c
index a56343d7956..d7585ee60a2 100644
--- a/usr.bin/mg/util.c
+++ b/usr.bin/mg/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.17 2005/11/22 05:02:44 kjell Exp $ */
+/* $OpenBSD: util.c,v 1.18 2006/06/01 04:17:34 kjell Exp $ */
/* This file is in the public domain. */
@@ -116,20 +116,29 @@ twiddle(int f, int n)
{
struct line *dotp;
int doto, cr;
+ int fudge = FALSE;
dotp = curwp->w_dotp;
doto = curwp->w_doto;
+ undo_add_boundary();
+ undo_no_boundary(TRUE);
if (doto == llength(dotp)) {
if (--doto <= 0)
return (FALSE);
+ backchar(f, 1);
+ fudge = TRUE;
} else {
if (doto == 0)
return (FALSE);
- ++curwp->w_doto;
}
- cr = lgetc(dotp, doto--);
- lputc(dotp, doto + 1, lgetc(dotp, doto));
- lputc(dotp, doto, cr);
+ cr = lgetc(dotp, doto - 1);
+ backdel(f, 1);
+ forwchar(f, 1);
+ linsert(1, cr);
+ if (fudge != TRUE)
+ backchar(f, 1);
+ undo_no_boundary(FALSE);
+ undo_add_boundary();
lchange(WFEDIT);
return (TRUE);
}