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:
Andrew Borodin 2010-02-24 16:23:25 +00:00
commit eb4d447e69
7 changed files with 69 additions and 77 deletions

View File

@ -20,6 +20,7 @@
# include "tty-ncurses.h"
#endif
/* colors specified on the command line: they override any other setting */
extern char *command_line_colors;
void tty_init_colors (gboolean disable, gboolean force);

View File

@ -43,6 +43,11 @@
/*** 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 */
gboolean slow_tty = FALSE;

View File

@ -21,6 +21,8 @@
/* {{{ Input }}} */
extern int reset_hp_softkeys;
extern void tty_init (gboolean slow, gboolean ugly_lines);
extern void tty_shutdown (void);

View File

@ -25,29 +25,22 @@
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/tty/color.h" /* command_line_colors */
#include "lib/strutil.h"
#include "src/args.h"
#include "src/main.h"
#include "src/textconf.h"
#include "subshell.h" /* use_subshell */
#include "src/args.h"
/*** 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 ****************************************************************************/
/* If true, show version info and exit */
@ -93,11 +86,11 @@ int mc_args__debug_level = 0;
static GOptionContext *context;
static gboolean mc_args__nouse_subshell = FALSE;
static gboolean mc_args__show_datadirs = FALSE;
GOptionGroup *main_group;
static GOptionGroup *main_group;
static const GOptionEntry argument_main_table[] = {
/* generic options */
{

View File

@ -42,11 +42,12 @@
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/skin.h"
#include "lib/tty/mouse.h"
#include "lib/tty/key.h" /* For init_key() */
#include "lib/tty/win.h" /* xterm_flag */
#include "lib/skin.h"
#include "lib/mcconfig.h"
#include "lib/filehighlight.h"
#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 */
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 */
const char *mc_prompt = NULL;
@ -937,9 +933,7 @@ create_panels (void)
int current_index;
int other_index;
panel_view_mode_t current_mode, other_mode;
char original_dir[1024];
original_dir[0] = 0;
char original_dir[BUF_1K] = "\0";
if (boot_current_is_left) {
current_index = 0;
@ -967,7 +961,7 @@ create_panels (void)
/* The other panel */
if (other_dir) {
if (original_dir[0])
if (original_dir[0] != '\0')
translated_mc_chdir (original_dir);
translated_mc_chdir (other_dir);
}
@ -1388,18 +1382,6 @@ midnight_execute_cmd (Widget *sender, unsigned long command)
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
init_xterm_support (void)
{
@ -1448,9 +1430,11 @@ init_xterm_support (void)
static void
setup_mc (void)
{
setup_pre ();
create_panels ();
setup_panels ();
#ifdef HAVE_SLANG
tty_display_8bit (full_eight_bits != 0);
#else
tty_display_8bit (eight_bit_clean != 0);
#endif
#ifdef HAVE_SUBSHELL_SUPPORT
if (use_subshell)
@ -1552,6 +1536,9 @@ midnight_callback (Dlg_head *h, Widget *sender,
unsigned long command;
switch (msg) {
case DLG_INIT:
setup_panels ();
return MSG_HANDLED;
case DLG_DRAW:
load_hint (1);
@ -1570,6 +1557,12 @@ midnight_callback (Dlg_head *h, Widget *sender,
case DLG_IDLE:
/* We only need the first idle event to show user menu after start */
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)
midnight_execute_cmd (NULL, CK_UserMenuCmd);
return MSG_HANDLED;
@ -1777,15 +1770,18 @@ load_hint (int force)
}
static void
setup_panels_and_run_mc (void)
create_panels_and_run_mc (void)
{
midnight_dlg->get_shortcut = midnight_get_shortcut;
create_panels ();
add_widget (midnight_dlg, the_menubar);
init_menu ();
add_widget (midnight_dlg, get_panel_widget (0));
add_widget (midnight_dlg, get_panel_widget (1));
add_widget (midnight_dlg, the_hint);
add_widget (midnight_dlg, cmdline);
add_widget (midnight_dlg, the_prompt);
@ -1793,11 +1789,6 @@ setup_panels_and_run_mc (void)
add_widget (midnight_dlg, 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_dlg (midnight_dlg);
}
@ -1807,45 +1798,39 @@ static char *
prepend_cwd_on_local (const char *filename)
{
char *d;
int l;
size_t l;
if (vfs_file_is_local (filename)) {
if (*filename == PATH_SEP) /* an absolute pathname */
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
if (!vfs_file_is_local (filename)
|| 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;
}
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)
{
if (!(view_one_file || edit_one_file))
return 0;
/* Invoke the internal view/edit routine with:
* the default processing and forcing the internal viewer/editor
*/
if (view_one_file) {
char *path = NULL;
if (view_one_file != NULL) {
char *path;
path = prepend_cwd_on_local (view_one_file);
view_file (path, 0, 1);
g_free (path);
}
#ifdef USE_INTERNAL_EDIT
else {
else
edit_file (edit_one_file, edit_one_file_start_line);
}
#endif /* USE_INTERNAL_EDIT */
midnight_shutdown = 1;
done_mc ();
return 1;
}
/* 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,
"[main]", NULL, DLG_WANT_IDLE);
if (view_one_file || edit_one_file)
if ((view_one_file != NULL) || (edit_one_file != NULL))
setup_dummy_mc ();
else
setup_mc ();
@ -1896,8 +1881,10 @@ do_nc (void)
help_map = (global_keymap_t *) help_keymap->data;
/* Check if we were invoked as an editor or file viewer */
if (!mc_maybe_editor_or_viewer ()) {
setup_panels_and_run_mc ();
if ((view_one_file != NULL) || (edit_one_file != NULL))
mc_maybe_editor_or_viewer ();
else {
create_panels_and_run_mc ();
/* Program end */
midnight_shutdown = 1;
@ -2149,7 +2136,7 @@ main (int argc, char *argv[])
#ifdef HAVE_SUBSHELL_SUPPORT
/* 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;
if (use_subshell)
@ -2216,12 +2203,11 @@ main (int argc, char *argv[])
if (use_subshell) {
mc_prompt = strip_ctrl_codes (subshell_prompt);
if (mc_prompt == NULL)
mc_prompt = "";
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
} else
#endif /* HAVE_SUBSHELL_SUPPORT */
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
/* Program main loop */
if (!midnight_shutdown)
do_nc ();

View File

@ -29,6 +29,8 @@ struct WButtonBar;
void midnight_set_buttonbar (struct WButtonBar *b);
/* 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 auto_menu;
extern int pause_after_run;
@ -103,6 +105,7 @@ extern const global_keymap_t *help_map;
#ifdef HAVE_SUBSHELL_SUPPORT
void do_update_prompt (void);
int load_prompt (int fd, void *unused);
#endif
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 */
void sort_cmd (void);
void change_panel (void);
int load_prompt (int, void *);
void save_cwds_stat (void);
void quiet_quit_cmd (void); /* For cmd.c and command.c */

View File

@ -344,6 +344,9 @@ save_panel_types (void)
{
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,
"auto_save_setup_panels", auto_save_setup))
return;