From: Michael D. Lowis Date: Tue, 3 Apr 2018 15:42:09 +0000 (-0400) Subject: simplified log entry data type X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=766f30b0874d09c59fe0579b5b7d1b97014c4b29;p=projs%2Ftide.git simplified log entry data type --- diff --git a/inc/edit.h b/inc/edit.h index f055231..2c67658 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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; diff --git a/lib/buf.c b/lib/buf.c index 62afe92..585ce83 100644 --- 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); } }