]> git.mdlowis.com Git - projs/tide.git/commitdiff
simplified log entry data type
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 3 Apr 2018 15:42:09 +0000 (11:42 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 3 Apr 2018 15:42:09 +0000 (11:42 -0400)
inc/edit.h
lib/buf.c

index f055231529318a2acfb55e8416abc4ded9221ed5..2c67658162d066b789da8fc985e7b726b6ade4c8 100644 (file)
@@ -10,20 +10,10 @@ char* strmcat(char* first, ...);
  *****************************************************************************/
 /* undo/redo list item */
 typedef struct Log {
-    struct Log* next;   /* pointer to next operation in the stack */
-    bool insert;        /* whether this operation was an insert or delete */
-    uint transid;       /* transaction id used to group related edits together */
-    union {
-        struct {
-            size_t beg; /* offset in the file where insertion started */
-            size_t end; /* offset in the file where insertion ended */
-        } ins;
-        struct {
-            size_t off;  /* offset in the file where the deletion occurred */
-            size_t len;  /* number of runes deleted */
-            char* runes; /* array of runes containing deleted content */
-        } del;
-    } data;
+    struct Log* next; /* pointer to next operation in the stack */
+    size_t beg;       /* beginning of affected region */
+    size_t end;       /* end of affected region*/
+    char* data;       /* pointer to deleted character data */
 } Log;
 
 /* cursor/selection representation */
@@ -45,7 +35,6 @@ typedef struct {
     Log* undo;        /* undo list */
     Log* redo;        /* redo list */
     bool modified;    /* tracks whether the buffer has been modified */
-    uint transid;     /* tracks the last used transaction id for log entries */
     Sel selection;    /* the currently selected text */
 } Buf;
 
index 62afe92ac2ac2b1462432eebc26590bf8d246090..585ce838b0efb6f35e6a09cd941ad4668e81dc9e 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -231,9 +231,6 @@ void buf_undo(Buf* buf, Sel* sel) {
 void buf_redo(Buf* buf, Sel* sel) {
 }
 
-void buf_loglock(Buf* buf) {
-}
-
 void buf_logclear(Buf* buf) {
     log_clear(&(buf->redo));
     log_clear(&(buf->undo));
@@ -249,8 +246,8 @@ static void log_clear(Log** list) {
     while (*list) {
         Log* deadite = *list;
         *list = (*list)->next;
-        if (!deadite->insert)
-            free(deadite->data.del.runes);
+        if (deadite->data)
+            free(deadite->data);
         free(deadite);
     }
 }