Thumbnail

rani/cscroll.git

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

commit c878a4b55fb7fec177cfd188c632cba2ac068a60 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Thu Jan 06 17:03:45 2022 +0000 added 'color' option diff --git a/include/dir.h b/include/dir.h index 643c17a..8b2952f 100644 --- a/include/dir.h +++ b/include/dir.h @@ -457 +456 @@ extern struct dir_entry_t ** dir_entries;  // current working directory  extern char * cwd;   -extern bool show_dot_files;  extern bool permission_denied;    #endif /* DIR_H */ diff --git a/include/io.h b/include/io.h index 278e907..b9608e9 100644 --- a/include/io.h +++ b/include/io.h @@ -46 +48 @@  #include <stdbool.h>  #include <stdio.h>   +#include "dir.h" +  #define NO_IDENT 0     @@ -3711 +3911 @@ char * prompt(char *, char **);  char * curses_getline(char *);  void unmark_all(void);  void mark_all(void); +void set_color(void);      extern bool print_path;  extern int stdout_back;  extern size_t n_marked_files; -extern bool color;    #endif /* IO_H */ diff --git a/include/opts.h b/include/opts.h index 0d4dddb..7626a7d 100644 --- a/include/opts.h +++ b/include/opts.h @@ -55 +57 @@      extern bool show_icons; +extern bool show_dot_files; +extern bool color;    #endif diff --git a/src/commands.c b/src/commands.c index f8293f8..2550db4 100644 --- a/src/commands.c +++ b/src/commands.c @@ -66 +67 @@  #include <regex.h>  #include <sys/wait.h>   +#include "io.h"  #include "dir.h"  #include "opts.h"  #include "commands.h" @@ -14110 +14212 @@ void run_cmd(char * cmd) {      void set(char * v) { - if (0) - ; + if (!strcmp(v, "color")) { + color = true; + set_color(); + }  #if ICONS - if (!strcmp(v, "icons")) show_icons = true; + else if (!strcmp(v, "icons")) show_icons = true;  #endif   else {   printw("Unknown variable (%s)", v); @@ -15510 +15812 @@ void set(char * v) {      void unset(char * v) { - if (0) - ; + if (!strcmp(v, "color")) { + color = false; + set_color(); + }  #if ICONS - if (!strcmp(v, "icons")) show_icons = false; + else if (!strcmp(v, "icons")) show_icons = false;  #endif   else {   printw("Unknown variable (%s)", v); diff --git a/src/dir.c b/src/dir.c index eedc979..9a9472b 100644 --- a/src/dir.c +++ b/src/dir.c @@ -86 +87 @@  #include <errno.h>    #include "type.h" +#include "opts.h"  #include "dir.h"  #include "io.h"   @@ -177 +186 @@ char * cwd = NULL;  size_t n_dir_entries = 0;  struct dir_entry_t ** dir_entries = NULL;   -bool show_dot_files = false;  bool permission_denied = false;     diff --git a/src/io.c b/src/io.c index fae3be9..2c13bbb 100644 --- a/src/io.c +++ b/src/io.c @@ -187 +186 @@  bool print_path = false;  int stdout_back = 0;  size_t n_marked_files = false; -bool color = true;      void curses_init(void) { @@ -3217 +318 @@ void curses_init(void) {   noecho();   raw();   - 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); - } + start_color(); + set_color();  }     @@ -586 +4827 @@ void terminate_curses(void) {  }     +void set_color(void) { + if (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); + } else { + init_pair(BLUE, COLOR_WHITE, COLOR_BLACK); + init_pair(CYAN, COLOR_WHITE, COLOR_BLACK); + init_pair(GREEN, COLOR_WHITE, COLOR_BLACK); + init_pair(MAGENTA, COLOR_WHITE, COLOR_BLACK); + init_pair(YELLOW, COLOR_WHITE, COLOR_BLACK); + init_pair(RED, COLOR_WHITE, COLOR_BLACK); + init_pair(WHITE, COLOR_WHITE, COLOR_BLACK); + } +} + +  void curses_write_file(struct dir_entry_t * dir_entry, bool highlight) {   int cp = -1;   char f_ident; diff --git a/src/main.c b/src/main.c index d27cccb..c77d5c2 100644 --- a/src/main.c +++ b/src/main.c @@ -228 +228 @@ int main(int argc, char ** argv) {   color = false;  #if ICONS   } else if (!strcmp(argv[i], "-ni")) { -#endif   show_icons = false; +#endif   } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {   help();   } else { diff --git a/src/opts.c b/src/opts.c index 5786f6d..efa93ef 100644 --- a/src/opts.c +++ b/src/opts.c @@ -43 +45 @@      bool show_icons = true; +bool show_dot_files = false; +bool color = true;