1998-02-27 07:54:42 +03:00
|
|
|
/* Main program for the Midnight Commander
|
2007-09-25 19:33:35 +04:00
|
|
|
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
2009-05-20 16:34:33 +04:00
|
|
|
2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
2009-08-03 13:50:36 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
Written by: 1994, 1995, 1996, 1997 Miguel de Icaza
|
2010-04-30 17:31:06 +04:00
|
|
|
1994, 1995 Janne Kukonlehto
|
|
|
|
1997 Norbert Warmuth
|
2009-08-03 13:50:36 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2009-08-03 13:50:36 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-05-27 07:35:10 +04:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-02-05 21:28:18 +03:00
|
|
|
/** \file main.c
|
|
|
|
* \brief Source: this is a main module
|
|
|
|
*/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <config.h>
|
|
|
|
|
2005-02-08 12:04:03 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <locale.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-02-06 02:30:45 +03:00
|
|
|
#include <fcntl.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
#include <sys/types.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <sys/stat.h>
|
2009-02-27 14:54:26 +03:00
|
|
|
#include <sys/wait.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
#include <unistd.h>
|
2010-04-30 17:31:06 +04:00
|
|
|
#include <pwd.h> /* for username in xterm title */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-01-20 18:11:52 +03:00
|
|
|
#include "lib/global.h"
|
2009-05-09 19:17:57 +04:00
|
|
|
|
2010-01-08 17:47:19 +03:00
|
|
|
#include "lib/tty/tty.h"
|
|
|
|
#include "lib/tty/mouse.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "lib/tty/key.h" /* For init_key() */
|
|
|
|
#include "lib/tty/win.h" /* xterm_flag */
|
2010-02-15 14:21:30 +03:00
|
|
|
#include "lib/skin.h"
|
2010-01-21 16:06:15 +03:00
|
|
|
#include "lib/mcconfig.h"
|
|
|
|
#include "lib/filehighlight.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "lib/fileloc.h" /* MC_USERCONF_DIR */
|
2010-07-08 11:32:37 +04:00
|
|
|
#include "lib/strutil.h"
|
2010-01-21 13:30:08 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */
|
2010-01-21 13:30:08 +03:00
|
|
|
#ifdef ENABLE_VFS_SMB
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "lib/vfs/mc-vfs/smbfs.h" /* smbfs_set_debug() */
|
2010-01-21 13:30:08 +03:00
|
|
|
#endif /* ENABLE_VFS_SMB */
|
|
|
|
|
2010-11-11 16:58:29 +03:00
|
|
|
#include "lib/util.h"
|
2010-11-12 11:03:57 +03:00
|
|
|
#include "lib/widget.h"
|
2010-11-10 22:45:56 +03:00
|
|
|
|
2010-07-08 11:32:37 +04:00
|
|
|
#include "args.h"
|
2009-05-09 19:17:57 +04:00
|
|
|
#include "dir.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "panel.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include "tree.h"
|
2003-10-24 03:57:59 +04:00
|
|
|
#include "treestore.h"
|
2010-01-21 17:20:11 +03:00
|
|
|
#include "consaver/cons.saver.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "subshell.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "setup.h" /* save_setup() */
|
|
|
|
#include "boxes.h" /* sort_box() */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "layout.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "cmd.h" /* Normal commands */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "hotlist.h"
|
|
|
|
#include "panelize.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "learn.h" /* learn_keys() */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "listmode.h"
|
2003-06-22 13:17:46 +04:00
|
|
|
#include "execute.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "ext.h" /* For flush_extension_file() */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "command.h"
|
2010-04-30 17:31:06 +04:00
|
|
|
#include "user.h" /* user_file_menu_cmd() */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#include "chmod.h"
|
|
|
|
#include "chown.h"
|
2003-10-24 22:38:02 +04:00
|
|
|
#include "achown.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-11-06 14:41:54 +03:00
|
|
|
#include "main.h"
|
|
|
|
|
2002-11-13 12:30:57 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2010-03-21 13:57:33 +03:00
|
|
|
#include "src/editor/edit.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
#include "src/diffviewer/ydiff.h"
|
2002-11-13 12:30:57 +03:00
|
|
|
#endif
|
|
|
|
|
2010-03-21 13:57:33 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
2010-11-18 11:31:09 +03:00
|
|
|
#include "lib/charsets.h"
|
2010-09-09 16:50:26 +04:00
|
|
|
#include "selcodepage.h"
|
|
|
|
#endif /* HAVE_CHARSET */
|
2001-10-29 16:40:00 +03:00
|
|
|
|
2010-11-18 12:39:09 +03:00
|
|
|
#include "keybind-defaults.h" /* type global_keymap_t */
|
2009-07-05 19:04:42 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* When the modes are active, left_panel, right_panel and tree_panel */
|
|
|
|
/* Point to a proper data structure. You should check with the functions */
|
|
|
|
/* get_current_type and get_other_type the types of the panels before using */
|
|
|
|
/* This pointer variables */
|
|
|
|
|
|
|
|
/* The structures for the panels */
|
2004-08-16 22:25:16 +04:00
|
|
|
WPanel *left_panel = NULL;
|
|
|
|
WPanel *right_panel = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
mc_fhl_t *mc_filehighlight;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* The pointer to the tree */
|
2004-08-16 22:25:16 +04:00
|
|
|
WTree *the_tree = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* The Menubar */
|
2009-05-04 20:11:51 +04:00
|
|
|
struct WMenuBar *the_menubar = NULL;
|
2010-11-14 11:35:56 +03:00
|
|
|
static Menu *left_menu, *right_menu;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Pointers to the selected and unselected panel */
|
|
|
|
WPanel *current_panel = NULL;
|
|
|
|
|
2002-11-15 09:38:55 +03:00
|
|
|
/* Set if the command is being run from the "Right" menu */
|
2004-08-16 22:25:16 +04:00
|
|
|
int is_right = 0;
|
2002-11-15 09:38:55 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Set when main loop should be terminated */
|
|
|
|
volatile int quit = 0;
|
|
|
|
|
|
|
|
/* Set if you want the possible completions dialog for the first time */
|
|
|
|
int show_all_if_ambiguous = 0;
|
|
|
|
|
|
|
|
/* Set when cd symlink following is desirable (bash mode) */
|
|
|
|
int cd_symlinks = 1;
|
|
|
|
|
|
|
|
/* If set then dialogs just clean the screen when refreshing, else */
|
|
|
|
/* they do a complete refresh, refreshing all the parts of the program */
|
|
|
|
int fast_refresh = 0;
|
|
|
|
|
|
|
|
/* If true, at startup the user-menu is invoked */
|
2002-10-31 07:31:52 +03:00
|
|
|
int auto_menu = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* If true, then the +, - and \ keys have their special meaning only if the
|
|
|
|
* command line is emtpy, otherwise they behave like regular letters
|
|
|
|
*/
|
2002-10-31 07:31:52 +03:00
|
|
|
int only_leading_plus_minus = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
int pause_after_run = pause_on_dumb_terminals;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* It true saves the setup when quitting */
|
1998-05-12 08:26:21 +04:00
|
|
|
int auto_save_setup = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
#ifndef HAVE_CHARSET
|
2003-01-21 02:45:13 +03:00
|
|
|
/* If true, allow characters in the range 160-255 */
|
2000-07-21 17:15:53 +04:00
|
|
|
int eight_bit_clean = 1;
|
2003-01-21 02:45:13 +03:00
|
|
|
/*
|
|
|
|
* If true, also allow characters in the range 128-159.
|
|
|
|
* This is reported to break on many terminals (xterm, qansi-m).
|
|
|
|
*/
|
|
|
|
int full_eight_bits = 0;
|
2010-04-30 17:31:06 +04:00
|
|
|
#endif /* !HAVE_CHARSET */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-04-17 01:22:52 +04:00
|
|
|
/*
|
|
|
|
* If utf-8 terminal utf8_display = 1
|
|
|
|
* Display bits set UTF-8
|
|
|
|
*
|
2010-04-30 17:31:06 +04:00
|
|
|
*/
|
2009-04-17 01:22:52 +04:00
|
|
|
int utf8_display = 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* If true use the internal viewer */
|
|
|
|
int use_internal_view = 1;
|
|
|
|
|
|
|
|
/* The prompt */
|
2010-02-02 13:48:08 +03:00
|
|
|
const char *mc_prompt = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* The widget where we draw the prompt */
|
|
|
|
WLabel *the_prompt;
|
|
|
|
|
|
|
|
/* The hint bar */
|
|
|
|
WLabel *the_hint;
|
|
|
|
|
|
|
|
/* The button bar */
|
|
|
|
WButtonBar *the_bar;
|
|
|
|
|
2001-09-17 08:43:58 +04:00
|
|
|
/* Mouse type: GPM, xterm or none */
|
|
|
|
Mouse_Type use_mouse_p = MOUSE_NONE;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2006-01-29 23:26:05 +03:00
|
|
|
/* If on, default for "No" in delete operations */
|
|
|
|
int safe_delete = 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Controls screen clearing before an exec */
|
|
|
|
int clear_before_exec = 1;
|
|
|
|
|
|
|
|
/* Asks for confirmation before deleting a file */
|
|
|
|
int confirm_delete = 1;
|
|
|
|
|
2006-01-29 23:26:05 +03:00
|
|
|
/* Asks for confirmation before deleting a hotlist entry */
|
|
|
|
int confirm_directory_hotlist_delete = 1;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Asks for confirmation before overwriting a file */
|
|
|
|
int confirm_overwrite = 1;
|
|
|
|
|
|
|
|
/* Asks for confirmation before executing a program by pressing enter */
|
|
|
|
int confirm_execute = 0;
|
|
|
|
|
|
|
|
/* Asks for confirmation before leaving the program */
|
|
|
|
int confirm_exit = 1;
|
|
|
|
|
2010-02-03 17:59:33 +03:00
|
|
|
/* Asks for confirmation before clean up of history */
|
|
|
|
int confirm_history_cleanup = 1;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Asks for confirmation when using F3 to view a directory and there
|
|
|
|
are tagged files */
|
|
|
|
int confirm_view_dir = 0;
|
|
|
|
|
|
|
|
/* This flag indicates if the pull down menus by default drop down */
|
|
|
|
int drop_menus = 0;
|
|
|
|
|
|
|
|
/* The dialog handle for the main program */
|
2009-06-28 21:28:47 +04:00
|
|
|
Dlg_head *midnight_dlg = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Subshell: if set, then the prompt was not saved on CONSOLE_SAVE */
|
|
|
|
/* We need to paint it after CONSOLE_RESTORE, see: load_prompt */
|
|
|
|
int update_prompt = 0;
|
|
|
|
|
|
|
|
/* The home directory */
|
2004-09-25 17:46:23 +04:00
|
|
|
const char *home_dir = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-06-20 19:08:18 +04:00
|
|
|
/* Only used at program boot */
|
|
|
|
int boot_current_is_left = 1;
|
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
/* If this is true, then when browsing the tree the other window will
|
|
|
|
* automatically reload it's directory with the contents of the currently
|
|
|
|
* selected directory.
|
|
|
|
*/
|
|
|
|
int xtree_mode = 0;
|
|
|
|
|
2010-06-08 23:23:00 +04:00
|
|
|
/* path to X clipboard utility */
|
2010-11-10 14:09:42 +03:00
|
|
|
char *clipboard_store_path = NULL;
|
|
|
|
char *clipboard_paste_path = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-03-21 13:57:33 +03:00
|
|
|
mc_run_mode_t mc_run_mode = MC_RUN_FULL;
|
|
|
|
char *mc_run_param0 = NULL;
|
|
|
|
char *mc_run_param1 = NULL;
|
2002-12-01 11:18:17 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Used so that widgets know if they are being destroyed or
|
|
|
|
shut down */
|
|
|
|
int midnight_shutdown = 0;
|
|
|
|
|
|
|
|
/* The user's shell */
|
2009-07-12 14:22:41 +04:00
|
|
|
char *shell = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-21 02:01:10 +04:00
|
|
|
/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */
|
2004-08-16 22:25:16 +04:00
|
|
|
char *mc_home = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-21 02:01:10 +04:00
|
|
|
/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */
|
|
|
|
char *mc_home_alt = NULL;
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** file scope macro definitions ****************************************************************/
|
2009-09-28 18:04:25 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
/*
|
|
|
|
* Don't restrict the output on the screen manager level,
|
|
|
|
* the translation tables take care of it.
|
|
|
|
*/
|
|
|
|
#define full_eight_bits (1)
|
|
|
|
#define eight_bit_clean (1)
|
|
|
|
#endif /* !HAVE_CHARSET */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** file scope type declarations ****************************************************************/
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
|
|
|
/* If set, then print to the given file the last directory we were at */
|
|
|
|
static char *last_wd_string = NULL;
|
|
|
|
/* Set to 1 to suppress printing the last directory */
|
|
|
|
static int print_last_revert = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
static gboolean ctl_x_map_enabled = FALSE;
|
|
|
|
|
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/** Stop MC main dialog and the current dialog if it exists.
|
2002-07-03 10:19:40 +04:00
|
|
|
* Needed to provide fast exit from MC viewer or editor on shell exit */
|
2010-11-10 14:09:42 +03:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
stop_dialogs (void)
|
2002-07-03 10:19:40 +04:00
|
|
|
{
|
2010-04-03 15:19:09 +04:00
|
|
|
midnight_dlg->state = DLG_CLOSED;
|
2009-10-30 14:50:04 +03:00
|
|
|
|
2010-04-18 14:26:28 +04:00
|
|
|
if ((top_dlg != NULL) && (top_dlg->data != NULL))
|
|
|
|
((Dlg_head *) top_dlg->data)->state = DLG_CLOSED;
|
2002-07-03 10:19:40 +04:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-06-23 13:54:36 +04:00
|
|
|
static gboolean
|
1998-02-27 07:54:42 +03:00
|
|
|
quit_cmd_internal (int quiet)
|
|
|
|
{
|
|
|
|
int q = quit;
|
2010-06-18 14:35:27 +04:00
|
|
|
size_t n = dialog_switch_num () - 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-06-18 14:35:27 +04:00
|
|
|
if (n != 0)
|
2010-04-30 17:31:06 +04:00
|
|
|
{
|
2010-06-18 14:35:27 +04:00
|
|
|
char msg[BUF_MEDIUM];
|
|
|
|
|
|
|
|
g_snprintf (msg, sizeof (msg),
|
|
|
|
ngettext ("You have %zd opened screen. Quit anyway?",
|
2010-11-10 14:09:42 +03:00
|
|
|
"You have %zd opened screens. Quit anyway?", n), n);
|
2010-06-18 14:35:27 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
if (query_dialog (_("The Midnight Commander"), msg, D_NORMAL, 2, _("&Yes"), _("&No")) != 0)
|
2010-06-23 13:54:36 +04:00
|
|
|
return FALSE;
|
|
|
|
q = 1;
|
2010-11-10 14:09:42 +03:00
|
|
|
}
|
|
|
|
else if (quiet || !confirm_exit)
|
2010-06-18 14:35:27 +04:00
|
|
|
q = 1;
|
|
|
|
else if (query_dialog (_("The Midnight Commander"),
|
|
|
|
_("Do you really want to quit the Midnight Commander?"),
|
|
|
|
D_NORMAL, 2, _("&Yes"), _("&No")) == 0)
|
|
|
|
q = 1;
|
|
|
|
|
|
|
|
if (q != 0)
|
2010-04-30 17:31:06 +04:00
|
|
|
{
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!use_subshell)
|
|
|
|
stop_dialogs ();
|
|
|
|
else if ((q = exit_subshell ()))
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2010-04-30 17:31:06 +04:00
|
|
|
stop_dialogs ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2010-06-18 14:35:27 +04:00
|
|
|
|
|
|
|
if (q != 0)
|
2010-04-30 17:31:06 +04:00
|
|
|
quit |= 1;
|
2010-06-23 13:54:36 +04:00
|
|
|
return (quit != 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-06-23 13:54:36 +04:00
|
|
|
static gboolean
|
2002-10-31 07:31:52 +03:00
|
|
|
quit_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2010-06-23 13:54:36 +04:00
|
|
|
return quit_cmd_internal (0);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
static void
|
2001-10-01 10:51:15 +04:00
|
|
|
treebox_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *sel_dir;
|
|
|
|
|
2003-10-26 09:45:59 +03:00
|
|
|
sel_dir = tree_box (selection (current_panel)->fname);
|
2010-04-30 17:31:06 +04:00
|
|
|
if (sel_dir)
|
|
|
|
{
|
|
|
|
do_cd (sel_dir, cd_exact);
|
|
|
|
g_free (sel_dir);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2000-09-27 02:38:13 +04:00
|
|
|
#ifdef LISTMODE_EDITOR
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
2000-11-03 02:35:11 +03:00
|
|
|
listmode_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *newmode;
|
2003-09-01 13:03:30 +04:00
|
|
|
|
|
|
|
if (get_current_type () != view_listing)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
2003-09-01 13:03:30 +04:00
|
|
|
|
2003-10-26 09:45:59 +03:00
|
|
|
newmode = listmode_edit (current_panel->user_format);
|
2003-09-01 13:03:30 +04:00
|
|
|
if (!newmode)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
2003-09-01 13:03:30 +04:00
|
|
|
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (current_panel->user_format);
|
2003-10-26 09:45:59 +03:00
|
|
|
current_panel->list_type = list_user;
|
|
|
|
current_panel->user_format = newmode;
|
|
|
|
set_panel_formats (current_panel);
|
2003-09-01 13:03:30 +04:00
|
|
|
|
|
|
|
do_refresh ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2010-04-30 17:31:06 +04:00
|
|
|
#endif /* LISTMODE_EDITOR */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
Fri Apr 3 05:23:20 1998 Alex Tkachenko <alex@bcs.zp.ua>
* configure.in: ALL_LINGUAS test added, to allow specify list
of languages to be installed by setting env variable before
configure. If it is empty, it defaults to full list.
* src/menu.h menu_entry.{hot_pos, is_dupped} dropped
* src/menu.c: consistency fixes: pull-down menu items are now
accessible either with arrow keys or with hotkeys, denoted with &
(and highlighted). (key combinations, placed to the right of items
intended to be used from outside the menus). Freeing menu entries
removed as it no longer needed
* src/main.c, edit/editmenu.c: menubar init code is changed to conform
above fixes.
* edit/edit.h: use of "Cancel" in error_dialogs replaced with
"Dismiss", to avoid collisions in translation of "Cancel" in other
places with this case.
* src/boxes.c: select_format() and it's support removed, as it is
obsoleted by input line history feature. display_init()/display_callback
fixed to suite i18n changes. sort_box() - alike.
* src/option.c: pause_options added &'s and gettext calls to expand
statically assigned values.
* src/widget.c: (radio_callback) hotkey recognition is changed to
&-notation, rather than simple uppercase.
* src/dlg.c: (dlg_try_hotkey) plain symbol comparison replaced with
call to isalpha(), this fixes errorneous exit from input line, when
button hotkey is 8-bit NLS char.
1998-04-04 00:00:00 +04:00
|
|
|
/* NOTICE: hotkeys specified here are overriden in menubar_paint_idx (alex) */
|
2010-11-10 14:09:42 +03:00
|
|
|
|
2009-08-25 13:08:18 +04:00
|
|
|
static GList *
|
2009-10-01 22:23:50 +04:00
|
|
|
create_panel_menu (void)
|
2009-05-04 20:11:51 +04:00
|
|
|
{
|
2009-08-25 13:08:18 +04:00
|
|
|
GList *entries = NULL;
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("File listin&g"), CK_ListingCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Quick view"), CK_QuickViewCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Info"), CK_InfoCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Tree"), CK_TreeCmd));
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-11-10 14:09:42 +03:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Listing mode..."), CK_ChangeListingCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Sort order..."), CK_Sort));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Filter..."), CK_FilterCmd));
|
2009-05-24 14:41:16 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2010-11-10 14:09:42 +03:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Encoding..."), CK_PanelSetPanelEncoding));
|
2009-05-24 14:41:16 +04:00
|
|
|
#endif
|
2010-07-18 12:42:28 +04:00
|
|
|
#ifdef ENABLE_VFS_NET
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-07-13 15:58:44 +04:00
|
|
|
#ifdef ENABLE_VFS_FTP
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("FT&P link..."), CK_FtplinkCmd));
|
2010-07-13 15:58:44 +04:00
|
|
|
#endif
|
2010-07-13 17:01:25 +04:00
|
|
|
#ifdef ENABLE_VFS_FISH
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("S&hell link..."), CK_FishlinkCmd));
|
2010-07-13 17:01:25 +04:00
|
|
|
#endif
|
2009-11-14 19:10:57 +03:00
|
|
|
#ifdef ENABLE_VFS_SMB
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("SM&B link..."), CK_SmblinkCmd));
|
2010-07-18 12:42:28 +04:00
|
|
|
#endif
|
|
|
|
#endif /* ENABLE_VFS_NET */
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Rescan"), CK_RereadCmd));
|
2009-05-04 20:11:51 +04:00
|
|
|
|
|
|
|
return entries;
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-08-25 13:08:18 +04:00
|
|
|
static GList *
|
2009-05-04 20:11:51 +04:00
|
|
|
create_file_menu (void)
|
|
|
|
{
|
2009-08-25 13:08:18 +04:00
|
|
|
GList *entries = NULL;
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&View"), CK_ViewCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Vie&w file..."), CK_ViewFileCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Filtered view"), CK_FilteredViewCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Edit"), CK_EditCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Copy"), CK_CopyCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("C&hmod"), CK_ChmodCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Link"), CK_LinkCmd));
|
2010-05-10 13:43:34 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Symlink"), CK_SymlinkCmd));
|
2010-11-10 14:09:42 +03:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("Relative symlin&k"), CK_RelativeSymlinkCmd));
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Edit s&ymlink"), CK_EditSymlinkCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Ch&own"), CK_ChownCmd));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Advanced chown"), CK_ChownAdvancedCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Rename/Move"), CK_RenameCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Mkdir"), CK_MkdirCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Delete"), CK_DeleteCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Quick cd"), CK_QuickCdCmd));
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Select &group"), CK_SelectCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("U&nselect group"), CK_UnselectCmd));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries,
|
|
|
|
menu_entry_create (_("Reverse selec&tion"), CK_ReverseSelectionCmd));
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("E&xit"), CK_QuitCmd));
|
2009-05-04 20:11:51 +04:00
|
|
|
|
|
|
|
return entries;
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-08-25 13:08:18 +04:00
|
|
|
static GList *
|
2009-05-04 20:11:51 +04:00
|
|
|
create_command_menu (void)
|
|
|
|
{
|
1998-02-27 07:54:42 +03:00
|
|
|
/* I know, I'm lazy, but the tree widget when it's not running
|
|
|
|
* as a panel still has some problems, I have not yet finished
|
|
|
|
* the WTree widget port, sorry.
|
|
|
|
*/
|
2009-08-25 13:08:18 +04:00
|
|
|
GList *entries = NULL;
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&User menu"), CK_UserMenuCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Directory tree"), CK_TreeBoxCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Find file"), CK_FindCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("S&wap panels"), CK_SwapCmd));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("Switch &panels on/off"), CK_ShowCommandLine));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Compare directories"), CK_CompareDirsCmd));
|
2010-03-03 16:09:15 +03:00
|
|
|
#ifdef USE_DIFF_VIEW
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&View diff files"), CK_DiffViewCmd));
|
2010-03-03 16:09:15 +03:00
|
|
|
#endif
|
2010-04-30 17:31:06 +04:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("E&xternal panelize"), CK_ExternalPanelize));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries,
|
|
|
|
menu_entry_create (_("Show directory s&izes"), CK_SingleDirsizeCmd));
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Command &history"), CK_HistoryCmd));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("Di&rectory hotlist"), CK_QuickChdirCmd));
|
2009-12-29 14:39:13 +03:00
|
|
|
#ifdef ENABLE_VFS
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Active VFS list"), CK_ReselectVfs));
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_BACKGROUND
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Background jobs"), CK_JobsCmd));
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2010-04-18 14:58:18 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Screen lis&t"), CK_DialogListCmd));
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-07-10 20:03:38 +04:00
|
|
|
#ifdef ENABLE_VFS_UNDELFS
|
2010-04-30 17:31:06 +04:00
|
|
|
entries =
|
|
|
|
g_list_append (entries,
|
|
|
|
menu_entry_create (_("&Undelete files (ext2fs only)"), CK_UndeleteCmd));
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2000-09-27 02:38:13 +04:00
|
|
|
#ifdef LISTMODE_EDITOR
|
2010-04-30 17:31:06 +04:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Listing format edit"), CK_ListmodeCmd));
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2010-07-10 20:03:38 +04:00
|
|
|
#if defined (ENABLE_VFS_UNDELFS) || defined (LISTMODE_EDITOR)
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2000-09-27 02:38:13 +04:00
|
|
|
#endif
|
2010-04-30 17:31:06 +04:00
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("Edit &extension file"), CK_EditExtFileCmd));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Edit &menu file"), CK_EditMcMenuCmd));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries,
|
|
|
|
menu_entry_create (_("Edit hi&ghlighting group file"), CK_EditFhlFileCmd));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-04 20:11:51 +04:00
|
|
|
return entries;
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-08-25 13:08:18 +04:00
|
|
|
static GList *
|
2009-05-04 20:11:51 +04:00
|
|
|
create_options_menu (void)
|
|
|
|
{
|
2009-08-25 13:08:18 +04:00
|
|
|
GList *entries = NULL;
|
2009-05-04 20:11:51 +04:00
|
|
|
|
2009-10-01 22:23:50 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Configuration..."), CK_ConfigureBox));
|
2010-11-10 14:09:42 +03:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Layout..."), CK_LayoutBox));
|
|
|
|
entries =
|
|
|
|
g_list_append (entries, menu_entry_create (_("&Panel options..."), CK_PanelOptionsBox));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("C&onfirmation..."), CK_ConfirmBox));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Display bits..."), CK_DisplayBitsBox));
|
|
|
|
entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
|
2009-12-29 14:39:13 +03:00
|
|
|
#ifdef ENABLE_VFS
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Virtual FS..."), CK_ConfigureVfs));
|
2009-05-04 20:11:51 +04:00
|
|
|
#endif
|
2009-08-25 13:08:18 +04:00
|
|
|
entries = g_list_append (entries, menu_separator_create ());
|
2010-04-30 17:31:06 +04:00
|
|
|
entries = g_list_append (entries, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-04 20:11:51 +04:00
|
|
|
return entries;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-11-14 11:35:56 +03:00
|
|
|
static void
|
|
|
|
init_menu (void)
|
|
|
|
{
|
|
|
|
left_menu = create_menu ("", create_panel_menu (), "[Left and Right Menus]");
|
|
|
|
menubar_add_menu (the_menubar, left_menu);
|
|
|
|
menubar_add_menu (the_menubar, create_menu (_("&File"), create_file_menu (), "[File Menu]"));
|
|
|
|
menubar_add_menu (the_menubar,
|
|
|
|
create_menu (_("&Command"), create_command_menu (), "[Command Menu]"));
|
|
|
|
menubar_add_menu (the_menubar,
|
|
|
|
create_menu (_("&Options"), create_options_menu (), "[Options Menu]"));
|
|
|
|
right_menu = create_menu ("", create_panel_menu (), "[Left and Right Menus]");
|
|
|
|
menubar_add_menu (the_menubar, right_menu);
|
|
|
|
update_menu ();
|
|
|
|
menubar_set_visible (the_menubar, menubar_visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
menu_last_selected_cmd (void)
|
|
|
|
{
|
2009-05-04 20:11:51 +04:00
|
|
|
the_menubar->is_active = TRUE;
|
|
|
|
the_menubar->is_dropped = (drop_menus != 0);
|
2010-04-05 20:59:21 +04:00
|
|
|
the_menubar->previous_widget = dlg_get_current_widget_id (midnight_dlg);
|
2005-05-21 00:22:06 +04:00
|
|
|
dlg_select_widget (the_menubar);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
menu_cmd (void)
|
|
|
|
{
|
2009-05-04 20:11:51 +04:00
|
|
|
if (the_menubar->is_active)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-05-04 20:11:51 +04:00
|
|
|
if ((get_current_index () == 0) == (current_panel->active != 0))
|
2010-04-30 17:31:06 +04:00
|
|
|
the_menubar->selected = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
else
|
2010-04-30 17:31:06 +04:00
|
|
|
the_menubar->selected = g_list_length (the_menubar->menu) - 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
menu_last_selected_cmd ();
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-10-24 12:58:02 +04:00
|
|
|
static char *
|
2009-11-06 14:41:54 +03:00
|
|
|
midnight_get_shortcut (unsigned long command)
|
2009-10-24 12:58:02 +04:00
|
|
|
{
|
|
|
|
const char *ext_map;
|
|
|
|
const char *shortcut = NULL;
|
|
|
|
|
2010-11-18 11:43:23 +03:00
|
|
|
shortcut = keybind_lookup_keymap_shortcut (main_map, command);
|
2009-10-24 12:58:02 +04:00
|
|
|
if (shortcut != NULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
return g_strdup (shortcut);
|
2009-10-24 12:58:02 +04:00
|
|
|
|
2010-11-18 11:43:23 +03:00
|
|
|
shortcut = keybind_lookup_keymap_shortcut (panel_map, command);
|
2009-10-24 12:58:02 +04:00
|
|
|
if (shortcut != NULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
return g_strdup (shortcut);
|
2009-10-24 12:58:02 +04:00
|
|
|
|
2010-11-18 11:43:23 +03:00
|
|
|
ext_map = keybind_lookup_keymap_shortcut (main_map, CK_StartExtMap1);
|
2009-11-16 16:08:17 +03:00
|
|
|
if (ext_map != NULL)
|
2010-11-18 11:43:23 +03:00
|
|
|
shortcut = keybind_lookup_keymap_shortcut (main_x_map, command);
|
2009-11-16 16:08:17 +03:00
|
|
|
if (shortcut != NULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
return g_strdup_printf ("%s %s", ext_map, shortcut);
|
2009-11-16 16:08:17 +03:00
|
|
|
|
2009-10-24 12:58:02 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-04-18 14:23:06 +04:00
|
|
|
static char *
|
2010-11-10 14:09:42 +03:00
|
|
|
midnight_get_title (const Dlg_head * h, size_t len)
|
2010-04-18 14:23:06 +04:00
|
|
|
{
|
|
|
|
/* TODO: share code with update_xterm_title_path() */
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
char host[BUF_TINY];
|
|
|
|
char *p;
|
|
|
|
struct passwd *pw = NULL;
|
|
|
|
char *login = NULL;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
(void) h;
|
|
|
|
|
|
|
|
path = strip_home_and_password (current_panel->cwd);
|
|
|
|
res = gethostname (host, sizeof (host));
|
|
|
|
if (res != 0)
|
|
|
|
host[0] = '\0';
|
|
|
|
else
|
2010-11-10 14:09:42 +03:00
|
|
|
host[sizeof (host) - 1] = '\0';
|
2010-04-18 14:23:06 +04:00
|
|
|
|
|
|
|
pw = getpwuid (getuid ());
|
|
|
|
if (pw != NULL)
|
|
|
|
login = g_strdup_printf ("%s@%s", pw->pw_name, host);
|
|
|
|
else
|
|
|
|
login = g_strdup (host);
|
|
|
|
|
|
|
|
p = g_strdup_printf ("%s [%s]:%s", _("Panels:"), login, path);
|
|
|
|
path = str_trunc (p, len - 4);
|
|
|
|
g_free (login);
|
|
|
|
g_free (p);
|
|
|
|
|
|
|
|
return g_strdup (path);
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-02-03 15:55:36 +03:00
|
|
|
static void
|
|
|
|
toggle_panels_split (void)
|
|
|
|
{
|
|
|
|
horizontal_split = !horizontal_split;
|
|
|
|
layout_change ();
|
2010-04-30 17:31:06 +04:00
|
|
|
do_refresh ();
|
2010-02-03 15:55:36 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
1998-07-31 02:56:58 +04:00
|
|
|
* Just a hack for allowing url-like pathnames to be accepted from the
|
|
|
|
* command line.
|
|
|
|
*/
|
2010-11-10 14:09:42 +03:00
|
|
|
|
1998-07-31 02:56:58 +04:00
|
|
|
static void
|
|
|
|
translated_mc_chdir (char *dir)
|
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
char *newdir;
|
2010-04-30 13:29:28 +04:00
|
|
|
int ret;
|
1998-07-31 02:56:58 +04:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
newdir = vfs_translate_url (dir);
|
2010-04-30 13:29:28 +04:00
|
|
|
ret = mc_chdir (newdir);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (newdir);
|
1998-07-31 02:56:58 +04:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2003-10-15 01:58:56 +04:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
create_panels (void)
|
|
|
|
{
|
|
|
|
int current_index;
|
|
|
|
int other_index;
|
2009-12-31 21:46:02 +03:00
|
|
|
panel_view_mode_t current_mode, other_mode;
|
2010-02-15 14:14:01 +03:00
|
|
|
char original_dir[BUF_1K] = "\0";
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (boot_current_is_left)
|
|
|
|
{
|
|
|
|
current_index = 0;
|
|
|
|
other_index = 1;
|
|
|
|
current_mode = startup_left_mode;
|
|
|
|
other_mode = startup_right_mode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_index = 1;
|
|
|
|
other_index = 0;
|
|
|
|
current_mode = startup_right_mode;
|
|
|
|
other_mode = startup_left_mode;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
/* Creates the left panel */
|
2010-04-30 17:31:06 +04:00
|
|
|
if (mc_run_param0 != NULL)
|
|
|
|
{
|
|
|
|
if (mc_run_param1 != NULL)
|
|
|
|
{
|
|
|
|
/* Ok, user has specified two dirs, save the original one,
|
|
|
|
* since we may not be able to chdir to the proper
|
|
|
|
* second directory later
|
|
|
|
*/
|
|
|
|
mc_get_current_wd (original_dir, sizeof (original_dir) - 2);
|
|
|
|
}
|
|
|
|
translated_mc_chdir (mc_run_param0);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
set_display_type (current_index, current_mode);
|
|
|
|
|
|
|
|
/* The other panel */
|
2010-04-30 17:31:06 +04:00
|
|
|
if (mc_run_param1 != NULL)
|
|
|
|
{
|
|
|
|
if (original_dir[0] != '\0')
|
|
|
|
translated_mc_chdir (original_dir);
|
|
|
|
translated_mc_chdir (mc_run_param1);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
set_display_type (other_index, other_mode);
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (startup_left_mode == view_listing)
|
|
|
|
{
|
|
|
|
current_panel = left_panel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (right_panel)
|
|
|
|
current_panel = right_panel;
|
|
|
|
else
|
|
|
|
current_panel = left_panel;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the nice widgets */
|
2002-10-31 07:31:52 +03:00
|
|
|
cmdline = command_new (0, 0, 0);
|
2010-02-02 13:48:08 +03:00
|
|
|
the_prompt = label_new (0, 0, mc_prompt);
|
1998-02-27 07:54:42 +03:00
|
|
|
the_prompt->transparent = 1;
|
2002-10-31 07:31:52 +03:00
|
|
|
the_bar = buttonbar_new (keybar_visible);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-09-01 04:18:37 +04:00
|
|
|
the_hint = label_new (0, 0, 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
the_hint->transparent = 1;
|
|
|
|
the_hint->auto_adjust_cols = 0;
|
|
|
|
the_hint->widget.cols = COLS;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-05-04 20:11:51 +04:00
|
|
|
the_menubar = menubar_new (0, 0, COLS, NULL);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_current_pathname (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-05-04 13:40:06 +04:00
|
|
|
char *cwd_path;
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!command_prompt)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-04 13:40:06 +04:00
|
|
|
cwd_path = remove_encoding_from_path (current_panel->cwd);
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, cwd_path, FALSE);
|
2009-05-04 13:40:06 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
2009-05-04 13:40:06 +04:00
|
|
|
g_free (cwd_path);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_other_pathname (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-05-04 13:40:06 +04:00
|
|
|
char *cwd_path;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (get_other_type () != view_listing)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
if (!command_prompt)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-04 13:40:06 +04:00
|
|
|
cwd_path = remove_encoding_from_path (other_panel->cwd);
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, cwd_path, FALSE);
|
2009-05-04 13:40:06 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
2009-05-04 13:40:06 +04:00
|
|
|
g_free (cwd_path);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
2010-04-30 17:31:06 +04:00
|
|
|
copy_readlink (WPanel * panel)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
if (!command_prompt)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
|
|
|
if (S_ISLNK (selection (panel)->st.st_mode))
|
|
|
|
{
|
|
|
|
char buffer[MC_MAXPATHLEN];
|
|
|
|
char *p = concat_dir_and_file (panel->cwd, selection (panel)->fname);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
|
|
|
|
g_free (p);
|
|
|
|
if (i > 0)
|
|
|
|
{
|
|
|
|
buffer[i] = 0;
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, buffer, TRUE);
|
2010-04-30 17:31:06 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_current_readlink (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-10-26 09:45:59 +03:00
|
|
|
copy_readlink (current_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_other_readlink (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-12-31 21:46:02 +03:00
|
|
|
if (get_other_type () == view_listing)
|
2010-04-30 17:31:06 +04:00
|
|
|
copy_readlink (other_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Insert the selected file name into the input line */
|
|
|
|
|
2002-12-26 05:09:41 +03:00
|
|
|
static void
|
2002-10-31 07:31:52 +03:00
|
|
|
copy_prog_name (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
if (!command_prompt)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (get_current_type () == view_tree)
|
|
|
|
{
|
|
|
|
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
|
|
|
tmp = tree_selected_name (tree);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tmp = selection (current_panel)->fname;
|
2002-09-20 23:59:28 +04:00
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, tmp, TRUE);
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-09-20 23:59:28 +04:00
|
|
|
static void
|
2010-04-30 17:31:06 +04:00
|
|
|
copy_tagged (WPanel * panel)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!command_prompt)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
2002-09-20 23:36:55 +04:00
|
|
|
input_disable_update (cmdline);
|
2010-04-30 17:31:06 +04:00
|
|
|
if (panel->marked)
|
|
|
|
{
|
|
|
|
for (i = 0; i < panel->count; i++)
|
|
|
|
{
|
|
|
|
if (panel->dir.list[i].f.marked)
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, panel->dir.list[i].fname, TRUE);
|
2010-04-30 17:31:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-12 11:03:57 +03:00
|
|
|
command_insert (cmdline, panel->dir.list[panel->selected].fname, TRUE);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2002-09-20 23:36:55 +04:00
|
|
|
input_enable_update (cmdline);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_current_tagged (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-10-26 09:45:59 +03:00
|
|
|
copy_tagged (current_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_other_tagged (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-12-31 21:46:02 +03:00
|
|
|
if (get_other_type () == view_listing)
|
2010-04-30 17:31:06 +04:00
|
|
|
copy_tagged (other_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
1998-05-05 09:49:57 +04:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
2004-08-16 08:20:56 +04:00
|
|
|
ctl_x_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-11-06 14:41:54 +03:00
|
|
|
ctl_x_map_enabled = TRUE;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-25 20:19:45 +04:00
|
|
|
static cb_ret_t
|
2010-04-30 17:31:06 +04:00
|
|
|
midnight_execute_cmd (Widget * sender, unsigned long command)
|
2009-07-05 19:04:42 +04:00
|
|
|
{
|
2009-09-25 20:19:45 +04:00
|
|
|
cb_ret_t res = MSG_HANDLED;
|
|
|
|
|
2009-11-01 12:23:15 +03:00
|
|
|
(void) sender;
|
|
|
|
|
2010-05-25 14:05:37 +04:00
|
|
|
/* stop quick search before executing any command */
|
|
|
|
send_message ((Widget *) current_panel, WIDGET_COMMAND, CK_PanelStopSearch);
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
switch (command)
|
|
|
|
{
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_AddHotlist:
|
|
|
|
add2hotlist_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-03-08 12:10:36 +03:00
|
|
|
case CK_ChangeListingCmd:
|
|
|
|
change_listing_cmd ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ChmodCmd:
|
|
|
|
chmod_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ChownCmd:
|
|
|
|
chown_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_ChownAdvancedCmd:
|
|
|
|
chown_advanced_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_CompareDirsCmd:
|
|
|
|
compare_dirs_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_ConfigureBox:
|
|
|
|
configure_box ();
|
|
|
|
break;
|
2009-12-29 14:39:13 +03:00
|
|
|
#ifdef ENABLE_VFS
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ConfigureVfs:
|
|
|
|
configure_vfs ();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case CK_ConfirmBox:
|
|
|
|
confirm_box ();
|
|
|
|
break;
|
|
|
|
case CK_CopyCmd:
|
|
|
|
copy_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
|
|
|
case CK_CopyCurrentPathname:
|
|
|
|
copy_current_pathname ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_CopyCurrentReadlink:
|
|
|
|
copy_current_readlink ();
|
|
|
|
break;
|
|
|
|
case CK_CopyCurrentTagged:
|
|
|
|
copy_current_tagged ();
|
|
|
|
break;
|
2009-07-05 19:04:42 +04:00
|
|
|
case CK_CopyOtherPathname:
|
|
|
|
copy_other_pathname ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_CopyOtherReadlink:
|
|
|
|
copy_other_readlink ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-28 19:15:33 +03:00
|
|
|
case CK_CopyOtherTagged:
|
2009-10-01 22:23:50 +04:00
|
|
|
copy_other_tagged ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_DeleteCmd:
|
|
|
|
delete_cmd ();
|
|
|
|
break;
|
2010-04-18 14:58:18 +04:00
|
|
|
case CK_DialogListCmd:
|
|
|
|
dialog_switch_list ();
|
|
|
|
break;
|
2010-03-21 13:57:33 +03:00
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
case CK_DiffViewCmd:
|
|
|
|
diff_view_cmd ();
|
|
|
|
break;
|
|
|
|
#endif
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_DisplayBitsBox:
|
|
|
|
display_bits_box ();
|
|
|
|
break;
|
|
|
|
case CK_EditCmd:
|
|
|
|
edit_cmd ();
|
|
|
|
break;
|
2010-06-24 11:33:14 +04:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
|
|
|
case CK_EditForceInternalCmd:
|
|
|
|
edit_cmd_force_internal ();
|
|
|
|
break;
|
|
|
|
#endif
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_EditExtFileCmd:
|
|
|
|
ext_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_EditFhlFileCmd:
|
|
|
|
edit_fhl_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_EditMcMenuCmd:
|
|
|
|
edit_mc_menu_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_EditSymlinkCmd:
|
|
|
|
edit_symlink_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_ExternalPanelize:
|
|
|
|
external_panelize ();
|
|
|
|
break;
|
|
|
|
case CK_FilterCmd:
|
|
|
|
filter_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
|
|
|
case CK_FilteredViewCmd:
|
|
|
|
filtered_view_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_FindCmd:
|
|
|
|
find_cmd ();
|
|
|
|
break;
|
2010-07-13 17:01:25 +04:00
|
|
|
#ifdef ENABLE_VFS_FISH
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_FishlinkCmd:
|
|
|
|
fishlink_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-07-13 15:58:44 +04:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_VFS_FTP
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_FtplinkCmd:
|
|
|
|
ftplink_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
#endif
|
2009-11-06 14:55:21 +03:00
|
|
|
case CK_HelpCmd:
|
|
|
|
help_cmd ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_HistoryCmd:
|
|
|
|
history_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_InfoCmd:
|
2009-11-12 21:44:38 +03:00
|
|
|
if (sender == (Widget *) the_menubar)
|
2010-04-30 17:31:06 +04:00
|
|
|
info_cmd (); /* mwnu */
|
2009-11-10 11:42:31 +03:00
|
|
|
else
|
|
|
|
info_cmd_no_menu (); /* shortcut or buttonbar */
|
2009-10-01 22:23:50 +04:00
|
|
|
break;
|
|
|
|
#ifdef WITH_BACKGROUND
|
|
|
|
case CK_JobsCmd:
|
|
|
|
jobs_cmd ();
|
|
|
|
break;
|
|
|
|
#endif
|
2010-03-09 22:03:51 +03:00
|
|
|
case CK_LayoutBox:
|
|
|
|
layout_box ();
|
2009-10-01 22:23:50 +04:00
|
|
|
break;
|
|
|
|
case CK_LearnKeys:
|
|
|
|
learn_keys ();
|
|
|
|
break;
|
|
|
|
case CK_LinkCmd:
|
2010-05-10 13:43:34 +04:00
|
|
|
link_cmd (LINK_HARDLINK);
|
2009-10-01 22:23:50 +04:00
|
|
|
break;
|
|
|
|
case CK_ListingCmd:
|
|
|
|
listing_cmd ();
|
|
|
|
break;
|
|
|
|
#ifdef LISTMODE_EDITOR
|
|
|
|
case CK_ListmodeCmd:
|
|
|
|
listmode_cmd ();
|
|
|
|
break;
|
|
|
|
#endif
|
2009-11-06 14:55:21 +03:00
|
|
|
case CK_MenuCmd:
|
|
|
|
menu_cmd ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_MenuLastSelectedCmd:
|
|
|
|
menu_last_selected_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_MkdirCmd:
|
|
|
|
mkdir_cmd ();
|
|
|
|
break;
|
2010-03-09 22:03:51 +03:00
|
|
|
case CK_PanelOptionsBox:
|
|
|
|
panel_options_box ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
case CK_PanelSetPanelEncoding:
|
|
|
|
encoding_cmd ();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case CK_QuickCdCmd:
|
|
|
|
quick_cd_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_QuickChdirCmd:
|
|
|
|
quick_chdir_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_QuickViewCmd:
|
2009-11-12 21:44:38 +03:00
|
|
|
if (sender == (Widget *) the_menubar)
|
2010-04-30 17:31:06 +04:00
|
|
|
quick_view_cmd (); /* menu */
|
2009-11-10 11:42:31 +03:00
|
|
|
else
|
|
|
|
quick_cmd_no_menu (); /* shortcut or buttonabr */
|
2009-10-01 22:23:50 +04:00
|
|
|
break;
|
|
|
|
case CK_QuietQuitCmd:
|
|
|
|
quiet_quit_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
|
|
|
case CK_QuitCmd:
|
2009-09-29 00:25:46 +04:00
|
|
|
quit_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-05-10 13:43:34 +04:00
|
|
|
case CK_RelativeSymlinkCmd:
|
|
|
|
link_cmd (LINK_SYMLINK_RELATIVE);
|
|
|
|
break;
|
2009-10-24 16:40:19 +04:00
|
|
|
case CK_RenameCmd:
|
|
|
|
rename_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_RereadCmd:
|
|
|
|
reread_cmd ();
|
|
|
|
break;
|
2009-12-29 14:39:13 +03:00
|
|
|
#ifdef ENABLE_VFS
|
2009-07-05 19:04:42 +04:00
|
|
|
case CK_ReselectVfs:
|
2009-09-29 00:25:46 +04:00
|
|
|
reselect_vfs ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
#endif
|
|
|
|
case CK_ReverseSelectionCmd:
|
|
|
|
reverse_selection_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_SaveSetupCmd:
|
|
|
|
save_setup_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_SelectCmd:
|
|
|
|
select_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ShowCommandLine:
|
|
|
|
view_other_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_SingleDirsizeCmd:
|
|
|
|
smart_dirsize_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-07-18 11:32:24 +04:00
|
|
|
#ifdef ENABLE_VFS_SMB
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_SmblinkCmd:
|
|
|
|
smblink_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-07-18 11:32:24 +04:00
|
|
|
#endif /* ENABLE_VFS_SMB */
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_Sort:
|
|
|
|
sort_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_StartExtMap1:
|
|
|
|
ctl_x_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_SuspendCmd:
|
|
|
|
suspend_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_SwapCmd:
|
|
|
|
swap_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
|
|
|
case CK_SymlinkCmd:
|
2010-05-10 13:43:34 +04:00
|
|
|
link_cmd (LINK_SYMLINK_ABSOLUTE);
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ToggleListingCmd:
|
|
|
|
toggle_listing_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_ToggleShowHidden:
|
|
|
|
toggle_show_hidden ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-02-03 15:55:36 +03:00
|
|
|
case CK_TogglePanelsSplit:
|
|
|
|
toggle_panels_split ();
|
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_TreeCmd:
|
|
|
|
tree_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_TreeBoxCmd:
|
|
|
|
treebox_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2010-07-10 20:03:38 +04:00
|
|
|
#ifdef ENABLE_VFS_UNDELFS
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_UndeleteCmd:
|
|
|
|
undelete_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-09-24 16:55:52 +04:00
|
|
|
#endif
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_UnselectCmd:
|
|
|
|
unselect_cmd ();
|
2009-09-29 00:25:46 +04:00
|
|
|
break;
|
2009-10-01 22:23:50 +04:00
|
|
|
case CK_UserMenuCmd:
|
|
|
|
user_file_menu_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_ViewCmd:
|
|
|
|
view_cmd ();
|
|
|
|
break;
|
|
|
|
case CK_ViewFileCmd:
|
|
|
|
view_file_cmd ();
|
2009-07-05 19:04:42 +04:00
|
|
|
break;
|
2009-09-25 20:19:45 +04:00
|
|
|
default:
|
|
|
|
res = MSG_NOT_HANDLED;
|
2009-07-05 19:04:42 +04:00
|
|
|
}
|
2009-09-25 20:19:45 +04:00
|
|
|
|
|
|
|
return res;
|
2009-07-05 19:04:42 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
2001-09-15 20:54:40 +04:00
|
|
|
init_xterm_support (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2004-09-25 17:46:23 +04:00
|
|
|
const char *termvalue;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2001-09-15 20:54:40 +04:00
|
|
|
termvalue = getenv ("TERM");
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!termvalue || !(*termvalue))
|
|
|
|
{
|
|
|
|
fputs (_("The TERM environment variable is unset!\n"), stderr);
|
2010-03-31 13:28:06 +04:00
|
|
|
exit (EXIT_FAILURE);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2001-09-15 20:54:40 +04:00
|
|
|
/* Check mouse capabilities */
|
2006-05-15 17:26:18 +04:00
|
|
|
xmouse_seq = tty_tgetstr ("Km");
|
2001-09-15 20:54:40 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (strcmp (termvalue, "cygwin") == 0)
|
|
|
|
{
|
|
|
|
mc_args__force_xterm = 1;
|
|
|
|
use_mouse_p = MOUSE_DISABLED;
|
2002-08-26 19:26:38 +04:00
|
|
|
}
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
if (mc_args__force_xterm || strncmp (termvalue, "xterm", 5) == 0
|
2010-04-30 17:31:06 +04:00
|
|
|
|| strncmp (termvalue, "konsole", 7) == 0
|
|
|
|
|| strncmp (termvalue, "rxvt", 4) == 0
|
|
|
|
|| strcmp (termvalue, "Eterm") == 0 || strcmp (termvalue, "dtterm") == 0)
|
|
|
|
{
|
|
|
|
xterm_flag = 1;
|
|
|
|
|
|
|
|
/* Default to the standard xterm sequence */
|
|
|
|
if (!xmouse_seq)
|
|
|
|
{
|
|
|
|
xmouse_seq = ESC_STR "[M";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable mouse unless explicitly disabled by --nomouse */
|
|
|
|
if (use_mouse_p != MOUSE_DISABLED)
|
|
|
|
{
|
|
|
|
const char *color_term = getenv ("COLORTERM");
|
|
|
|
if (strncmp (termvalue, "rxvt", 4) == 0 ||
|
|
|
|
(color_term != NULL && strncmp (color_term, "rxvt", 4) == 0) ||
|
|
|
|
strcmp (termvalue, "Eterm") == 0)
|
|
|
|
{
|
|
|
|
use_mouse_p = MOUSE_XTERM_NORMAL_TRACKING;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
use_mouse_p = MOUSE_XTERM_BUTTON_EVENT_TRACKING;
|
|
|
|
}
|
|
|
|
}
|
2001-09-15 20:54:40 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
setup_mc (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2010-02-15 14:14:01 +03:00
|
|
|
#ifdef HAVE_SLANG
|
|
|
|
tty_display_8bit (full_eight_bits != 0);
|
|
|
|
#else
|
|
|
|
tty_display_8bit (eight_bit_clean != 0);
|
|
|
|
#endif
|
2001-07-14 10:25:45 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
if (use_subshell)
|
2010-04-30 17:31:06 +04:00
|
|
|
add_select_channel (subshell_pty, load_prompt, 0);
|
|
|
|
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
2001-07-14 10:25:45 +04:00
|
|
|
|
2009-08-06 13:17:01 +04:00
|
|
|
tty_setup_sigwinch (sigwinch_handler);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-02-17 17:16:32 +03:00
|
|
|
if ((tty_baudrate () < 9600) || tty_is_slow ())
|
2010-04-30 17:31:06 +04:00
|
|
|
verbose = 0;
|
2009-06-02 08:55:07 +04:00
|
|
|
|
2009-09-02 11:47:01 +04:00
|
|
|
init_xterm_support ();
|
2001-09-16 01:34:42 +04:00
|
|
|
init_mouse ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
2009-09-21 16:34:15 +04:00
|
|
|
setup_dummy_mc (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char d[MC_MAXPATHLEN];
|
2010-04-30 13:29:28 +04:00
|
|
|
int ret;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
mc_get_current_wd (d, MC_MAXPATHLEN);
|
|
|
|
setup_mc ();
|
2010-04-30 13:29:28 +04:00
|
|
|
ret = mc_chdir (d);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
static void
|
|
|
|
check_codeset ()
|
2009-05-13 18:40:27 +04:00
|
|
|
{
|
2009-11-09 14:21:31 +03:00
|
|
|
const char *current_system_codepage = NULL;
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
current_system_codepage = str_detect_termencoding ();
|
2009-11-09 14:21:31 +03:00
|
|
|
|
2009-07-08 16:17:10 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2009-11-09 14:21:31 +03:00
|
|
|
{
|
2010-04-30 17:31:06 +04:00
|
|
|
const char *_display_codepage;
|
2009-11-09 14:21:31 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
_display_codepage = get_codepage_id (display_codepage);
|
2009-11-09 14:21:31 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!strcmp (_display_codepage, current_system_codepage))
|
|
|
|
{
|
|
|
|
utf8_display = str_isutf8 (current_system_codepage);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-09 14:21:31 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
display_codepage = get_codepage_index (current_system_codepage);
|
|
|
|
if (display_codepage == -1)
|
|
|
|
{
|
|
|
|
display_codepage = 0;
|
|
|
|
}
|
2009-11-09 14:21:31 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
mc_config_set_string (mc_main_config, "Misc", "display_codepage", cp_display);
|
2009-11-09 14:21:31 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
utf8_display = str_isutf8 (current_system_codepage);
|
2009-05-13 18:40:27 +04:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-06-02 23:41:40 +04:00
|
|
|
static void
|
|
|
|
done_screen (void)
|
|
|
|
{
|
|
|
|
if (!(quit & SUBSHELL_EXIT))
|
2010-04-30 17:31:06 +04:00
|
|
|
clr_scr ();
|
2009-06-02 23:41:40 +04:00
|
|
|
tty_reset_shell_mode ();
|
|
|
|
tty_noraw_mode ();
|
|
|
|
tty_keypad (FALSE);
|
|
|
|
tty_colors_done ();
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
done_mc (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2002-09-08 19:50:02 +04:00
|
|
|
disable_mouse ();
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Setup shutdown
|
|
|
|
*
|
|
|
|
* We sync the profiles since the hotlist may have changed, while
|
|
|
|
* we only change the setup data if we have the auto save feature set
|
|
|
|
*/
|
2009-08-03 13:50:36 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (auto_save_setup)
|
2010-04-30 17:31:06 +04:00
|
|
|
save_setup (); /* does also call save_hotlist */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
save_hotlist ();
|
|
|
|
save_panel_types ();
|
2009-05-27 19:44:42 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
done_screen ();
|
2010-07-08 11:32:37 +04:00
|
|
|
|
|
|
|
vfs_stamp_path (vfs_get_current_dir ());
|
|
|
|
|
2010-07-26 14:52:56 +04:00
|
|
|
if ((current_panel != NULL) && (get_current_type () == view_listing))
|
|
|
|
vfs_stamp_path (current_panel->cwd);
|
2010-07-08 11:32:37 +04:00
|
|
|
|
2010-07-26 14:52:56 +04:00
|
|
|
if ((other_panel != NULL) && (get_other_type () == view_listing))
|
|
|
|
vfs_stamp_path (other_panel->cwd);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
static cb_ret_t
|
2010-04-30 17:31:06 +04:00
|
|
|
midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-11-07 14:17:38 +03:00
|
|
|
unsigned long command;
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
switch (msg)
|
|
|
|
{
|
2010-02-15 14:14:01 +03:00
|
|
|
case DLG_INIT:
|
2010-04-30 17:31:06 +04:00
|
|
|
setup_panels ();
|
|
|
|
return MSG_HANDLED;
|
2001-11-30 00:03:16 +03:00
|
|
|
|
2009-11-08 13:49:27 +03:00
|
|
|
case DLG_DRAW:
|
2010-04-30 17:31:06 +04:00
|
|
|
load_hint (1);
|
|
|
|
/* We handle the special case of the output lines */
|
|
|
|
if (console_flag && output_lines)
|
|
|
|
show_console_contents (output_start_y,
|
|
|
|
LINES - output_lines - keybar_visible -
|
|
|
|
1, LINES - keybar_visible - 1);
|
|
|
|
return MSG_HANDLED;
|
2009-11-08 13:49:27 +03:00
|
|
|
|
2009-12-07 21:22:16 +03:00
|
|
|
case DLG_RESIZE:
|
2010-04-30 17:31:06 +04:00
|
|
|
setup_panels ();
|
|
|
|
menubar_arrange (the_menubar);
|
|
|
|
return MSG_HANDLED;
|
2009-12-07 21:22:16 +03:00
|
|
|
|
2003-09-07 09:39:51 +04:00
|
|
|
case DLG_IDLE:
|
2010-04-30 17:31:06 +04:00
|
|
|
/* We only need the first idle event to show user menu after start */
|
|
|
|
set_idle_proc (h, 0);
|
2010-02-15 14:14:01 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (boot_current_is_left)
|
|
|
|
dlg_select_widget (get_panel_widget (0));
|
|
|
|
else
|
|
|
|
dlg_select_widget (get_panel_widget (1));
|
2010-02-15 14:14:01 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (auto_menu)
|
|
|
|
midnight_execute_cmd (NULL, CK_UserMenuCmd);
|
|
|
|
return MSG_HANDLED;
|
2003-09-07 09:39:51 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
case DLG_KEY:
|
2010-04-30 17:31:06 +04:00
|
|
|
if (ctl_x_map_enabled)
|
|
|
|
{
|
|
|
|
ctl_x_map_enabled = FALSE;
|
2010-11-18 11:43:23 +03:00
|
|
|
command = keybind_lookup_keymap_command (main_x_map, parm);
|
2010-04-30 17:31:06 +04:00
|
|
|
if (command != CK_Ignore_Key)
|
|
|
|
return midnight_execute_cmd (NULL, command);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: should handle all menu shortcuts before this point */
|
|
|
|
if (the_menubar->is_active)
|
|
|
|
return MSG_NOT_HANDLED;
|
|
|
|
|
|
|
|
if (parm == '\t')
|
2010-11-12 11:03:57 +03:00
|
|
|
input_free_completions (cmdline);
|
2010-04-30 17:31:06 +04:00
|
|
|
|
|
|
|
if (parm == '\n')
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
for (i = 0; cmdline->buffer[i] != '\0' &&
|
|
|
|
(cmdline->buffer[i] == ' ' || cmdline->buffer[i] == '\t'); i++)
|
2010-04-30 17:31:06 +04:00
|
|
|
;
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
if (cmdline->buffer[i] != '\0')
|
2010-04-30 17:31:06 +04:00
|
|
|
{
|
|
|
|
send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
input_insert (cmdline, "", FALSE);
|
2010-04-30 17:31:06 +04:00
|
|
|
cmdline->point = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ctrl-Enter and Alt-Enter */
|
|
|
|
if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') && (parm & (KEY_M_CTRL | KEY_M_ALT)))
|
|
|
|
{
|
|
|
|
copy_prog_name ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ctrl-Shift-Enter */
|
|
|
|
if (parm == (KEY_M_CTRL | KEY_M_SHIFT | '\n'))
|
|
|
|
{
|
|
|
|
copy_current_pathname ();
|
|
|
|
copy_prog_name ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!alternate_plus_minus || !(console_flag || xterm_flag))
|
|
|
|
&& !quote && !current_panel->searching)
|
|
|
|
{
|
|
|
|
if (!only_leading_plus_minus)
|
|
|
|
{
|
|
|
|
/* Special treatement, since the input line will eat them */
|
|
|
|
if (parm == '+')
|
|
|
|
{
|
|
|
|
select_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parm == '\\' || parm == '-')
|
|
|
|
{
|
|
|
|
unselect_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parm == '*')
|
|
|
|
{
|
|
|
|
reverse_selection_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!command_prompt || !cmdline->buffer[0])
|
|
|
|
{
|
|
|
|
/* Special treatement '+', '-', '\', '*' only when this is
|
|
|
|
* first char on input line
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (parm == '+')
|
|
|
|
{
|
|
|
|
select_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parm == '\\' || parm == '-')
|
|
|
|
{
|
|
|
|
unselect_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parm == '*')
|
|
|
|
{
|
|
|
|
reverse_selection_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MSG_NOT_HANDLED;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case DLG_HOTKEY_HANDLED:
|
2010-04-30 17:31:06 +04:00
|
|
|
if ((get_current_type () == view_listing) && current_panel->searching)
|
|
|
|
{
|
2010-11-10 14:09:42 +03:00
|
|
|
current_panel->dirty = 1; /* FIXME: unneeded? */
|
2010-05-25 14:05:37 +04:00
|
|
|
send_message ((Widget *) current_panel, WIDGET_COMMAND, CK_PanelStopSearch);
|
2010-04-30 17:31:06 +04:00
|
|
|
}
|
|
|
|
return MSG_HANDLED;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
case DLG_UNHANDLED_KEY:
|
2010-04-30 17:31:06 +04:00
|
|
|
if (command_prompt)
|
|
|
|
{
|
|
|
|
cb_ret_t v;
|
|
|
|
|
|
|
|
v = send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
|
|
|
if (v == MSG_HANDLED)
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctl_x_map_enabled)
|
|
|
|
{
|
|
|
|
ctl_x_map_enabled = FALSE;
|
2010-11-18 11:43:23 +03:00
|
|
|
command = keybind_lookup_keymap_command (main_x_map, parm);
|
2010-04-30 17:31:06 +04:00
|
|
|
}
|
|
|
|
else
|
2010-11-18 11:43:23 +03:00
|
|
|
command = keybind_lookup_keymap_command (main_map, parm);
|
2009-11-07 14:17:38 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
return (command == CK_Ignore_Key) ? MSG_NOT_HANDLED : midnight_execute_cmd (NULL, command);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-10 08:42:13 +04:00
|
|
|
case DLG_POST_KEY:
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!the_menubar->is_active)
|
|
|
|
update_dirty_panels ();
|
|
|
|
return MSG_HANDLED;
|
2003-09-10 08:42:13 +04:00
|
|
|
|
2009-11-08 13:49:27 +03:00
|
|
|
case DLG_ACTION:
|
2010-04-30 17:31:06 +04:00
|
|
|
/* shortcut */
|
|
|
|
if (sender == NULL)
|
|
|
|
midnight_execute_cmd (NULL, parm);
|
|
|
|
/* message from menu */
|
|
|
|
else if (sender == (Widget *) the_menubar)
|
|
|
|
midnight_execute_cmd (sender, parm);
|
|
|
|
/* message from buttonbar */
|
|
|
|
else if (sender == (Widget *) the_bar)
|
|
|
|
{
|
|
|
|
if (data == NULL)
|
|
|
|
midnight_execute_cmd (sender, parm);
|
|
|
|
else
|
|
|
|
send_message ((Widget *) data, WIDGET_COMMAND, parm);
|
|
|
|
}
|
|
|
|
return MSG_HANDLED;
|
2009-11-08 13:49:27 +03:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
default:
|
2010-04-30 17:31:06 +04:00
|
|
|
return default_dlg_callback (h, sender, msg, parm, data);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_panels_and_run_mc (void)
|
2002-12-26 19:10:45 +03:00
|
|
|
{
|
2010-11-10 14:09:42 +03:00
|
|
|
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
|
|
|
midnight_dlg->get_title = midnight_get_title;
|
2010-04-18 14:23:06 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
create_panels ();
|
2010-02-15 14:14:01 +03:00
|
|
|
|
2003-09-13 03:07:09 +04:00
|
|
|
add_widget (midnight_dlg, the_menubar);
|
2009-10-24 12:58:02 +04:00
|
|
|
init_menu ();
|
|
|
|
|
2003-09-13 03:07:09 +04:00
|
|
|
add_widget (midnight_dlg, get_panel_widget (0));
|
|
|
|
add_widget (midnight_dlg, get_panel_widget (1));
|
2010-02-15 14:14:01 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
add_widget (midnight_dlg, the_hint);
|
2001-04-07 01:48:11 +04:00
|
|
|
add_widget (midnight_dlg, cmdline);
|
|
|
|
add_widget (midnight_dlg, the_prompt);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-11-06 16:19:52 +03:00
|
|
|
add_widget (midnight_dlg, the_bar);
|
|
|
|
midnight_set_buttonbar (the_bar);
|
2009-10-01 22:23:50 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Run the Midnight Commander if no file was specified in the command line */
|
|
|
|
run_dlg (midnight_dlg);
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** result must be free'd (I think this should go in util.c) */
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static char *
|
2004-08-30 03:54:47 +04:00
|
|
|
prepend_cwd_on_local (const char *filename)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *d;
|
2010-02-15 14:14:01 +03:00
|
|
|
size_t l;
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!vfs_file_is_local (filename) || g_path_is_absolute (filename))
|
|
|
|
return g_strdup (filename);
|
2010-02-15 14:14:01 +03:00
|
|
|
|
|
|
|
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;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Invoke the internal view/edit routine with:
|
2010-02-15 14:14:01 +03:00
|
|
|
* the default processing and forcing the internal viewer/editor
|
|
|
|
*/
|
2010-11-10 14:09:42 +03:00
|
|
|
|
2010-02-15 14:14:01 +03:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
mc_maybe_editor_or_viewer (void)
|
|
|
|
{
|
2010-04-30 17:31:06 +04:00
|
|
|
switch (mc_run_mode)
|
|
|
|
{
|
2010-03-21 13:57:33 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
|
|
|
case MC_RUN_EDITOR:
|
2010-05-12 10:29:57 +04:00
|
|
|
edit_file (mc_run_param0, mc_args__edit_start_line);
|
2010-04-30 17:31:06 +04:00
|
|
|
break;
|
|
|
|
#endif /* USE_INTERNAL_EDIT */
|
2010-03-21 13:57:33 +03:00
|
|
|
case MC_RUN_VIEWER:
|
2010-04-30 17:31:06 +04:00
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
path = prepend_cwd_on_local (mc_run_param0);
|
|
|
|
view_file (path, 0, 1);
|
|
|
|
g_free (path);
|
|
|
|
break;
|
|
|
|
}
|
2010-03-21 13:57:33 +03:00
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
case MC_RUN_DIFFVIEWER:
|
2010-04-30 17:31:06 +04:00
|
|
|
diff_view (mc_run_param0, mc_run_param1, mc_run_param0, mc_run_param1);
|
|
|
|
break;
|
|
|
|
#endif /* USE_DIFF_VIEW */
|
2010-03-21 13:57:33 +03:00
|
|
|
default:
|
2010-04-30 17:31:06 +04:00
|
|
|
break;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
midnight_shutdown = 1;
|
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Run the main dialog that occupies the whole screen */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
do_nc (void)
|
|
|
|
{
|
2010-10-12 13:33:09 +04:00
|
|
|
dlg_colors_t midnight_colors;
|
|
|
|
midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_");
|
|
|
|
midnight_colors[DLG_COLOR_FOCUS] = mc_skin_color_get ("dialog", "focus");
|
|
|
|
midnight_colors[DLG_COLOR_HOT_NORMAL] = mc_skin_color_get ("dialog", "hotnormal");
|
|
|
|
midnight_colors[DLG_COLOR_HOT_FOCUS] = mc_skin_color_get ("dialog", "hotfocus");
|
|
|
|
midnight_colors[DLG_COLOR_TITLE] = mc_skin_color_get ("dialog", "title");
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-10-24 12:58:02 +04:00
|
|
|
panel_init ();
|
2009-10-02 00:42:07 +04:00
|
|
|
|
2009-11-19 11:34:20 +03:00
|
|
|
midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
2010-04-30 17:31:06 +04:00
|
|
|
"[main]", NULL, DLG_WANT_IDLE);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-03-21 13:57:33 +03:00
|
|
|
if (mc_run_mode == MC_RUN_FULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
setup_mc ();
|
2010-03-21 13:57:33 +03:00
|
|
|
else
|
2010-04-30 17:31:06 +04:00
|
|
|
setup_dummy_mc ();
|
2009-09-21 16:34:15 +04:00
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* start check display_codepage and source_codepage */
|
2009-10-24 12:58:02 +04:00
|
|
|
check_codeset ();
|
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* Check if we were invoked as an editor or file viewer */
|
2010-03-21 13:57:33 +03:00
|
|
|
if (mc_run_mode != MC_RUN_FULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
mc_maybe_editor_or_viewer ();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
create_panels_and_run_mc ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
/* Program end */
|
|
|
|
midnight_shutdown = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
/* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */
|
|
|
|
if (mc_args__last_wd_file && vfs_current_is_local ())
|
|
|
|
last_wd_string = g_strdup (current_panel->cwd);
|
2009-11-06 14:41:54 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2009-11-06 14:41:54 +03:00
|
|
|
|
2010-05-30 18:43:50 +04:00
|
|
|
dialog_switch_shutdown ();
|
|
|
|
done_mc ();
|
1998-03-13 06:44:54 +03:00
|
|
|
destroy_dlg (midnight_dlg);
|
2009-10-24 12:58:02 +04:00
|
|
|
panel_deinit ();
|
1998-02-27 07:54:42 +03:00
|
|
|
current_panel = 0;
|
2010-05-30 18:43:50 +04:00
|
|
|
done_setup ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** POSIX version. The only version we support. */
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
2001-06-15 02:33:00 +04:00
|
|
|
OS_Setup (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-06-30 21:49:40 +04:00
|
|
|
const char *shell_env = getenv ("SHELL");
|
2004-09-25 17:46:23 +04:00
|
|
|
const char *mc_libdir;
|
2009-06-30 21:49:40 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if ((shell_env == NULL) || (shell_env[0] == '\0'))
|
|
|
|
{
|
2004-09-23 18:07:44 +04:00
|
|
|
struct passwd *pwd;
|
|
|
|
pwd = getpwuid (geteuid ());
|
|
|
|
if (pwd != NULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
shell = g_strdup (pwd->pw_shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
shell = g_strdup (shell_env);
|
2009-06-30 21:49:40 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if ((shell == NULL) || (shell[0] == '\0'))
|
|
|
|
{
|
|
|
|
g_free (shell);
|
|
|
|
shell = g_strdup ("/bin/sh");
|
2004-09-23 18:07:44 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-22 04:13:32 +04:00
|
|
|
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
|
|
|
/* and can be overriden by the MC_DATADIR environment variable */
|
2009-06-30 21:49:40 +04:00
|
|
|
mc_libdir = getenv ("MC_DATADIR");
|
2010-04-30 17:31:06 +04:00
|
|
|
if (mc_libdir != NULL)
|
|
|
|
{
|
|
|
|
mc_home = g_strdup (mc_libdir);
|
|
|
|
mc_home_alt = g_strdup (SYSCONFDIR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mc_home = g_strdup (SYSCONFDIR);
|
|
|
|
mc_home_alt = g_strdup (DATADIR);
|
1998-08-27 00:23:10 +04:00
|
|
|
}
|
2009-06-30 21:49:40 +04:00
|
|
|
|
|
|
|
/* This variable is used by the subshell */
|
|
|
|
home_dir = getenv ("HOME");
|
|
|
|
|
|
|
|
if (!home_dir)
|
2010-04-30 17:31:06 +04:00
|
|
|
home_dir = mc_home;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
sigchld_handler_no_subshell (int sig)
|
|
|
|
{
|
2003-02-27 08:09:35 +03:00
|
|
|
#ifdef __linux__
|
1998-02-27 07:54:42 +03:00
|
|
|
int pid, status;
|
|
|
|
|
|
|
|
if (!console_flag)
|
2010-04-30 17:31:06 +04:00
|
|
|
return;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* COMMENT: if it were true that after the call to handle_console(..INIT)
|
|
|
|
the value of console_flag never changed, we could simply not install
|
|
|
|
this handler at all if (!console_flag && !use_subshell). */
|
|
|
|
|
|
|
|
/* That comment is no longer true. We need to wait() on a sigchld
|
|
|
|
handler (that's at least what the tarfs code expects currently). */
|
|
|
|
|
|
|
|
pid = waitpid (cons_saver_pid, &status, WUNTRACED | WNOHANG);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (pid == cons_saver_pid)
|
|
|
|
{
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (WIFSTOPPED (status))
|
|
|
|
{
|
|
|
|
/* Someone has stopped cons.saver - restart it */
|
|
|
|
kill (pid, SIGCONT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* cons.saver has died - disable console saving */
|
|
|
|
handle_console (CONSOLE_DONE);
|
|
|
|
console_flag = 0;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2005-02-08 22:59:45 +03:00
|
|
|
/* If we got here, some other child exited; ignore it */
|
2010-04-30 17:31:06 +04:00
|
|
|
#endif /* __linux__ */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2005-02-08 22:59:45 +03:00
|
|
|
(void) sig;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2003-10-15 01:58:56 +04:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
init_sigchld (void)
|
|
|
|
{
|
|
|
|
struct sigaction sigchld_action;
|
|
|
|
|
|
|
|
sigchld_action.sa_handler =
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2010-04-30 17:31:06 +04:00
|
|
|
use_subshell ? sigchld_handler :
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
sigchld_handler_no_subshell;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
sigemptyset (&sigchld_action.sa_mask);
|
|
|
|
|
|
|
|
#ifdef SA_RESTART
|
2001-08-18 19:18:56 +04:00
|
|
|
sigchld_action.sa_flags = SA_RESTART;
|
1998-02-27 07:54:42 +03:00
|
|
|
#else
|
2001-08-18 19:18:56 +04:00
|
|
|
sigchld_action.sa_flags = 0;
|
2010-04-30 17:31:06 +04:00
|
|
|
#endif /* !SA_RESTART */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1)
|
|
|
|
{
|
2001-08-18 19:18:56 +04:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2010-04-30 17:31:06 +04:00
|
|
|
/*
|
|
|
|
* This may happen on QNX Neutrino 6, where SA_RESTART
|
|
|
|
* is defined but not implemented. Fallback to no subshell.
|
|
|
|
*/
|
|
|
|
use_subshell = 0;
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
2001-08-18 19:18:56 +04:00
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/** Define this function for glib-style error handling */
|
|
|
|
GQuark
|
|
|
|
mc_main_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string (PACKAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Save current stat of directories to avoid reloading the panels
|
|
|
|
* when no modifications have taken place
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
save_cwds_stat (void)
|
|
|
|
{
|
|
|
|
if (panels_options.fast_reload)
|
|
|
|
{
|
|
|
|
mc_stat (current_panel->cwd, &(current_panel->dir_stat));
|
|
|
|
if (get_other_type () == view_listing)
|
|
|
|
mc_stat (other_panel->cwd, &(other_panel->dir_stat));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
void
|
|
|
|
do_update_prompt (void)
|
|
|
|
{
|
|
|
|
if (update_prompt)
|
|
|
|
{
|
|
|
|
printf ("\r\n%s", subshell_prompt);
|
|
|
|
fflush (stdout);
|
|
|
|
update_prompt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
|
|
|
change_panel (void)
|
|
|
|
{
|
2010-11-12 11:03:57 +03:00
|
|
|
input_free_completions (cmdline);
|
2010-11-10 14:09:42 +03:00
|
|
|
dlg_one_down (midnight_dlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-11-14 11:35:56 +03:00
|
|
|
void
|
|
|
|
update_menu (void)
|
|
|
|
{
|
|
|
|
menu_set_name (left_menu, horizontal_split ? _("&Above") : _("&Left"));
|
|
|
|
menu_set_name (right_menu, horizontal_split ? _("&Below") : _("&Right"));
|
|
|
|
menubar_arrange (the_menubar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
gboolean
|
|
|
|
quiet_quit_cmd (void)
|
|
|
|
{
|
|
|
|
print_last_revert = 1;
|
|
|
|
return quit_cmd_internal (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Wrapper for do_subshell_chdir, check for availability of subshell */
|
|
|
|
|
|
|
|
void
|
|
|
|
subshell_chdir (const char *directory)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
if (use_subshell)
|
|
|
|
{
|
|
|
|
if (vfs_current_is_local ())
|
|
|
|
do_subshell_chdir (directory, 0, 1);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int
|
|
|
|
do_cd (const char *new_dir, enum cd_enum exact)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
res = do_panel_cd (current_panel, new_dir, exact);
|
|
|
|
|
|
|
|
#if HAVE_CHARSET
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
const char *enc_name;
|
|
|
|
|
|
|
|
enc_name = vfs_get_encoding (current_panel->cwd);
|
|
|
|
if (enc_name != NULL)
|
|
|
|
current_panel->codepage = get_codepage_index (enc_name);
|
|
|
|
else
|
|
|
|
current_panel->codepage = SELECT_CHARSET_NO_TRANSLATE;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_CHARSET */
|
|
|
|
|
|
|
|
return res ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
int
|
|
|
|
load_prompt (int fd, void *unused)
|
|
|
|
{
|
|
|
|
(void) fd;
|
|
|
|
(void) unused;
|
|
|
|
|
|
|
|
if (!read_subshell_prompt ())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Don't actually change the prompt if it's invisible */
|
|
|
|
if (((Dlg_head *) top_dlg->data == midnight_dlg) && command_prompt)
|
|
|
|
{
|
|
|
|
char *tmp_prompt;
|
|
|
|
int prompt_len;
|
|
|
|
|
|
|
|
tmp_prompt = strip_ctrl_codes (subshell_prompt);
|
|
|
|
prompt_len = str_term_width1 (tmp_prompt);
|
|
|
|
|
|
|
|
/* Check for prompts too big */
|
|
|
|
if (COLS > 8 && prompt_len > COLS - 8)
|
|
|
|
{
|
|
|
|
prompt_len = COLS - 8;
|
|
|
|
tmp_prompt[prompt_len] = '\0';
|
|
|
|
}
|
|
|
|
mc_prompt = tmp_prompt;
|
|
|
|
label_set_text (the_prompt, mc_prompt);
|
2010-11-12 11:03:57 +03:00
|
|
|
input_set_origin ((WInput *) cmdline, prompt_len, COLS - prompt_len);
|
2010-11-10 14:09:42 +03:00
|
|
|
|
|
|
|
/* since the prompt has changed, and we are called from one of the
|
|
|
|
* tty_get_event channels, the prompt updating does not take place
|
|
|
|
* automatically: force a cursor update and a screen refresh
|
|
|
|
*/
|
|
|
|
update_cursor (midnight_dlg);
|
|
|
|
mc_refresh ();
|
|
|
|
}
|
|
|
|
update_prompt = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
|
|
|
sort_cmd (void)
|
|
|
|
{
|
|
|
|
WPanel *p;
|
|
|
|
const panel_field_t *sort_order;
|
|
|
|
|
|
|
|
if (!SELECTED_IS_PANEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p = MENU_PANEL;
|
|
|
|
sort_order = sort_box (p->current_sort_field, &p->reverse, &p->case_sensitive, &p->exec_first);
|
|
|
|
|
|
|
|
panel_set_sort_order (p, sort_order);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
|
|
|
toggle_show_hidden (void)
|
|
|
|
{
|
|
|
|
panels_options.show_dot_files = !panels_options.show_dot_files;
|
|
|
|
update_panels (UP_RELOAD, UP_KEEPSEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
|
|
|
midnight_set_buttonbar (WButtonBar * b)
|
|
|
|
{
|
|
|
|
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 2, Q_ ("ButtonBar|Menu"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 3, Q_ ("ButtonBar|View"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 4, Q_ ("ButtonBar|Edit"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 5, Q_ ("ButtonBar|Copy"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 6, Q_ ("ButtonBar|RenMov"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 7, Q_ ("ButtonBar|Mkdir"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 8, Q_ ("ButtonBar|Delete"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 9, Q_ ("ButtonBar|PullDn"), main_map, NULL);
|
|
|
|
buttonbar_set_label (b, 10, Q_ ("ButtonBar|Quit"), main_map, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/** Show current directory in the xterm title */
|
|
|
|
|
|
|
|
void
|
|
|
|
update_xterm_title_path (void)
|
|
|
|
{
|
|
|
|
/* TODO: share code with midnight_get_title () */
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
char host[BUF_TINY];
|
|
|
|
char *p;
|
|
|
|
struct passwd *pw = NULL;
|
|
|
|
char *login = NULL;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
if (xterm_flag && xterm_title)
|
|
|
|
{
|
|
|
|
path = strip_home_and_password (current_panel->cwd);
|
|
|
|
res = gethostname (host, sizeof (host));
|
|
|
|
if (res)
|
|
|
|
{ /* On success, res = 0 */
|
|
|
|
host[0] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
host[sizeof (host) - 1] = '\0';
|
|
|
|
}
|
|
|
|
pw = getpwuid (getuid ());
|
|
|
|
if (pw)
|
|
|
|
{
|
|
|
|
login = g_strdup_printf ("%s@%s", pw->pw_name, host);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
login = g_strdup (host);
|
|
|
|
}
|
|
|
|
p = g_strdup_printf ("mc [%s]:%s", login, path);
|
|
|
|
fprintf (stdout, "\33]0;%s\7", str_term_form (p));
|
|
|
|
g_free (login);
|
|
|
|
g_free (p);
|
|
|
|
if (!alternate_plus_minus)
|
|
|
|
numeric_keypad_mode ();
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Load new hint and display it.
|
|
|
|
* IF force is not 0, ignore the timeout.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
load_hint (int force)
|
|
|
|
{
|
|
|
|
char *hint;
|
|
|
|
|
|
|
|
if (!the_hint->widget.owner)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!message_visible)
|
|
|
|
{
|
|
|
|
label_set_text (the_hint, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hint = get_random_hint (force);
|
|
|
|
|
|
|
|
if (hint != NULL)
|
|
|
|
{
|
|
|
|
if (*hint)
|
|
|
|
set_hintbar (hint);
|
|
|
|
g_free (hint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char text[BUF_SMALL];
|
|
|
|
|
|
|
|
g_snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"), VERSION);
|
|
|
|
set_hintbar (text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
1999-04-17 02:02:09 +04:00
|
|
|
int
|
2002-10-31 07:31:52 +03:00
|
|
|
main (int argc, char *argv[])
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-05-02 14:45:48 +04:00
|
|
|
struct stat s;
|
|
|
|
char *mc_dir;
|
2009-09-28 18:04:25 +04:00
|
|
|
GError *error = NULL;
|
|
|
|
gboolean isInitialized;
|
2009-05-02 14:45:48 +04:00
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
bindtextdomain ("mc", LOCALEDIR);
|
|
|
|
textdomain ("mc");
|
1998-12-30 05:51:01 +03:00
|
|
|
|
2002-09-11 08:58:24 +04:00
|
|
|
/* Set up temporary directory */
|
|
|
|
mc_tmpdir ();
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
OS_Setup ();
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_init_strings (NULL);
|
|
|
|
|
1998-08-27 00:23:10 +04:00
|
|
|
vfs_init ();
|
1998-12-02 08:18:20 +03:00
|
|
|
|
2009-02-26 00:53:52 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2009-06-14 19:18:27 +04:00
|
|
|
edit_stack_init ();
|
2009-02-26 00:53:52 +03:00
|
|
|
#endif
|
|
|
|
|
2010-05-12 10:29:57 +04:00
|
|
|
if (!mc_args_handle (argc, argv, "mc"))
|
|
|
|
exit (EXIT_FAILURE);
|
2005-07-21 00:29:08 +04:00
|
|
|
|
2009-07-12 14:22:41 +04:00
|
|
|
/* NOTE: This has to be called before tty_init or whatever routine
|
1998-02-27 07:54:42 +03:00
|
|
|
calls any define_sequence */
|
|
|
|
init_key ();
|
|
|
|
|
|
|
|
/* Must be done before installing the SIGCHLD handler [[FIXME]] */
|
|
|
|
handle_console (CONSOLE_INIT);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2002-11-16 00:41:57 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
/* Don't use subshell when invoked as viewer or editor */
|
2010-03-21 13:57:33 +03:00
|
|
|
if (mc_run_mode != MC_RUN_FULL)
|
2010-04-30 17:31:06 +04:00
|
|
|
use_subshell = 0;
|
2002-11-16 00:41:57 +03:00
|
|
|
|
|
|
|
if (use_subshell)
|
2010-04-30 17:31:06 +04:00
|
|
|
subshell_get_console_attributes ();
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Install the SIGCHLD handler; must be done before init_subshell() */
|
|
|
|
init_sigchld ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* We need this, since ncurses endwin () doesn't restore the signals */
|
|
|
|
save_stop_handler ();
|
|
|
|
|
|
|
|
/* Must be done before init_subshell, to set up the terminal size: */
|
|
|
|
/* FIXME: Should be removed and LINES and COLS computed on subshell */
|
2009-09-01 15:05:01 +04:00
|
|
|
tty_init ((gboolean) mc_args__slow_terminal, (gboolean) mc_args__ugly_line_drawing);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
load_setup ();
|
|
|
|
|
2010-05-06 23:19:02 +04:00
|
|
|
/* Removing this from the X code let's us type C-c */
|
|
|
|
load_key_defs ();
|
|
|
|
|
|
|
|
load_keymap_defs ();
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
tty_init_colors (mc_args__disable_colors, mc_args__force_colors);
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
isInitialized = mc_skin_init (&error);
|
2009-09-28 18:04:25 +04:00
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
mc_filehighlight = mc_fhl_new (TRUE);
|
|
|
|
|
2009-05-30 21:39:02 +04:00
|
|
|
dlg_set_default_colors ();
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
if (!isInitialized)
|
|
|
|
{
|
clang: fixed useful warnings (-Wformat related)
../../mc/edit/editcmd.c:2519:50: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
match_expr = g_strdup_printf ("(^|\\s+|\\b)%.*s[^\\s\\.=\\+\\[\\]\\(\\)\\,\\;\\:\\\"\\'\\-\\?\\/\\|\\\\\\{\\}\\*\\&\\^\\%%\\$#@\\!]+", word_len, bufpos);
^ ~~~~~~~~
../../mc/edit/editcmd.c:2700:38: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
^ ~~~~~~~~
2 diagnostics generated.
make[2]: *** [editcmd.o] Error 1
make[2]: Target `all' not remade because of errors.
../../../mc/src/mcconfig/common.c:71:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
^~~~~~~~~~~~~~~
../../../mc/src/mcconfig/common.c:83:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
^~~~~~~~~~~~~~~
2 diagnostics generated.
make[3]: *** [libmcconfig_la-common.lo] Error 1
make[3]: Target `all' not remade because of errors.
../../mc/src/main.c:2165:41: error: format string is not a string literal (potentially insecure) [-Wformat-security]
message (D_ERROR, _("Warning"), error->message);
^~~~~~~~~~~~~~
1 diagnostic generated.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
2009-12-06 16:32:16 +03:00
|
|
|
message (D_ERROR, _("Warning"), "%s", error->message);
|
2010-04-30 17:31:06 +04:00
|
|
|
g_error_free (error);
|
2009-09-28 18:04:25 +04:00
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-02 14:45:48 +04:00
|
|
|
/* create home directory */
|
|
|
|
/* do it after the screen library initialization to show the error message */
|
2009-10-05 18:32:46 +04:00
|
|
|
mc_dir = concat_dir_and_file (home_dir, MC_USERCONF_DIR);
|
2009-05-02 14:45:48 +04:00
|
|
|
canonicalize_pathname (mc_dir);
|
2010-04-30 17:31:06 +04:00
|
|
|
if ((stat (mc_dir, &s) != 0) && (errno == ENOENT) && mkdir (mc_dir, 0700) != 0)
|
|
|
|
message (D_ERROR, _("Warning"), _("Cannot create %s directory"), mc_dir);
|
2009-05-02 14:45:48 +04:00
|
|
|
g_free (mc_dir);
|
|
|
|
|
2001-02-10 07:28:56 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
/* Done here to ensure that the subshell doesn't */
|
|
|
|
/* inherit the file descriptors opened below, etc */
|
|
|
|
if (use_subshell)
|
2010-04-30 17:31:06 +04:00
|
|
|
init_subshell ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Also done after init_subshell, to save any shell init file messages */
|
|
|
|
if (console_flag)
|
2010-04-30 17:31:06 +04:00
|
|
|
handle_console (CONSOLE_SAVE);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-01 02:36:24 +04:00
|
|
|
if (alternate_plus_minus)
|
2010-04-30 17:31:06 +04:00
|
|
|
application_keypad_mode ();
|
1999-03-30 10:09:56 +04:00
|
|
|
|
2001-09-08 01:15:04 +04:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2010-04-30 17:31:06 +04:00
|
|
|
if (use_subshell)
|
|
|
|
{
|
|
|
|
mc_prompt = strip_ctrl_codes (subshell_prompt);
|
|
|
|
if (mc_prompt == NULL)
|
|
|
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Program main loop */
|
2003-03-05 23:18:11 +03:00
|
|
|
if (!midnight_shutdown)
|
2010-04-30 17:31:06 +04:00
|
|
|
do_nc ();
|
1999-04-06 07:49:34 +04:00
|
|
|
|
|
|
|
/* Save the tree store */
|
1999-04-17 02:02:09 +04:00
|
|
|
tree_store_save ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-10-29 22:04:44 +03:00
|
|
|
free_keymap_defs ();
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Virtual File System shutdown */
|
|
|
|
vfs_shut ();
|
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
flush_extension_file (); /* does only free memory */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
mc_fhl_free (&mc_filehighlight);
|
2009-10-24 12:58:02 +04:00
|
|
|
mc_skin_deinit ();
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-06-02 21:40:37 +04:00
|
|
|
tty_shutdown ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
if (console_flag && !(quit & SUBSHELL_EXIT))
|
2010-04-30 17:31:06 +04:00
|
|
|
handle_console (CONSOLE_RESTORE);
|
1998-04-01 02:36:24 +04:00
|
|
|
if (alternate_plus_minus)
|
2010-04-30 17:31:06 +04:00
|
|
|
numeric_keypad_mode ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-04-30 17:31:06 +04:00
|
|
|
signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (console_flag)
|
2010-04-30 17:31:06 +04:00
|
|
|
handle_console (CONSOLE_DONE);
|
|
|
|
putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
|
|
|
|
|
|
|
|
if (mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file && last_wd_string && !print_last_revert)
|
|
|
|
{
|
|
|
|
int last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
|
|
|
|
S_IRUSR | S_IWUSR);
|
|
|
|
|
|
|
|
if (last_wd_fd != -1)
|
|
|
|
{
|
|
|
|
ssize_t ret1;
|
|
|
|
int ret2;
|
|
|
|
ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
|
|
|
|
ret2 = close (last_wd_fd);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (last_wd_string);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-21 02:01:10 +04:00
|
|
|
g_free (mc_home_alt);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (mc_home);
|
2009-06-30 21:49:40 +04:00
|
|
|
g_free (shell);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
done_key ();
|
2001-10-29 16:40:00 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
free_codepages_list ();
|
2010-02-05 14:02:47 +03:00
|
|
|
g_free (autodetect_codeset);
|
2001-10-29 16:40:00 +03:00
|
|
|
#endif
|
2010-07-11 19:08:18 +04:00
|
|
|
g_free (clipboard_store_path);
|
|
|
|
g_free (clipboard_paste_path);
|
2010-06-08 23:23:00 +04:00
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_uninit_strings ();
|
|
|
|
|
2010-03-21 13:57:33 +03:00
|
|
|
g_free (mc_run_param0);
|
|
|
|
g_free (mc_run_param1);
|
1999-04-21 23:18:31 +04:00
|
|
|
|
2009-02-26 00:53:52 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2009-06-14 19:18:27 +04:00
|
|
|
edit_stack_free ();
|
2009-02-26 00:53:52 +03:00
|
|
|
#endif
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2010-11-10 14:09:42 +03:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|