summaryrefslogtreecommitdiff
path: root/usr.bin
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
commitbaebb7eeaa3aae82347b7732f5eeb058bd7978ed (patch)
treeab911ecf0c648d423806ae417b48b3936fb56078 /usr.bin
parent41b510063431c6988acaffe1b9be6589a4eb65a0 (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')
-rw-r--r--usr.bin/mg/random.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/mg/random.c b/usr.bin/mg/random.c
index 10ca9ea3c60..f48cb7426ea 100644
--- a/usr.bin/mg/random.c
+++ b/usr.bin/mg/random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: random.c,v 1.17 2005/11/22 05:02:44 kjell Exp $ */
+/* $OpenBSD: random.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);
}