From: Michael D. Lowis Date: Tue, 18 Jul 2017 14:12:38 +0000 (-0400) Subject: minor touch-ups X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=27aaa74bae4907ab96c00ba16c56be140e398ea6;p=projs%2Ftide.git minor touch-ups --- diff --git a/TODO.md b/TODO.md index b5c6e91..cbe2cda 100644 --- 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 diff --git a/inc/edit.h b/inc/edit.h index c2323ec..36081f8 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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 { diff --git a/inc/stdc.h b/inc/stdc.h index 57d6596..3d867af 100644 --- a/inc/stdc.h +++ b/inc/stdc.h @@ -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 diff --git a/lib/exec.c b/lib/exec.c index 0c4d5bc..8cd698d 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -6,7 +6,7 @@ #include #include -#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++]));