From 55b42079488e0c3e8aaf85828ad028491934f9d3 Mon Sep 17 00:00:00 2001 From: pommicket Date: Mon, 16 Jun 2025 12:19:17 -0400 Subject: better inotify --- main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 3ca8029..b8e8528 100644 --- a/main.c +++ b/main.c @@ -383,6 +383,7 @@ int main(int argc, char **argv) { if (!ted) { die("Not enough memory available to run ted."); } + ted->inotify_fd = -1; ted->last_save_time = -1e50; ted->pid = process_get_id(); ted_update_time(ted); @@ -604,6 +605,12 @@ int main(int argc, char **argv) { PROFILE_TIME(fonts_end) PROFILE_TIME(create_start) + #if HAS_INOTIFY + ted->inotify_fd = inotify_init1(IN_CLOEXEC | IN_NONBLOCK); + if (ted->inotify_fd == -1) { + perror("inotify_init1"); + } + #endif { TextBuffer *lbuffer = ted->line_buffer = line_buffer_new(ted); if (!lbuffer || buffer_has_error(lbuffer)) @@ -901,6 +908,9 @@ int main(int argc, char **argv) { // check if active buffer should be reloaded { TextBuffer *active_buffer = ted->active_buffer; + #if HAS_INOTIFY + ted_check_inotify(ted); + #endif if (active_buffer && buffer_externally_changed(active_buffer)) { if (buffer_settings(active_buffer)->auto_reload) buffer_reload(active_buffer); -- cgit v1.2.3