commit 78b85ed09193bbe86565ebd8f9df8fad8efe3dea
Author: rani <clagv.randomgames@gmail.com>
Date: Mon Feb 06 20:42:07 2023 +0000
diff --git a/include/dir.h b/include/dir.h
index 777520c..8618ace 100644
--- a/include/dir.h
+++ b/include/dir.h
@@ -216 +217 @@ enum file_type_t {
FILE_FIFO,
FILE_LINK,
FILE_BLK,
+ FILE_CHR,
FILE_SOCK,
FILE_UNKNOWN
};
diff --git a/include/io.h b/include/io.h
index 6a63e81..a3ad08c 100644
--- a/include/io.h
+++ b/include/io.h
@@ -5124 +5126 @@ enum colors {
COLOR_UNKNOWN = 6,
COLOR_FILE = 7,
COLOR_BLOCK = 8,
- COLOR_MEDIA = 9,
- COLOR_ARCHIVE = 10,
-
- CUSTOM_DIR = 11,
- CUSTOM_LINK = 12,
- CUSTOM_EXEC = 13,
- CUSTOM_SOCK = 14,
- CUSTOM_FIFO = 15,
- CUSTOM_UNKNOWN = 16,
- CUSTOM_FILE = 17,
- CUSTOM_BLOCK = 18,
- CUSTOM_MEDIA = 19,
- CUSTOM_ARCHIVE = 20,
-
- RED = 21,
- WHITE = 22,
- YELLOW = 23,
- MAGENTA = 24,
+ COLOR_CHAR = 9,
+ COLOR_MEDIA = 10,
+ COLOR_ARCHIVE = 11,
+
+ CUSTOM_DIR = 12,
+ CUSTOM_LINK = 13,
+ CUSTOM_EXEC = 14,
+ CUSTOM_SOCK = 15,
+ CUSTOM_FIFO = 16,
+ CUSTOM_UNKNOWN = 17,
+ CUSTOM_FILE = 18,
+ CUSTOM_BLOCK = 19,
+ CUSTOM_CHR = 20,
+ CUSTOM_MEDIA = 21,
+ CUSTOM_ARCHIVE = 22,
+
+ RED = 23,
+ WHITE = 24,
+ YELLOW = 25,
+ MAGENTA = 26,
};
enum keys {
diff --git a/include/opts.h b/include/opts.h
index d293afa..5951ce4 100644
--- a/include/opts.h
+++ b/include/opts.h
@@ -396 +398 @@ extern uint32_t fifo_color;
extern uint32_t link_color;
#define BLK_COLOR_VAR "block_color"
extern uint32_t blk_color;
+#define CHR_COLOR_VAR "char_color"
+extern uint32_t chr_color;
#define SOCK_COLOR_VAR "sock_color"
extern uint32_t sock_color;
#define UNKNOWN_COLOR_VAR "unknown_color"
@@ -527 +547 @@ extern uint32_t archive_color;
#define OPENER_VAR "opener"
extern struct opener_t opener;
-extern uint32_t custom_colors[11];
+extern uint32_t custom_colors[12];
extern bool oneshot;
extern bool show_dot_dirs;
diff --git a/src/dir.c b/src/dir.c
index ad341c7..c1c9b6f 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -849 +8411 @@ struct dir_entry_t * gen_dir_entry(char * dir_path, char * d_name) {
switch(buf->st_mode & S_IFMT) {
case S_IFBLK:
- case S_IFCHR:
dir_entry->file_type = FILE_BLK;
break;
+ case S_IFCHR:
+ dir_entry->file_type = FILE_CHR;
+ break;
case S_IFSOCK:
dir_entry->file_type = FILE_SOCK;
break;
@@ -3039 +30516 @@ char * mode_to_s(struct dir_entry_t * f) {
char * p = s;
uint16_t mode = f->mode;
- if (f->file_type == FILE_DIR) *p++ = 'd';
- else *p++ = '.';
+ switch (f->file_type) {
+ case FILE_BLK: *p++ = 'b'; break;
+ case FILE_CHR: *p++ = 'c'; break;
+ case FILE_DIR: *p++ = 'd'; break;
+ case FILE_LINK: *p++ = 'l'; break;
+ case FILE_FIFO: *p++ = '|'; break;
+ case FILE_SOCK: *p++ = '='; break;
+ default: *p++ = '.'; break;
+ }
// owner mode
if (MOWNER(mode) & M_READ) *p++ = 'r';
else *p++ = '-';
diff --git a/src/io.c b/src/io.c
index e12078e..fc6e808 100644
--- a/src/io.c
+++ b/src/io.c
@@ -426 +427 @@ static int default_colors[] = {
[COLOR_UNKNOWN] = COLOR_RED,
[COLOR_FILE] = COLOR_WHITE,
[COLOR_BLOCK] = COLOR_YELLOW,
+ [COLOR_CHAR] = COLOR_YELLOW,
[COLOR_MEDIA] = COLOR_MAGENTA,
[COLOR_ARCHIVE] = COLOR_RED,
};
@@ -616 +627 @@ static char * ansi_colors[] = {
[COLOR_UNKNOWN] = ANSI_RED,
[COLOR_FILE] = ANSI_WHITE,
[COLOR_BLOCK] = ANSI_YELLOW,
+ [COLOR_CHAR] = ANSI_YELLOW,
[COLOR_MEDIA] = ANSI_MAGENTA,
[COLOR_ARCHIVE] = ANSI_RED,
};
@@ -15810 +16013 @@ void curses_write_file(struct dir_entry_t * dir_entry, bool highlight) {
void print_mode(struct dir_entry_t * f) {
enum colors m_colors[127] = {
- ['s'] = YELLOW, ['d'] = COLOR_DIR, ['.'] = WHITE,
- ['r'] = RED, ['w'] = MAGENTA, ['x'] = COLOR_EXEC,
- ['S'] = YELLOW, ['t'] = RED, ['T'] = RED,
- ['-'] = WHITE, ['?'] = WHITE,
+ ['s'] = YELLOW, ['r'] = RED, ['w'] = MAGENTA,
+ ['x'] = COLOR_EXEC, ['S'] = YELLOW, ['t'] = RED,
+ ['T'] = RED, ['-'] = WHITE, ['?'] = WHITE,
+
+ ['.'] = WHITE,
+ ['d'] = COLOR_DIR, ['b'] = COLOR_BLOCK, ['c'] = COLOR_CHAR,
+ ['l'] = COLOR_LINK, ['|'] = COLOR_FIFO, ['='] = COLOR_SOCK,
};
char * mode = mode_to_s(f);
@@ -5396 +5448 @@ enum colors get_file_color(struct dir_entry_t * de) {
cp = COLOR_FIFO; break;
case FILE_BLK:
cp = COLOR_BLOCK; break;
+ case FILE_CHR:
+ cp = COLOR_CHAR; break;
case FILE_LINK:
cp = COLOR_LINK; break;
case FILE_SOCK:
@@ -5816 +5887 @@ char get_file_ident(struct dir_entry_t * de) {
f_ident = '|';
break;
case FILE_BLK:
+ case FILE_CHR:
f_ident = '#';
break;
case FILE_LINK:
diff --git a/src/opts.c b/src/opts.c
index a9cc5b3..71eefa2 100644
--- a/src/opts.c
+++ b/src/opts.c
@@ -227 +227 @@ bool oneshot = false;
bool show_dot_dirs = false;
struct opener_t opener = {NULL, 0};
-uint32_t custom_colors[11];
+uint32_t custom_colors[12];
uint32_t dir_color = COLOR_DEFAULT;
uint32_t link_color = COLOR_DEFAULT;
@@ -326 +327 @@ uint32_t fifo_color = COLOR_DEFAULT;
uint32_t unknown_color = COLOR_DEFAULT;
uint32_t reg_color = COLOR_DEFAULT;
uint32_t blk_color = COLOR_DEFAULT;
+uint32_t chr_color = COLOR_DEFAULT;
uint32_t media_color = COLOR_DEFAULT;
uint32_t archive_color = COLOR_DEFAULT;
@@ -1946 +1957 @@ void generate_colors(void) {
custom_colors[COLOR_UNKNOWN] = unknown_color;
custom_colors[COLOR_FILE] = reg_color;
custom_colors[COLOR_BLOCK] = blk_color;
+ custom_colors[COLOR_CHAR] = chr_color;
custom_colors[COLOR_MEDIA] = media_color;
custom_colors[COLOR_ARCHIVE] = archive_color;
}
diff --git a/src/var.c b/src/var.c
index 7344966..4479601 100644
--- a/src/var.c
+++ b/src/var.c
@@ -1086 +10812 @@ static void set_block(void * p) {
}
+static void set_char(void * p) {
+ chr_color = hextorgb((char*)p);
+ set_color();
+}
+
+
static void set_sock(void * p) {
sock_color = hextorgb((char*)p);
set_color();
@@ -1647 +1707 @@ static void set_opener(void * p) {
void var_init(void) {
- var_map = map_new(15);
+ var_map = map_new(18);
map_insert(var_map, ICONS_VAR, set_icons);
map_insert(var_map, COLOR_VAR, set_color_f);
@@ -1766 +1827 @@ void var_init(void) {
map_insert(var_map, FIFO_COLOR_VAR, set_fifo);
map_insert(var_map, LINK_COLOR_VAR, set_link);
map_insert(var_map, BLK_COLOR_VAR, set_block);
+ map_insert(var_map, CHR_COLOR_VAR, set_char);
map_insert(var_map, SOCK_COLOR_VAR, set_sock);
map_insert(var_map, UNKNOWN_COLOR_VAR, set_unknown);
map_insert(var_map, EXEC_COLOR_VAR, set_exec);