mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 21:42:00 +03:00
Merge branch '1992_mc_startup'
* 1992_mc_startup: Fixed variable declarations and added missing includes. Ticket #1992: incorrect sturtup of MC with some special paths.
This commit is contained in:
commit
eb4d447e69
@ -20,6 +20,7 @@
|
|||||||
# include "tty-ncurses.h"
|
# include "tty-ncurses.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* colors specified on the command line: they override any other setting */
|
||||||
extern char *command_line_colors;
|
extern char *command_line_colors;
|
||||||
|
|
||||||
void tty_init_colors (gboolean disable, gboolean force);
|
void tty_init_colors (gboolean disable, gboolean force);
|
||||||
|
@ -43,6 +43,11 @@
|
|||||||
|
|
||||||
/*** global variables **************************************************/
|
/*** global variables **************************************************/
|
||||||
|
|
||||||
|
/* If true program softkeys (HP terminals only) on startup and after every
|
||||||
|
command ran in the subshell to the description found in the termcap/terminfo
|
||||||
|
database */
|
||||||
|
int reset_hp_softkeys = 0;
|
||||||
|
|
||||||
/* If true lines are drown by spaces */
|
/* If true lines are drown by spaces */
|
||||||
gboolean slow_tty = FALSE;
|
gboolean slow_tty = FALSE;
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
/* {{{ Input }}} */
|
/* {{{ Input }}} */
|
||||||
|
|
||||||
|
extern int reset_hp_softkeys;
|
||||||
|
|
||||||
extern void tty_init (gboolean slow, gboolean ugly_lines);
|
extern void tty_init (gboolean slow, gboolean ugly_lines);
|
||||||
extern void tty_shutdown (void);
|
extern void tty_shutdown (void);
|
||||||
|
|
||||||
|
23
src/args.c
23
src/args.c
@ -25,29 +25,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/tty/tty.h"
|
#include "lib/tty/tty.h"
|
||||||
|
#include "lib/tty/color.h" /* command_line_colors */
|
||||||
#include "lib/strutil.h"
|
#include "lib/strutil.h"
|
||||||
|
|
||||||
#include "src/args.h"
|
#include "src/main.h"
|
||||||
#include "src/textconf.h"
|
#include "src/textconf.h"
|
||||||
|
#include "subshell.h" /* use_subshell */
|
||||||
|
|
||||||
|
#include "src/args.h"
|
||||||
|
|
||||||
/*** external variables **************************************************************************/
|
/*** external variables **************************************************************************/
|
||||||
|
|
||||||
extern int reset_hp_softkeys;
|
|
||||||
extern int use_subshell;
|
|
||||||
|
|
||||||
extern char *mc_home;
|
|
||||||
extern char *mc_home_alt;
|
|
||||||
|
|
||||||
/* colors specified on the command line: they override any other setting */
|
|
||||||
extern char *command_line_colors;
|
|
||||||
|
|
||||||
extern const char *edit_one_file;
|
|
||||||
extern const char *view_one_file;
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
/* If true, show version info and exit */
|
/* If true, show version info and exit */
|
||||||
@ -93,11 +86,11 @@ int mc_args__debug_level = 0;
|
|||||||
|
|
||||||
static GOptionContext *context;
|
static GOptionContext *context;
|
||||||
|
|
||||||
|
|
||||||
static gboolean mc_args__nouse_subshell = FALSE;
|
static gboolean mc_args__nouse_subshell = FALSE;
|
||||||
static gboolean mc_args__show_datadirs = FALSE;
|
static gboolean mc_args__show_datadirs = FALSE;
|
||||||
|
|
||||||
GOptionGroup *main_group;
|
static GOptionGroup *main_group;
|
||||||
|
|
||||||
static const GOptionEntry argument_main_table[] = {
|
static const GOptionEntry argument_main_table[] = {
|
||||||
/* generic options */
|
/* generic options */
|
||||||
{
|
{
|
||||||
|
108
src/main.c
108
src/main.c
@ -42,11 +42,12 @@
|
|||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
|
|
||||||
#include "lib/tty/tty.h"
|
#include "lib/tty/tty.h"
|
||||||
#include "lib/skin.h"
|
|
||||||
#include "lib/tty/mouse.h"
|
#include "lib/tty/mouse.h"
|
||||||
#include "lib/tty/key.h" /* For init_key() */
|
#include "lib/tty/key.h" /* For init_key() */
|
||||||
#include "lib/tty/win.h" /* xterm_flag */
|
#include "lib/tty/win.h" /* xterm_flag */
|
||||||
|
|
||||||
|
#include "lib/skin.h"
|
||||||
|
|
||||||
#include "lib/mcconfig.h"
|
#include "lib/mcconfig.h"
|
||||||
#include "lib/filehighlight.h"
|
#include "lib/filehighlight.h"
|
||||||
#include "lib/fileloc.h" /* MC_USERCONF_DIR */
|
#include "lib/fileloc.h" /* MC_USERCONF_DIR */
|
||||||
@ -197,11 +198,6 @@ int mouse_move_pages = 1;
|
|||||||
/* If true: l&r arrows are used to chdir if the input line is empty */
|
/* If true: l&r arrows are used to chdir if the input line is empty */
|
||||||
int navigate_with_arrows = 0;
|
int navigate_with_arrows = 0;
|
||||||
|
|
||||||
/* If true program softkeys (HP terminals only) on startup and after every
|
|
||||||
command ran in the subshell to the description found in the termcap/terminfo
|
|
||||||
database */
|
|
||||||
int reset_hp_softkeys = 0;
|
|
||||||
|
|
||||||
/* The prompt */
|
/* The prompt */
|
||||||
const char *mc_prompt = NULL;
|
const char *mc_prompt = NULL;
|
||||||
|
|
||||||
@ -937,9 +933,7 @@ create_panels (void)
|
|||||||
int current_index;
|
int current_index;
|
||||||
int other_index;
|
int other_index;
|
||||||
panel_view_mode_t current_mode, other_mode;
|
panel_view_mode_t current_mode, other_mode;
|
||||||
char original_dir[1024];
|
char original_dir[BUF_1K] = "\0";
|
||||||
|
|
||||||
original_dir[0] = 0;
|
|
||||||
|
|
||||||
if (boot_current_is_left) {
|
if (boot_current_is_left) {
|
||||||
current_index = 0;
|
current_index = 0;
|
||||||
@ -967,7 +961,7 @@ create_panels (void)
|
|||||||
|
|
||||||
/* The other panel */
|
/* The other panel */
|
||||||
if (other_dir) {
|
if (other_dir) {
|
||||||
if (original_dir[0])
|
if (original_dir[0] != '\0')
|
||||||
translated_mc_chdir (original_dir);
|
translated_mc_chdir (original_dir);
|
||||||
translated_mc_chdir (other_dir);
|
translated_mc_chdir (other_dir);
|
||||||
}
|
}
|
||||||
@ -1388,18 +1382,6 @@ midnight_execute_cmd (Widget *sender, unsigned long command)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
setup_pre (void)
|
|
||||||
{
|
|
||||||
/* Call all the inits */
|
|
||||||
|
|
||||||
#ifdef HAVE_SLANG
|
|
||||||
tty_display_8bit (full_eight_bits != 0);
|
|
||||||
#else
|
|
||||||
tty_display_8bit (eight_bit_clean != 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_xterm_support (void)
|
init_xterm_support (void)
|
||||||
{
|
{
|
||||||
@ -1448,9 +1430,11 @@ init_xterm_support (void)
|
|||||||
static void
|
static void
|
||||||
setup_mc (void)
|
setup_mc (void)
|
||||||
{
|
{
|
||||||
setup_pre ();
|
#ifdef HAVE_SLANG
|
||||||
create_panels ();
|
tty_display_8bit (full_eight_bits != 0);
|
||||||
setup_panels ();
|
#else
|
||||||
|
tty_display_8bit (eight_bit_clean != 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
if (use_subshell)
|
if (use_subshell)
|
||||||
@ -1552,6 +1536,9 @@ midnight_callback (Dlg_head *h, Widget *sender,
|
|||||||
unsigned long command;
|
unsigned long command;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
|
case DLG_INIT:
|
||||||
|
setup_panels ();
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
case DLG_DRAW:
|
case DLG_DRAW:
|
||||||
load_hint (1);
|
load_hint (1);
|
||||||
@ -1570,6 +1557,12 @@ midnight_callback (Dlg_head *h, Widget *sender,
|
|||||||
case DLG_IDLE:
|
case DLG_IDLE:
|
||||||
/* We only need the first idle event to show user menu after start */
|
/* We only need the first idle event to show user menu after start */
|
||||||
set_idle_proc (h, 0);
|
set_idle_proc (h, 0);
|
||||||
|
|
||||||
|
if (boot_current_is_left)
|
||||||
|
dlg_select_widget (get_panel_widget (0));
|
||||||
|
else
|
||||||
|
dlg_select_widget (get_panel_widget (1));
|
||||||
|
|
||||||
if (auto_menu)
|
if (auto_menu)
|
||||||
midnight_execute_cmd (NULL, CK_UserMenuCmd);
|
midnight_execute_cmd (NULL, CK_UserMenuCmd);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
@ -1777,15 +1770,18 @@ load_hint (int force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_panels_and_run_mc (void)
|
create_panels_and_run_mc (void)
|
||||||
{
|
{
|
||||||
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
||||||
|
|
||||||
|
create_panels ();
|
||||||
|
|
||||||
add_widget (midnight_dlg, the_menubar);
|
add_widget (midnight_dlg, the_menubar);
|
||||||
init_menu ();
|
init_menu ();
|
||||||
|
|
||||||
add_widget (midnight_dlg, get_panel_widget (0));
|
add_widget (midnight_dlg, get_panel_widget (0));
|
||||||
add_widget (midnight_dlg, get_panel_widget (1));
|
add_widget (midnight_dlg, get_panel_widget (1));
|
||||||
|
|
||||||
add_widget (midnight_dlg, the_hint);
|
add_widget (midnight_dlg, the_hint);
|
||||||
add_widget (midnight_dlg, cmdline);
|
add_widget (midnight_dlg, cmdline);
|
||||||
add_widget (midnight_dlg, the_prompt);
|
add_widget (midnight_dlg, the_prompt);
|
||||||
@ -1793,11 +1789,6 @@ setup_panels_and_run_mc (void)
|
|||||||
add_widget (midnight_dlg, the_bar);
|
add_widget (midnight_dlg, the_bar);
|
||||||
midnight_set_buttonbar (the_bar);
|
midnight_set_buttonbar (the_bar);
|
||||||
|
|
||||||
if (boot_current_is_left)
|
|
||||||
dlg_select_widget (get_panel_widget (0));
|
|
||||||
else
|
|
||||||
dlg_select_widget (get_panel_widget (1));
|
|
||||||
|
|
||||||
/* Run the Midnight Commander if no file was specified in the command line */
|
/* Run the Midnight Commander if no file was specified in the command line */
|
||||||
run_dlg (midnight_dlg);
|
run_dlg (midnight_dlg);
|
||||||
}
|
}
|
||||||
@ -1807,45 +1798,39 @@ static char *
|
|||||||
prepend_cwd_on_local (const char *filename)
|
prepend_cwd_on_local (const char *filename)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
int l;
|
size_t l;
|
||||||
|
|
||||||
if (vfs_file_is_local (filename)) {
|
if (!vfs_file_is_local (filename)
|
||||||
if (*filename == PATH_SEP) /* an absolute pathname */
|
|| g_path_is_absolute (filename))
|
||||||
return g_strdup (filename);
|
|
||||||
d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
|
|
||||||
mc_get_current_wd (d, MC_MAXPATHLEN);
|
|
||||||
l = strlen (d);
|
|
||||||
d[l++] = PATH_SEP;
|
|
||||||
strcpy (d + l, filename);
|
|
||||||
canonicalize_pathname (d);
|
|
||||||
return d;
|
|
||||||
} else
|
|
||||||
return g_strdup (filename);
|
return g_strdup (filename);
|
||||||
|
|
||||||
|
d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
|
||||||
|
mc_get_current_wd (d, MC_MAXPATHLEN);
|
||||||
|
l = strlen (d);
|
||||||
|
d[l++] = PATH_SEP;
|
||||||
|
strcpy (d + l, filename);
|
||||||
|
canonicalize_pathname (d);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/* Invoke the internal view/edit routine with:
|
||||||
|
* the default processing and forcing the internal viewer/editor
|
||||||
|
*/
|
||||||
|
static void
|
||||||
mc_maybe_editor_or_viewer (void)
|
mc_maybe_editor_or_viewer (void)
|
||||||
{
|
{
|
||||||
if (!(view_one_file || edit_one_file))
|
if (view_one_file != NULL) {
|
||||||
return 0;
|
char *path;
|
||||||
|
|
||||||
/* Invoke the internal view/edit routine with:
|
|
||||||
* the default processing and forcing the internal viewer/editor
|
|
||||||
*/
|
|
||||||
if (view_one_file) {
|
|
||||||
char *path = NULL;
|
|
||||||
path = prepend_cwd_on_local (view_one_file);
|
path = prepend_cwd_on_local (view_one_file);
|
||||||
view_file (path, 0, 1);
|
view_file (path, 0, 1);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
else {
|
else
|
||||||
edit_file (edit_one_file, edit_one_file_start_line);
|
edit_file (edit_one_file, edit_one_file_start_line);
|
||||||
}
|
|
||||||
#endif /* USE_INTERNAL_EDIT */
|
#endif /* USE_INTERNAL_EDIT */
|
||||||
midnight_shutdown = 1;
|
midnight_shutdown = 1;
|
||||||
done_mc ();
|
done_mc ();
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the main dialog that occupies the whole screen */
|
/* Run the main dialog that occupies the whole screen */
|
||||||
@ -1863,7 +1848,7 @@ do_nc (void)
|
|||||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
||||||
"[main]", NULL, DLG_WANT_IDLE);
|
"[main]", NULL, DLG_WANT_IDLE);
|
||||||
|
|
||||||
if (view_one_file || edit_one_file)
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
setup_dummy_mc ();
|
setup_dummy_mc ();
|
||||||
else
|
else
|
||||||
setup_mc ();
|
setup_mc ();
|
||||||
@ -1896,8 +1881,10 @@ do_nc (void)
|
|||||||
help_map = (global_keymap_t *) help_keymap->data;
|
help_map = (global_keymap_t *) help_keymap->data;
|
||||||
|
|
||||||
/* Check if we were invoked as an editor or file viewer */
|
/* Check if we were invoked as an editor or file viewer */
|
||||||
if (!mc_maybe_editor_or_viewer ()) {
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
setup_panels_and_run_mc ();
|
mc_maybe_editor_or_viewer ();
|
||||||
|
else {
|
||||||
|
create_panels_and_run_mc ();
|
||||||
|
|
||||||
/* Program end */
|
/* Program end */
|
||||||
midnight_shutdown = 1;
|
midnight_shutdown = 1;
|
||||||
@ -2149,7 +2136,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
/* Don't use subshell when invoked as viewer or editor */
|
/* Don't use subshell when invoked as viewer or editor */
|
||||||
if (edit_one_file || view_one_file)
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
use_subshell = 0;
|
use_subshell = 0;
|
||||||
|
|
||||||
if (use_subshell)
|
if (use_subshell)
|
||||||
@ -2216,12 +2203,11 @@ main (int argc, char *argv[])
|
|||||||
if (use_subshell) {
|
if (use_subshell) {
|
||||||
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
||||||
if (mc_prompt == NULL)
|
if (mc_prompt == NULL)
|
||||||
mc_prompt = "";
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||||
|
|
||||||
|
|
||||||
/* Program main loop */
|
/* Program main loop */
|
||||||
if (!midnight_shutdown)
|
if (!midnight_shutdown)
|
||||||
do_nc ();
|
do_nc ();
|
||||||
|
@ -29,6 +29,8 @@ struct WButtonBar;
|
|||||||
void midnight_set_buttonbar (struct WButtonBar *b);
|
void midnight_set_buttonbar (struct WButtonBar *b);
|
||||||
|
|
||||||
/* See main.c for details on these variables */
|
/* See main.c for details on these variables */
|
||||||
|
extern const char *edit_one_file;
|
||||||
|
extern const char *view_one_file;
|
||||||
extern int mark_moves_down;
|
extern int mark_moves_down;
|
||||||
extern int auto_menu;
|
extern int auto_menu;
|
||||||
extern int pause_after_run;
|
extern int pause_after_run;
|
||||||
@ -103,6 +105,7 @@ extern const global_keymap_t *help_map;
|
|||||||
|
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
void do_update_prompt (void);
|
void do_update_prompt (void);
|
||||||
|
int load_prompt (int fd, void *unused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum cd_enum {
|
enum cd_enum {
|
||||||
@ -113,7 +116,6 @@ enum cd_enum {
|
|||||||
int do_cd (const char *new_dir, enum cd_enum cd_type); /* For find.c */
|
int do_cd (const char *new_dir, enum cd_enum cd_type); /* For find.c */
|
||||||
void sort_cmd (void);
|
void sort_cmd (void);
|
||||||
void change_panel (void);
|
void change_panel (void);
|
||||||
int load_prompt (int, void *);
|
|
||||||
void save_cwds_stat (void);
|
void save_cwds_stat (void);
|
||||||
void quiet_quit_cmd (void); /* For cmd.c and command.c */
|
void quiet_quit_cmd (void); /* For cmd.c and command.c */
|
||||||
|
|
||||||
|
@ -344,6 +344,9 @@ save_panel_types (void)
|
|||||||
{
|
{
|
||||||
panel_view_mode_t type;
|
panel_view_mode_t type;
|
||||||
|
|
||||||
|
if ((view_one_file != NULL) || (edit_one_file != NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
||||||
"auto_save_setup_panels", auto_save_setup))
|
"auto_save_setup_panels", auto_save_setup))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user