*****************************************************************************/
/* 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 */
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;
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));
while (*list) {
Log* deadite = *list;
*list = (*list)->next;
- if (!deadite->insert)
- free(deadite->data.del.runes);
+ if (deadite->data)
+ free(deadite->data);
free(deadite);
}
}