diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | src/icons-in-terminal.h | 2 | ||||
-rw-r--r-- | src/icons-nerdfont.h | 248 | ||||
-rw-r--r-- | src/icons.h | 356 | ||||
-rw-r--r-- | src/nnn.c | 17 |
5 files changed, 564 insertions, 66 deletions
@@ -19,7 +19,8 @@ O_NOMOUSE := 0 # no mouse support O_NOBATCH := 0 # no built-in batch renamer O_NOFIFO := 0 # no FIFO previewer support O_CTX8 := 0 # enable 8 contexts -O_ICONS := 0 # support icons +O_ICONS := 0 # support icons-in-terminal +O_NERD := 0 # support icons-nerdfont O_QSORT := 0 # use Alexey Tourbin's QSORT implementation O_BENCH := 0 # benchmark mode (stops at first user input) @@ -77,6 +78,10 @@ ifeq ($(O_ICONS),1) CPPFLAGS += -DICONS endif +ifeq ($(O_NERD),1) + CPPFLAGS += -DNERD +endif + ifeq ($(O_QSORT),1) CPPFLAGS += -DTOURBIN_QSORT endif diff --git a/src/icons-in-terminal.h b/src/icons-in-terminal.h index 37f5d29..11df87a 100644 --- a/src/icons-in-terminal.h +++ b/src/icons-in-terminal.h @@ -1,5 +1,5 @@ #ifndef ICONS_IN_TERMINAL -# define ICONS_IN_TERMINAL +#define ICONS_IN_TERMINAL # define POWERLINE_BRANCH "\ue0a0" # define POWERLINE_LINE_NUMBER "\ue0a1" diff --git a/src/icons-nerdfont.h b/src/icons-nerdfont.h new file mode 100644 index 0000000..7662b3e --- /dev/null +++ b/src/icons-nerdfont.h @@ -0,0 +1,248 @@ +#ifndef ICONS_NERDFONT +#define ICONS_NERDFONT + +// You can find hex codes for nerd fonts here +// https://www.nerdfonts.com/cheat-sheet + +// Generics +#define ICON_DIRECTORY "\ue5ff" +#define ICON_FILE "\uf713" +#define ICON_EXEC "\uf144" +#define ICON_MANUAL "\uf5bd" + +// Top level and common icons +#define ICON_GIT "\ue5fb" +#define ICON_DESKTOP "\ufcbe" +#define ICON_BRIEFCASE "\uf5d5" +#define ICON_DOCUMENT "\uf718" +#define ICON_DOWNLOADS "\uf5d7" +#define ICON_MUSIC "\uf832" +#define ICON_MUSICFILE "\uf886" +#define ICON_PICTURES "\uf753" +#define ICON_PICTUREFILE "\uf71e" +#define ICON_PUBLIC "\ue5ff" +#define ICON_TEMPLATES "\ufac6" +#define ICON_VIDEOS "\uf72f" +#define ICON_VIDEOFILE "\ufcdc" +#define ICON_CHANGELOG "\uf7d9" +#define ICON_CONFIGURE "\uf423" +#define ICON_LICENSE "\uf718" +#define ICON_MAKEFILE "\uf68c" +#define ICON_ARCHIVE "\ufac3" +#define ICON_SCRIPT "\uf977" +#define ICON_CPLUSPLUS "\ue61d" +#define ICON_JAVA "\ue738" +#define ICON_CLOJURE "\ue76a" +#define ICON_JAVASCRIPT "\ue74e" +#define ICON_LINUX "\uf83c" +#define ICON_FSHARP "\ue7a7" +#define ICON_RUBY "\ue23e" +#define ICON_C "\ue61e" +#define ICON_HTML "\uf72d" +#define ICON_REACT "\ue625" +#define ICON_PYTHON "\ue235" +#define ICON_DATABASE "\uf6b7" +#define ICON_WORDDOC "\uf72b" +#define ICON_PLAYLIST "\uf910" +#define ICON_OPTICALDISK "\ufd1e" + + +/* Numbers */ +#define ICON_EXT_1 ICON_MANUAL +#define ICON_EXT_7Z ICON_ARCHIVE + +/* A */ +#define ICON_EXT_A ICON_MANUAL +#define ICON_EXT_APK ICON_ARCHIVE +#define ICON_EXT_ASM ICON_FILE +#define ICON_EXT_AUP ICON_MUSICFILE +#define ICON_EXT_AVI ICON_VIDEOFILE + +/* B */ +#define ICON_EXT_BAT ICON_SCRIPT +#define ICON_EXT_BIN "\uf471" +#define ICON_EXT_BMP ICON_PICTUREFILE +#define ICON_EXT_BZ2 ICON_ARCHIVE + +/* C */ +#define ICON_EXT_C ICON_C +#define ICON_EXT_CPLUSPLUS ICON_CPLUSPLUS +#define ICON_EXT_CAB ICON_ARCHIVE +#define ICON_EXT_CBR ICON_ARCHIVE +#define ICON_EXT_CBZ ICON_ARCHIVE +#define ICON_EXT_CC ICON_CPLUSPLUS +#define ICON_EXT_CLASS ICON_JAVA +#define ICON_EXT_CLJ ICON_CLOJURE +#define ICON_EXT_CLJC ICON_CLOJURE +#define ICON_EXT_CLJS ICON_CLOJURE +#define ICON_EXT_CMAKE ICON_MAKEFILE +#define ICON_EXT_COFFEE "\ue751" +#define ICON_EXT_CONF ICON_CONFIGURE +#define ICON_EXT_CPIO ICON_ARCHIVE +#define ICON_EXT_CPP ICON_CPLUSPLUS +#define ICON_EXT_CSS "\ue614" +#define ICON_EXT_CUE ICON_PLAYLIST +#define ICON_EXT_CVS ICON_CONFIGURE +#define ICON_EXT_CXX ICON_CPLUSPLUS + +/* D */ +#define ICON_EXT_DB ICON_DATABASE +#define ICON_EXT_DEB "\ue77d" +#define ICON_EXT_DIFF "\ufa59" +#define ICON_EXT_DLL ICON_SCRIPT +#define ICON_EXT_DOC ICON_WORDDOC +#define ICON_EXT_DOCX ICON_WORDDOC + +/* E */ +#define ICON_EXT_EJS ICON_JAVASCRIPT +#define ICON_EXT_ELF ICON_LINUX +#define ICON_EXT_EPUB ICON_MANUAL +#define ICON_EXT_EXE ICON_EXEC + +/* F */ +#define ICON_EXT_FSHARP ICON_FSHARP +#define ICON_EXT_FLAC ICON_MUSICFILE +#define ICON_EXT_FLV ICON_VIDEOFILE +#define ICON_EXT_FS ICON_FSHARP +#define ICON_EXT_FSI ICON_FSHARP +#define ICON_EXT_FSSCRIPT ICON_FSHARP +#define ICON_EXT_FSX ICON_FSHARP + +/* G */ +#define ICON_EXT_GEM ICON_RUBY +#define ICON_EXT_GIF ICON_PICTUREFILE +#define ICON_EXT_GO "\ufcd1" +#define ICON_EXT_GZ ICON_ARCHIVE +#define ICON_EXT_GZIP ICON_ARCHIVE + +/* H */ +#define ICON_EXT_H ICON_C +#define ICON_EXT_HH ICON_CPLUSPLUS +#define ICON_EXT_HTACCESS ICON_CONFIGURE +#define ICON_EXT_HTPASSWD ICON_CONFIGURE +#define ICON_EXT_HTM ICON_HTML +#define ICON_EXT_HTML ICON_HTML +#define ICON_EXT_HXX ICON_CPLUSPLUS + +/* I */ +#define ICON_EXT_ICO ICON_PICTUREFILE +#define ICON_EXT_IMG ICON_PICTUREFILE +#define ICON_EXT_INI ICON_CONFIGURE +#define ICON_EXT_ISO ICON_OPTICALDISK + +/* J */ +#define ICON_EXT_JAR ICON_JAVA +#define ICON_EXT_JAVA ICON_JAVA +#define ICON_EXT_JL ICON_CONFIGURE +#define ICON_EXT_JPEG ICON_PICTUREFILE +#define ICON_EXT_JPG ICON_PICTUREFILE +#define ICON_EXT_JS ICON_JAVASCRIPT +#define ICON_EXT_JSON "\ufb25" +#define ICON_EXT_JSX ICON_REACT + +/* K */ + +/* L */ +#define ICON_EXT_LHA ICON_ARCHIVE +#define ICON_EXT_LOG ICON_DOCUMENT +#define ICON_EXT_LUA "\ue620" +#define ICON_EXT_LZH ICON_ARCHIVE +#define ICON_EXT_LZMA ICON_ARCHIVE + +/* M */ +#define ICON_EXT_M4A ICON_MUSICFILE +#define ICON_EXT_M4V ICON_VIDEOFILE +#define ICON_EXT_MD "\ue609" +#define ICON_EXT_MK ICON_MAKEFILE +#define ICON_EXT_MKV ICON_VIDEOFILE +#define ICON_EXT_MOV ICON_VIDEOFILE +#define ICON_EXT_MP3 ICON_MUSICFILE +#define ICON_EXT_MP4 ICON_VIDEOFILE +#define ICON_EXT_MPEG ICON_VIDEOFILE +#define ICON_EXT_MPG ICON_VIDEOFILE +#define ICON_EXT_MSI "\ufab2" + +/* N */ + +/* O */ +#define ICON_EXT_O ICON_MANUAL +#define ICON_EXT_OGG ICON_MUSICFILE +#define ICON_EXT_ODOWNLOAD ICON_DOWNLOADS +#define ICON_EXT_OUT ICON_LINUX + +/* P */ +#define ICON_EXT_PART ICON_DOWNLOADS +#define ICON_EXT_PATCH "\ufa59" +#define ICON_EXT_PDF "\uf724" +#define ICON_EXT_PHP "\ue73d" +#define ICON_EXT_PNG ICON_PICTUREFILE +#define ICON_EXT_PPT "\uf726" +#define ICON_EXT_PPTX "\uf726" +#define ICON_EXT_PSB "\ue7b8" +#define ICON_EXT_PSD "\ue7b8" +#define ICON_EXT_PY ICON_PYTHON +#define ICON_EXT_PYC ICON_PYTHON +#define ICON_EXT_PYD ICON_PYTHON +#define ICON_EXT_PYO ICON_PYTHON + +/* Q */ + +/* R */ +#define ICON_EXT_RAR ICON_ARCHIVE +#define ICON_EXT_RC ICON_CONFIGURE +#define ICON_EXT_ROM "\uf795" +#define ICON_EXT_RPM ICON_ARCHIVE +#define ICON_EXT_RSS "\uf96b" +#define ICON_EXT_RTF "\uf724" + +/* S */ +#define ICON_EXT_SASS "\ue603" +#define ICON_EXT_SCSS "\ue603" +#define ICON_EXT_SO ICON_MANUAL +#define ICON_EXT_SCALA "\ue737" +#define ICON_EXT_SH ICON_SCRIPT +#define ICON_EXT_SLIM ICON_SCRIPT +#define ICON_EXT_SLN "\ue70c" +#define ICON_EXT_SQL ICON_DATABASE +#define ICON_EXT_SRT "\uf679" +#define ICON_EXT_SUB "\uf679" +#define ICON_EXT_SVG ICON_PICTUREFILE + +/* T */ +#define ICON_EXT_TAR ICON_ARCHIVE +#define ICON_EXT_TEX "\uf6fc" +#define ICON_EXT_TGZ ICON_ARCHIVE +#define ICON_EXT_TS "\ue628" +#define ICON_EXT_TSX ICON_REACT +#define ICON_EXT_TXT ICON_DOCUMENT +#define ICON_EXT_TXZ ICON_ARCHIVE + +/* U */ + +/* V */ +#define ICON_EXT_VID ICON_VIDEOFILE +#define ICON_EXT_VIM "\ue62b" +#define ICON_EXT_VIMRC "\ue62b" + +/* W */ +#define ICON_EXT_WAV ICON_MUSICFILE +#define ICON_EXT_WEBM ICON_VIDEOFILE +#define ICON_EXT_WMA ICON_VIDEOFILE +#define ICON_EXT_WMV ICON_VIDEOFILE + +/* X */ +#define ICON_EXT_XBPS ICON_ARCHIVE +#define ICON_EXT_XHTML ICON_HTML +#define ICON_EXT_XLS "\uf71a" +#define ICON_EXT_XLSX "\uf71a" +#define ICON_EXT_XML ICON_HTML +#define ICON_EXT_XZ ICON_ARCHIVE + +/* Y */ +#define ICON_EXT_YAML ICON_CONFIGURE +#define ICON_EXT_YML ICON_CONFIGURE + +/* Z */ +#define ICON_EXT_ZIP ICON_ARCHIVE + +#endif // ICONS_NERDFONT diff --git a/src/icons.h b/src/icons.h index 255ad37..c735c24 100644 --- a/src/icons.h +++ b/src/icons.h @@ -1,4 +1,10 @@ +#pragma once + +#if defined(ICONS) #include "icons-in-terminal.h" +#elif defined(NERD) +#include "icons-nerdfont.h" +#endif struct icon_pair { const char *match; @@ -6,6 +12,7 @@ struct icon_pair { /* * Hex xterm 256 color code, 0 to follow file specific (if any) * Codes: https://jonasjacek.github.io/colors/ + * Spectrum sorted: https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg */ const unsigned char color; }; @@ -18,11 +25,23 @@ struct icon_pair { #define ICON_PADDING_LEFT "" #define ICON_PADDING_RIGHT " " -#define VIDEO_COLOR 93 /* Purple */ -#define AUDIO_COLOR 220 /* Gold1 */ -#define IMAGE_COLOR 82 /* Chartreuse2 */ -#define BOOKS_COLOR 202 /* OrangeRed1 */ -#define ARCHIVE_COLOR 209 /* Salmon1 */ +#define COLOR_VIDEO 93 /* Purple */ +#define COLOR_AUDIO 220 /* Gold1 */ +#define COLOR_IMAGE 82 /* Chartreuse2 */ +#define COLOR_BOOKS 202 /* OrangeRed1 */ +#define COLOR_ARCHIVE 209 /* Salmon1 */ +#define COLOR_C 81 /* SteelBlue1 */ +#define COLOR_JAVA 32 /* DeepSkyBlue3 */ +#define COLOR_JAVASCRIPT 47 /* SpringGreen2 */ +#define COLOR_REACT 39 /* DeepSkyBlue1 */ +#define COLOR_CSS 199 /* DeepPink1 */ +#define COLOR_PYTHON 227 /* LightGoldenrod1 */ +#define COLOR_LUA 19 /* LightGoldenrod1 */ +#define COLOR_DOCUMENT 15 /* WHITE */ +#define COLOR_FSHARP 31 /* DeepSkyBlue3 */ +#define COLOR_RUBY 160 /* Red3 */ +#define COLOR_SCALA 196 /* Red1 */ +#define COLOR_VIM 28 /* Green4 */ /* * Using symbols defined in icons-in-terminal.h, or even using icons-in-terminal is not necessary. @@ -30,13 +49,20 @@ struct icon_pair { * If you are using icons-in-terminal the creator recommends that you do use the symbols in the generated header. */ +#if defined(ICONS) static const struct icon_pair dir_icon = {"", FA_FOLDER, 0}; static const struct icon_pair file_icon = {"", FA_FILE_O, 0}; static const struct icon_pair exec_icon = {"", FA_COG, 0}; +#elif defined(NERD) +static const struct icon_pair dir_icon = {"", ICON_DIRECTORY, 0}; +static const struct icon_pair file_icon = {"", ICON_FILE, 0}; +static const struct icon_pair exec_icon = {"", ICON_EXEC, 0}; +#endif /* All entries are case-insensitive */ static const struct icon_pair icons_name[] = { +#if defined(ICONS) {".git", FA_GIT, 0}, {"Desktop", FA_DESKTOP, 0}, {"Documents", FA_BRIEFCASE, 0}, @@ -50,6 +76,21 @@ static const struct icon_pair icons_name[] = { {"configure", FILE_CONFIG, 0}, {"License", FA_COPYRIGHT, 0}, {"Makefile", FILE_CMAKE, 0}, +#elif defined(NERD) + {".git", ICON_GIT, 0}, + {"Desktop", ICON_DESKTOP, 0}, + {"Documents", ICON_BRIEFCASE, 0}, + {"Downloads", ICON_DOWNLOADS, 0}, + {"Music", ICON_MUSIC, 0}, + {"Pictures", ICON_PICTURES, 0}, + {"Public", ICON_PUBLIC, 0}, + {"Templates", ICON_TEMPLATES, 0}, + {"Videos", ICON_VIDEOS, 0}, + {"CHANGELOG", ICON_CHANGELOG, 0}, + {"configure", ICON_CONFIGURE, 0}, + {"License", ICON_LICENSE, 0}, + {"Makefile", ICON_MAKEFILE, 0}, +#endif }; /* @@ -59,29 +100,30 @@ static const struct icon_pair icons_name[] = { */ static const struct icon_pair icons_ext[] = { +#if defined(ICONS) /* Numbers */ {"1", FILE_MANPAGE, 0}, - {"7z", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"7z", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* A */ {"a", FILE_MANPAGE, 0}, - {"apk", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"apk", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"asm", FILE_NASM, 0}, - {"aup", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"avi", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"aup", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"avi", FA_FILE_MOVIE_O, COLOR_VIDEO}, /* B */ {"bat", MFIZZ_SCRIPT, 0}, {"bin", OCT_FILE_BINARY, 0}, - {"bmp", FA_FILE_IMAGE_O, IMAGE_COLOR}, - {"bz2", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"bmp", FA_FILE_IMAGE_O, COLOR_IMAGE}, + {"bz2", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* C */ {"c", MFIZZ_C, 0}, {"c++", MFIZZ_CPLUSPLUS, 0}, - {"cab", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, - {"cbr", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, - {"cbz", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"cab", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, + {"cbr", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, + {"cbz", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"cc", MFIZZ_CPLUSPLUS, 0}, {"class", MFIZZ_JAVA, 0}, {"clj", MFIZZ_CLOJURE, 0}, @@ -90,16 +132,16 @@ static const struct icon_pair icons_ext[] = { {"cmake", FILE_CMAKE, 0}, {"coffee", MFIZZ_COFFEE_BEAN, 0}, {"conf", FA_COGS, 0}, - {"cpio", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"cpio", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"cpp", MFIZZ_CPLUSPLUS, 0}, {"css", MFIZZ_CSS3, 0}, - {"cue", FA_FILE_AUDIO_O, AUDIO_COLOR}, + {"cue", FA_FILE_AUDIO_O, COLOR_AUDIO}, {"cvs", FA_COGS, 0}, {"cxx", MFIZZ_CPLUSPLUS, 0}, /* D */ {"db", MFIZZ_DATABASE_ALT2, 0}, - {"deb", MFIZZ_DEBIAN, ARCHIVE_COLOR}, + {"deb", MFIZZ_DEBIAN, COLOR_ARCHIVE}, {"diff", FILE_DIFF, 0}, {"dll", FILE_MANPAGE, 0}, {"doc", FILE_WORD, 0}, @@ -108,13 +150,13 @@ static const struct icon_pair icons_ext[] = { /* E */ {"ejs", FA_FILE_CODE_O, 0}, {"elf", FA_LINUX, 0}, - {"epub", FA_FILE_PDF_O, BOOKS_COLOR}, + {"epub", FA_FILE_PDF_O, COLOR_BOOKS}, {"exe", FA_WINDOWS, 0}, /* F */ {"f#", DEV_FSHARP, 0}, - {"flac", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"flv", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"flac", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"flv", FA_FILE_MOVIE_O, COLOR_VIDEO}, {"fs", DEV_FSHARP, 0}, {"fsi", DEV_FSHARP, 0}, {"fsscript", DEV_FSHARP, 0}, @@ -122,10 +164,10 @@ static const struct icon_pair icons_ext[] = { /* G */ {"gem", FA_FILE_ARCHIVE_O, 0}, - {"gif", FA_FILE_IMAGE_O, IMAGE_COLOR}, + {"gif", FA_FILE_IMAGE_O, COLOR_IMAGE}, {"go", MFIZZ_GO, 0}, - {"gz", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, - {"gzip", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"gz", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, + {"gzip", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* H */ {"h", MFIZZ_C, 0}, @@ -137,17 +179,17 @@ static const struct icon_pair icons_ext[] = { {"hxx", MFIZZ_CPLUSPLUS, 0}, /* I */ - {"ico", FA_FILE_IMAGE_O, IMAGE_COLOR}, - {"img", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"ico", FA_FILE_IMAGE_O, COLOR_IMAGE}, + {"img", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"ini", FA_COGS, 0}, - {"iso", LINEA_MUSIC_CD, ARCHIVE_COLOR}, + {"iso", LINEA_MUSIC_CD, COLOR_ARCHIVE}, /* J */ {"jar", MFIZZ_JAVA, 0}, {"java", MFIZZ_JAVA, 0}, {"jl", FA_COGS, 0}, - {"jpeg", FA_FILE_IMAGE_O, IMAGE_COLOR}, - {"jpg", FA_FILE_IMAGE_O, IMAGE_COLOR}, + {"jpeg", FA_FILE_IMAGE_O, COLOR_IMAGE}, + {"jpg", FA_FILE_IMAGE_O, COLOR_IMAGE}, {"js", DEV_JAVASCRIPT_BADGE, 0}, {"json", MFIZZ_JAVASCRIPT, 0}, {"jsx", FILE_JSX, 0}, @@ -155,40 +197,40 @@ static const struct icon_pair icons_ext[] = { /* K */ /* L */ - {"lha", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"lha", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"log", FA_FILE_TEXT_O, 0}, {"lua", FILE_LUA, 0}, - {"lzh", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, - {"lzma", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"lzh", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, + {"lzma", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* M */ - {"m4a", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"m4v", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"m4a", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"m4v", FA_FILE_MOVIE_O, COLOR_VIDEO}, {"markdown", DEV_MARKDOWN, 0}, {"md", DEV_MARKDOWN, 0}, {"mk", FILE_CMAKE, 0}, - {"mkv", FA_FILE_MOVIE_O, VIDEO_COLOR}, - {"mov", FA_FILE_MOVIE_O, VIDEO_COLOR}, - {"mp3", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"mp4", FA_FILE_MOVIE_O, VIDEO_COLOR}, - {"mpeg", FA_FILE_MOVIE_O, VIDEO_COLOR}, - {"mpg", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"mkv", FA_FILE_MOVIE_O, COLOR_VIDEO}, + {"mov", FA_FILE_MOVIE_O, COLOR_VIDEO}, + {"mp3", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"mp4", FA_FILE_MOVIE_O, COLOR_VIDEO}, + {"mpeg", FA_FILE_MOVIE_O, COLOR_VIDEO}, + {"mpg", FA_FILE_MOVIE_O, COLOR_VIDEO}, {"msi", FA_WINDOWS, 0}, /* N */ /* O */ {"o", FILE_MANPAGE, 0}, - {"ogg", FA_FILE_AUDIO_O, AUDIO_COLOR}, + {"ogg", FA_FILE_AUDIO_O, COLOR_AUDIO}, {"opdownload", FA_DOWNLOAD, 0}, {"out", FA_LINUX, 0}, /* P */ {"part", FA_DOWNLOAD, 0}, {"patch", FILE_PATCH, 0}, - {"pdf", FA_FILE_PDF_O, BOOKS_COLOR}, + {"pdf", FA_FILE_PDF_O, COLOR_BOOKS}, {"php", MFIZZ_PHP, 0}, - {"png", FA_FILE_IMAGE_O, IMAGE_COLOR}, + {"png", FA_FILE_IMAGE_O, COLOR_IMAGE}, {"ppt", FILE_POWERPOINT, 0}, {"pptx", FILE_POWERPOINT, 0}, {"psb", DEV_PHOTOSHOP, 0}, @@ -201,10 +243,10 @@ static const struct icon_pair icons_ext[] = { /* Q */ /* R */ - {"rar", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"rar", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"rc", FA_COGS, 0}, {"rom", FA_LOCK, 0}, - {"rpm", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"rpm", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"rss", FA_RSS_SQUARE, 0}, {"rtf", FA_FILE_PDF_O, 0}, @@ -217,44 +259,246 @@ static const struct icon_pair icons_ext[] = { {"sql", MFIZZ_MYSQL, 0}, {"srt", FA_COMMENTS_O, 0}, {"sub", FA_COMMENTS_O, 0}, - {"svg", FA_FILE_IMAGE_O, IMAGE_COLOR}, + {"svg", FA_FILE_IMAGE_O, COLOR_IMAGE}, /* T */ - {"tar", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"tar", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"tex", FILE_TEX, 0}, - {"tgz", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"tgz", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"ts", FILE_TS, 0}, {"tsx", FILE_TSX, 0}, {"txt", FA_FILE_TEXT_O, 0}, - {"txz", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"txz", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* U */ /* V */ - {"vid", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"vid", FA_FILE_MOVIE_O, COLOR_VIDEO}, {"vim", DEV_VIM, 0}, {"vimrc", DEV_VIM, 0}, /* W */ - {"wav", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"webm", FA_FILE_MOVIE_O, VIDEO_COLOR}, - {"wma", FA_FILE_AUDIO_O, AUDIO_COLOR}, - {"wmv", FA_FILE_MOVIE_O, VIDEO_COLOR}, + {"wav", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"webm", FA_FILE_MOVIE_O, COLOR_VIDEO}, + {"wma", FA_FILE_AUDIO_O, COLOR_AUDIO}, + {"wmv", FA_FILE_MOVIE_O, COLOR_VIDEO}, /* X */ - {"xbps", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"xbps", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, {"xhtml", FA_FILE_CODE_O, 0}, {"xls", FILE_EXCEL, 0}, {"xlsx", FILE_EXCEL, 0}, {"xml", FA_FILE_CODE_O, 0}, - {"xz", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR}, + {"xz", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, /* Y */ {"yaml", FA_COGS, 0}, {"yml", FA_COGS, 0}, /* Z */ - {"zip", FA_FILE_ARCHIVE_O, ARCHIVE_COLOR} + {"zip", FA_FILE_ARCHIVE_O, COLOR_ARCHIVE}, + + /* Other */ +#elif defined(NERD) + /* Numbers */ + {"1", ICON_EXT_1, 0}, + {"7z", ICON_EXT_7Z, COLOR_ARCHIVE}, + + /* A */ + {"a", ICON_EXT_A, 0}, + {"apk", ICON_EXT_APK, COLOR_ARCHIVE}, + {"asm", ICON_EXT_ASM, 0}, + {"aup", ICON_EXT_AUP, COLOR_AUDIO}, + {"avi", ICON_EXT_AVI, COLOR_VIDEO}, + + /* B */ + {"bat", ICON_EXT_BAT, 0}, + {"bin", ICON_EXT_BIN, 0}, + {"bmp", ICON_EXT_BMP, COLOR_IMAGE}, + {"bz2", ICON_EXT_BZ2, COLOR_ARCHIVE}, + + /* C */ + {"c", ICON_EXT_C, COLOR_C}, + {"c++", ICON_EXT_CPLUSPLUS, COLOR_C}, + {"cab", ICON_EXT_CAB, COLOR_ARCHIVE}, + {"cbr", ICON_EXT_CBR, COLOR_ARCHIVE}, + {"cbz", ICON_EXT_CBZ, COLOR_ARCHIVE}, + {"cc", ICON_EXT_CC, COLOR_C}, + {"class", ICON_EXT_CLASS, COLOR_JAVA}, + {"clj", ICON_EXT_CLJ, 0}, + {"cljc", ICON_EXT_CLJC, 0}, + {"cljs", ICON_EXT_CLJS, 0}, + {"cmake", ICON_EXT_CMAKE, 0}, + {"coffee", ICON_EXT_COFFEE, 0}, + {"conf", ICON_EXT_CONF, 0}, + {"cpio", ICON_EXT_CPIO, COLOR_ARCHIVE}, + {"cpp", ICON_EXT_CPP, 0}, + {"css", ICON_EXT_CSS, COLOR_CSS}, + {"cue", ICON_EXT_CUE, COLOR_AUDIO}, + {"cvs", ICON_EXT_CVS, 0}, + {"cxx", ICON_EXT_CXX, COLOR_C}, + + /* D */ + {"db", ICON_EXT_DB, 0}, + {"deb", ICON_EXT_DEB, COLOR_ARCHIVE}, + {"diff", ICON_EXT_DIFF, 0}, + {"dll", ICON_EXT_DLL, 0}, + {"doc", ICON_EXT_DOC, COLOR_DOCUMENT}, + {"docx", ICON_EXT_DOCX, COLOR_DOCUMENT}, + + /* E */ + {"ejs", ICON_EXT_EJS, COLOR_JAVASCRIPT}, + {"elf", ICON_EXT_ELF, 0}, + {"epub", ICON_EXT_EPUB, COLOR_BOOKS}, + {"exe", ICON_EXT_EXE, 0}, + + /* F */ + {"f#", ICON_EXT_FSHARP, COLOR_FSHARP}, + {"flac", ICON_EXT_FLAC, COLOR_AUDIO}, + {"flv", ICON_EXT_FLV, COLOR_VIDEO}, + {"fs", ICON_EXT_FS, COLOR_FSHARP}, + {"fsi", ICON_EXT_FSI, COLOR_FSHARP}, + {"fsscript", ICON_EXT_FSSCRIPT, COLOR_FSHARP}, + {"fsx", ICON_EXT_FSX, COLOR_FSHARP}, + + /* G */ + {"gem", ICON_EXT_GEM, COLOR_RUBY}, + {"gif", ICON_EXT_GIF, COLOR_IMAGE}, + {"go", ICON_EXT_GO, 0}, + {"gz", ICON_EXT_GZ, COLOR_ARCHIVE}, + {"gzip", ICON_EXT_GZIP, COLOR_ARCHIVE}, + + /* H */ + {"h", ICON_EXT_H, COLOR_C}, + {"hh", ICON_EXT_HH, COLOR_C}, + {"htaccess", ICON_EXT_HTACCESS, 0}, + {"htpasswd", ICON_EXT_HTPASSWD, 0}, + {"htm", ICON_EXT_HTM, 0}, + {"html", ICON_EXT_HTML, 0}, + {"hxx", ICON_EXT_HXX, COLOR_C}, + + /* I */ + {"ico", ICON_EXT_ICO, COLOR_IMAGE}, + {"img", ICON_EXT_IMG, COLOR_ARCHIVE}, + {"ini", ICON_EXT_INI, 0}, + {"iso", ICON_EXT_ISO, COLOR_ARCHIVE}, + + /* J */ + {"jar", ICON_EXT_JAR, COLOR_JAVA}, + {"java", ICON_EXT_JAVA, COLOR_JAVA}, + {"jl", ICON_EXT_JL, 0}, + {"jpeg", ICON_EXT_JPEG, COLOR_IMAGE}, + {"jpg", ICON_EXT_JPG, COLOR_IMAGE}, + {"js", ICON_EXT_JS, COLOR_JAVASCRIPT}, + {"json", ICON_EXT_JSON, COLOR_JAVASCRIPT}, + {"jsx", ICON_EXT_JSX, COLOR_REACT}, + + /* K */ + + /* L */ + {"lha", ICON_EXT_LHA, COLOR_ARCHIVE}, + {"log", ICON_EXT_LOG, 0}, + {"lua", ICON_EXT_LUA, 0}, + {"lzh", ICON_EXT_LZH, COLOR_ARCHIVE}, + {"lzma", ICON_EXT_LZMA, COLOR_ARCHIVE}, + + /* M */ + {"m4a", ICON_EXT_M4A, COLOR_AUDIO}, + {"m4v", ICON_EXT_M4V, COLOR_VIDEO}, + {"markdown", ICON_EXT_MD, 0}, + {"md", ICON_EXT_MD, 0}, + {"mk", ICON_EXT_MK, 0}, + {"mkv", ICON_EXT_MKV, COLOR_VIDEO}, + {"mov", ICON_EXT_MOV, COLOR_VIDEO}, + {"mp3", ICON_EXT_MP3, COLOR_AUDIO}, + {"mp4", ICON_EXT_MP4, COLOR_VIDEO}, + {"mpeg", ICON_EXT_MPEG, COLOR_VIDEO}, + {"mpg", ICON_EXT_MPG, COLOR_VIDEO}, + {"msi", ICON_EXT_MSI, 0}, + + /* N */ + + /* O */ + {"o", ICON_EXT_O, 0}, + {"ogg", ICON_EXT_OGG, COLOR_AUDIO}, + {"opdownload", ICON_EXT_ODOWNLOAD, 0}, + {"out", ICON_EXT_OUT, 0}, + + /* P */ + {"part", ICON_EXT_PART, 0}, + {"patch", ICON_EXT_PATCH, 0}, + {"pdf", ICON_EXT_PDF, COLOR_BOOKS}, + {"php", ICON_EXT_PHP, 0}, + {"png", ICON_EXT_PNG, COLOR_IMAGE}, + {"ppt", ICON_EXT_PPT, 0}, + {"pptx", ICON_EXT_PPTX, 0}, + {"psb", ICON_EXT_PSB, 0}, + {"psd", ICON_EXT_PSD, 0}, + {"py", ICON_EXT_PY, COLOR_PYTHON}, + {"pyc", ICON_EXT_PYC, COLOR_PYTHON}, + {"pyd", ICON_EXT_PYD, COLOR_PYTHON}, + {"pyo", ICON_EXT_PYO, COLOR_PYTHON}, + + /* Q */ + + /* R */ + {"rar", ICON_EXT_RAR, COLOR_ARCHIVE}, + {"rc", ICON_EXT_RC, 0}, + {"rom", ICON_EXT_ROM, 0}, + {"rpm", ICON_EXT_RPM, COLOR_ARCHIVE}, + {"rss", ICON_EXT_RSS, 0}, + {"rtf", ICON_EXT_RTF, 0}, + + /* S */ + {"sass", ICON_EXT_SASS, COLOR_CSS}, + {"scss", ICON_EXT_SCSS, COLOR_CSS}, + {"so", ICON_EXT_SO, 0}, + {"scala", ICON_EXT_SCALA, COLOR_SCALA}, + {"sh", ICON_EXT_SH, 0}, + {"slim", ICON_EXT_SLIM, COLOR_DOCUMENT}, + {"sln", ICON_EXT_SLN, 0}, + {"sql", ICON_EXT_SQL, 0}, + {"srt", ICON_EXT_SRT, 0}, + {"sub", ICON_EXT_SUB, 0}, + {"svg", ICON_EXT_SVG, COLOR_IMAGE}, + + /* T */ + {"tar", ICON_EXT_TAR, COLOR_ARCHIVE}, + {"tex", ICON_EXT_TEX, 0}, + {"tgz", ICON_EXT_TGZ, COLOR_ARCHIVE}, + {"ts", ICON_EXT_TS, COLOR_JAVASCRIPT}, + {"tsx", ICON_EXT_TSX, COLOR_REACT}, + {"txt", ICON_EXT_TXT, COLOR_DOCUMENT}, + {"txz", ICON_EXT_TXZ, COLOR_ARCHIVE}, + + /* U */ + + /* V */ + {"vid", ICON_EXT_VID, COLOR_VIDEO}, + {"vim", ICON_EXT_VIM, COLOR_VIM}, + {"vimrc", ICON_EXT_VIMRC, COLOR_VIM}, + + /* W */ + {"wav", ICON_EXT_WAV, COLOR_AUDIO}, + {"webm", ICON_EXT_WEBM, COLOR_VIDEO}, + {"wma", ICON_EXT_WMA, COLOR_AUDIO}, + {"wmv", ICON_EXT_WMV, COLOR_VIDEO}, + + /* X */ + {"xbps", ICON_EXT_XBPS, COLOR_ARCHIVE}, + {"xhtml", ICON_EXT_XHTML, 0}, + {"xls", ICON_EXT_XLS, 0}, + {"xlsx", ICON_EXT_XLSX, 0}, + {"xml", ICON_EXT_XML, 0}, + {"xz", ICON_EXT_XZ, COLOR_ARCHIVE}, + + /* Y */ + {"yaml", ICON_EXT_YAML, COLOR_DOCUMENT}, + {"yml", ICON_EXT_YML, COLOR_DOCUMENT}, + + /* Z */ + {"zip", ICON_EXT_ZIP, COLOR_ARCHIVE}, /* Other */ +#endif }; @@ -112,8 +112,9 @@ #include "nnn.h" #include "dbg.h" -#ifdef ICONS +#if defined(ICONS) || defined(NERD) #include "icons.h" +#define ICONS_ENABLED #endif #ifdef TOURBIN_QSORT @@ -691,7 +692,7 @@ static const char * const patterns[] = { #define C_SOC (C_PIP + 1) /* Socket: MediumOrchid1 */ #define C_UND (C_SOC + 1) /* Unknown OR 0B regular/exe file: Red1 */ -#ifdef ICONS +#ifdef ICONS_ENABLED /* 0-9, A-Z, OTHER = 36. */ static ushort icon_positions[37]; #endif @@ -1739,7 +1740,7 @@ static bool initcurses(void *oldmask) } } -#ifdef ICONS +#ifdef ICONS_ENABLED if (!g_state.oldcolor) { uchar icolors[256] = {0}; char c; @@ -3480,7 +3481,7 @@ static char *get_lsperms(mode_t mode) return bits; } -#ifdef ICONS +#ifdef ICONS_ENABLED static const struct icon_pair * get_icon(const struct entry *ent){ ushort i = 0; @@ -3626,7 +3627,7 @@ static void printent(const struct entry *ent, uint namecols, bool sel) addch((ent->flags & FILE_SELECTED) ? '+' : ' '); -#ifdef ICONS +#ifdef ICONS_ENABLED if (!g_state.oldcolor) print_icon(ent, attrs); #endif @@ -3758,7 +3759,7 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel) attrs ^= A_DIM; } } else { -#ifndef ICONS +#ifndef ICONS_ENABLED addstr(" "); #endif if (ent->flags & FILE_MISSING) @@ -3770,7 +3771,7 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel) if (pair && fcolors[pair]) attrs |= COLOR_PAIR(pair); -#ifdef ICONS +#ifdef ICONS_ENABLED attroff(attrs); addstr(" "); if (sel) @@ -5573,7 +5574,7 @@ static int adjust_cols(int ncols) } /* 3 = Preceding space, indicator, newline */ -#ifdef ICONS +#ifdef ICONS_ENABLED ncols -= 3 + xstrlen(ICON_PADDING_LEFT) + xstrlen(ICON_PADDING_RIGHT) + 1; #else ncols -= 3; |