-/* Debug Telemetry
- *****************************************************************************/
-void telem_send(char* fmt, ...);
-
/* Buffer management functions
*****************************************************************************/
/* undo/redo list item */
--- /dev/null
+/*
+ Helper functions for reading and writing file descriptors as well as outputting telemetry data.
+*/
+void telem_send(char* fmt, ...);
+long writefd(int fd, char* data, long towrite);
void x11_mkwin(XConf* x, int width, int height, int evmask);
void x11_mkdialog(XConf* x, int width, int height, int evmask);
-void x11_process_events(XConf* x);
+bool x11_process_events(XConf* x);
void x11_event_loop(XConf* x, void (*redraw)(XConf* x));
int x11_getptr(XConf* x, int* ptrx, int* ptry);
uint32_t x11_getkey(XConf* x, XEvent* e);
#include <stdc.h>
+#include <io.h>
#include <regex.h>
#include <sys/stat.h>
#include <sys/wait.h>
--- /dev/null
+char* ARGV0 = NULL;
\ No newline at end of file
#include <dbc.h>
#include <utf.h>
#include <edit.h>
+#include <io.h>
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
buf->gapend = buf->bufend;
}
-static long writefd(int fd, char* data, long towrite)
-{
- require(fd >= 0);
- long nwrite = 0;
- while (towrite && ((nwrite = write(fd, data, towrite)) > 0))
- {
- data += nwrite;
- towrite -= nwrite;
- }
- return nwrite;
-}
-
long gapbuf_save(GapBuf* buf, char* path)
{
require(buf != NULL);
buf->bufend = buf->bufstart + buf->bufsize;
buf->gapstart = buf->bufstart;
buf->gapend = buf->bufend;
+
/* Read the file into the buffer */
while (sb.st_size && (nread = read(fd, buf->gapstart, sb.st_size)) > 0)
buf->gapstart += nread, sb.st_size -= nread;
#include <utf.h>
#include <edit.h>
#include <win.h>
+#include <io.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/types.h>
#include <pwd.h>
+#include <io.h>
static int TelemFd = -1;
static char TelemBuf[16384];
-static long writefd(int fd, char* data, long towrite)
-{
- long nwrite = 0;
- while (towrite && ((nwrite = write(fd, data, towrite)) > 0))
- {
- data += nwrite;
- towrite -= nwrite;
- }
- return nwrite;
-}
-
static int open_telem(char* path)
{
static unsigned long prev = 0;
--- /dev/null
+#include <io.h>
+
+long writefd(int fd, char* data, long towrite)
+{
+ long nwrite = 0;
+ while (towrite && ((nwrite = write(fd, data, towrite)) > 0))
+ {
+ data += nwrite;
+ towrite -= nwrite;
+ }
+ return nwrite;
+}
#include <x11.h>
#include <utf.h>
+#include <io.h>
#include <locale.h>
#include <signal.h>
#include <sys/types.h>
}
}
-void x11_process_events(XConf* x)
+bool x11_process_events(XConf* x)
{
+ bool has_event = false;
int nevents;
/* reap zombie background processes */
for (int status; waitpid(-1, &status, WNOHANG) > 0;);
XGetMotionEvents(x->display, x->self, CurrentTime, CurrentTime, &nevents);
for (XEvent e; XPending(x->display);)
{
+ has_event = true;
XNextEvent(x->display, &e);
update_state(x, &e);
if (!XFilterEvent(&e, None) && x->eventfns[e.type])
{
+ telem_send("EV_HANDLE(type: %d)\n", e.type);
(x->eventfns[e.type])(x, &e);
}
+ else
+ {
+ telem_send("EV_IGNORE(type: %d)\n", e.type);
+ }
}
}
+ return has_event;
}
void x11_event_loop(XConf* x, void (*redraw)(XConf* x))
#include <edit.h>
#include <win.h>
#include <x11.h>
+#include <io.h>
#include <draw.h>
#include <locale.h>
#include <sys/wait.h>
{
/* redraw if we have changes or if we have input from a job */
x11_process_events(&X);
- if (!job) xredraw(&X);
+ if (x11_process_events(&X) || !job)
+ {
+ xredraw(&X);
+ }
}
void win_init(void)