[PATCH]: aligned file extensions and different sorting mode for .files
malc
malc at pulsesoft.com
Sun Oct 28 00:30:26 UTC 2001
--
mailto:malc at pulsesoft.com
-------------- next part --------------
? mc.patch
? edit/.deps
? slang/.deps
? src/.deps
Index: src/dir.c
===================================================================
RCS file: /cvs/gnome/mc/src/dir.c,v
retrieving revision 1.27
diff -u -p -r1.27 dir.c
--- src/dir.c 2001/09/07 17:52:19 1.27
+++ src/dir.c 2001/10/28 00:25:01
@@ -145,13 +145,21 @@ sort_ext (const file_entry *a, const fil
int bd = MY_ISDIR (b);
if (ad == bd || mix_all_files){
+ if (a->fname[0] == '.' || b->fname[0] == '.') {
+ if (a->fname[0] == '.' && b->fname[0] == '.')
+ return sort_name (a, b); /* so they appear at bottom */
+ else
+ return sort_name (a, b) * -reverse;
+ } else {
exta = extension (a->fname);
extb = extension (b->fname);
+
r = string_sortcomp (exta, extb);
if (r)
- return r * reverse;
+ return r * reverse;
else
- return sort_name (a, b);
+ return sort_name (a, b);
+ }
} else
return bd-ad;
}
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/mc/src/main.c,v
retrieving revision 1.173
diff -u -p -r1.173 main.c
--- src/main.c 2001/10/01 06:51:15 1.173
+++ src/main.c 2001/10/28 00:25:15
@@ -829,6 +829,9 @@ int quiet_quit_cmd (void)
return quit;
}
+/* To align file extensions */
+int align_file_extensions = 1;
+
/*
* Touch window and refresh window functions
*/
Index: src/main.h
===================================================================
RCS file: /cvs/gnome/mc/src/main.h,v
retrieving revision 1.27
diff -u -p -r1.27 main.h
--- src/main.h 2001/10/23 01:39:25 1.27
+++ src/main.h 2001/10/28 00:25:18
@@ -105,6 +105,7 @@ extern int only_leading_plus_minus;
extern int ftpfs_directory_timeout;
extern int output_starts_shell;
extern int midnight_shutdown;
+extern int align_file_extensions;
extern char search_buffer [256];
extern char cmd_buf [512];
extern char *cmdline_geometry;
Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/mc/src/screen.c,v
retrieving revision 1.101
diff -u -p -r1.101 screen.c
--- src/screen.c 2001/10/01 04:31:49 1.101
+++ src/screen.c 2001/10/28 00:25:32
@@ -169,9 +169,59 @@ add_permission_string (char *dest, int w
char *
string_file_name (file_entry *fe, int len)
{
- return fe->fname;
+/* start modification */
+#ifdef ALIGN_EXT_2
+ char *ext;
+ int flen, elen;
+ static char buffer [1000]; /* at most fname len (duh!) */
+
+ flen = strlen(fe->fname);
+ ext = extension(fe->fname);
+ elen = strlen(ext);
+
+ if (fe->fname[0] == '.' || elen == 0) return fe->fname;
+ memcpy(buffer, fe->fname, flen - elen - 1);
+ buffer[flen - elen - 1] = 0;
+
+ return buffer;
+
+#else
+ if (align_file_extensions == 0) {
+ return fe->fname;
+ } else {
+
+ char *ext;
+ int flen, dlen, elen;
+ static char buffer [100]; /* at most len */
+
+ flen = strlen(fe->fname);
+ dlen = len - (flen - 1);
+
+ if (fe->fname[0] == '.' || dlen <= 0) return fe->fname;
+ ext = extension(fe->fname);
+ elen = strlen(ext);
+ if (elen == 0) return fe->fname;
+
+ memset(buffer, ' ', len);
+ memcpy(buffer, fe->fname, flen - elen - 1);
+ memcpy(buffer + (len - elen), ext, elen);
+ buffer[len] = 0;
+
+ /* end */
+ return buffer;
+ }
+#endif
}
+#ifdef ALIGN_EXT_2
+/* ext */
+char *
+string_file_ext (file_entry *fe, int len)
+{
+ return extension(fe->fname);
+}
+#endif
+
/* size */
char *
string_file_size (file_entry *fe, int len)
@@ -385,6 +435,10 @@ static struct {
sortfn *sort_routine;
} formats [] = {
{ "name", 12, 1, J_LEFT_FIT, N_("Name"), 1, string_file_name, (sortfn *) sort_name },
+#ifdef ALIGN_EXT_2
+{ "ext", 3, 1, J_RIGHT, N_("Extension"),1, string_file_ext, NULL
+ },
+#endif
{ "size", 7, 0, J_RIGHT, N_("Size"), 1, string_file_size, (sortfn *) sort_size },
{ "bsize", 7, 0, J_RIGHT, N_("Size"), 1, string_file_size_brief, (sortfn *) sort_size },
{ "type", GT, 0, J_LEFT, "", 2, string_file_type, (sortfn *) sort_type },
Index: src/setup.c
===================================================================
RCS file: /cvs/gnome/mc/src/setup.c,v
retrieving revision 1.56
diff -u -p -r1.56 setup.c
--- src/setup.c 2001/10/01 06:08:57 1.56
+++ src/setup.c 2001/10/28 00:25:35
@@ -156,6 +156,7 @@ static const struct {
{ "show_backups", &show_backups },
{ "show_dot_files", &show_dot_files },
{ "verbose", &verbose },
+ { "align_file_extensions", &align_file_extensions },
{ "mark_moves_down", &mark_moves_down },
{ "pause_after_run", &pause_after_run },
{ "shell_patterns", &easy_patterns },
More information about the mc-devel
mailing list