]> git.mdlowis.com Git - projs/tide.git/commitdiff
minor touch-ups
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 18 Jul 2017 14:12:38 +0000 (10:12 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 18 Jul 2017 14:12:38 +0000 (10:12 -0400)
TODO.md
inc/edit.h
inc/stdc.h
lib/exec.c

diff --git a/TODO.md b/TODO.md
index b5c6e91e6eb9ed365e1fcb09db12ee81c505b62b..cbe2cdaed3f32a384e3565d7db151e8c77432439 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -4,7 +4,6 @@ Up Next:
 
 * Send tag to send commands or data to the subprocess
 * Middle click executes send when in command mode and edit region
-* AutoSave feature?
 
 * moving from tags to the gutter does not transfer focus to edit region
 * implement transaction control in buf.c
index c2323ecfbcfbef043ada7520560a8564808272e4..36081f82cbe9efd2ceeedccdbd2ebb2f821f0a4c 100644 (file)
@@ -28,7 +28,6 @@ typedef void (*event_cbfn_t)(int fd, void* data);
 bool event_poll(int ms);
 void event_watchfd(int fd, int iodir, event_cbfn_t fn, void* data);
 
-
 /* Buffer management functions
  *****************************************************************************/
 /* undo/redo list item */
@@ -160,17 +159,17 @@ typedef struct {
 } Row;
 
 typedef struct {
-    bool sync_needed;   /* whether the view needs to be synced with cursor */
-    bool sync_center;   /* cursor should be centered on screen if possible */
-    bool sync_lines;    /* whether the line numbers should be recalculated */
-    size_t nrows;       /* number of rows in the view */
-    size_t ncols;       /* number of columns in the view */
-    Row** rows;         /* array of row data structures */
     Buf buffer;         /* the buffer used to populate the view */
     Sel selection;      /* range of currently selected text */
     size_t prev_csr;    /* previous cursor location */
+    size_t nrows;       /* number of rows in the view */
+    size_t ncols;       /* number of columns in the view */
+    Row** rows;         /* array of row data structures */
     SyntaxSpan* spans;  /* list of colored regions */
     int clrnor, clrsel; /* text color pairs for normal and selected text */
+    bool sync_needed;   /* whether the view needs to be synced with cursor */
+    bool sync_center;   /* cursor should be centered on screen if possible */
+    bool sync_lines;    /* whether the line numbers should be recalculated */
 } View;
 
 enum {
index 57d65962817a9754cee6c534bb2fd664163d7081..3d867aff8af8a0f97c468e78d9ddda3041112fc5 100644 (file)
@@ -195,3 +195,13 @@ static inline char* _getopt_(int* p_argc, char*** p_argv) {
     #define static_assert(expr) \
         typedef char unique_id[( expr )?1:-1]
 #endif
+
+#ifndef min
+    #define min(x,y) \
+        ((x) < (y) ? (x) : (y))
+#endif
+
+#ifndef max
+    #define max(x,y) \
+        ((x) > (y) ? (x) : (y))
+#endif
index 0c4d5bc3780bd50024ba1d7b9dffcec16b16cb51..8cd698d78116ab291c8b602150914ccfbcc80772 100644 (file)
@@ -6,7 +6,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 
-#define PIPE_READ 0
+#define PIPE_READ  0
 #define PIPE_WRITE 1
 
 typedef struct {
@@ -19,7 +19,7 @@ typedef struct {
 typedef struct Job Job;
 
 typedef struct {
-    Job* job;     /* pointer to the job teh receiver belongs to */
+    Job* job;     /* pointer to the job the receiver belongs to */
     View* view;   /* destination view */
     size_t beg;   /* start of output */
     size_t count; /* number of bytes written */
@@ -173,15 +173,9 @@ static void recv_data(int fd, void* data) {
     if (fd >= 0) {
         long i = 0, nread = read(fd, buffer, sizeof(buffer));
         if (nread > 0) {
-            if (!rcvr->count) {
-                if (sel.end < sel.beg) {
-                    size_t temp = sel.beg;
-                    sel.beg = sel.end, sel.end = temp;
-                }
-                rcvr->beg = sel.beg = sel.end = buf_change(buf, sel.beg, sel.end);
-                view->selection = sel;
-            }
-            for (; i < nread;) {
+            if (!rcvr->count)
+                rcvr->beg = min(sel.beg, sel.end);
+            while (i < nread) {
                 Rune r;
                 size_t len = 0;
                 while (!utf8decode(&r, &len, buffer[i++]));