mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support du abort on Ctrl-C
This commit is contained in:
parent
c07efcacc0
commit
2f32c32c7b
21
src/nnn.c
21
src/nnn.c
|
@ -330,6 +330,7 @@ static bm bookmark[BM_MAX];
|
||||||
static size_t g_tmpfplen; /* path to tmp files for copy without X, keybind help and file stats */
|
static size_t g_tmpfplen; /* path to tmp files for copy without X, keybind help and file stats */
|
||||||
static uchar g_crc;
|
static uchar g_crc;
|
||||||
static uchar BLK_SHIFT = 9;
|
static uchar BLK_SHIFT = 9;
|
||||||
|
static bool interrupted = FALSE;
|
||||||
|
|
||||||
/* For use in functions which are isolated and don't return the buffer */
|
/* For use in functions which are isolated and don't return the buffer */
|
||||||
static char g_buf[CMD_LEN_MAX] __attribute__ ((aligned));
|
static char g_buf[CMD_LEN_MAX] __attribute__ ((aligned));
|
||||||
|
@ -538,6 +539,11 @@ static uchar crc8fast(uchar const message[], size_t n)
|
||||||
return remainder;
|
return remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void signal_handler(int signum)
|
||||||
|
{
|
||||||
|
interrupted = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Messages show up at the bottom */
|
/* Messages show up at the bottom */
|
||||||
static void printmsg(const char *msg)
|
static void printmsg(const char *msg)
|
||||||
{
|
{
|
||||||
|
@ -2568,6 +2574,9 @@ static int dentfill(char *path, struct entry **dents)
|
||||||
: sb.st_blocks);
|
: sb.st_blocks);
|
||||||
} else
|
} else
|
||||||
dir_blocks += ent_blocks;
|
dir_blocks += ent_blocks;
|
||||||
|
|
||||||
|
if (interrupted)
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
|
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
|
||||||
|
@ -2646,6 +2655,9 @@ static int dentfill(char *path, struct entry **dents)
|
||||||
dir_blocks += dentp->blocks;
|
dir_blocks += dentp->blocks;
|
||||||
else
|
else
|
||||||
num_files = num_saved;
|
num_files = num_saved;
|
||||||
|
|
||||||
|
if (interrupted)
|
||||||
|
return n;
|
||||||
} else {
|
} else {
|
||||||
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
|
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
|
||||||
dir_blocks += dentp->blocks;
|
dir_blocks += dentp->blocks;
|
||||||
|
@ -2947,6 +2959,13 @@ begin:
|
||||||
}
|
}
|
||||||
|
|
||||||
populate(path, lastname);
|
populate(path, lastname);
|
||||||
|
if (interrupted) {
|
||||||
|
interrupted = FALSE;
|
||||||
|
signal(SIGINT, &signal_handler);
|
||||||
|
cfg.apparentsz = 0;
|
||||||
|
cfg.blkorder = 0;
|
||||||
|
BLK_SHIFT = 9;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LINUX_INOTIFY
|
#ifdef LINUX_INOTIFY
|
||||||
if (presel != FILTER && inotify_wd == -1) {
|
if (presel != FILTER && inotify_wd == -1) {
|
||||||
|
@ -4212,7 +4231,7 @@ int main(int argc, char *argv[])
|
||||||
cfg.restrict0b = 1;
|
cfg.restrict0b = 1;
|
||||||
|
|
||||||
/* Ignore certain signals */
|
/* Ignore certain signals */
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGINT, &signal_handler);
|
||||||
signal(SIGQUIT, SIG_IGN);
|
signal(SIGQUIT, SIG_IGN);
|
||||||
|
|
||||||
/* Test initial path */
|
/* Test initial path */
|
||||||
|
|
Loading…
Reference in a new issue