Added option to customize colors

pull/19/head
mananapr 5 years ago
parent 8906b222e7
commit 0261c68f04

84
cf.c

@ -5,7 +5,7 @@
| (__| _| | | __/\__ \
\___|_| |_|_|\___||___/
*/
*/
/////////////
@ -62,7 +62,7 @@ struct passwd *info;
Base directory to be used for sorting
`dir` for current_win
`next_dir` for preview_win
*/
*/
char sort_dir[250];
// Stores the path for the cache directory
@ -127,7 +127,7 @@ int startx, starty, maxx, maxy;
/*
Initializes the program
Sets the relevant file paths
*/
*/
void init()
{
// Get UID of user
@ -164,23 +164,23 @@ void init()
/*
Initializes ncurses
*/
*/
void curses_init()
{
initscr();
noecho();
curs_set(0);
start_color();
init_pair(1, 2, 0);
init_pair(2, 1, 0);
init_pair(3, 6, 0);
init_pair(1, DIR_COLOR, 0);
init_pair(2, STATUS_FILECOUNT_COLOR, 0);
init_pair(3, STATUS_SELECTED_COLOR, 0);
init_pair(4, 0, 0);
}
/*
Checks if `path` is a file or directory
*/
*/
int is_regular_file(const char *path)
{
struct stat path_stat;
@ -191,7 +191,7 @@ int is_regular_file(const char *path)
/*
Checks if a file exists or not
*/
*/
int fileExists(char *file)
{
if( access( file, F_OK ) != -1 )
@ -203,7 +203,7 @@ int fileExists(char *file)
/*
Gets the last token from temp_dir by using `tokenizer` as a delimeter
*/
*/
void getLastToken(char *tokenizer)
{
pch = strtok(temp_dir, tokenizer);
@ -217,7 +217,7 @@ void getLastToken(char *tokenizer)
/*
Get number of bookmarks
*/
*/
int getNumberOfBookmarks()
{
FILE *fp = fopen(bookmarks_path, "r");
@ -238,7 +238,7 @@ int getNumberOfBookmarks()
/*
Displays the bookmarks in `keys_win`
*/
*/
void displayBookmarks()
{
FILE *fp = fopen(bookmarks_path, "r");
@ -257,7 +257,7 @@ void displayBookmarks()
/*
Opens the bookmark denoted by `secondKey`
*/
*/
void openBookmarkDir(char secondKey)
{
FILE *fp = fopen(bookmarks_path, "r");
@ -281,7 +281,7 @@ void openBookmarkDir(char secondKey)
/*
Checks if bookmark denoted with `bookmark` exists
*/
*/
int bookmarkExists(char bookmark)
{
FILE *fp = fopen(bookmarks_path, "r");
@ -305,7 +305,7 @@ int bookmarkExists(char bookmark)
/*
Adds new bookmark
*/
*/
void addBookmark(char bookmark, char *path)
{
FILE *fp = fopen(bookmarks_path, "a+");
@ -316,7 +316,7 @@ void addBookmark(char bookmark, char *path)
/*
Creates a new window with dimensions `height` and `width` starting at `starty` and `startx`
*/
*/
WINDOW *create_newwin(int height, int width, int starty, int startx)
{
WINDOW *local_win;
@ -327,7 +327,7 @@ WINDOW *create_newwin(int height, int width, int starty, int startx)
/*
For qsort
*/
*/
int compare (const void * a, const void * b )
{
// They store the full paths of the arguments
@ -349,7 +349,7 @@ int compare (const void * a, const void * b )
/*
Gets file MIME
*/
*/
void getMIME(char *filepath, char mime[10])
{
char cmd[250];
@ -369,7 +369,7 @@ void getMIME(char *filepath, char mime[10])
/*
Opens a file using xdg-open
*/
*/
void openFile(char *filepath)
{
char mime[10];
@ -394,7 +394,7 @@ void openFile(char *filepath)
/*
Checks if path is in clipboard
*/
*/
int checkClipboard(char *filepath)
{
FILE *f = fopen(clipboard_path, "r");
@ -419,7 +419,7 @@ int checkClipboard(char *filepath)
/*
Writes to clipboard
*/
*/
void writeClipboard(char *filepath)
{
FILE *f = fopen(clipboard_path,"a+");
@ -436,7 +436,7 @@ void writeClipboard(char *filepath)
/*
Removes entry from clipboard
*/
*/
void removeClipboard(char *filepath)
{
char cmd[250];
@ -448,7 +448,7 @@ void removeClipboard(char *filepath)
/*
Empties Clipboard
*/
*/
void emptyClipboard()
{
if( remove(clipboard_path) == -1)
@ -460,7 +460,7 @@ void emptyClipboard()
/*
Gets previews of images
*/
*/
void getImgPreview(char *filepath, int maxy, int maxx)
{
pid_t pid;
@ -515,7 +515,7 @@ void getImgPreview(char *filepath, int maxy, int maxx)
/*
Gets previews of text in files
*/
*/
void getTextPreview(char *filepath, int maxy, int maxx)
{
// Don't Generate Preview if file size > 50MB
@ -542,7 +542,7 @@ void getTextPreview(char *filepath, int maxy, int maxx)
/*
Gets previews of video files
*/
*/
void getVidPreview(char *filepath, int maxy, int maxx)
{
char buf[250];
@ -558,7 +558,7 @@ void getVidPreview(char *filepath, int maxy, int maxx)
/*
Gets previews of archives
*/
*/
void getArchivePreview(char *filepath, int maxy, int maxx)
{
char buf[250];
@ -571,7 +571,7 @@ void getArchivePreview(char *filepath, int maxy, int maxx)
/*
Gets previews of video files (Dummy)
*/
*/
void getDummyVidPreview(char *filepath, int maxy, int maxx)
{
wmove(preview_win,1,2);
@ -582,7 +582,7 @@ void getDummyVidPreview(char *filepath, int maxy, int maxx)
/*
Sets `temp_dir` to filepath and then stores the extension in `last`
*/
*/
void getFileType(char *filepath)
{
strcpy(temp_dir, filepath);
@ -592,7 +592,7 @@ void getFileType(char *filepath)
/*
Checks `last` for extension and then calls the appropriate preview function
*/
*/
void getPreview(char *filepath, int maxy, int maxx)
{
getFileType(filepath);
@ -612,7 +612,7 @@ void getPreview(char *filepath, int maxy, int maxx)
/*
Gets path of parent directory
*/
*/
void getParentPath(char *path)
{
char *p;
@ -629,7 +629,7 @@ void getParentPath(char *path)
/*
Returns number of files in `char* directory`
*/
*/
int getNumberofFiles(char* directory)
{
int len=0;
@ -658,7 +658,7 @@ int getNumberofFiles(char* directory)
/*
Stores all the file names in `char* directory` to `char *target[]`
*/
*/
int getFiles(char* directory, char* target[])
{
int i = 0;
@ -688,7 +688,7 @@ int getFiles(char* directory, char* target[])
/*
Copy files in clipboard to `present_dir`
*/
*/
void copyFiles(char *present_dir)
{
FILE *f = fopen(clipboard_path, "r");
@ -712,7 +712,7 @@ void copyFiles(char *present_dir)
/*
Removes files in clipboard
*/
*/
void removeFiles()
{
FILE *f = fopen(clipboard_path, "r");
@ -736,7 +736,7 @@ void removeFiles()
/*
Rename files in clipboard
*/
*/
void renameFiles()
{
// For opening clipboard and temp_clipboard
@ -794,7 +794,7 @@ void renameFiles()
/*
Move files in clipboard to `present_dir`
*/
*/
void moveFiles(char *present_dir)
{
FILE *f = fopen(clipboard_path, "r");
@ -819,7 +819,7 @@ void moveFiles(char *present_dir)
/*
Creates current_win, preview_win and status_win
*/
*/
void init_windows()
{
current_win = create_newwin(maxy, maxx/2+3, 0, 0);
@ -830,7 +830,7 @@ void init_windows()
/*
Displays current status in the status bar
*/
*/
void displayStatus()
{
wmove(status_win,1,1);
@ -847,7 +847,7 @@ void displayStatus()
/*
Displays message on status bar
*/
*/
void displayAlert(char *message)
{
wclear(status_win);
@ -859,7 +859,7 @@ void displayAlert(char *message)
/*
*/
*/
void refreshWindows()
{
if(SHOW_BORDERS == 1)
@ -874,7 +874,7 @@ void refreshWindows()
/*
Checks if some flags are enabled and handles them accordingly
*/
*/
void handleFlags(char** directories)
{
// Clear the preview_win

@ -11,6 +11,17 @@
// Set to 0 if you want to disable borders
#define SHOW_BORDERS 1
/*
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
/*
Change your keybindings in this section

Loading…
Cancel
Save