]> git.mdlowis.com Git - projs/tide.git/commitdiff
refactored undo/redo log api
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 26 Oct 2019 03:39:18 +0000 (23:39 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 26 Oct 2019 03:39:18 +0000 (23:39 -0400)
inc/edit.h
src/lib/buf.c
src/lib/editlog.c

index c9529e9d5ff34e943c1732f6d5f4d96f0b71beb9..41d1447fea743ec73651a86351b13ee1f2fbe0c1 100644 (file)
@@ -56,10 +56,10 @@ char gapbuf_getb(GapBuf* buf, size_t off);
 void gapbuf_putb(GapBuf* buf, char b, Sel* p_sel);
 void gapbuf_del(GapBuf* buf, size_t off, size_t len);
 
-void editlog_seqstart(Buf* log);
-void editlog_seqstop(Buf* log);
-void editlog_clear(Buf* log);
-void editlog_lastins(Buf* buf, Sel* p_sel);
+void editlog_seqstart(EditLog* log);
+void editlog_seqstop(EditLog* log);
+void editlog_clear(EditLog* log);
+void editlog_lastins(EditLog* log, Sel* p_sel);
 void editlog_undo(Buf* log);
 void editlog_redo(Buf* log);
 void editlog_add(Buf* buf, size_t beg, size_t end, char* data);
index 08b84ff2eae5d39d6dd9d354f230871ea0783bfc..055adb8cc382c553f0fc4485ebb9696b02ee735e 100644 (file)
@@ -234,22 +234,22 @@ int buf_save(Buf* buf, char* path)
  ******************************************************************************/
 void buf_logstart(Buf* buf)
 {
-    editlog_seqstart(buf);
+    editlog_seqstart(&(buf->log));
 }
 
 void buf_logstop(Buf* buf)
 {
-    editlog_seqstop(buf);
+    editlog_seqstop(&(buf->log));
 }
 
 void buf_logclear(Buf* buf)
 {
-    editlog_clear(buf);
+    editlog_clear(&(buf->log));
 }
 
 void buf_lastins(Buf* buf)
 {
-    editlog_lastins(buf, &(buf->selection));
+    editlog_lastins(&(buf->log), &(buf->selection));
 }
 
 void buf_undo(Buf* buf)
index d570343a8d4b192cfdec039c336a7cb740ebd475..c7a28d74f624dcc2a91ad932b670713f478cc294 100644 (file)
@@ -78,32 +78,32 @@ static void log_clear(Log** list)
     }
 }
 
-void editlog_seqstart(Buf* buf)
+void editlog_seqstart(EditLog* log)
 {
-    require(buf != NULL);
-    buf->log.transid = abs(buf->log.transid);
+    require(log != NULL);
+    log->transid = abs(log->transid);
 }
 
-void editlog_seqstop(Buf* buf)
+void editlog_seqstop(EditLog* log)
 {
-    require(buf != NULL);
-    if (buf->log.transid > 0)
+    require(log != NULL);
+    if (log->transid > 0)
     {
-        buf->log.transid = -(buf->log.transid + 1);
+        log->transid = -(log->transid + 1);
     }
 }
 
-void editlog_clear(Buf* buf)
+void editlog_clear(EditLog* log)
 {
-    require(buf != NULL);
-    log_clear(&(buf->log.redo));
-    log_clear(&(buf->log.undo));
+    require(log != NULL);
+    log_clear(&(log->redo));
+    log_clear(&(log->undo));
 }
 
-void editlog_lastins(Buf* buf, Sel* p_sel)
+void editlog_lastins(EditLog* elog, Sel* p_sel)
 {
-    require(buf != NULL);
-    Log* log = buf->log.undo;
+    require(elog != NULL);
+    Log* log = elog->undo;
     if (log)
     {
         Sel sel = { .beg = log->beg, .end = log->end };