mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Merge branch '3047_panel_dir_fix'
* 3047_panel_dir_fix: Ticket #3047: fix mc arguments handling.
This commit is contained in:
commit
245142fcbe
@ -171,9 +171,16 @@ screen modes, and able to send mouse escape sequences).
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.PP
|
||||
If specified, the first path name is the directory to show in the
|
||||
selected panel; the second path name is the directory to be shown in
|
||||
the other panel.
|
||||
If both paths are specified, the first path name is the directory to show
|
||||
in the left panel; the second path name is the directory to be shown in
|
||||
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"
|
||||
.SH "Overview"
|
||||
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
|
||||
Не использовать X11 для получения состояния модификаторов Alt, Ctrl, Shift.
|
||||
.PP
|
||||
Первое путевое имя (path name) в командной строке (если указано) задает
|
||||
каталог, который будет отображаться в активной панели; второй путь \-
|
||||
каталог, отображаемый во второй панели.
|
||||
Если в командной строке указаны два каталога, первый будет отображаться
|
||||
в левой панели, второй \- в правой.
|
||||
.PP
|
||||
Если указан только один каталог, он будет отображён в активной панели,
|
||||
во второй панели будет отображён текущий каталог.
|
||||
.PP
|
||||
Если каталоги не указаны, в активной панели будет отображён текущий каталог,
|
||||
а во второй панели \- каталог, указанный в параметре "other_dir" в файла panels.ini.
|
||||
.\"NODE "Overview"
|
||||
.SH "Главное окно программы"
|
||||
Главное окно программы Midnight Commander состоит из трех полей. Два
|
||||
|
@ -580,6 +580,22 @@ create_panels (void)
|
||||
char *current_dir, *other_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)
|
||||
{
|
||||
/* left panel is active */
|
||||
@ -587,11 +603,25 @@ create_panels (void)
|
||||
other_index = 1;
|
||||
current_mode = startup_left_mode;
|
||||
other_mode = startup_right_mode;
|
||||
/* if mc_run_param0 is NULL, working directory will be used for the left panel */
|
||||
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;
|
||||
|
||||
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;
|
||||
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
|
||||
{
|
||||
@ -601,19 +631,23 @@ create_panels (void)
|
||||
current_mode = startup_right_mode;
|
||||
other_mode = startup_left_mode;
|
||||
|
||||
/* if mc_run_param0 is not NULL (it was setup from command line), it will be used
|
||||
* 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)
|
||||
if (mc_run_param0 == NULL && mc_run_param1 == 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;
|
||||
}
|
||||
else
|
||||
else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
|
||||
{
|
||||
current_dir = NULL;
|
||||
other_dir = mc_run_param1;
|
||||
/* one argument */
|
||||
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_free (mc_run_param1);
|
||||
g_free (saved_other_dir);
|
||||
|
||||
mc_config_deinit_config_paths ();
|
||||
|
||||
|
@ -193,6 +193,9 @@ gboolean is_autodetect_codeset_enabled = FALSE;
|
||||
char *spell_language = NULL;
|
||||
#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 */
|
||||
char *last_wd_string = NULL;
|
||||
|
||||
@ -986,13 +989,13 @@ load_setup (void)
|
||||
if (startup_left_mode != view_listing && startup_right_mode != view_listing)
|
||||
startup_left_mode = view_listing;
|
||||
|
||||
if (mc_run_param1 == NULL)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
|
||||
vpath = vfs_path_from_str (buffer);
|
||||
if (vfs_file_is_local (vpath))
|
||||
mc_run_param1 = buffer;
|
||||
saved_other_dir = buffer;
|
||||
else
|
||||
g_free (buffer);
|
||||
vfs_path_free (vpath);
|
||||
|
@ -117,6 +117,9 @@ extern gboolean is_autodetect_codeset_enabled;
|
||||
extern char *spell_language;
|
||||
#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 */
|
||||
extern char *last_wd_string;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user