]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed undo/redo coalescing of inserts
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 23 Aug 2018 01:58:31 +0000 (21:58 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 23 Aug 2018 01:58:31 +0000 (21:58 -0400)
lib/buf.c
lib/config.c
lib/job.c

index 30558219a3c3fd9bdfaa98ea54e5930d2763fb22..93dc9dc85797bd0137de65dc586be722e5757e8a 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -163,13 +163,24 @@ static void log_clear(Log** list) {
     }
 }
 
+static void dumplog(Buf* buf) {
+#if 0
+    printf("\nUndo:\n");
+    for (Log* log = buf->undo; log; log = log->next)
+        printf("    %lu-%lu '%s'\n", log->beg, log->end, log->data);
+    printf("Redo:\n");
+    for (Log* log = buf->redo; log; log = log->next)
+        printf("    %lu-%lu '%s'\n", log->beg, log->end, log->data);
+#endif
+}
+
 static void log_add(Buf* buf, size_t beg, size_t end, char* data) {
     Log* prev = buf->undo;
     log_clear(&(buf->redo));
     /* decide if this is an insert or delete */
     if (!data) {
         if (prev && !prev->data && prev->end == beg)
-            prev->end++;
+            prev->end = end;
         else
             buf->undo = mklog(beg, end, data, prev);
     } else {
@@ -188,6 +199,7 @@ static void log_add(Buf* buf, size_t beg, size_t end, char* data) {
             buf->undo = mklog(beg, end, data, prev);
         }
     }
+    dumplog(buf);
 }
 
 static void log_swap(Buf* buf, Log** src, Log** dest) {
@@ -218,6 +230,7 @@ static void log_swap(Buf* buf, Log** src, Log** dest) {
     /* push item onto redo stack */
     item->next = *dest;
     *dest = item;
+    dumplog(buf);
 }
 
 void buf_undo(Buf* buf) {
index 38a150264febd4e985657448b5f1b534c6b8c819..78f05c28c27e7ff6be92ea40c0bf6dcdbbc95bc2 100644 (file)
@@ -5,7 +5,7 @@
 #include <edit.h>
 
 #ifdef __MACH__
-    #define FONT "Verdana:size=10"
+    #define FONT "Verdana:size=11"
     #define LNSPACE 0
 #else
     #define FONT "Verdana:size=11"
index 7d8f57c0309681bd1f0c2a5fecf390cf5fd0362f..1ed6f902c9b41a0a9a49905d0135807e8700a907 100644 (file)
--- a/lib/job.c
+++ b/lib/job.c
@@ -27,6 +27,7 @@ static void pipe_read(Job* job) {
     long nread = read(job->fd, buffer, sizeof(buffer)-1);
     if (nread <= 0) {
         job->readfn = NULL;
+        view_selprev(pipedata->dest);
     } else if (nread > 0) {
         buffer[nread] = '\0';
         view_putstr(pipedata->dest, buffer);