Skip to content

Commit

Permalink
Proper macros for file icons
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-arch committed Dec 9, 2024
1 parent 1cd97ab commit f449443
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
13 changes: 10 additions & 3 deletions src/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,20 @@ char
# define B_BLACK EMPTY_STR
#endif /* _NERD || _ICONS_IN_TERMINAL */

/* Default icons and colors for directories, regular files, and symlinks */
#define DEF_DIR_ICON ICON_DIR
/* Default icons and colors */
#define DEF_DIR_ICON ICON_DIR /* Directory */
#define DEF_DIR_ICON_COLOR YELLOW
#define DEF_FILE_ICON ICON_REG

#define DEF_FILE_ICON ICON_REG /* Regular file */
#define DEF_FILE_ICON_COLOR WHITE

#define DEF_LINK_ICON ICON_LINK /* Symbolic link */
#define DEF_LINK_ICON_COLOR CYAN

#define DEF_EXEC_ICON ICON_EXEC /* Executable file */
#define DEF_EXEC_ICON_COLOR WHITE

#define DEF_NOPERM_ICON ICON_LOCK /* File without access permissions */
#define DEF_NOPERM_ICON_COLOR YELLOW

/* Per file extension icons */
Expand Down
15 changes: 6 additions & 9 deletions src/listing.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ get_dir_icon(const filesn_t n)
{
/* Default values for directories */
file_info[n].icon = DEF_DIR_ICON;
file_info[n].icon_color = DEF_DIR_ICON_COLOR;
/* DIR_ICO_C is set from the color scheme file */
file_info[n].icon_color = *dir_ico_c ? dir_ico_c : DEF_DIR_ICON_COLOR;

if (!file_info[n].name)
return;
Expand Down Expand Up @@ -2944,12 +2945,8 @@ load_dir_info(const struct stat *a, const filesn_t n)
file_info[n].dir = 1;

#ifndef _NO_ICONS
if (conf.icons == 1) {
if (conf.icons == 1)
get_dir_icon(n);

if (*dir_ico_c) /* If set from the color scheme file */
file_info[n].icon_color = dir_ico_c;
}
#endif /* !_NO_ICONS */

const int daccess = (a &&
Expand Down Expand Up @@ -2992,7 +2989,7 @@ load_link_info(const int fd, const filesn_t n)
file_info[n].symlink = 1;

#ifndef _NO_ICONS
file_info[n].icon = ICON_LINK;
file_info[n].icon = DEF_LINK_ICON;
file_info[n].icon_color = conf.color_lnk_as_target == 1 ?
DEF_LINK_ICON_COLOR : DEF_FILE_ICON_COLOR;
#endif /* !_NO_ICONS */
Expand Down Expand Up @@ -3060,7 +3057,7 @@ load_regfile_info(const struct stat *a, const filesn_t n)
if (user.uid != 0 && a
&& check_file_access(a->st_mode, a->st_uid, a->st_gid) == 0) {
#ifndef _NO_ICONS
file_info[n].icon = ICON_LOCK;
file_info[n].icon = DEF_NOPERM_ICON;
file_info[n].icon_color = DEF_NOPERM_ICON_COLOR;
#endif /* !_NO_ICONS */
file_info[n].color = nf_c;
Expand Down Expand Up @@ -3107,7 +3104,7 @@ load_regfile_info(const struct stat *a, const filesn_t n)

#ifndef _NO_ICONS
if (file_info[n].exec == 1) {
file_info[n].icon = ICON_EXEC;
file_info[n].icon = DEF_EXEC_ICON;
file_info[n].icon_color = DEF_EXEC_ICON_COLOR;
}
#endif /* !_NO_ICONS */
Expand Down

0 comments on commit f449443

Please sign in to comment.