Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit b24e6225ef1846fda8a67870855ed02fc097d5c7 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Sun Dec 05 21:51:43 2021 +0000 added option to turn off colors diff --git a/README.md b/README.md index d608e9e..736c739 100644 --- a/README.md +++ b/README.md @@ -57 +57 @@ A small file manager written in C.    ## Usage   -If an argument is provided, cscroll will open the path supplied. Otherwise it will open on the current working directory. +If an argument is provided, cscroll will open the path supplied. Otherwise it will open on the current working directory. ([see 'Options'](#options))    Files will be highlighted and shown with an identifier in correspondence to the file type.   @@ -276 +277 @@ Files that are executable but have another identifier will keep the identifier b  ### Options    * `-p`: Print the path cscroll ends in. Useful for commands like `cd $(cscroll -p)` to cd into the last directory. +* `-nc`: Turn off coloring.    ### Commands   diff --git a/include/io.h b/include/io.h index 4acf2d5..ae3ff4f 100644 --- a/include/io.h +++ b/include/io.h @@ -395 +396 @@ void mark_all(void);  extern bool print_path;  extern int stdout_back;  extern size_t n_marked_files; +extern bool color;    #endif /* IO_H */ diff --git a/src/io.c b/src/io.c index 9ae2f13..feaec4d 100644 --- a/src/io.c +++ b/src/io.c @@ -126 +127 @@  bool print_path = false;  int stdout_back = 0;  size_t n_marked_files = false; +bool color = true;    void curses_init(void) {   if (print_path) { @@ -2315 +2418 @@ void curses_init(void) {   curs_set(0);   noecho();   raw(); - start_color();   - init_pair(BLUE, COLOR_BLUE, COLOR_BLACK); - init_pair(CYAN, COLOR_CYAN, COLOR_BLACK); - init_pair(GREEN, COLOR_GREEN, COLOR_BLACK); - init_pair(MAGENTA, COLOR_MAGENTA, COLOR_BLACK); - init_pair(YELLOW, COLOR_YELLOW, COLOR_BLACK); - init_pair(RED, COLOR_RED, COLOR_BLACK); - init_pair(WHITE, COLOR_WHITE, COLOR_BLACK); + if (color) { + start_color(); + + init_pair(BLUE, COLOR_BLUE, COLOR_BLACK); + init_pair(CYAN, COLOR_CYAN, COLOR_BLACK); + init_pair(GREEN, COLOR_GREEN, COLOR_BLACK); + init_pair(MAGENTA, COLOR_MAGENTA, COLOR_BLACK); + init_pair(YELLOW, COLOR_YELLOW, COLOR_BLACK); + init_pair(RED, COLOR_RED, COLOR_BLACK); + init_pair(WHITE, COLOR_WHITE, COLOR_BLACK); + }  }     diff --git a/src/main.c b/src/main.c index 79b430c..a04f327 100644 --- a/src/main.c +++ b/src/main.c @@ -147 +149 @@ int main(int argc, char ** argv) {   if (argc > 1) {   for (int i = 1; i < argc; i++) {   if (!strcmp(argv[i], "-p")) { - print_path = true; + print_path = true; + } else if (!strcmp(argv[i], "-nc")) { + color = false;   } else {   cwd = realpath(argv[i], NULL);   chdir(cwd);