[PATCH] dotdot in the root directory
Jaroslaw Swierczynski
swiergot at intersec.pl
Wed Jan 29 21:26:27 UTC 2003
Hi,
In my opinion .. in the root directory may be very useful. Perhaps MC
should let users choose. I've been trying to code it but I run into
problems.
I splitted everything into three patches. The first one
(config.diff) adds support for a new option (dotdot_in_rootdir) in
configuration file and this works just fine. The goal of the second
patch is to add a new position in Layout setup. This is where the
problems begin. The new positions is put in wrong place in the dialog.
What is more, first keypress in the dialog causes segfault. I admit I
didn't spend much time on this but unfortunatelly I don't have much
free time at all now. Besides it is my first contact with MC code. I
think it will take a second for you to say what is wrong. And there is
the third patch that adds entries to translations files (to pot and to
polish po) but building MC with this fails on some exotic translation.
Surely I don't have something installed on my system.
I hope the patches will be useful and included to MC. I also hope to
learn something from you what I did wrong.
--
[ ----------< Live Long And Prosper !!! >---------- ]
[ Jaroslaw Swierczynski <swiergot at intersec.pl> ]
[ RLU: 207395 GG: 1834439 JID: swiergot at intersec.pl ]
[ ----> Slackware Linux. Join the revolution. <---- ]
-------------- next part --------------
diff -ruN mc-4.6.0-pre3.orig/src/dir.c mc-4.6.0-pre3/src/dir.c
--- mc-4.6.0-pre3.orig/src/dir.c 2003-01-21 03:25:50.000000000 +0100
+++ mc-4.6.0-pre3/src/dir.c 2003-01-28 18:44:49.000000000 +0100
@@ -28,6 +28,7 @@
#include "dir.h"
#include "wtools.h"
#include "tree.h"
+#include "layout.h" /* dotdot_in_rootdir */
/* If true show files starting with a dot */
int show_dot_files = 1;
@@ -503,8 +504,9 @@
}
if (next_free) {
- /* Add ".." except the root directory */
- if (strcmp (vfs_canon ("."), "/") != 0)
+ /* Add ".." except the root directory or including the root
+ directory if dotdot_in_rootdir is set */
+ if (dotdot_in_rootdir || (strcmp (vfs_canon ("."), "/") != 0))
add_dotdot_to_list (list, next_free++);
do_sort (list, sort, next_free - 1, reverse, case_sensitive);
} else {
@@ -655,8 +657,9 @@
tree_store_end_check ();
g_hash_table_destroy (marked_files);
if (next_free) {
- /* Add ".." except the root directory */
- if (strcmp (vfs_canon ("."), "/") != 0)
+ /* Add ".." except the root directory or including the root
+ directory if dotdot_in_rootdir is set */
+ if (dotdot_in_rootdir || (strcmp (vfs_canon ("."), "/") != 0))
add_dotdot_to_list (list, next_free++);
do_sort (list, sort, next_free - 1, rev, case_sensitive);
} else
diff -ruN mc-4.6.0-pre3.orig/src/layout.c mc-4.6.0-pre3/src/layout.c
--- mc-4.6.0-pre3.orig/src/layout.c 2002-12-28 06:11:40.000000000 +0100
+++ mc-4.6.0-pre3/src/layout.c 2003-01-28 22:24:25.000000000 +0100
@@ -104,6 +104,9 @@
/* The starting line for the output of the subprogram */
int output_start_y = 0;
+/* Controls whether to show .. in root directory */
+int dotdot_in_rootdir = 0;
+
/* The maximum number of views managed by the set_display_type routine */
/* Must be at least two (for current and other). Please note that until */
/* Janne gets around this, we will only manage two of them :-) */
diff -ruN mc-4.6.0-pre3.orig/src/layout.h mc-4.6.0-pre3/src/layout.h
--- mc-4.6.0-pre3.orig/src/layout.h 2002-12-26 17:20:51.000000000 +0100
+++ mc-4.6.0-pre3/src/layout.h 2003-01-28 18:34:46.000000000 +0100
@@ -35,6 +35,7 @@
extern int output_start_y;
extern int message_visible;
extern int xterm_title;
+extern int dotdot_in_rootdir;
extern int horizontal_split;
extern int nice_rotating_dash;
diff -ruN mc-4.6.0-pre3.orig/src/setup.c mc-4.6.0-pre3/src/setup.c
--- mc-4.6.0-pre3.orig/src/setup.c 2002-12-27 14:39:25.000000000 +0100
+++ mc-4.6.0-pre3/src/setup.c 2003-01-28 18:17:27.000000000 +0100
@@ -213,6 +213,7 @@
{ "nice_rotating_dash", &nice_rotating_dash },
{ "horizontal_split", &horizontal_split },
+ { "dotdot_in_rootdir", &dotdot_in_rootdir },
{ 0, 0 }
};
-------------- next part --------------
diff -ruN mc-4.6.0-pre3.orig/src/layout.c mc-4.6.0-pre3/src/layout.c
--- mc-4.6.0-pre3.orig/src/layout.c 2003-01-29 21:57:47.000000000 +0100
+++ mc-4.6.0-pre3/src/layout.c 2003-01-29 21:58:07.000000000 +0100
@@ -135,6 +135,7 @@
static int _xterm_title;
static int _permission_mode;
static int _filetype_mode;
+static int _dotdot_in_rootdir;
static int height;
@@ -173,6 +174,7 @@
{ N_("&Equal split"), &equal_split, 0, "eq" },
{ N_("pe&Rmissions"), &permission_mode, 0, "pr" },
{ N_("&File types"), &filetype_mode, 0, "ft" },
+ { N_("&Show .. in /"), &dotdot_in_rootdir, 0, "dd" },
{ 0, 0, 0, 0 }
};
@@ -316,6 +318,7 @@
_keybar_visible = check_options [2].widget->state & C_BOOL;
_message_visible = check_options [1].widget->state & C_BOOL;
_xterm_title = check_options [0].widget->state & C_BOOL;
+ _dotdot_in_rootdir = check_options [10].widget->state & C_BOOL;
if (console_flag){
int minimum;
if (_output_lines < 0)
@@ -383,7 +386,7 @@
first_width = l1;
}
- for (i = 0; i <= 8; i++)
+ for (i = 0; i <= 9; i++)
{
check_options[i].text = _(check_options[i].text);
l1 = strlen (check_options[i].text) + 7;
@@ -408,6 +411,10 @@
if (l1 > second_width)
second_width = l1;
}
+ check_options[9].text = _(check_options[9].text);
+ l1 = strlen (check_options[9].text) + 7;
+ if (l1 > second_width)
+ second_width = l1;
if (console_flag)
{
l1 = strlen (output_lines_label) + 13;
@@ -461,6 +468,8 @@
check_options [i].widget = check_new (8 - i, 7 + first_width, XTRACT(i));
add_widget (layout_dlg, check_options [i].widget);
}
+ check_options [9].widget = check_new (9, 7 + first_width, XTRACT(9));
+ add_widget (layout_dlg, check_options [9].widget);
check_options [8].widget = check_new (10, 6, XTRACT(8));
add_widget (layout_dlg, check_options [8].widget);
check_options [7].widget = check_new (9, 6, XTRACT(7));
@@ -474,6 +483,7 @@
_keybar_visible = keybar_visible;
_message_visible = message_visible;
_xterm_title = xterm_title;
+ _dotdot_in_rootdir = dotdot_in_rootdir;
bright_widget = button_new(6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback, 0, ">");
add_widget (layout_dlg, bright_widget);
bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback, 0, "<");
-------------- next part --------------
diff -ruN mc-4.6.0-pre3.orig/po/mc.pot mc-4.6.0-pre3/po/mc.pot
--- mc-4.6.0-pre3.orig/po/mc.pot 2003-01-22 08:46:54.000000000 +0100
+++ mc-4.6.0-pre3/po/mc.pot 2003-01-28 18:40:59.000000000 +0100
@@ -2370,6 +2370,10 @@
msgid "&File types"
msgstr ""
+#: src/layout.c:176
+msgid "&Show .. in /"
+msgstr ""
+
#: src/layout.c:362 src/learn.c:61 src/learn.c:176 src/option.c:147
msgid "&Save"
msgstr ""
diff -ruN mc-4.6.0-pre3.orig/po/pl.po mc-4.6.0-pre3/po/pl.po
--- mc-4.6.0-pre3.orig/po/pl.po 2003-01-22 08:47:00.000000000 +0100
+++ mc-4.6.0-pre3/po/pl.po 2003-01-28 18:40:04.000000000 +0100
@@ -2490,6 +2490,10 @@
msgid "&File types"
msgstr "Typy plik?w"
+#: src/layout.c:176
+msgid "&Show .. in /"
+msgstr "Pokazuj .. w /"
+
#: src/layout.c:362 src/learn.c:61 src/learn.c:176 src/option.c:147
msgid "&Save"
msgstr "&Zapisz"
More information about the mc-devel
mailing list