files highlighting



3) this patch allow to highlight files in depend of they are extensions
Patch isn't complete, and in future I want to describe extensions in ini-file.
diff -Naur mc/src/color.c mc-new/src/color.c
--- mc/src/color.c	Wed Jun 13 10:19:48 2001
+++ mc-new/src/color.c	Mon Jul  2 15:48:51 2001
@@ -112,6 +112,12 @@
     { "editnormal=",     0, 0 },	/* normal */       /* 34 */
     { "editbold=",       0, 0 },	/* search->found */
     { "editmarked=",     0, 0 },	/* marked/selected */
+
+/* colors for specific files - mAX */
+    { "hidden=",     0, 0 }, /* hidden files */            /* 37 */
+    { "ft_arch=",    0, 0 }, /* archive file type */
+    { "ft_src=",     0, 0 }, /* sources file type */
+    { "ft_media=",   0, 0 }, /* multimedia file type */
 };
 
 struct color_table_s {
diff -Naur mc/src/color.h mc-new/src/color.h
--- mc/src/color.h	Tue May 29 20:02:28 2001
+++ mc-new/src/color.h	Mon Jul  2 15:48:59 2001
@@ -91,5 +91,11 @@
 #define EDITOR_MARKED_COLOR          (PORT_COLOR (MY_COLOR_PAIR (36),A_REVERSE))
 #define EDITOR_UNDERLINED_COLOR      VIEW_UNDERLINED_COLOR
 
-#endif /* __COLOR_H */
+/* colors for specific files - mAX */
+#define FILE_TYPE_COLOR_INDEX	      37
+#define HIDDEN_COLOR    (PORT_COLOR (MY_COLOR_PAIR (FILE_TYPE_COLOR_INDEX+0),0))
+#define ARCH_COLOR	(PORT_COLOR (MY_COLOR_PAIR (FILE_TYPE_COLOR_INDEX+1),0))
+#define SRC_COLOR	(PORT_COLOR (MY_COLOR_PAIR (FILE_TYPE_COLOR_INDEX+2),0))
+#define MEDIA_COLOR	(PORT_COLOR (MY_COLOR_PAIR (FILE_TYPE_COLOR_INDEX+3),0))
 
+#endif /* __COLOR_H */
diff -Naur mc/src/screen.c mc-new/src/screen.c
--- mc/src/screen.c	Fri Jun 29 15:01:37 2001
+++ mc-new/src/screen.c	Mon Jul  2 15:23:15 2001
@@ -461,6 +461,28 @@
     return (dest + len);
 }
 
+/* return color by file extension - mAX */
+/* TODO: make this configurable */
+int
+color_by_file_type(char *ext) {
+    if (!strcmp(ext, "gz")  || !strcmp(ext, "bz2") || !strcmp(ext, "tar") ||
+	!strcmp(ext, "tgz") || !strcmp(ext, "rpm") || !strcmp(ext, "Z")   ||
+	!strcmp(ext, "rar") || !strcmp(ext, "zip") || !strcmp(ext, "arj") ||
+	!strcmp(ext, "RAR") || !strcmp(ext, "ZIP") || !strcmp(ext, "ARJ")
+    ) return ARCH_COLOR;
+
+    if (!strcmp(ext, "c")   || !strcmp(ext, "cc")  || !strcmp(ext, "cpp") ||
+	!strcmp(ext, "h")   || !strcmp(ext, "hh")  || !strcmp(ext, "hpp") ||
+	!strcmp(ext, "pas") || !strcmp(ext, "pl")  || !strcmp(ext, "cgi")
+    ) return SRC_COLOR;
+
+    if (!strcmp(ext, "mp3") || !strcmp(ext, "mpg") || !strcmp(ext, "mpeg") ||
+	!strcmp(ext, "wav") || !strcmp(ext, "avi") || !strcmp(ext, "mp2")
+    ) return MEDIA_COLOR;
+
+    return NORMAL_COLOR;
+}
+
 int
 file_compute_color (int attr, file_entry *fe)
 {
@@ -480,6 +502,8 @@
     }
 
     /* if filetype_mode == true  */
+    if (fe->fname[0]=='.' && strcmp(fe->fname, "..")) /* show '..' and '.' as HIDDEN - mAX */
+	return (HIDDEN_COLOR);
     if (S_ISDIR (fe->buf.st_mode))
         return (DIRECTORY_COLOR);
     else if (S_ISLNK (fe->buf.st_mode)){
@@ -502,7 +526,7 @@
     else if (fe->fname && (!strcmp (fe->fname, "core") || !strcmp (extension(fe->fname), "core")))
 	return (CORE_COLOR);
 
-    return (NORMAL_COLOR); /* just for safeness */
+    return (color_by_file_type(extension(fe->fname))); /* return color by file extension - mAX */
 }
 
 /* Formats the file number file_index of panel in the buffer dest */
diff -Naur mc/src/text.c mc-new/src/text.c
--- mc/src/text.c	Thu Jun 14 18:59:52 2001
+++ mc-new/src/text.c	Mon Jul  2 15:18:07 2001
@@ -48,7 +48,11 @@
 "special=black,blue:"
 "editnormal=lightgray,blue:"
 "editbold=yellow,blue:"
-"editmarked=black,cyan";
+"editmarked=black,cyan:"
+"hidden=cyan,blue:"		/* hidden files - mAX */
+"ft_arch=brightmagenta,blue:"	/* archive files type - mAX */
+"ft_src=brightcyan,blue:"	/* source files type - mAX */
+"ft_media=green,blue:";		/* multimedia files type - mAX */
 
 void
 edition_post_exec (void)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]