summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincent <vincent@openbsd.org>2002-02-21 04:21:05 +0000
committervincent <vincent@openbsd.org>2002-02-21 04:21:05 +0000
commitfcb2c90f32c618f536422e6c75a3b2655dbfa610 (patch)
treeca108a853e76a940a55cec2328033f824982cee8
parentIf there is a /var/run/dhclient.pid file, stash its contents and (diff)
downloadwireguard-openbsd-fcb2c90f32c618f536422e6c75a3b2655dbfa610.tar.xz
wireguard-openbsd-fcb2c90f32c618f536422e6c75a3b2655dbfa610.zip
Save undo records for newline insertions.
That makes mg behave more like GNU emacs.
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/line.c9
-rw-r--r--usr.bin/mg/undo.c23
3 files changed, 32 insertions, 3 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index b4a49d18490..1e7847ea942 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.32 2002/02/21 04:16:27 vincent Exp $ */
+/* $OpenBSD: def.h,v 1.33 2002/02/21 04:21:05 vincent Exp $ */
#include <sys/queue.h>
@@ -574,6 +574,7 @@ int cntnonmatchlines(int, int);
/* undo.c X */
int undo_init(void);
int undo_enable(int);
+int undo_add_custom(int, LINE *, int, void *, int);
int undo_add_boundary(void);
int undo_add_insert(LINE *, int, int);
int undo_add_delete(LINE *, int, int);
diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c
index d88f60bef0f..02fa4c4b5b8 100644
--- a/usr.bin/mg/line.c
+++ b/usr.bin/mg/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.13 2002/02/20 22:30:54 vincent Exp $ */
+/* $OpenBSD: line.c,v 1.14 2002/02/21 04:21:05 vincent Exp $ */
/*
* Text line handling.
@@ -248,6 +248,13 @@ lnewline()
lchange(WFHARD);
+ if (!undoaction) {
+ /* XXX */
+ undo_add_custom(INSERT, curwp->w_dotp, curwp->w_doto,
+ strdup("\n"), 1);
+ }
+
+
/* Get the address and offset of "." */
lp1 = curwp->w_dotp;
doto = curwp->w_doto;
diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c
index 1866d7432d5..2dbe5a5dbc3 100644
--- a/usr.bin/mg/undo.c
+++ b/usr.bin/mg/undo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undo.c,v 1.4 2002/02/21 04:16:27 vincent Exp $ */
+/* $OpenBSD: undo.c,v 1.5 2002/02/21 04:21:05 vincent Exp $ */
/*
* Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org>
* All rights reserved.
@@ -187,6 +187,27 @@ undo_enable(int on)
}
int
+undo_add_custom(int type, LINE *lp, int offset, void *content, int size)
+{
+ struct undo_rec *rec;
+
+ if (undo_disable_flag)
+ return TRUE;
+ rec = new_undo_record();
+ rec->pos = find_offset(lp, offset);
+ rec->buf = curbp;
+ rec->type = type;
+ rec->content = content;
+ rec->region.r_linep = lp;
+ rec->region.r_offset = offset;
+ rec->region.r_size = size;
+
+ LIST_INSERT_HEAD(&undo_list, rec, next);
+
+ return TRUE;
+}
+
+int
undo_add_boundary(void)
{
struct undo_rec *rec;