summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-06-16 12:19:17 -0400
committerpommicket <pommicket@gmail.com>2025-06-16 12:19:29 -0400
commit55b42079488e0c3e8aaf85828ad028491934f9d3 (patch)
treee69c7ec5fc8ba7ec82f1f8ddef692bc209b46d7b /main.c
parent5ad0bd2422e5b8bb23e50256837ae0c2538a85e0 (diff)
better inotify
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 10 insertions, 0 deletions
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);