From a3bc4b299c707e62c0543a134c4cc27af4311284 Mon Sep 17 00:00:00 2001 From: mananapr Date: Sat, 26 Jan 2019 00:42:24 +0530 Subject: [PATCH] Added checks for qsort, fixed some typos in README, cleaned up config file --- README.md | 2 +- cf.c | 9 ++++++++- config.h | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 994d172..0fe7db9 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ or press `m` in `cfiles` to add new bookmarks. If `$XDG_CACHE_HOME` is not set, then `$HOME/.cache` is used. ## Image Previews -`cfiles` uses `w3mimgdisplay` to generate imagepreviews. To setup imagepreviews, move the `displayimg` and `clearimg` scripts to wherever you like and the set the appropriate path in `config,h`. +`cfiles` uses `w3mimgdisplay` to generate image previews. To setup image previews, move the `displayimg` and `clearimg` scripts to wherever you like and the set the appropriate path in `config.h`. You may have to modify the scripts a little, about which you can read [here](https://wiki.vifm.info/index.php/How_to_preview_images). ## Why C? diff --git a/cf.c b/cf.c index 6bdcc14..b3a5ec9 100644 --- a/cf.c +++ b/cf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -602,6 +603,10 @@ void getImgPreview(char *filepath, int maxy, int maxx) execl(DISPLAYIMG,DISPLAYIMG,arg1,arg2,arg3,arg4,filepath,(char *)NULL); exit(1); } + else + { + signal(SIGCHLD, SIG_IGN); + } } @@ -1160,7 +1165,9 @@ int main(int argc, char* argv[]) allocSize = snprintf(NULL,0,"%s",dir); sort_dir = malloc(allocSize+1); strncpy(sort_dir,dir,allocSize+1); - qsort(directories, len, sizeof (char*), compare); + + if( len > 0 ) + qsort(directories, len, sizeof (char*), compare); // In case the last file is selected and it get's removed or moved if(selection > len-1) diff --git a/config.h b/config.h index ad78f74..4c9ba8e 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,7 @@ #ifndef CONFIG #define CONFIG + /* cfiles settings */ @@ -11,22 +12,26 @@ // Set to 0 if you want to disable borders #define SHOW_BORDERS 1 -// Program usd to open non-text file (Eg: `xdg-open` or `thunar`) +// Program used to open non-text file (Eg: `xdg-open` or `thunar`) #define FILE_OPENER "/usr/bin/xdg-open" // Display Image Script #define DISPLAYIMG "/home/manan/Scripts/displayimg" + // Clear Image Preview Script #define CLEARIMG "/home/manan/Scripts/clearimg" + /* Color Settings */ // Shell Color Number to use for directories #define DIR_COLOR 2 + // Shell Color Number to use for file count which is displayed in the statusbar #define STATUS_FILECOUNT_COLOR 1 + // Shell Color Number to use for selected file which is displayed in the statusbar #define STATUS_SELECTED_COLOR 6