diff options
author | Vincent Labrecque <vincent@cvs.openbsd.org> | 2002-02-21 04:21:06 +0000 |
---|---|---|
committer | Vincent Labrecque <vincent@cvs.openbsd.org> | 2002-02-21 04:21:06 +0000 |
commit | 366edcbbc557ff4038e8308cbe066b3fbe320610 (patch) | |
tree | 7cf03d42329057fdd2ad12e6bf74876053bf511b /usr.bin/mg | |
parent | fe4c5b87b5ae9ee2fd922a008c834af5f671fc45 (diff) |
Save undo records for newline insertions.
That makes mg behave more like GNU emacs.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/line.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/undo.c | 23 |
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; |