]> Sergey Matveev's repositories - nnn.git/commitdiff
Remove repetitive code
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Aug 2021 13:57:24 +0000 (19:27 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Aug 2021 13:57:24 +0000 (19:27 +0530)
src/nnn.c

index 7deaf76aa7e43ee564a3afde88cf1aaa3bd0a4e0..ee870b6eee28dc116d3fff2308061aa3b9a170d5 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2979,6 +2979,13 @@ static int handle_alt_key(wint_t *wch)
        return r;
 }
 
+static inline int handle_event(void)
+{
+       if (nselected && isselfileempty())
+               clearselection();
+       return CONTROL('L');
+}
+
 /*
  * Returns SEL_* if key is bound and 0 otherwise.
  * Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}).
@@ -3063,10 +3070,7 @@ try_quit:
                                                break;
 
                                        if (event->mask & INOTIFY_MASK) {
-                                               c = CONTROL('L');
-                                               if (nselected && isselfileempty())
-                                                       clearselection();
-                                               DPRINTF_S("issue refresh");
+                                               c = handle_event();
                                                break;
                                        }
                                }
@@ -3079,18 +3083,12 @@ try_quit:
 
                        memset((void *)event_data, 0x0, sizeof(struct kevent) * NUM_EVENT_SLOTS);
                        if (kevent(kq, events_to_monitor, NUM_EVENT_SLOTS,
-                                  event_data, NUM_EVENT_FDS, &gtimeout) > 0) {
-                               c = CONTROL('L');
-                               if (nselected && isselfileempty())
-                                       clearselection();
-                       }
+                                  event_data, NUM_EVENT_FDS, &gtimeout) > 0)
+                               c = handle_event();
                }
 #elif defined(HAIKU_NM)
-               if (!cfg.blkorder && haiku_nm_active && (idle & 1) && haiku_is_update_needed(haiku_hnd)) {
-                       c = CONTROL('L');
-                       if (nselected && isselfileempty())
-                               clearselection();
-               }
+               if (!cfg.blkorder && haiku_nm_active && (idle & 1) && haiku_is_update_needed(haiku_hnd))
+                       c = handle_event();
 #endif
        } else
                idle = 0;