diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-13 20:07:27 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-13 20:07:27 +0000 |
commit | 6a60c6908c6c48c32478ac4d20d9522a09c3027e (patch) | |
tree | c1b1b8b7a27282ac2caaaef11091469ec5c42a7f /usr.bin | |
parent | 743895f9bc8fc496339eeed44d3f2a6ddf08423c (diff) |
Make undoing of a yank operation work as expected
(i.e. undo boundaries are placed around entire yanked block)
ok cloder@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/random.c | 6 | ||||
-rw-r--r-- | usr.bin/mg/undo.c | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/mg/random.c b/usr.bin/mg/random.c index bc117ed0096..9a42f0b5919 100644 --- a/usr.bin/mg/random.c +++ b/usr.bin/mg/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.12 2005/06/14 18:14:40 kjell Exp $ */ +/* $OpenBSD: random.c,v 1.13 2005/10/13 20:07:26 kjell Exp $ */ /* This file is in the public domain. */ @@ -437,6 +437,8 @@ yank(int f, int n) /* newline counting */ nline = 0; + undo_add_boundary(); + undo_no_boundary(TRUE); while (n--) { /* mark around last yank */ isetmark(); @@ -464,6 +466,8 @@ yank(int f, int n) curwp->w_linep = lp; curwp->w_flag |= WFHARD; } + undo_no_boundary(FALSE); + undo_add_boundary(); return (TRUE); } diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c index 61f276d3541..a96d1d5a491 100644 --- a/usr.bin/mg/undo.c +++ b/usr.bin/mg/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.29 2005/10/11 01:08:53 kjell Exp $ */ +/* $OpenBSD: undo.c,v 1.30 2005/10/13 20:07:26 kjell Exp $ */ /* * Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org> * All rights reserved. @@ -175,22 +175,36 @@ lastrectype(void) return (0); } +/* + * undo_enable(TRUE/FALSE) will enable / disable the undo mechanism. + * Returns TRUE if previously enabled, FALSE otherwise. + */ int undo_enable(int on) { int pon = undo_disable_flag; undo_disable_flag = (on == TRUE) ? 0 : 1; - return (pon ? FALSE : TRUE); + return ((pon == TRUE) ? FALSE : TRUE); } +/* + * If undo is enabled, then: + * undo_no_boundary(TRUE) stops recording undo boundaries between actions. + * undo_no_boundary(FALSE) enables undo boundaries. + * If undo is disabled, this function has no effect. + */ void undo_no_boundary(int flag) { - if (!undo_disable_flag) + if (undo_disable_flag == FALSE) nobound = flag; } +/* + * Record an undo boundary, unless 'nobound' is set via undo_no_boundary. + * Does nothing if previous undo entry is already a boundary. + */ int undo_add_boundary(void) { |