* 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
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 */
} 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 {
#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
#include <unistd.h>
#include <sys/wait.h>
-#define PIPE_READ 0
+#define PIPE_READ 0
#define PIPE_WRITE 1
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 */
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++]));