Added option to toggle visibility hidden files

pull/2/head
mananapr 6 years ago
parent 4d51e33274
commit 08026df90c

@ -43,6 +43,7 @@ To install, simply move the generated executable to a directory that is in your
| <kbd>dd</kbd> | Move files from selection list to trash |
| <kbd>dD</kbd> | Remove selected files |
| <kbd>i</kbd> | View mediainfo and general info |
| <kbd>.</kbd> | Toggle hidden files |
| <kbd>r</kbd> | Reload |
| <kbd>q</kbd> | Quit |
@ -81,7 +82,7 @@ a similar UI.
- [x] Add file previews
- [x] Improve file previews
- [x] Add config file for easy user customizability
- [ ] Add more options in config file
- [x] Add more options in config file
- [ ] Add bookmarks
- [ ] Add ability to run external scripts
- [ ] Refactor Code

36
cf.c

@ -83,6 +83,9 @@ int searchFlag = 0;
// Flag is set to 1 when user goes up a directory
int backFlag = 0;
// Flag to display hidden files
int hiddenFlag = SHOW_HIDDEN;
// Stores the last token in the path. For eg, it will store 'a' is path is /b/a
char *last;
@ -459,9 +462,14 @@ int getNumberofFiles(char* directory)
}
while ((pDirent = readdir(pDir)) != NULL) {
// Skip hidden files
if(pDirent->d_name[0] != '.' )
// Skip . and ..
if( strcmp(pDirent->d_name,".") != 0 && strcmp(pDirent->d_name,"..") != 0 )
{
if( pDirent->d_name[0] == '.' )
if( hiddenFlag == 0 )
continue;
len++;
}
}
return len;
}
@ -482,9 +490,14 @@ void getFiles(char* directory, char* target[])
}
while ((pDirent = readdir(pDir)) != NULL) {
// Skip hidden files
if(pDirent->d_name[0] != '.')
// Skip . and ..
if( strcmp(pDirent->d_name,".") != 0 && strcmp(pDirent->d_name,"..") != 0 )
{
if( pDirent->d_name[0] == '.' )
if( hiddenFlag == 0 )
continue;
target[i++] = strdup(pDirent->d_name);
}
}
closedir (pDir);
@ -957,7 +970,10 @@ int main(int argc, char* argv[])
// Search in the same directory
case KEY_SEARCHDIR:
sprintf(cmd,"cd %s && ls | fzf",dir);
if( hiddenFlag == 1 )
sprintf(cmd,"cd %s && ls -a | fzf",dir);
else
sprintf(cmd,"cd %s && ls | fzf",dir);
endwin();
if((fp = popen(cmd,"r")) == NULL)
{
@ -1104,6 +1120,16 @@ int main(int argc, char* argv[])
getVidPreview(next_dir,maxy,maxx/2+2);
break;
// Enable/Disable hidden files
case KEY_TOGGLEHIDE:
if( hiddenFlag == 1 )
hiddenFlag = 0;
else
hiddenFlag = 1;
start = 0;
selection = 0;
break;
// Clear Preview Window
case KEY_RELOAD:
clearFlag = 1;

@ -1,6 +1,14 @@
#ifndef CONFIG
#define CONFIG
/*
cfiles settings
*/
// Set to 1 if you want to see hidden files on startup
#define SHOW_HIDDEN 0
/*
Change your keybindings in this section
*/
@ -62,6 +70,9 @@
// Open Shell
#define KEY_SHELL 'S'
// Toggle Hiddem Files
#define KEY_TOGGLEHIDE '.'
// Reload
#define KEY_RELOAD 'r'

Loading…
Cancel
Save