mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #3047: fix mc arguments handling.
Following cases from command line are possible: * 'mc' (no arguments): active panel uses current directory passive panel uses "other_dir" from ini * 'mc dir1 dir2' (two arguments): left panel uses dir1 right panel uses dir2 * 'mc dir1' (single argument): active panel uses current directory passive panel uses dir1 Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
c2a8c08673
commit
6da546bcf3
@ -171,9 +171,16 @@ screen modes, and able to send mouse escape sequences).
|
|||||||
.I \-X, \-\-no\-x11
|
.I \-X, \-\-no\-x11
|
||||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||||
.PP
|
.PP
|
||||||
If specified, the first path name is the directory to show in the
|
If both paths are specified, the first path name is the directory to show
|
||||||
selected panel; the second path name is the directory to be shown in
|
in the left panel; the second path name is the directory to be shown in
|
||||||
the other panel.
|
the right panel.
|
||||||
|
.PP
|
||||||
|
If one path is specified, the path name is the directory to show
|
||||||
|
in the active panel; current directory is shown in the passive panel.
|
||||||
|
.PP
|
||||||
|
If no paths are specified, current directory is shown in the active panel;
|
||||||
|
value of "other_dir" from panels.ini is the directory to be shown in
|
||||||
|
the passive panel.
|
||||||
.\"NODE "Overview"
|
.\"NODE "Overview"
|
||||||
.SH "Overview"
|
.SH "Overview"
|
||||||
The screen of the Midnight Commander is divided into four parts.
|
The screen of the Midnight Commander is divided into four parts.
|
||||||
|
@ -148,9 +148,14 @@ modes, and able to send mouse escape sequences).
|
|||||||
.I \-X, \-\-no\-x11
|
.I \-X, \-\-no\-x11
|
||||||
Не использовать X11 для получения состояния модификаторов Alt, Ctrl, Shift.
|
Не использовать X11 для получения состояния модификаторов Alt, Ctrl, Shift.
|
||||||
.PP
|
.PP
|
||||||
Первое путевое имя (path name) в командной строке (если указано) задает
|
Если в командной строке указаны два каталога, первый будет отображаться
|
||||||
каталог, который будет отображаться в активной панели; второй путь \-
|
в левой панели, второй \- в правой.
|
||||||
каталог, отображаемый во второй панели.
|
.PP
|
||||||
|
Если указан только один каталог, он будет отображён в активной панели,
|
||||||
|
во второй панели будет отображён текущий каталог.
|
||||||
|
.PP
|
||||||
|
Если каталоги не указаны, в активной панели будет отображён текущий каталог,
|
||||||
|
а во второй панели \- каталог, указанный в параметре "other_dir" в файла panels.ini.
|
||||||
.\"NODE "Overview"
|
.\"NODE "Overview"
|
||||||
.SH "Главное окно программы"
|
.SH "Главное окно программы"
|
||||||
Главное окно программы Midnight Commander состоит из трех полей. Два
|
Главное окно программы Midnight Commander состоит из трех полей. Два
|
||||||
|
@ -580,6 +580,22 @@ create_panels (void)
|
|||||||
char *current_dir, *other_dir;
|
char *current_dir, *other_dir;
|
||||||
vfs_path_t *original_dir;
|
vfs_path_t *original_dir;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Following cases from command line are possible:
|
||||||
|
* 'mc' (no arguments): mc_run_param0 == NULL, mc_run_param1 == NULL
|
||||||
|
* active panel uses current directory
|
||||||
|
* passive panel uses "other_dir" from ini
|
||||||
|
*
|
||||||
|
* 'mc dir1 dir2' (two arguments): mc_run_param0 != NULL, mc_run_param1 != NULL
|
||||||
|
* left panel uses mc_run_param0
|
||||||
|
* right panel uses mc_run_param1
|
||||||
|
*
|
||||||
|
* 'mc dir1' (single argument): mc_run_param0 != NULL, mc_run_param1 == NULL
|
||||||
|
* active panel uses current directory
|
||||||
|
* passive panel uses mc_run_param0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Set up panel directories */
|
||||||
if (boot_current_is_left)
|
if (boot_current_is_left)
|
||||||
{
|
{
|
||||||
/* left panel is active */
|
/* left panel is active */
|
||||||
@ -587,12 +603,26 @@ create_panels (void)
|
|||||||
other_index = 1;
|
other_index = 1;
|
||||||
current_mode = startup_left_mode;
|
current_mode = startup_left_mode;
|
||||||
other_mode = startup_right_mode;
|
other_mode = startup_right_mode;
|
||||||
/* if mc_run_param0 is NULL, working directory will be used for the left panel */
|
|
||||||
|
if (mc_run_param0 == NULL && mc_run_param1 == NULL)
|
||||||
|
{
|
||||||
|
/* no arguments */
|
||||||
|
current_dir = NULL; /* assume current dir */
|
||||||
|
other_dir = saved_other_dir; /* from ini */
|
||||||
|
}
|
||||||
|
else if (mc_run_param0 != NULL && mc_run_param1 != NULL)
|
||||||
|
{
|
||||||
|
/* two arguments */
|
||||||
current_dir = (char *) mc_run_param0;
|
current_dir = (char *) mc_run_param0;
|
||||||
/* mc_run_param1 is never NULL. It is setup from command line or from panels.ini
|
|
||||||
* (value of other_dir). mc_run_param1 will be used for the right panel */
|
|
||||||
other_dir = mc_run_param1;
|
other_dir = mc_run_param1;
|
||||||
}
|
}
|
||||||
|
else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
|
||||||
|
{
|
||||||
|
/* one argument */
|
||||||
|
current_dir = NULL; /* assume current dir */
|
||||||
|
other_dir = (char *) mc_run_param0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* right panel is active */
|
/* right panel is active */
|
||||||
@ -601,19 +631,23 @@ create_panels (void)
|
|||||||
current_mode = startup_right_mode;
|
current_mode = startup_right_mode;
|
||||||
other_mode = startup_left_mode;
|
other_mode = startup_left_mode;
|
||||||
|
|
||||||
/* if mc_run_param0 is not NULL (it was setup from command line), it will be used
|
if (mc_run_param0 == NULL && mc_run_param1 == NULL)
|
||||||
* for the left panel, working directory will be used for the right one;
|
|
||||||
* if mc_run_param0 is NULL, working directory will be used for the right (active) panel,
|
|
||||||
* mc_run_param1 will be used for the left one */
|
|
||||||
if (mc_run_param0 != NULL)
|
|
||||||
{
|
{
|
||||||
current_dir = NULL;
|
/* no arguments */
|
||||||
|
current_dir = NULL; /* assume current dir */
|
||||||
|
other_dir = saved_other_dir; /* from ini */
|
||||||
|
}
|
||||||
|
else if (mc_run_param0 != NULL && mc_run_param1 != NULL)
|
||||||
|
{
|
||||||
|
/* two arguments */
|
||||||
|
current_dir = mc_run_param1;
|
||||||
other_dir = (char *) mc_run_param0;
|
other_dir = (char *) mc_run_param0;
|
||||||
}
|
}
|
||||||
else
|
else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
|
||||||
{
|
{
|
||||||
current_dir = NULL;
|
/* one argument */
|
||||||
other_dir = mc_run_param1;
|
current_dir = NULL; /* assume current dir */;
|
||||||
|
other_dir = (char *) mc_run_param0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,6 +469,7 @@ main (int argc, char *argv[])
|
|||||||
g_list_free ((GList *) mc_run_param0);
|
g_list_free ((GList *) mc_run_param0);
|
||||||
}
|
}
|
||||||
g_free (mc_run_param1);
|
g_free (mc_run_param1);
|
||||||
|
g_free (saved_other_dir);
|
||||||
|
|
||||||
mc_config_deinit_config_paths ();
|
mc_config_deinit_config_paths ();
|
||||||
|
|
||||||
|
@ -193,6 +193,9 @@ gboolean is_autodetect_codeset_enabled = FALSE;
|
|||||||
char *spell_language = NULL;
|
char *spell_language = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Value of "other_dir" key in ini file */
|
||||||
|
char *saved_other_dir = NULL;
|
||||||
|
|
||||||
/* If set, then print to the given file the last directory we were at */
|
/* If set, then print to the given file the last directory we were at */
|
||||||
char *last_wd_string = NULL;
|
char *last_wd_string = NULL;
|
||||||
|
|
||||||
@ -986,13 +989,13 @@ load_setup (void)
|
|||||||
if (startup_left_mode != view_listing && startup_right_mode != view_listing)
|
if (startup_left_mode != view_listing && startup_right_mode != view_listing)
|
||||||
startup_left_mode = view_listing;
|
startup_left_mode = view_listing;
|
||||||
|
|
||||||
if (mc_run_param1 == NULL)
|
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
|
buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
|
||||||
vpath = vfs_path_from_str (buffer);
|
vpath = vfs_path_from_str (buffer);
|
||||||
if (vfs_file_is_local (vpath))
|
if (vfs_file_is_local (vpath))
|
||||||
mc_run_param1 = buffer;
|
saved_other_dir = buffer;
|
||||||
else
|
else
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
|
@ -117,6 +117,9 @@ extern gboolean is_autodetect_codeset_enabled;
|
|||||||
extern char *spell_language;
|
extern char *spell_language;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Value of "other_dir" key in ini file */
|
||||||
|
extern char *saved_other_dir;
|
||||||
|
|
||||||
/* If set, then print to the given file the last directory we were at */
|
/* If set, then print to the given file the last directory we were at */
|
||||||
extern char *last_wd_string;
|
extern char *last_wd_string;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user