summaryrefslogtreecommitdiff
path: root/src/main/main.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-04-29 11:03:47 +0200
committerAlbert Cervin <albert@acervin.com>2024-05-06 11:05:30 +0200
commitc42412e1643c88c81cf5b38404cc010881437fe9 (patch)
tree2650521affdaf0ba9c62f276514250f28af3129e /src/main/main.c
parentc16a45eb19e436a558d2d8723fa4fda663ed3da8 (diff)
downloaddged-c42412e1643c88c81cf5b38404cc010881437fe9.tar.gz
dged-c42412e1643c88c81cf5b38404cc010881437fe9.tar.xz
dged-c42412e1643c88c81cf5b38404cc010881437fe9.zip
OpenBSD port work
Diffstat (limited to 'src/main/main.c')
-rw-r--r--src/main/main.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/main/main.c b/src/main/main.c
index b0e408d..169716d 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -1,3 +1,4 @@
+#include <errno.h>
#include <getopt.h>
#include <locale.h>
#include <signal.h>
@@ -93,17 +94,7 @@ void reload_buffer(struct buffer *buffer) {
}
void update_file_watches(struct reactor *reactor) {
- // first, find invalid file watches and try to update them
- VEC_FOR_EACH(&g_watched_files, struct watched_file * w) {
- if (w->watch_id == INVALID_WATCH) {
- message("re-watching: %s", w->buffer->filename);
- w->watch_id =
- reactor_watch_file(reactor, w->buffer->filename, FileWritten);
- reload_buffer(w->buffer);
- }
- }
-
- // then pick up any events we might have
+ // first, pick up any events we might have
struct file_event ev;
while (reactor_next_file_event(reactor, &ev)) {
// find the buffer we need to reload
@@ -120,6 +111,16 @@ void update_file_watches(struct reactor *reactor) {
}
}
}
+
+ // then, find invalid file watches and try to update them
+ VEC_FOR_EACH(&g_watched_files, struct watched_file * w) {
+ if (w->watch_id == INVALID_WATCH) {
+ message("re-watching: %s", w->buffer->filename);
+ w->watch_id =
+ reactor_watch_file(reactor, w->buffer->filename, FileWritten);
+ reload_buffer(w->buffer);
+ }
+ }
}
static void usage() {
@@ -218,8 +219,17 @@ int main(int argc, char *argv[]) {
frame_allocator = frame_allocator_create(16 * 1024 * 1024);
struct reactor *reactor = reactor_create();
+ if (reactor == NULL) {
+ fprintf(stderr, "Failed to create event reactor: %s\n", strerror(errno));
+ return 8;
+ }
display = display_create();
+ if (display == NULL) {
+ fprintf(stderr, "Failed to set up display: %s\n", strerror(errno));
+ return 9;
+ }
+
display_clear(display);
signal(SIGWINCH, resized);