Skip to content

Commit

Permalink
Remove repetitive code
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Aug 14, 2021
1 parent 0b07b77 commit 7cbc79a
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}).
Expand Down Expand Up @@ -3063,10 +3070,7 @@ static int nextsel(int presel)
break;

if (event->mask & INOTIFY_MASK) {
c = CONTROL('L');
if (nselected && isselfileempty())
clearselection();
DPRINTF_S("issue refresh");
c = handle_event();
break;
}
}
Expand All @@ -3079,18 +3083,12 @@ static int nextsel(int presel)

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;
Expand Down

0 comments on commit 7cbc79a

Please sign in to comment.