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
|
|
|
|
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>
|
|
|
|
#include <signal.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>
|
2009-02-06 02:30:45 +03:00
|
|
|
#include <pwd.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-09-03 09:07:40 +04:00
|
|
|
#include "global.h"
|
2009-05-09 19:17:57 +04:00
|
|
|
|
2009-05-08 14:01:05 +04:00
|
|
|
#include "../src/tty/tty.h"
|
|
|
|
#include "../src/tty/color.h"
|
2009-05-09 19:17:57 +04:00
|
|
|
#include "../src/tty/mouse.h"
|
2009-05-26 19:01:58 +04:00
|
|
|
#include "../src/tty/key.h" /* For init_key() */
|
2009-05-24 13:39:14 +04:00
|
|
|
#include "../src/tty/win.h" /* xterm_flag */
|
2009-05-09 19:17:57 +04:00
|
|
|
|
|
|
|
#include "dir.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "dialog.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include "tree.h"
|
2003-10-24 03:57:59 +04:00
|
|
|
#include "treestore.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "cons.saver.h"
|
|
|
|
#include "subshell.h"
|
2002-10-31 07:31:52 +03:00
|
|
|
#include "setup.h" /* save_setup() */
|
2009-05-20 16:34:33 +04:00
|
|
|
#include "../src/mcconfig/mcconfig.h"
|
2002-12-08 07:16:30 +03:00
|
|
|
#include "boxes.h" /* sort_box() */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "layout.h"
|
|
|
|
#include "cmd.h" /* Normal commands */
|
|
|
|
#include "hotlist.h"
|
|
|
|
#include "panelize.h"
|
2002-12-08 07:16:30 +03: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"
|
2002-10-31 07:31:52 +03:00
|
|
|
#include "ext.h" /* For flush_extension_file() */
|
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
|
|
|
#include "strutil.h"
|
2009-06-20 01:32:15 +04:00
|
|
|
#include <pwd.h> /* for username in xterm title */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Listbox for the command history feature */
|
|
|
|
#include "widget.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "wtools.h"
|
|
|
|
|
|
|
|
#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
|
|
|
|
2002-09-11 14:05:24 +04:00
|
|
|
#ifdef WITH_SMBFS
|
|
|
|
#include "../vfs/smbfs.h" /* smbfs_set_debug() */
|
|
|
|
#endif
|
|
|
|
|
2002-11-13 12:30:57 +03:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
|
|
|
# include "../edit/edit.h"
|
|
|
|
#endif
|
|
|
|
|
2001-10-29 16:40:00 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
#include "charsets.h"
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_CHARSET */
|
2001-10-29 16:40:00 +03:00
|
|
|
|
2003-11-08 02:50:18 +03:00
|
|
|
#ifdef USE_VFS
|
|
|
|
#include "../vfs/gc.h"
|
|
|
|
#endif
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "popt.h"
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
/* 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 */
|
2004-08-16 22:25:16 +04:00
|
|
|
struct WMenu *the_menubar = NULL;
|
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, marking a files moves the cursor down */
|
2002-10-31 07:31:52 +03:00
|
|
|
int mark_moves_down = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2001-09-08 01:15:04 +04: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;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
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;
|
2009-04-17 01:22:52 +04:00
|
|
|
|
2002-10-31 07:31:52 +03: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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int utf8_display = 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* If true use the internal viewer */
|
|
|
|
int use_internal_view = 1;
|
|
|
|
|
|
|
|
/* Have we shown the fast-reload warning in the past? */
|
|
|
|
int fast_reload_w = 0;
|
|
|
|
|
|
|
|
/* Move page/item? When clicking on the top or bottom of a panel */
|
|
|
|
int mouse_move_pages = 1;
|
|
|
|
|
|
|
|
/* If true: l&r arrows are used to chdir if the input line is empty */
|
|
|
|
int navigate_with_arrows = 0;
|
|
|
|
|
2009-08-03 13:50:36 +04:00
|
|
|
/* If true program softkeys (HP terminals only) on startup and after every
|
|
|
|
command ran in the subshell to the description found in the termcap/terminfo
|
1998-02-27 07:54:42 +03:00
|
|
|
database */
|
|
|
|
int reset_hp_softkeys = 0;
|
|
|
|
|
|
|
|
/* The prompt */
|
2005-09-05 06:10:48 +04:00
|
|
|
const char *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;
|
|
|
|
|
|
|
|
/* For slow terminals */
|
2009-07-12 14:22:41 +04:00
|
|
|
static int slow_terminal = 0;
|
|
|
|
|
|
|
|
/* If true use +, -, | for line drawing */
|
|
|
|
static int ugly_line_drawing = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
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
|
|
|
|
|
|
|
/* If true, assume we are running on an xterm terminal */
|
|
|
|
static int force_xterm = 0;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2009-05-13 18:40:27 +04:00
|
|
|
/* if skip_check_codeset = 1 do not show warning about
|
|
|
|
* system and display codeset is different
|
|
|
|
*/
|
|
|
|
int skip_check_codeset = 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* 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
|
|
|
|
|
|
|
/* The value of the other directory, only used when loading the setup */
|
2004-08-16 22:25:16 +04:00
|
|
|
char *other_dir = NULL;
|
2001-06-20 19:08:18 +04:00
|
|
|
|
|
|
|
/* Only used at program boot */
|
|
|
|
int boot_current_is_left = 1;
|
|
|
|
|
2004-08-16 22:25:16 +04:00
|
|
|
static char *this_dir = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
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;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
/* If set, then print to the given file the last directory we were at */
|
2004-08-16 22:25:16 +04:00
|
|
|
static char *last_wd_file = NULL;
|
|
|
|
static char *last_wd_string = NULL;
|
2002-10-31 07:31:52 +03:00
|
|
|
/* Set to 1 to suppress printing the last directory */
|
1998-02-27 07:54:42 +03:00
|
|
|
static int print_last_revert = 0;
|
|
|
|
|
2009-07-08 22:37:01 +04:00
|
|
|
/* Set to force black and white display at program startup */
|
|
|
|
static gboolean disable_colors = FALSE;
|
|
|
|
/* Force colors, only used by Slang */
|
|
|
|
static gboolean force_colors = FALSE;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* colors specified on the command line: they override any other setting */
|
2004-08-16 22:25:16 +04:00
|
|
|
char *command_line_colors = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* File name to view if argument was supplied */
|
2004-08-30 03:54:47 +04:00
|
|
|
static const char *view_one_file = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-12-09 01:15:13 +03:00
|
|
|
/* File name to edit if argument was supplied */
|
2005-06-23 01:38:52 +04:00
|
|
|
const char *edit_one_file = NULL;
|
2002-12-01 11:18:17 +03:00
|
|
|
|
|
|
|
/* Line to start the editor on */
|
|
|
|
static int edit_one_file_start_line = 0;
|
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;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
char cmd_buf[512];
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Save current stat of directories to avoid reloading the panels */
|
|
|
|
/* when no modifications have taken place */
|
|
|
|
void
|
|
|
|
save_cwds_stat (void)
|
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
if (fast_reload) {
|
2003-10-26 09:45:59 +03:00
|
|
|
mc_stat (current_panel->cwd, &(current_panel->dir_stat));
|
1998-02-27 07:54:42 +03:00
|
|
|
if (get_other_type () == view_listing)
|
2003-10-26 09:45:59 +03:00
|
|
|
mc_stat (other_panel->cwd, &(other_panel->dir_stat));
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
void
|
2001-06-15 02:33:00 +04:00
|
|
|
do_update_prompt (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
if (update_prompt) {
|
1998-02-27 07:54:42 +03:00
|
|
|
printf ("%s", subshell_prompt);
|
|
|
|
fflush (stdout);
|
|
|
|
update_prompt = 0;
|
|
|
|
}
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
change_panel (void)
|
|
|
|
{
|
2002-09-20 23:36:55 +04:00
|
|
|
free_completions (cmdline);
|
1998-02-27 07:54:42 +03:00
|
|
|
dlg_one_down (midnight_dlg);
|
|
|
|
}
|
|
|
|
|
2002-07-03 10:19:40 +04:00
|
|
|
/* Stop MC main dialog and the current dialog if it exists.
|
|
|
|
* Needed to provide fast exit from MC viewer or editor on shell exit */
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
stop_dialogs (void)
|
2002-07-03 10:19:40 +04:00
|
|
|
{
|
|
|
|
midnight_dlg->running = 0;
|
|
|
|
if (current_dlg) {
|
|
|
|
current_dlg->running = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static int
|
|
|
|
quit_cmd_internal (int quiet)
|
|
|
|
{
|
|
|
|
int q = quit;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (quiet || !confirm_exit) {
|
1998-02-27 07:54:42 +03:00
|
|
|
q = 1;
|
2002-10-31 07:31:52 +03:00
|
|
|
} else {
|
|
|
|
if (query_dialog
|
|
|
|
(_(" The Midnight Commander "),
|
2009-01-10 16:13:56 +03:00
|
|
|
_(" Do you really want to quit the Midnight Commander? "), D_NORMAL,
|
2002-10-31 07:31:52 +03:00
|
|
|
2, _("&Yes"), _("&No")) == 0)
|
1998-02-27 07:54:42 +03:00
|
|
|
q = 1;
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
if (q) {
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
if (!use_subshell)
|
2002-07-03 10:19:40 +04:00
|
|
|
stop_dialogs ();
|
2002-10-31 07:31:52 +03:00
|
|
|
else if ((q = exit_subshell ()))
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2002-10-31 07:31:52 +03:00
|
|
|
stop_dialogs ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
if (q)
|
2002-10-31 07:31:52 +03:00
|
|
|
quit |= 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
return quit;
|
|
|
|
}
|
|
|
|
|
2002-11-13 07:01:04 +03:00
|
|
|
static void
|
2002-10-31 07:31:52 +03:00
|
|
|
quit_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
quit_cmd_internal (0);
|
|
|
|
}
|
|
|
|
|
2005-05-23 20:37:01 +04:00
|
|
|
void
|
2002-10-31 07:31:52 +03:00
|
|
|
quiet_quit_cmd (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
print_last_revert = 1;
|
|
|
|
quit_cmd_internal (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wrapper for do_subshell_chdir, check for availability of subshell */
|
|
|
|
void
|
2004-08-29 21:15:23 +04:00
|
|
|
subshell_chdir (const char *directory)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2002-10-31 07:31:52 +03:00
|
|
|
if (use_subshell) {
|
1998-02-27 07:54:42 +03:00
|
|
|
if (vfs_current_is_local ())
|
|
|
|
do_subshell_chdir (directory, 0, 1);
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-03-31 01:04:59 +04:00
|
|
|
void
|
2003-05-05 19:30:43 +04:00
|
|
|
directory_history_add (struct WPanel *panel, const char *dir)
|
1998-03-31 01:04:59 +04:00
|
|
|
{
|
2003-05-05 19:30:43 +04:00
|
|
|
char *tmp;
|
2003-02-18 08:25:45 +03:00
|
|
|
|
2009-02-06 01:40:32 +03:00
|
|
|
tmp = g_strdup (dir);
|
2003-05-05 19:30:43 +04:00
|
|
|
strip_password (tmp, 1);
|
2003-02-18 08:25:45 +03:00
|
|
|
|
2003-05-05 19:30:43 +04:00
|
|
|
panel->dir_history = list_append_unique (panel->dir_history, tmp);
|
1998-03-31 01:04:59 +04:00
|
|
|
}
|
|
|
|
|
1998-09-12 03:27:49 +04:00
|
|
|
/*
|
|
|
|
* If we moved to the parent directory move the selection pointer to
|
|
|
|
* the old directory name; If we leave VFS dir, remove FS specificator.
|
1998-09-29 20:01:16 +04:00
|
|
|
*
|
|
|
|
* You do _NOT_ want to add any vfs aware code here. <pavel@ucw.cz>
|
1998-09-12 03:27:49 +04:00
|
|
|
*/
|
2004-09-25 17:46:23 +04:00
|
|
|
static const char *
|
2004-08-29 21:15:23 +04:00
|
|
|
get_parent_dir_name (const char *cwd, const char *lwd)
|
1998-09-12 03:27:49 +04:00
|
|
|
{
|
2004-09-25 17:46:23 +04:00
|
|
|
const char *p;
|
1998-09-12 03:27:49 +04:00
|
|
|
if (strlen (lwd) > strlen (cwd))
|
2005-11-02 14:50:51 +03:00
|
|
|
if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd) &&
|
2009-04-24 02:47:22 +04:00
|
|
|
((gsize)strlen (cwd) == (gsize) p - (gsize) lwd || (p == lwd && cwd[0] == PATH_SEP &&
|
2005-11-02 14:50:51 +03:00
|
|
|
cwd[1] == '\0'))) {
|
2002-10-31 07:31:52 +03:00
|
|
|
return (p + 1);
|
1998-09-12 03:27:49 +04:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-18 09:43:04 +03:00
|
|
|
/*
|
|
|
|
* Changes the current directory of the panel.
|
|
|
|
* Don't record change in the directory history.
|
|
|
|
*/
|
1998-12-03 00:27:27 +03:00
|
|
|
static int
|
2004-08-29 21:15:23 +04:00
|
|
|
_do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2004-08-30 03:54:47 +04:00
|
|
|
const char *directory;
|
|
|
|
char *olddir;
|
2002-10-31 07:31:52 +03:00
|
|
|
char temp[MC_MAXPATHLEN];
|
1998-06-01 18:34:43 +04:00
|
|
|
char *translated_url;
|
2003-10-11 10:44:54 +04:00
|
|
|
|
2005-01-19 09:14:44 +03:00
|
|
|
if (cd_type == cd_parse_command) {
|
|
|
|
while (*new_dir == ' ')
|
|
|
|
new_dir++;
|
|
|
|
}
|
|
|
|
|
2009-02-06 01:40:32 +03:00
|
|
|
olddir = g_strdup (panel->cwd);
|
2004-08-30 03:54:47 +04:00
|
|
|
new_dir = translated_url = vfs_translate_url (new_dir);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Convert *new_path to a suitable pathname, handle ~user */
|
2002-10-31 07:31:52 +03:00
|
|
|
|
|
|
|
if (cd_type == cd_parse_command) {
|
|
|
|
if (!strcmp (new_dir, "-")) {
|
1998-02-27 07:54:42 +03:00
|
|
|
strcpy (temp, panel->lwd);
|
|
|
|
new_dir = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
directory = *new_dir ? new_dir : home_dir;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
|
|
|
if (mc_chdir (directory) == -1) {
|
1998-02-27 07:54:42 +03:00
|
|
|
strcpy (panel->cwd, olddir);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (olddir);
|
|
|
|
g_free (translated_url);
|
1998-02-27 07:54:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (translated_url);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Success: save previous directory, shutdown status of previous dir */
|
|
|
|
strcpy (panel->lwd, olddir);
|
2002-09-20 23:36:55 +04:00
|
|
|
free_completions (cmdline);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
|
|
|
|
|
2003-10-11 10:44:54 +04:00
|
|
|
vfs_release_path (olddir);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
subshell_chdir (panel->cwd);
|
|
|
|
|
|
|
|
/* Reload current panel */
|
1999-03-03 00:33:48 +03:00
|
|
|
panel_clean_dir (panel);
|
2002-10-31 07:31:52 +03:00
|
|
|
panel->count =
|
2003-06-06 04:52:35 +04:00
|
|
|
do_load_dir (panel->cwd, &panel->dir, panel->sort_type,
|
2009-01-26 02:26:31 +03:00
|
|
|
panel->reverse, panel->case_sensitive,
|
|
|
|
panel->exec_first, panel->filter);
|
1998-12-11 05:13:35 +03:00
|
|
|
try_to_select (panel, get_parent_dir_name (panel->cwd, olddir));
|
2003-02-05 11:37:21 +03:00
|
|
|
load_hint (0);
|
2003-09-10 08:42:13 +04:00
|
|
|
panel->dirty = 1;
|
2002-12-26 19:10:45 +03:00
|
|
|
update_xterm_title_path ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (olddir);
|
1998-09-12 03:27:49 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-02-18 09:43:04 +03:00
|
|
|
/*
|
|
|
|
* Changes the current directory of the panel.
|
|
|
|
* Record change in the directory history.
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
int
|
2004-08-29 21:15:23 +04:00
|
|
|
do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1998-03-31 01:04:59 +04:00
|
|
|
int r;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-11 06:53:35 +04:00
|
|
|
r = _do_panel_cd (panel, new_dir, cd_type);
|
1998-03-31 01:04:59 +04:00
|
|
|
if (r)
|
2003-02-18 09:43:04 +03:00
|
|
|
directory_history_add (panel, panel->cwd);
|
1998-03-31 01:04:59 +04:00
|
|
|
return r;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-04-11 06:53:35 +04:00
|
|
|
int
|
2004-08-29 21:15:23 +04:00
|
|
|
do_cd (const char *new_dir, enum cd_enum exact)
|
1998-04-11 06:53:35 +04:00
|
|
|
{
|
2003-10-26 09:45:59 +03:00
|
|
|
return (do_panel_cd (current_panel, new_dir, exact));
|
1998-04-11 06:53:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-31 07:31:52 +03:00
|
|
|
directory_history_next (WPanel *panel)
|
1998-04-11 06:53:35 +04:00
|
|
|
{
|
2003-02-18 08:25:45 +03:00
|
|
|
GList *nextdir;
|
|
|
|
|
|
|
|
nextdir = g_list_next (panel->dir_history);
|
|
|
|
|
|
|
|
if (!nextdir)
|
1998-04-11 06:53:35 +04:00
|
|
|
return;
|
2003-02-18 08:25:45 +03:00
|
|
|
|
|
|
|
if (_do_panel_cd (panel, (char *) nextdir->data, cd_exact))
|
|
|
|
panel->dir_history = nextdir;
|
1998-04-11 06:53:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-31 07:31:52 +03:00
|
|
|
directory_history_prev (WPanel *panel)
|
1998-04-11 06:53:35 +04:00
|
|
|
{
|
2003-02-18 08:25:45 +03:00
|
|
|
GList *prevdir;
|
|
|
|
|
|
|
|
prevdir = g_list_previous (panel->dir_history);
|
|
|
|
|
|
|
|
if (!prevdir)
|
1998-04-11 06:53:35 +04:00
|
|
|
return;
|
2003-02-18 08:25:45 +03:00
|
|
|
|
|
|
|
if (_do_panel_cd (panel, (char *) prevdir->data, cd_exact))
|
|
|
|
panel->dir_history = prevdir;
|
1998-04-11 06:53:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-31 07:31:52 +03:00
|
|
|
directory_history_list (WPanel *panel)
|
1998-04-11 06:53:35 +04:00
|
|
|
{
|
|
|
|
char *s;
|
2003-02-18 09:19:11 +03:00
|
|
|
|
|
|
|
if (!panel->dir_history)
|
|
|
|
return;
|
|
|
|
|
|
|
|
s = show_hist (panel->dir_history, panel->widget.x, panel->widget.y);
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_do_panel_cd (panel, s, cd_exact))
|
|
|
|
directory_history_add (panel, panel->cwd);
|
|
|
|
else
|
2009-01-10 16:13:56 +03:00
|
|
|
message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (s);
|
1998-04-11 06:53:35 +04:00
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
int
|
|
|
|
load_prompt (int fd, void *unused)
|
|
|
|
{
|
2005-02-08 22:59:45 +03:00
|
|
|
(void) fd;
|
|
|
|
(void) unused;
|
|
|
|
|
2002-08-15 10:53:44 +04:00
|
|
|
if (!read_subshell_prompt ())
|
1998-02-27 07:54:42 +03:00
|
|
|
return 0;
|
2001-07-06 02:35:16 +04:00
|
|
|
|
|
|
|
/* Don't actually change the prompt if it's invisible */
|
2002-10-31 07:31:52 +03:00
|
|
|
if (current_dlg == midnight_dlg && command_prompt) {
|
2005-09-05 06:10:48 +04:00
|
|
|
char *tmp_prompt;
|
2002-10-31 07:31:52 +03:00
|
|
|
int prompt_len;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2005-09-05 06:10:48 +04:00
|
|
|
tmp_prompt = strip_ctrl_codes (subshell_prompt);
|
patches by Rostislav Beneš: mc-28-fix
rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c
now, basic mc's function should work well, editor and view are still broken.
2008-12-29 02:53:08 +03:00
|
|
|
prompt_len = str_term_width1 (tmp_prompt);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Check for prompts too big */
|
2002-09-11 01:18:11 +04:00
|
|
|
if (COLS > 8 && prompt_len > COLS - 8) {
|
2005-09-05 06:10:48 +04:00
|
|
|
tmp_prompt[COLS - 8] = '\0';
|
1998-02-27 07:54:42 +03:00
|
|
|
prompt_len = COLS - 8;
|
|
|
|
}
|
2005-09-05 06:10:48 +04:00
|
|
|
prompt = tmp_prompt;
|
1998-02-27 07:54:42 +03:00
|
|
|
label_set_text (the_prompt, prompt);
|
2002-10-31 07:31:52 +03:00
|
|
|
winput_set_origin ((WInput *) cmdline, prompt_len,
|
|
|
|
COLS - prompt_len);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-08-03 13:50:36 +04:00
|
|
|
/* since the prompt has changed, and we are called from one of the
|
2009-06-19 21:33:41 +04:00
|
|
|
* tty_get_event channels, the prompt updating does not take place
|
1998-02-27 07:54:42 +03:00
|
|
|
* automatically: force a cursor update and a screen refresh
|
|
|
|
*/
|
2001-07-06 02:35:16 +04:00
|
|
|
update_cursor (midnight_dlg);
|
2009-05-13 12:38:11 +04:00
|
|
|
tty_refresh ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
update_prompt = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-11-13 07:01:04 +03:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
sort_cmd (void)
|
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
WPanel *p;
|
1998-02-27 07:54:42 +03:00
|
|
|
sortfn *sort_order;
|
|
|
|
|
|
|
|
if (!SELECTED_IS_PANEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p = MENU_PANEL;
|
2009-01-26 02:26:31 +03:00
|
|
|
sort_order = sort_box (p->sort_type, &p->reverse,
|
|
|
|
&p->case_sensitive,
|
|
|
|
&p->exec_first);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-12-31 02:49:58 +03:00
|
|
|
panel_set_sort_order (p, sort_order);
|
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);
|
2002-10-31 07:31:52 +03:00
|
|
|
if (sel_dir) {
|
|
|
|
do_cd (sel_dir, cd_exact);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (sel_dir);
|
1998-02-27 07:54: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)
|
|
|
|
return;
|
|
|
|
|
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)
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* LISTMODE_EDITOR */
|
1998-02-27 07:54: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) */
|
2003-08-02 00:00:28 +04:00
|
|
|
static menu_entry LeftMenu[] = {
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Listing mode..."), NULL_HOTKEY, listing_cmd},
|
|
|
|
{' ', N_("&Quick view C-x q"), NULL_HOTKEY, quick_view_cmd},
|
|
|
|
{' ', N_("&Info C-x i"), NULL_HOTKEY, info_cmd},
|
|
|
|
{' ', N_("&Tree"), NULL_HOTKEY, tree_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Sort order..."), NULL_HOTKEY, sort_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Filter..."), NULL_HOTKEY, filter_cmd},
|
2009-05-24 14:41:16 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2008-12-29 02:54:37 +03:00
|
|
|
{' ', "",NULL_HOTKEY, 0},
|
2009-04-21 12:48:13 +04:00
|
|
|
{' ', N_("&Encoding... C-t"), NULL_HOTKEY, encoding_cmd},
|
2009-05-24 14:41:16 +04:00
|
|
|
#endif
|
2002-10-31 07:31:52 +03:00
|
|
|
#ifdef USE_NETCODE
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
2009-05-11 11:28:57 +04:00
|
|
|
#ifdef ENABLE_VFS_MCFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Network link..."), NULL_HOTKEY, netlink_cmd},
|
2002-04-19 11:21:09 +04:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("FT&P link..."), NULL_HOTKEY, ftplink_cmd},
|
|
|
|
{' ', N_("S&hell link..."), NULL_HOTKEY, fishlink_cmd},
|
1999-06-23 01:02:08 +04:00
|
|
|
#ifdef WITH_SMBFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("SM&B link..."), NULL_HOTKEY, smblink_cmd},
|
1999-06-23 01:02:08 +04:00
|
|
|
#endif
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Rescan C-r"), NULL_HOTKEY, reread_cmd}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static menu_entry RightMenu[] = {
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Listing mode..."), NULL_HOTKEY, listing_cmd},
|
|
|
|
{' ', N_("&Quick view C-x q"), NULL_HOTKEY, quick_view_cmd},
|
|
|
|
{' ', N_("&Info C-x i"), NULL_HOTKEY, info_cmd},
|
|
|
|
{' ', N_("&Tree"), NULL_HOTKEY, tree_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Sort order..."), NULL_HOTKEY, sort_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Filter..."), NULL_HOTKEY, filter_cmd},
|
2009-05-24 14:41:16 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2008-12-29 02:54:37 +03:00
|
|
|
{' ', "",NULL_HOTKEY, 0},
|
2009-04-21 12:48:13 +04:00
|
|
|
{' ', N_("&Encoding... C-t"), NULL_HOTKEY, encoding_cmd},
|
2009-05-24 14:41:16 +04:00
|
|
|
#endif
|
2002-10-31 07:31:52 +03:00
|
|
|
#ifdef USE_NETCODE
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
2009-05-11 11:28:57 +04:00
|
|
|
#ifdef ENABLE_VFS_MCFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Network link..."), NULL_HOTKEY, netlink_cmd},
|
2002-04-19 11:21:09 +04:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("FT&P link..."), NULL_HOTKEY, ftplink_cmd},
|
|
|
|
{' ', N_("S&hell link..."), NULL_HOTKEY, fishlink_cmd},
|
1999-06-23 01:02:08 +04:00
|
|
|
#ifdef WITH_SMBFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("SM&B link..."), NULL_HOTKEY, smblink_cmd},
|
1999-06-23 01:02:08 +04:00
|
|
|
#endif
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Rescan C-r"), NULL_HOTKEY, reread_cmd}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static menu_entry FileMenu[] = {
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&View F3"), NULL_HOTKEY, view_cmd},
|
|
|
|
{' ', N_("Vie&w file... "), NULL_HOTKEY, view_file_cmd},
|
|
|
|
{' ', N_("&Filtered view M-!"), NULL_HOTKEY, filtered_view_cmd},
|
|
|
|
{' ', N_("&Edit F4"), NULL_HOTKEY, edit_cmd},
|
|
|
|
{' ', N_("&Copy F5"), NULL_HOTKEY, copy_cmd},
|
|
|
|
{' ', N_("c&Hmod C-x c"), NULL_HOTKEY, chmod_cmd},
|
|
|
|
{' ', N_("&Link C-x l"), NULL_HOTKEY, link_cmd},
|
|
|
|
{' ', N_("&SymLink C-x s"), NULL_HOTKEY, symlink_cmd},
|
|
|
|
{' ', N_("edit s&Ymlink C-x C-s"), NULL_HOTKEY, edit_symlink_cmd},
|
|
|
|
{' ', N_("ch&Own C-x o"), NULL_HOTKEY, chown_cmd},
|
|
|
|
{' ', N_("&Advanced chown "), NULL_HOTKEY, chown_advanced_cmd},
|
|
|
|
{' ', N_("&Rename/Move F6"), NULL_HOTKEY, ren_cmd},
|
|
|
|
{' ', N_("&Mkdir F7"), NULL_HOTKEY, mkdir_cmd},
|
|
|
|
{' ', N_("&Delete F8"), NULL_HOTKEY, delete_cmd},
|
|
|
|
{' ', N_("&Quick cd M-c"), NULL_HOTKEY, quick_cd_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("select &Group M-+"), NULL_HOTKEY, select_cmd},
|
|
|
|
{' ', N_("u&Nselect group M-\\"), NULL_HOTKEY, unselect_cmd},
|
2009-05-26 14:59:12 +04:00
|
|
|
{' ', N_("reverse selec&Tion M-*"), NULL_HOTKEY, reverse_selection_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("e&Xit F10"), NULL_HOTKEY, quit_cmd}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static menu_entry CmdMenu[] = {
|
2009-05-21 09:13:12 +04:00
|
|
|
{' ', N_("&User menu F2"), NULL_HOTKEY, user_file_menu_cmd},
|
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.
|
|
|
|
*/
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Directory tree"), NULL_HOTKEY, treebox_cmd},
|
|
|
|
{' ', N_("&Find file M-?"), NULL_HOTKEY, find_cmd},
|
|
|
|
{' ', N_("s&Wap panels C-u"), NULL_HOTKEY, swap_cmd},
|
|
|
|
{' ', N_("switch &Panels on/off C-o"), NULL_HOTKEY, view_other_cmd},
|
|
|
|
{' ', N_("&Compare directories C-x d"), NULL_HOTKEY, compare_dirs_cmd},
|
2009-05-26 14:59:12 +04:00
|
|
|
{' ', N_("e&Xternal panelize C-x !"), NULL_HOTKEY, external_panelize},
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("show directory s&Izes"), NULL_HOTKEY, dirsizes_cmd},
|
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
2009-06-25 22:16:58 +04:00
|
|
|
{' ', N_("Command &history M-h"), NULL_HOTKEY, history_cmd},
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("di&Rectory hotlist C-\\"), NULL_HOTKEY, quick_chdir_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef USE_VFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Active VFS list C-x a"), NULL_HOTKEY, reselect_vfs},
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_BACKGROUND
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Background jobs C-x j"), NULL_HOTKEY, jobs_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef USE_EXT2FSLIB
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Undelete files (ext2fs only)"), NULL_HOTKEY, undelete_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2000-09-27 02:38:13 +04:00
|
|
|
#ifdef LISTMODE_EDITOR
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Listing format edit"), NULL_HOTKEY, listmode_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2000-09-27 02:38:13 +04:00
|
|
|
#if defined (USE_EXT2FSLIB) || defined (LISTMODE_EDITOR)
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
2000-09-27 02:38:13 +04:00
|
|
|
#endif
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("Edit &extension file"), NULL_HOTKEY, ext_cmd},
|
2009-05-26 14:59:12 +04:00
|
|
|
{' ', N_("Edit &menu file"), NULL_HOTKEY, edit_mc_menu_cmd}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Must keep in sync with the constants in menu_cmd */
|
2002-10-31 07:31:52 +03:00
|
|
|
static menu_entry OptMenu[] = {
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Configuration..."), NULL_HOTKEY, configure_box},
|
|
|
|
{' ', N_("&Layout..."), NULL_HOTKEY, layout_cmd},
|
|
|
|
{' ', N_("c&Onfirmation..."), NULL_HOTKEY, confirm_box},
|
|
|
|
{' ', N_("&Display bits..."), NULL_HOTKEY, display_bits_box},
|
|
|
|
{' ', N_("learn &Keys..."), NULL_HOTKEY, learn_keys},
|
2002-10-31 07:31:52 +03:00
|
|
|
#ifdef USE_VFS
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', N_("&Virtual FS..."), NULL_HOTKEY, configure_vfs},
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* !USE_VFS */
|
2008-12-29 01:57:59 +03:00
|
|
|
{' ', "", NULL_HOTKEY, 0},
|
|
|
|
{' ', N_("&Save setup"), NULL_HOTKEY, save_setup_cmd}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define menu_entries(x) sizeof(x)/sizeof(menu_entry)
|
|
|
|
|
2002-11-13 00:01:50 +03:00
|
|
|
static Menu *MenuBar[5];
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
init_menu (void)
|
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
MenuBar[0] =
|
|
|
|
create_menu (horizontal_split ? _(" &Above ") : _(" &Left "),
|
2003-08-02 00:00:28 +04:00
|
|
|
LeftMenu, menu_entries (LeftMenu),
|
2002-10-31 07:31:52 +03:00
|
|
|
"[Left and Right Menus]");
|
|
|
|
MenuBar[1] =
|
|
|
|
create_menu (_(" &File "), FileMenu, menu_entries (FileMenu),
|
|
|
|
"[File Menu]");
|
|
|
|
MenuBar[2] =
|
|
|
|
create_menu (_(" &Command "), CmdMenu, menu_entries (CmdMenu),
|
|
|
|
"[Command Menu]");
|
|
|
|
MenuBar[3] =
|
|
|
|
create_menu (_(" &Options "), OptMenu, menu_entries (OptMenu),
|
|
|
|
"[Options Menu]");
|
|
|
|
MenuBar[4] =
|
|
|
|
create_menu (horizontal_split ? _(" &Below ") : _(" &Right "),
|
2003-08-02 00:00:28 +04:00
|
|
|
RightMenu, menu_entries (RightMenu),
|
2002-10-31 07:31:52 +03:00
|
|
|
"[Left and Right Menus]");
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
done_menu (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
destroy_menu (MenuBar[i]);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
menu_last_selected_cmd (void)
|
|
|
|
{
|
|
|
|
the_menubar->active = 1;
|
|
|
|
the_menubar->dropped = drop_menus;
|
2003-09-13 11:43:20 +04:00
|
|
|
the_menubar->previous_widget = midnight_dlg->current->dlg_id;
|
2005-05-21 00:22:06 +04:00
|
|
|
dlg_select_widget (the_menubar);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
menu_cmd (void)
|
|
|
|
{
|
|
|
|
if (the_menubar->active)
|
|
|
|
return;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-10-26 09:45:59 +03:00
|
|
|
if ((get_current_index () == 0) ^ (!current_panel->active))
|
1998-02-27 07:54:42 +03:00
|
|
|
the_menubar->selected = 0;
|
|
|
|
else
|
|
|
|
the_menubar->selected = 4;
|
|
|
|
menu_last_selected_cmd ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flag toggling functions */
|
|
|
|
void
|
|
|
|
toggle_fast_reload (void)
|
|
|
|
{
|
|
|
|
fast_reload = !fast_reload;
|
2002-10-31 07:31:52 +03:00
|
|
|
if (fast_reload_w == 0 && fast_reload) {
|
2009-01-10 16:13:56 +03:00
|
|
|
message (D_NORMAL, _(" Information "),
|
2002-10-31 07:31:52 +03:00
|
|
|
_
|
|
|
|
(" Using the fast reload option may not reflect the exact \n"
|
2003-11-05 03:33:34 +03:00
|
|
|
" directory contents. In this case you'll need to do a \n"
|
2002-10-31 07:31:52 +03:00
|
|
|
" manual reload of the directory. See the man page for \n"
|
|
|
|
" the details. "));
|
1998-02-27 07:54:42 +03:00
|
|
|
fast_reload_w = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
toggle_mix_all_files (void)
|
|
|
|
{
|
|
|
|
mix_all_files = !mix_all_files;
|
1998-04-30 07:21:52 +04:00
|
|
|
update_panels (UP_RELOAD, UP_KEEPSEL);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
toggle_show_backup (void)
|
|
|
|
{
|
|
|
|
show_backups = !show_backups;
|
1998-04-30 07:21:52 +04:00
|
|
|
update_panels (UP_RELOAD, UP_KEEPSEL);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
toggle_show_hidden (void)
|
|
|
|
{
|
|
|
|
show_dot_files = !show_dot_files;
|
1998-04-30 07:21:52 +04:00
|
|
|
update_panels (UP_RELOAD, UP_KEEPSEL);
|
1998-02-27 07:54: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.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
translated_mc_chdir (char *dir)
|
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
char *newdir;
|
1998-07-31 02:56:58 +04:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
newdir = vfs_translate_url (dir);
|
|
|
|
mc_chdir (newdir);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (newdir);
|
1998-07-31 02:56:58 +04: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;
|
|
|
|
int current_mode;
|
|
|
|
int other_mode;
|
2002-10-31 07:31:52 +03:00
|
|
|
char original_dir[1024];
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
original_dir[0] = 0;
|
|
|
|
|
|
|
|
if (boot_current_is_left) {
|
1998-02-27 07:54:42 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
/* Creates the left panel */
|
2002-10-31 07:31:52 +03:00
|
|
|
if (this_dir) {
|
|
|
|
if (other_dir) {
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Ok, user has specified two dirs, save the original one,
|
|
|
|
* since we may not be able to chdir to the proper
|
|
|
|
* second directory later
|
|
|
|
*/
|
2002-10-31 07:31:52 +03:00
|
|
|
mc_get_current_wd (original_dir, sizeof (original_dir) - 2);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1998-07-31 02:56:58 +04:00
|
|
|
translated_mc_chdir (this_dir);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
set_display_type (current_index, current_mode);
|
|
|
|
|
|
|
|
/* The other panel */
|
2002-10-31 07:31:52 +03:00
|
|
|
if (other_dir) {
|
|
|
|
if (original_dir[0])
|
1998-07-31 02:56:58 +04:00
|
|
|
translated_mc_chdir (original_dir);
|
|
|
|
translated_mc_chdir (other_dir);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
set_display_type (other_index, other_mode);
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (startup_left_mode == view_listing) {
|
1998-02-27 07:54:42 +03:00
|
|
|
current_panel = left_panel;
|
|
|
|
} else {
|
|
|
|
if (right_panel)
|
|
|
|
current_panel = right_panel;
|
|
|
|
else
|
|
|
|
current_panel = left_panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the nice widgets */
|
2002-10-31 07:31:52 +03:00
|
|
|
cmdline = command_new (0, 0, 0);
|
2003-09-01 04:18:37 +04:00
|
|
|
the_prompt = label_new (0, 0, 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
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
the_menubar = menubar_new (0, 0, COLS, MenuBar, 5);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
return;
|
|
|
|
|
2009-05-04 13:40:06 +04:00
|
|
|
cwd_path = remove_encoding_from_path (current_panel->cwd);
|
|
|
|
command_insert (cmdline, cwd_path, 0);
|
|
|
|
|
|
|
|
if (cwd_path [strlen (cwd_path ) - 1] != PATH_SEP)
|
2002-10-31 07:31:52 +03:00
|
|
|
command_insert (cmdline, PATH_SEP_STR, 0);
|
2009-05-04 13:40:06 +04:00
|
|
|
g_free (cwd_path);
|
1998-02-27 07:54: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)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!command_prompt)
|
|
|
|
return;
|
|
|
|
|
2009-05-04 13:40:06 +04:00
|
|
|
cwd_path = remove_encoding_from_path (other_panel->cwd);
|
|
|
|
command_insert (cmdline, cwd_path, 0);
|
|
|
|
|
|
|
|
if (cwd_path [strlen (cwd_path ) - 1] != PATH_SEP)
|
2002-10-31 07:31:52 +03:00
|
|
|
command_insert (cmdline, PATH_SEP_STR, 0);
|
2009-05-04 13:40:06 +04:00
|
|
|
g_free (cwd_path);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_readlink (WPanel *panel)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
if (!command_prompt)
|
|
|
|
return;
|
2003-08-18 04:47:43 +04:00
|
|
|
if (S_ISLNK (selection (panel)->st.st_mode)) {
|
2002-10-31 07:31:52 +03:00
|
|
|
char buffer[MC_MAXPATHLEN];
|
|
|
|
char *p =
|
2009-02-06 13:17:03 +03:00
|
|
|
concat_dir_and_file (panel->cwd, selection (panel)->fname);
|
1998-02-27 07:54:42 +03:00
|
|
|
int i;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-08-30 02:45:04 +04:00
|
|
|
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (p);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (i > 0) {
|
2002-10-31 07:31:52 +03:00
|
|
|
buffer[i] = 0;
|
2002-09-20 23:59:28 +04:00
|
|
|
command_insert (cmdline, buffer, 1);
|
1998-02-27 07:54: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
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_other_readlink (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
if (get_other_type () != view_listing)
|
|
|
|
return;
|
2003-10-26 09:45:59 +03:00
|
|
|
copy_readlink (other_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-12-26 05:09:41 +03:00
|
|
|
/* Insert the selected file name into the input line */
|
|
|
|
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)
|
|
|
|
return;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (get_current_type () == view_tree) {
|
1998-02-27 07:54:42 +03:00
|
|
|
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
2002-11-29 07:55:06 +03:00
|
|
|
tmp = tree_selected_name (tree);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
2003-10-26 09:45:59 +03:00
|
|
|
tmp = selection (current_panel)->fname;
|
2002-09-20 23:59:28 +04:00
|
|
|
|
|
|
|
command_insert (cmdline, tmp, 1);
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-20 23:59:28 +04:00
|
|
|
static void
|
2002-10-31 07:31:52 +03:00
|
|
|
copy_tagged (WPanel *panel)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!command_prompt)
|
|
|
|
return;
|
2002-09-20 23:36:55 +04:00
|
|
|
input_disable_update (cmdline);
|
2002-09-20 23:59:28 +04:00
|
|
|
if (panel->marked) {
|
|
|
|
for (i = 0; i < panel->count; i++) {
|
|
|
|
if (panel->dir.list[i].f.marked)
|
|
|
|
command_insert (cmdline, panel->dir.list[i].fname, 1);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
2002-09-20 23:59:28 +04:00
|
|
|
command_insert (cmdline, panel->dir.list[panel->selected].fname,
|
|
|
|
1);
|
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
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
copy_other_tagged (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
if (get_other_type () != view_listing)
|
|
|
|
return;
|
2003-10-26 09:45:59 +03:00
|
|
|
copy_tagged (other_panel);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
2002-11-13 02:33:15 +03:00
|
|
|
init_labels (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2005-02-08 12:53:51 +03:00
|
|
|
buttonbar_set_label (midnight_dlg, 1, _("Help"), help_cmd);
|
|
|
|
buttonbar_set_label (midnight_dlg, 2, _("Menu"), user_file_menu_cmd);
|
|
|
|
buttonbar_set_label (midnight_dlg, 9, _("PullDn"), menu_cmd);
|
|
|
|
buttonbar_set_label (midnight_dlg, 10, _("Quit"), quit_cmd);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static const key_map ctl_x_map[] = {
|
2002-11-13 07:01:04 +03:00
|
|
|
{XCTRL ('c'), quit_cmd},
|
2002-10-31 07:31:52 +03:00
|
|
|
{'d', compare_dirs_cmd},
|
2001-06-02 10:52:28 +04:00
|
|
|
#ifdef USE_VFS
|
2002-10-31 07:31:52 +03:00
|
|
|
{'a', reselect_vfs},
|
|
|
|
#endif /* USE_VFS */
|
|
|
|
{'p', copy_current_pathname},
|
|
|
|
{XCTRL ('p'), copy_other_pathname},
|
|
|
|
{'t', copy_current_tagged},
|
|
|
|
{XCTRL ('t'), copy_other_tagged},
|
|
|
|
{'c', chmod_cmd},
|
|
|
|
{'o', chown_cmd},
|
|
|
|
{'r', copy_current_readlink},
|
|
|
|
{XCTRL ('r'), copy_other_readlink},
|
|
|
|
{'l', link_cmd},
|
|
|
|
{'s', symlink_cmd},
|
|
|
|
{XCTRL ('s'), edit_symlink_cmd},
|
|
|
|
{'i', info_cmd_no_menu},
|
|
|
|
{'q', quick_cmd_no_menu},
|
|
|
|
{'h', add2hotlist_cmd},
|
|
|
|
{'!', external_panelize},
|
2001-07-15 08:14:39 +04:00
|
|
|
#ifdef WITH_BACKGROUND
|
2002-10-31 07:31:52 +03:00
|
|
|
{'j', jobs_cmd},
|
|
|
|
#endif /* WITH_BACKGROUND */
|
|
|
|
{0, 0}
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
1998-05-05 09:49:57 +04:00
|
|
|
static int ctl_x_map_enabled = 0;
|
|
|
|
|
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
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
ctl_x_map_enabled = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
nothing (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static const key_map default_map[] = {
|
|
|
|
{KEY_F (19), menu_last_selected_cmd},
|
2005-05-23 20:37:01 +04:00
|
|
|
{KEY_F (20), quiet_quit_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-08-03 13:50:36 +04:00
|
|
|
{XCTRL ('@'), smart_dirsize_cmd},
|
2005-09-06 15:38:45 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Copy useful information to the command line */
|
2002-10-31 07:31:52 +03:00
|
|
|
{ALT ('a'), copy_current_pathname},
|
|
|
|
{ALT ('A'), copy_other_pathname},
|
|
|
|
|
|
|
|
{ALT ('c'), quick_cd_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* To access the directory hotlist */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('\\'), quick_chdir_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-05-05 09:49:57 +04:00
|
|
|
/* Suspend */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('z'), suspend_cmd},
|
2002-11-13 11:21:45 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* The filtered view command */
|
2002-11-13 11:21:45 +03:00
|
|
|
{ALT ('!'), filtered_view_cmd},
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Find file */
|
2002-10-31 07:31:52 +03:00
|
|
|
{ALT ('?'), find_cmd},
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Panel refresh */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('r'), reread_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-07-14 09:37:27 +04:00
|
|
|
/* Toggle listing between long, user defined and full formats */
|
2002-10-31 07:31:52 +03:00
|
|
|
{ALT ('t'), toggle_listing_cmd},
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Swap panels */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('u'), swap_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* View output */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('o'), view_other_cmd},
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Control-X keybindings */
|
2002-10-31 07:31:52 +03:00
|
|
|
{XCTRL ('x'), ctl_x_cmd},
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-08-02 19:36:46 +04:00
|
|
|
/* Show/hide hidden files */
|
|
|
|
{ALT ('.'), toggle_show_hidden},
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Trap dlg's exit commands */
|
2002-10-31 07:31:52 +03:00
|
|
|
{ESC_CHAR, nothing},
|
|
|
|
{XCTRL ('c'), nothing},
|
|
|
|
{XCTRL ('g'), nothing},
|
|
|
|
{0, 0},
|
1998-02-27 07:54:42 +03:00
|
|
|
};
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
setup_sigwinch (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-07-23 07:22:32 +04:00
|
|
|
#if (defined(HAVE_SLANG) || (NCURSES_VERSION_MAJOR >= 4)) && defined(SIGWINCH)
|
1998-02-27 07:54:42 +03:00
|
|
|
struct sigaction act, oact;
|
1998-09-22 18:45:38 +04:00
|
|
|
act.sa_handler = flag_winch;
|
|
|
|
sigemptyset (&act.sa_mask);
|
|
|
|
act.sa_flags = 0;
|
2003-07-23 07:22:32 +04:00
|
|
|
#ifdef SA_RESTART
|
2002-10-31 07:31:52 +03:00
|
|
|
act.sa_flags |= SA_RESTART;
|
2003-07-23 07:22:32 +04:00
|
|
|
#endif
|
1998-09-22 18:45:38 +04:00
|
|
|
sigaction (SIGWINCH, &act, &oact);
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-15 02:33:00 +04:00
|
|
|
setup_pre (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
/* Call all the inits */
|
2001-06-06 02:49:15 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2001-08-16 02:45:20 +04:00
|
|
|
/*
|
|
|
|
* 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)
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* !HAVE_CHARSET */
|
2001-06-06 02:49:15 +04:00
|
|
|
|
2009-06-08 13:49:46 +04:00
|
|
|
#ifdef HAVE_SLANG
|
|
|
|
tty_display_8bit (full_eight_bits != 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
#else
|
2009-06-08 13:49:46 +04:00
|
|
|
tty_display_8bit (eight_bit_clean != 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2002-10-31 07:31:52 +03:00
|
|
|
if (!termvalue || !(*termvalue)) {
|
2002-10-23 13:01:08 +04:00
|
|
|
fputs (_("The TERM environment variable is unset!\n"), stderr);
|
2001-09-15 20:54:40 +04:00
|
|
|
exit (1);
|
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
|
|
|
|
2002-08-26 19:26:38 +04:00
|
|
|
if (strcmp (termvalue, "cygwin") == 0) {
|
|
|
|
force_xterm = 1;
|
|
|
|
use_mouse_p = MOUSE_DISABLED;
|
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (force_xterm || strncmp (termvalue, "xterm", 5) == 0
|
|
|
|
|| strncmp (termvalue, "rxvt", 4) == 0
|
2006-02-04 15:29:30 +03:00
|
|
|
|| strcmp (termvalue, "Eterm") == 0
|
2002-10-31 07:31:52 +03:00
|
|
|
|| strcmp (termvalue, "dtterm") == 0) {
|
2001-09-15 20:54:40 +04:00
|
|
|
xterm_flag = 1;
|
|
|
|
|
|
|
|
/* Default to the standard xterm sequence */
|
|
|
|
if (!xmouse_seq) {
|
|
|
|
xmouse_seq = ESC_STR "[M";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable mouse unless explicitly disabled by --nomouse */
|
2001-09-17 08:43:58 +04:00
|
|
|
if (use_mouse_p != MOUSE_DISABLED) {
|
2006-03-06 12:28:14 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
setup_mc (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
setup_pre ();
|
|
|
|
init_menu ();
|
|
|
|
create_panels ();
|
|
|
|
setup_panels ();
|
2001-07-14 10:25:45 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
if (use_subshell)
|
|
|
|
add_select_channel (subshell_pty, load_prompt, 0);
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
2001-07-14 10:25:45 +04:00
|
|
|
|
2001-09-15 20:54:40 +04:00
|
|
|
setup_sigwinch ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-07-12 14:22:41 +04:00
|
|
|
verbose = !((tty_baudrate () < 9600) || tty_is_slow ());
|
2009-06-02 08:55:07 +04:00
|
|
|
|
2001-09-16 01:34:42 +04:00
|
|
|
init_mouse ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
2005-06-23 01:38:52 +04:00
|
|
|
setup_dummy_mc ()
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char d[MC_MAXPATHLEN];
|
|
|
|
|
|
|
|
mc_get_current_wd (d, MC_MAXPATHLEN);
|
|
|
|
setup_mc ();
|
|
|
|
mc_chdir (d);
|
|
|
|
}
|
|
|
|
|
2009-05-13 18:40:27 +04:00
|
|
|
static void check_codeset()
|
|
|
|
{
|
|
|
|
const char *_system_codepage = NULL;
|
2009-07-08 16:17:10 +04:00
|
|
|
#ifdef HAVE_CHARSET
|
2009-05-13 18:40:27 +04:00
|
|
|
const char *_source_codepage = NULL;
|
|
|
|
const char *_display_codepage = NULL;
|
|
|
|
int profile_changed = 0;
|
|
|
|
|
|
|
|
#define CONFY 16
|
|
|
|
#define CONFX 54
|
|
|
|
|
|
|
|
if ( !skip_check_codeset ) {
|
|
|
|
|
|
|
|
QuickWidget ecs_widgets [] = {
|
|
|
|
{ quick_button, 4, 6, 13, CONFY, N_("&Skip"),
|
|
|
|
0, B_EXIT, 0, 0, NULL , NULL, NULL},
|
|
|
|
{ quick_button, 1, 11, 13, CONFY, N_("&Fix it"),
|
|
|
|
0, B_ENTER, 0, 0, NULL , NULL, NULL},
|
|
|
|
{ quick_checkbox, 1, 13, 11, CONFY, N_("don't ask again"),
|
|
|
|
11, 0, &skip_check_codeset, NULL, NULL , NULL, NULL},
|
|
|
|
{ quick_label, 2, 30, 3, CONFY, N_("Chosen display charset (Settings->Display bits)\n"
|
|
|
|
"or source codeset (in mcedit ctrl-t) \n"
|
|
|
|
"does not match one set via locale. \n"
|
|
|
|
"Set correct codeset manually or press <<Fix it>> \n"
|
|
|
|
"to set locale default.\n\n"
|
|
|
|
"Or set \'don't ask again\' and press <<Skip>>"),
|
|
|
|
0, 0, 0, 0, NULL , NULL, NULL},
|
|
|
|
|
|
|
|
NULL_QuickWidget
|
|
|
|
};
|
|
|
|
|
|
|
|
QuickDialog ecs =
|
|
|
|
{ CONFX, CONFY, -1, -1, N_(" Confirmation "), "[Confirmation]",
|
|
|
|
ecs_widgets, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_system_codepage = str_detect_termencoding();
|
|
|
|
_source_codepage = get_codepage_id (source_codepage);
|
|
|
|
_display_codepage = get_codepage_id (display_codepage);
|
|
|
|
|
|
|
|
if ( (strcmp (_system_codepage, _display_codepage)) ||
|
|
|
|
(strcmp (_system_codepage, _source_codepage)) ) {
|
|
|
|
if (quick_dialog (&ecs) == B_ENTER){
|
|
|
|
display_codepage = get_codepage_index (_system_codepage);
|
|
|
|
cp_display = get_codepage_id (display_codepage);
|
|
|
|
if ( !strcmp (cp_display, _system_codepage)) {
|
|
|
|
mc_config_set_string(mc_main_config, "Misc", "display_codepage", cp_display);
|
|
|
|
mc_config_set_string(mc_main_config, "Misc", "source_codepage", cp_display);
|
|
|
|
display_codepage = get_codepage_index ( cp_display );
|
|
|
|
utf8_display = str_isutf8 (_system_codepage);
|
|
|
|
source_codepage = display_codepage;
|
2009-07-13 13:34:35 +04:00
|
|
|
cp_source = cp_display;
|
2009-05-13 18:40:27 +04:00
|
|
|
profile_changed = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( skip_check_codeset ) {
|
|
|
|
mc_config_set_int(mc_main_config, "Midnight-Commander", "skip_check_codeset", 1);
|
|
|
|
profile_changed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( profile_changed )
|
|
|
|
save_configure ();
|
|
|
|
}
|
2009-07-08 16:17:10 +04:00
|
|
|
#else /* HAVE_CHARSET */
|
|
|
|
_system_codepage = str_detect_termencoding();
|
|
|
|
utf8_display = str_isutf8 (_system_codepage);
|
|
|
|
#endif /* HAVE_CHARSET */
|
2009-05-13 18:40:27 +04:00
|
|
|
}
|
|
|
|
|
2009-06-02 23:41:40 +04:00
|
|
|
static void
|
|
|
|
done_screen (void)
|
|
|
|
{
|
|
|
|
if (!(quit & SUBSHELL_EXIT))
|
|
|
|
clr_scr ();
|
|
|
|
tty_reset_shell_mode ();
|
|
|
|
tty_noraw_mode ();
|
|
|
|
tty_keypad (FALSE);
|
|
|
|
tty_colors_done ();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
done_menu ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
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)
|
2002-10-31 07:31:52 +03:00
|
|
|
save_setup (); /* does also call save_hotlist */
|
2009-05-27 19:44:42 +04:00
|
|
|
else {
|
2002-10-31 07:31:52 +03:00
|
|
|
save_hotlist ();
|
2009-05-27 19:44:42 +04:00
|
|
|
save_panel_types ();
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
done_screen ();
|
|
|
|
vfs_add_current_stamps ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This should be called after destroy_dlg since panel widgets
|
|
|
|
* save their state on the profiles
|
|
|
|
*/
|
2002-10-31 07:31:52 +03:00
|
|
|
static void
|
|
|
|
done_mc_profile (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
done_setup ();
|
|
|
|
}
|
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
static cb_ret_t
|
|
|
|
midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int i;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
|
|
|
switch (msg) {
|
2001-11-30 00:03:16 +03:00
|
|
|
|
2003-09-07 09:39:51 +04:00
|
|
|
case DLG_IDLE:
|
|
|
|
/* We only need the first idle event */
|
|
|
|
set_idle_proc (h, 0);
|
|
|
|
if (auto_menu) {
|
2001-11-30 00:03:16 +03:00
|
|
|
user_file_menu_cmd ();
|
|
|
|
}
|
2003-09-07 09:39:51 +04:00
|
|
|
return MSG_HANDLED;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
case DLG_KEY:
|
2002-10-31 07:31:52 +03:00
|
|
|
if (ctl_x_map_enabled) {
|
|
|
|
ctl_x_map_enabled = 0;
|
|
|
|
for (i = 0; ctl_x_map[i].key_code; i++)
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == ctl_x_map[i].key_code) {
|
2004-08-16 08:20:56 +04:00
|
|
|
(*ctl_x_map[i].fn) ();
|
2002-10-31 07:31:52 +03:00
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
1998-05-05 09:49:57 +04:00
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2001-07-06 03:27:01 +04:00
|
|
|
/* FIXME: should handle all menu shortcuts before this point */
|
|
|
|
if (the_menubar->active)
|
2003-09-08 01:24:01 +04:00
|
|
|
return MSG_NOT_HANDLED;
|
2001-07-06 03:27:01 +04:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == KEY_F (10)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
quit_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '\t')
|
2002-09-20 23:36:55 +04:00
|
|
|
free_completions (cmdline);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2005-05-29 15:54:22 +04:00
|
|
|
if (parm == '\n') {
|
2005-06-08 00:55:13 +04:00
|
|
|
for (i = 0; cmdline->buffer[i] && (cmdline->buffer[i] == ' ' ||
|
|
|
|
cmdline->buffer[i] == '\t'); i++);
|
2005-05-29 15:54:22 +04:00
|
|
|
if (cmdline->buffer[i]) {
|
|
|
|
send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
stuff (cmdline, "", 0);
|
|
|
|
cmdline->point = 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-12-26 05:09:41 +03:00
|
|
|
/* Ctrl-Enter and Alt-Enter */
|
2003-09-08 01:24:01 +04:00
|
|
|
if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n')
|
|
|
|
&& (parm & (KEY_M_CTRL | KEY_M_ALT))) {
|
2002-12-26 05:09:41 +03:00
|
|
|
copy_prog_name ();
|
1998-02-27 07:54:42 +03:00
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
2003-11-14 23:43:11 +03:00
|
|
|
/* Ctrl-Shift-Enter */
|
|
|
|
if (parm == (KEY_M_CTRL | KEY_M_SHIFT | '\n')) {
|
|
|
|
copy_current_pathname ();
|
|
|
|
copy_prog_name ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if ((!alternate_plus_minus || !(console_flag || xterm_flag))
|
2003-10-26 09:45:59 +03:00
|
|
|
&& !quote && !current_panel->searching) {
|
2002-10-31 07:31:52 +03:00
|
|
|
if (!only_leading_plus_minus) {
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Special treatement, since the input line will eat them */
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '+') {
|
1998-02-27 07:54:42 +03:00
|
|
|
select_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '\\' || parm == '-') {
|
1998-02-27 07:54:42 +03:00
|
|
|
unselect_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
1998-04-01 02:36:24 +04:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '*') {
|
1998-04-01 02:36:24 +04:00
|
|
|
reverse_selection_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
2005-05-29 15:54:22 +04:00
|
|
|
} else if (!command_prompt || !cmdline->buffer[0]) {
|
2009-08-03 13:50:36 +04:00
|
|
|
/* Special treatement '+', '-', '\', '*' only when this is
|
1998-02-27 07:54:42 +03:00
|
|
|
* first char on input line
|
|
|
|
*/
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '+') {
|
1998-02-27 07:54:42 +03:00
|
|
|
select_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '\\' || parm == '-') {
|
1998-02-27 07:54:42 +03:00
|
|
|
unselect_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == '*') {
|
1998-02-27 07:54:42 +03:00
|
|
|
reverse_selection_cmd ();
|
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
|
|
|
}
|
2003-09-08 01:24:01 +04:00
|
|
|
return MSG_NOT_HANDLED;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case DLG_HOTKEY_HANDLED:
|
2003-10-26 09:45:59 +03:00
|
|
|
if ((get_current_type () == view_listing) && current_panel->searching) {
|
|
|
|
current_panel->searching = 0;
|
|
|
|
current_panel->dirty = 1;
|
2003-09-07 09:58:55 +04:00
|
|
|
}
|
2003-09-08 01:24:01 +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:
|
2002-10-31 07:31:52 +03:00
|
|
|
if (command_prompt) {
|
1998-02-27 07:54:42 +03:00
|
|
|
int v;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
v = send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (v)
|
|
|
|
return v;
|
|
|
|
}
|
2001-07-15 02:13:46 +04:00
|
|
|
if (ctl_x_map_enabled) {
|
2002-10-31 07:31:52 +03:00
|
|
|
ctl_x_map_enabled = 0;
|
|
|
|
for (i = 0; ctl_x_map[i].key_code; i++)
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == ctl_x_map[i].key_code) {
|
2004-08-16 08:20:56 +04:00
|
|
|
(*ctl_x_map[i].fn) ();
|
2002-10-31 07:31:52 +03:00
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; default_map[i].key_code; i++) {
|
2003-09-08 01:24:01 +04:00
|
|
|
if (parm == default_map[i].key_code) {
|
2004-08-16 08:20:56 +04:00
|
|
|
(*default_map[i].fn) ();
|
2002-10-31 07:31:52 +03:00
|
|
|
return MSG_HANDLED;
|
1998-05-05 09:49:57 +04:00
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1998-05-05 09:49:57 +04:00
|
|
|
return MSG_NOT_HANDLED;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
case DLG_DRAW:
|
2003-09-07 09:58:55 +04:00
|
|
|
/* We handle the special case of the output lines */
|
1998-02-27 07:54:42 +03:00
|
|
|
if (console_flag && output_lines)
|
|
|
|
show_console_contents (output_start_y,
|
2002-10-31 07:31:52 +03:00
|
|
|
LINES - output_lines - keybar_visible -
|
|
|
|
1, LINES - keybar_visible - 1);
|
2002-09-05 10:59:17 +04:00
|
|
|
return MSG_HANDLED;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2003-09-10 08:42:13 +04:00
|
|
|
case DLG_POST_KEY:
|
2003-09-12 07:14:44 +04:00
|
|
|
if (!the_menubar->active)
|
|
|
|
update_dirty_panels ();
|
2003-09-10 08:42:13 +04:00
|
|
|
return MSG_HANDLED;
|
|
|
|
|
2003-09-08 01:24:01 +04:00
|
|
|
default:
|
|
|
|
return default_dlg_callback (h, msg, parm);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-26 19:38:25 +03:00
|
|
|
/* Show current directory in the xterm title */
|
2002-12-26 19:10:45 +03:00
|
|
|
void
|
|
|
|
update_xterm_title_path (void)
|
|
|
|
{
|
2009-06-20 01:32:15 +04:00
|
|
|
const char *path;
|
|
|
|
char host[BUF_TINY];
|
|
|
|
char *p;
|
|
|
|
struct passwd *pw = NULL;
|
|
|
|
char *login = NULL;
|
|
|
|
int res = 0;
|
2002-12-26 19:10:45 +03:00
|
|
|
if (xterm_flag && xterm_title) {
|
2009-06-20 01:32:15 +04:00
|
|
|
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);
|
2009-01-26 18:21:06 +03:00
|
|
|
if (!alternate_plus_minus)
|
|
|
|
numeric_keypad_mode ();
|
2002-12-26 19:10:45 +03:00
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
}
|
2002-12-26 19:38:25 +03:00
|
|
|
|
2003-02-05 11:37:21 +03:00
|
|
|
/*
|
|
|
|
* Load new hint and display it.
|
|
|
|
* IF force is not 0, ignore the timeout.
|
|
|
|
*/
|
2002-09-05 20:36:43 +04:00
|
|
|
void
|
2003-02-05 11:37:21 +03:00
|
|
|
load_hint (int force)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *hint;
|
|
|
|
|
|
|
|
if (!the_hint->widget.parent)
|
|
|
|
return;
|
2002-09-05 20:36:43 +04:00
|
|
|
|
2002-12-26 19:10:45 +03:00
|
|
|
if (!message_visible) {
|
2002-09-05 20:36:43 +04:00
|
|
|
label_set_text (the_hint, 0);
|
1998-02-27 07:54:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-02-05 11:37:21 +03:00
|
|
|
if ((hint = get_random_hint (force))) {
|
1998-02-27 07:54:42 +03:00
|
|
|
if (*hint)
|
|
|
|
set_hintbar (hint);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (hint);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
2002-09-05 20:36:43 +04:00
|
|
|
char text[BUF_SMALL];
|
|
|
|
|
2009-02-06 01:49:00 +03:00
|
|
|
g_snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"),
|
2002-09-05 20:36:43 +04:00
|
|
|
VERSION);
|
|
|
|
set_hintbar (text);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-15 02:33:00 +04:00
|
|
|
setup_panels_and_run_mc (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-09-13 03:07:09 +04:00
|
|
|
add_widget (midnight_dlg, the_menubar);
|
|
|
|
add_widget (midnight_dlg, get_panel_widget (0));
|
|
|
|
add_widget (midnight_dlg, get_panel_widget (1));
|
1998-02-27 07:54:42 +03:00
|
|
|
add_widget (midnight_dlg, the_hint);
|
2003-02-05 11:37:21 +03:00
|
|
|
load_hint (1);
|
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
|
|
|
add_widget (midnight_dlg, the_bar);
|
2002-11-13 02:33:15 +03:00
|
|
|
init_labels ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-09-13 03:07:09 +04:00
|
|
|
if (boot_current_is_left)
|
2005-05-21 00:22:06 +04:00
|
|
|
dlg_select_widget (get_panel_widget (0));
|
2003-09-13 03:07:09 +04:00
|
|
|
else
|
2005-05-21 00:22:06 +04:00
|
|
|
dlg_select_widget (get_panel_widget (1));
|
2003-09-13 03:07:09 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
int l;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (vfs_file_is_local (filename)) {
|
1998-02-27 07:54:42 +03:00
|
|
|
if (*filename == PATH_SEP) /* an absolute pathname */
|
2009-02-06 01:40:32 +03:00
|
|
|
return g_strdup (filename);
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
|
1998-02-27 07:54:42 +03:00
|
|
|
mc_get_current_wd (d, MC_MAXPATHLEN);
|
2002-10-31 07:31:52 +03:00
|
|
|
l = strlen (d);
|
1998-02-27 07:54:42 +03:00
|
|
|
d[l++] = PATH_SEP;
|
|
|
|
strcpy (d + l, filename);
|
2004-01-24 02:53:37 +03:00
|
|
|
canonicalize_pathname (d);
|
|
|
|
return d;
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
2009-02-06 01:40:32 +03:00
|
|
|
return g_strdup (filename);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static int
|
1998-02-27 07:54:42 +03:00
|
|
|
mc_maybe_editor_or_viewer (void)
|
|
|
|
{
|
|
|
|
if (!(view_one_file || edit_one_file))
|
2002-10-31 07:31:52 +03:00
|
|
|
return 0;
|
|
|
|
|
2005-06-23 01:38:52 +04:00
|
|
|
setup_dummy_mc ();
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Invoke the internal view/edit routine with:
|
|
|
|
* the default processing and forcing the internal viewer/editor
|
|
|
|
*/
|
|
|
|
if (view_one_file) {
|
2005-06-23 01:38:52 +04:00
|
|
|
char *path = NULL;
|
2002-10-31 07:31:52 +03:00
|
|
|
path = prepend_cwd_on_local (view_one_file);
|
|
|
|
view_file (path, 0, 1);
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (path);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2001-08-20 09:39:21 +04:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
1998-02-27 07:54:42 +03:00
|
|
|
else {
|
2004-09-19 21:46:39 +04:00
|
|
|
edit_file (edit_one_file, edit_one_file_start_line);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* USE_INTERNAL_EDIT */
|
1998-02-27 07:54:42 +03:00
|
|
|
midnight_shutdown = 1;
|
|
|
|
done_mc ();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-08-31 09:50:06 +04:00
|
|
|
/* Run the main dialog that occupies the whole screen */
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
do_nc (void)
|
|
|
|
{
|
2009-07-27 13:22:24 +04:00
|
|
|
const int midnight_colors[4] =
|
|
|
|
{
|
|
|
|
NORMAL_COLOR, /* NORMALC */
|
|
|
|
REVERSE_COLOR, /* FOCUSC */
|
|
|
|
INPUT_COLOR, /* HOT_NORMALC */
|
|
|
|
NORMAL_COLOR /* HOT_FOCUSC */
|
|
|
|
};
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
|
|
|
"[main]", NULL, DLG_WANT_IDLE);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* start check display_codepage and source_codepage */
|
2009-05-13 18:40:27 +04:00
|
|
|
check_codeset();
|
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* Check if we were invoked as an editor or file viewer */
|
|
|
|
if (!mc_maybe_editor_or_viewer ()) {
|
|
|
|
setup_mc ();
|
|
|
|
setup_panels_and_run_mc ();
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* Program end */
|
|
|
|
midnight_shutdown = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-06-28 21:28:47 +04:00
|
|
|
/* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */
|
|
|
|
if (last_wd_file && vfs_current_is_local ()) {
|
|
|
|
last_wd_string = g_strdup (current_panel->cwd);
|
|
|
|
}
|
|
|
|
done_mc ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1998-03-13 06:44:54 +03:00
|
|
|
destroy_dlg (midnight_dlg);
|
1998-02-27 07:54:42 +03:00
|
|
|
current_panel = 0;
|
|
|
|
done_mc_profile ();
|
|
|
|
}
|
|
|
|
|
2003-07-23 07:22:32 +04: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
|
|
|
|
|
|
|
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)
|
2009-02-06 01:40:32 +03:00
|
|
|
shell = g_strdup (pwd->pw_shell);
|
2009-06-30 21:49:40 +04:00
|
|
|
} else
|
|
|
|
shell = g_strdup (shell_env);
|
|
|
|
|
|
|
|
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");
|
|
|
|
if (mc_libdir != NULL) {
|
2009-02-06 01:40:32 +03:00
|
|
|
mc_home = g_strdup (mc_libdir);
|
2009-06-30 21:49:40 +04:00
|
|
|
mc_home_alt = g_strdup (SYSCONFDIR);
|
1998-08-27 00:23:10 +04:00
|
|
|
} else {
|
2009-05-21 02:01:10 +04:00
|
|
|
mc_home = g_strdup (SYSCONFDIR);
|
2009-06-30 21:49:40 +04:00
|
|
|
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)
|
|
|
|
home_dir = mc_home;
|
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
if (pid == cons_saver_pid) {
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-08-10 03:36:06 +04:00
|
|
|
if (WIFSTOPPED (status)) {
|
2001-07-06 21:29:20 +04:00
|
|
|
/* Someone has stopped cons.saver - restart it */
|
1998-02-27 07:54:42 +03:00
|
|
|
kill (pid, SIGCONT);
|
2002-08-10 03:36:06 +04:00
|
|
|
} else {
|
2001-07-12 02:58:32 +04:00
|
|
|
/* cons.saver has died - disable console saving */
|
1998-02-27 07:54:42 +03:00
|
|
|
handle_console (CONSOLE_DONE);
|
2001-07-06 21:29:20 +04:00
|
|
|
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 */
|
2003-02-27 08:09:35 +03: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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
use_subshell ? sigchld_handler :
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
sigchld_handler_no_subshell;
|
|
|
|
|
|
|
|
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;
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* !SA_RESTART */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-08-18 19:18:56 +04:00
|
|
|
if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1) {
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
/*
|
|
|
|
* This may happen on QNX Neutrino 6, where SA_RESTART
|
|
|
|
* is defined but not implemented. Fallback to no subshell.
|
|
|
|
*/
|
|
|
|
use_subshell = 0;
|
2002-10-31 07:31:52 +03:00
|
|
|
#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
|
|
|
|
|
|
|
static void
|
2002-10-31 07:31:52 +03:00
|
|
|
print_mc_usage (poptContext ctx, FILE *stream)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2002-10-22 03:28:33 +04:00
|
|
|
int leftColWidth;
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
poptSetOtherOptionHelp (ctx,
|
|
|
|
_("[flags] [this_dir] [other_panel_dir]\n"));
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
|
2002-09-19 10:03:24 +04:00
|
|
|
/* print help for options */
|
2002-10-22 03:28:33 +04:00
|
|
|
leftColWidth = poptPrintHelp (ctx, stream, 0);
|
|
|
|
fprintf (stream, " %-*s %s\n", leftColWidth, _("+number"),
|
2002-09-19 10:43:06 +04:00
|
|
|
_("Set initial line number for the internal editor"));
|
2002-10-31 07:31:52 +03:00
|
|
|
fputs (_
|
|
|
|
("\n"
|
|
|
|
"Please send any bug reports (including the output of `mc -V')\n"
|
|
|
|
"to mc-devel@gnome.org\n"), stream);
|
2004-08-17 14:40:16 +04:00
|
|
|
show_version (0);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_color_usage (void)
|
|
|
|
{
|
2002-10-14 03:12:06 +04:00
|
|
|
/*
|
|
|
|
* FIXME: undocumented keywords: viewunderline, editnormal, editbold,
|
|
|
|
* and editmarked. To preserve translations, lines should be split.
|
|
|
|
*/
|
2002-10-14 02:57:52 +04:00
|
|
|
/* TRANSLATORS: don't translate keywords and names of colors */
|
2002-10-31 07:31:52 +03:00
|
|
|
fputs (_
|
|
|
|
("--colors KEYWORD={FORE},{BACK}\n\n"
|
|
|
|
"{FORE} and {BACK} can be omitted, and the default will be used\n"
|
|
|
|
"\n" "Keywords:\n"
|
2004-10-22 09:47:25 +04:00
|
|
|
" Global: errors, reverse, gauge, input, viewunderline\n"
|
2002-10-31 07:31:52 +03:00
|
|
|
" File display: normal, selected, marked, markselect\n"
|
2004-10-22 09:47:25 +04:00
|
|
|
" Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
|
|
|
|
" errdhotfocus\n"
|
2002-10-31 07:31:52 +03:00
|
|
|
" Menus: menu, menuhot, menusel, menuhotsel\n"
|
2009-05-12 01:15:55 +04:00
|
|
|
" Editor: editnormal, editbold, editmarked, editwhitespace,\n"
|
|
|
|
" editlinestate\n"), stdout);
|
2009-04-24 02:47:22 +04:00
|
|
|
fputs (_
|
|
|
|
(
|
2004-10-22 09:47:25 +04:00
|
|
|
" Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"
|
2002-10-31 07:31:52 +03:00
|
|
|
" File types: directory, executable, link, stalelink, device, special, core\n"
|
|
|
|
"\n" "Colors:\n"
|
|
|
|
" black, gray, red, brightred, green, brightgreen, brown,\n"
|
|
|
|
" yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
|
|
|
|
" brightcyan, lightgray and white\n\n"), stdout);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-05-19 12:58:41 +04:00
|
|
|
static void
|
2002-09-19 10:03:24 +04:00
|
|
|
process_args (poptContext ctx, int c, const char *option_arg)
|
1998-04-09 08:58:24 +04:00
|
|
|
{
|
|
|
|
switch (c) {
|
|
|
|
case 'V':
|
2004-08-17 14:40:16 +04:00
|
|
|
show_version (1);
|
2002-11-20 18:54:33 +03:00
|
|
|
exit (0);
|
1998-04-09 08:58:24 +04:00
|
|
|
break;
|
1999-03-20 21:08:52 +03:00
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
case 'c':
|
2009-07-08 22:37:01 +04:00
|
|
|
disable_colors = FALSE;
|
|
|
|
force_colors = TRUE; /* for S-Lang only */
|
1998-04-09 08:58:24 +04:00
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
case 'f':
|
2009-05-21 02:01:10 +04:00
|
|
|
printf ("%s (%s)\n", mc_home, mc_home_alt);
|
2002-11-20 18:54:33 +03:00
|
|
|
exit (0);
|
1998-04-09 08:58:24 +04:00
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
#ifdef USE_NETCODE
|
|
|
|
case 'l':
|
2003-10-23 23:05:52 +04:00
|
|
|
mc_setctl ("/#ftp:", VFS_SETCTL_LOGFILE, (void *) option_arg);
|
2002-09-13 14:04:21 +04:00
|
|
|
#ifdef WITH_SMBFS
|
|
|
|
smbfs_set_debugf (option_arg);
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* WITH_SMBFS */
|
2002-09-11 14:05:24 +04:00
|
|
|
break;
|
|
|
|
|
1999-06-23 01:02:08 +04:00
|
|
|
#ifdef WITH_SMBFS
|
2002-09-11 14:05:24 +04:00
|
|
|
case 'D':
|
|
|
|
smbfs_set_debug (atoi (option_arg));
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* WITH_SMBFS */
|
|
|
|
#endif /* USE_NETCODE */
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
case 'd':
|
2001-09-17 08:43:58 +04:00
|
|
|
use_mouse_p = MOUSE_DISABLED;
|
1998-04-09 08:58:24 +04:00
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
case 'u':
|
|
|
|
use_subshell = 0;
|
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
case 'H':
|
|
|
|
print_color_usage ();
|
2002-11-20 18:54:33 +03:00
|
|
|
exit (0);
|
1998-04-09 08:58:24 +04:00
|
|
|
break;
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-09 08:58:24 +04:00
|
|
|
case 'h':
|
2002-09-19 10:03:24 +04:00
|
|
|
print_mc_usage (ctx, stdout);
|
2002-11-20 18:54:33 +03:00
|
|
|
exit (0);
|
1998-04-09 08:58:24 +04:00
|
|
|
}
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-19 10:29:25 +04:00
|
|
|
static const struct poptOption argument_table[] = {
|
2003-10-08 09:06:37 +04:00
|
|
|
/* generic options */
|
2009-04-24 02:47:22 +04:00
|
|
|
{"help", 'h', POPT_ARG_NONE, {NULL}, 'h',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Displays this help message"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"version", 'V', POPT_ARG_NONE, {NULL}, 'V',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Displays the current version"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
|
|
|
|
/* terminal options */
|
2009-04-24 02:47:22 +04:00
|
|
|
{"xterm", 'x', POPT_ARG_NONE, {&force_xterm}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Forces xterm features"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"nomouse", 'd', POPT_ARG_NONE, {NULL}, 'd',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Disable mouse support in text version"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
#if defined(HAVE_SLANG)
|
2009-04-24 02:47:22 +04:00
|
|
|
{"termcap", 't', 0, {&SLtt_Try_Termcap}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Tries to use termcap instead of terminfo"), NULL},
|
1998-04-09 08:58:24 +04:00
|
|
|
#endif
|
2009-04-24 02:47:22 +04:00
|
|
|
{"resetsoft", 'k', POPT_ARG_NONE, {&reset_hp_softkeys}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Resets soft keys on HP terminals"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"slow", 's', POPT_ARG_NONE, {&slow_terminal}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("To run on slow terminals"), NULL},
|
2009-07-12 14:22:41 +04:00
|
|
|
{"stickchars", 'a', POPT_ARG_NONE, {&ugly_line_drawing}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Use stickchars to draw"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
|
|
|
|
/* color options */
|
2009-07-08 22:37:01 +04:00
|
|
|
{"nocolor", 'b', POPT_ARG_NONE, {&disable_colors}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Requests to run in black and white"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"color", 'c', POPT_ARG_NONE, {NULL}, 'c',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Request to run in color mode"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"colors", 'C', POPT_ARG_STRING, {&command_line_colors}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Specifies a color configuration"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"help-colors", 'H', POPT_ARG_NONE, {NULL}, 'H',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Displays a help screen on how to change the color scheme"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
|
|
|
|
/* debug options */
|
1998-04-09 08:58:24 +04:00
|
|
|
#ifdef USE_NETCODE
|
2009-04-24 02:47:22 +04:00
|
|
|
{"ftplog", 'l', POPT_ARG_STRING, {NULL}, 'l',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Log ftp dialog to specified file"), NULL},
|
2002-09-11 14:05:24 +04:00
|
|
|
#ifdef WITH_SMBFS
|
2009-04-24 02:47:22 +04:00
|
|
|
{"debuglevel", 'D', POPT_ARG_STRING, {NULL}, 'D',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Set debug level"), NULL},
|
2002-09-11 14:05:24 +04:00
|
|
|
#endif
|
2003-10-08 09:06:37 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* options for wrappers */
|
2009-04-24 02:47:22 +04:00
|
|
|
{"datadir", 'f', POPT_ARG_NONE, {NULL}, 'f',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Print data directory"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"printwd", 'P', POPT_ARG_STRING, {&last_wd_file}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Print last working directory to specified file"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
|
|
|
|
/* subshell options */
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2009-04-24 02:47:22 +04:00
|
|
|
{"subshell", 'U', POPT_ARG_NONE, {&use_subshell}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Enables subshell support (default)"), NULL},
|
2009-04-24 02:47:22 +04:00
|
|
|
{"nosubshell", 'u', POPT_ARG_NONE, {NULL}, 'u',
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Disables subshell support"), NULL},
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
2003-10-08 09:06:37 +04:00
|
|
|
|
|
|
|
/* single file operations */
|
2009-04-24 02:47:22 +04:00
|
|
|
{"view", 'v', POPT_ARG_STRING, {&view_one_file}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Launches the file viewer on a file"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
#ifdef USE_INTERNAL_EDIT
|
2009-04-24 02:47:22 +04:00
|
|
|
{"edit", 'e', POPT_ARG_STRING, {&edit_one_file}, 0,
|
2004-08-16 03:06:19 +04:00
|
|
|
N_("Edits one file"), NULL},
|
2003-10-08 09:06:37 +04:00
|
|
|
#endif
|
2002-09-19 10:29:25 +04:00
|
|
|
|
2009-04-24 02:47:22 +04:00
|
|
|
{NULL, '\0', 0, {NULL}, 0, NULL , NULL}
|
1998-04-09 08:58:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2002-10-31 07:31:52 +03:00
|
|
|
handle_args (int argc, char *argv[])
|
1998-04-09 08:58:24 +04:00
|
|
|
{
|
2002-10-31 07:31:52 +03:00
|
|
|
char *tmp;
|
|
|
|
poptContext ctx;
|
2004-08-16 22:31:05 +04:00
|
|
|
const char *base;
|
2002-10-31 07:31:52 +03:00
|
|
|
int c;
|
1998-04-09 08:58:24 +04:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
ctx =
|
|
|
|
poptGetContext ("mc", argc, argv, argument_table,
|
|
|
|
POPT_CONTEXT_NO_EXEC);
|
1998-04-09 08:58:24 +04:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
while ((c = poptGetNextOpt (ctx)) > 0) {
|
2002-09-19 10:03:24 +04:00
|
|
|
process_args (ctx, c, poptGetOptArg (ctx));
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
if (c < -1) {
|
2002-09-19 10:03:24 +04:00
|
|
|
print_mc_usage (ctx, stderr);
|
2002-10-31 07:31:52 +03:00
|
|
|
fprintf (stderr, "%s: %s\n",
|
|
|
|
poptBadOption (ctx, POPT_BADOPTION_NOALIAS),
|
|
|
|
poptStrerror (c));
|
2002-10-31 09:52:33 +03:00
|
|
|
exit (1);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2002-10-31 09:52:33 +03:00
|
|
|
|
2001-01-27 09:43:42 +03:00
|
|
|
tmp = poptGetArg (ctx);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-12-03 02:44:06 +03:00
|
|
|
/*
|
|
|
|
* Check for special invocation names mcedit and mcview,
|
1998-02-27 07:54:42 +03:00
|
|
|
* if none apply then set the current directory and the other
|
|
|
|
* directory from the command line arguments
|
|
|
|
*/
|
1998-05-13 12:29:55 +04:00
|
|
|
base = x_basename (argv[0]);
|
2002-10-31 07:31:52 +03:00
|
|
|
if (!STRNCOMP (base, "mce", 3) || !STRCOMP (base, "vi")) {
|
1998-02-27 07:54:42 +03:00
|
|
|
edit_one_file = "";
|
2002-10-31 07:31:52 +03:00
|
|
|
if (tmp) {
|
2008-12-18 15:21:23 +03:00
|
|
|
/*
|
|
|
|
* Check for filename:lineno, followed by an optional colon.
|
|
|
|
* This format is used by many programs (especially compilers)
|
|
|
|
* in error messages and warnings. It is supported so that
|
|
|
|
* users can quickly copy and paste file locations.
|
|
|
|
*/
|
|
|
|
char *end = tmp + strlen (tmp), *p = end;
|
|
|
|
if (p > tmp && p[-1] == ':')
|
|
|
|
p--;
|
patches by Rostislav Beneš: mc-28-fix
rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c
now, basic mc's function should work well, editor and view are still broken.
2008-12-29 02:53:08 +03:00
|
|
|
while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
|
2008-12-18 15:21:23 +03:00
|
|
|
p--;
|
|
|
|
if (tmp < p && p < end && p[-1] == ':') {
|
|
|
|
struct stat st;
|
|
|
|
gchar *fname = g_strndup (tmp, p - 1 - tmp);
|
|
|
|
/*
|
|
|
|
* Check that the file before the colon actually exists.
|
|
|
|
* If it doesn't exist, revert to the old behavior.
|
|
|
|
*/
|
|
|
|
if (mc_stat (tmp, &st) == -1 && mc_stat (fname, &st) != -1) {
|
|
|
|
edit_one_file = fname;
|
|
|
|
edit_one_file_start_line = atoi (p);
|
|
|
|
} else {
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (fname);
|
2008-12-18 15:21:23 +03:00
|
|
|
goto try_plus_filename;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try_plus_filename:
|
patches by Rostislav Beneš: mc-28-fix
rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c
now, basic mc's function should work well, editor and view are still broken.
2008-12-29 02:53:08 +03:00
|
|
|
if (*tmp == '+' && g_ascii_isdigit ((gchar) tmp[1])) {
|
2008-12-18 15:21:23 +03:00
|
|
|
int start_line = atoi (tmp);
|
|
|
|
if (start_line > 0) {
|
|
|
|
char *file = poptGetArg (ctx);
|
|
|
|
if (file) {
|
|
|
|
tmp = file;
|
|
|
|
edit_one_file_start_line = start_line;
|
|
|
|
}
|
1999-12-09 01:15:13 +03:00
|
|
|
}
|
|
|
|
}
|
2009-02-06 01:40:32 +03:00
|
|
|
edit_one_file = g_strdup (tmp);
|
1999-12-09 01:15:13 +03:00
|
|
|
}
|
|
|
|
}
|
2002-10-31 07:31:52 +03:00
|
|
|
} else if (!STRNCOMP (base, "mcv", 3) || !STRCOMP (base, "view")) {
|
1999-12-09 01:15:13 +03:00
|
|
|
if (tmp)
|
2009-02-06 01:40:32 +03:00
|
|
|
view_one_file = g_strdup (tmp);
|
2001-01-27 09:43:42 +03:00
|
|
|
else {
|
2002-10-23 13:01:08 +04:00
|
|
|
fputs ("No arguments given to the viewer\n", stderr);
|
2002-10-31 09:52:33 +03:00
|
|
|
exit (1);
|
2002-10-31 07:31:52 +03:00
|
|
|
}
|
2001-09-08 08:06:03 +04:00
|
|
|
} else {
|
2002-10-31 07:31:52 +03:00
|
|
|
/* sets the current dir and the other dir */
|
1998-02-27 07:54:42 +03:00
|
|
|
if (tmp) {
|
2009-02-06 01:40:32 +03:00
|
|
|
this_dir = g_strdup (tmp);
|
1998-12-03 02:44:06 +03:00
|
|
|
if ((tmp = poptGetArg (ctx)))
|
2009-02-06 01:40:32 +03:00
|
|
|
other_dir = g_strdup (tmp);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
1998-11-04 02:34:54 +03:00
|
|
|
|
1998-12-03 02:44:06 +03:00
|
|
|
poptFreeContext (ctx);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef HAVE_SLANG
|
|
|
|
SLtt_Ignore_Beep = 1;
|
1998-12-02 08:18:20 +03:00
|
|
|
#endif
|
2002-10-31 07:31:52 +03:00
|
|
|
|
2005-07-21 00:29:08 +04:00
|
|
|
handle_args (argc, argv);
|
|
|
|
|
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 */
|
|
|
|
if (edit_one_file || view_one_file)
|
|
|
|
use_subshell = 0;
|
|
|
|
|
|
|
|
if (use_subshell)
|
|
|
|
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-07-12 14:22:41 +04:00
|
|
|
tty_init ((gboolean) slow_terminal, (gboolean) ugly_line_drawing);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
load_setup ();
|
|
|
|
|
2009-07-08 22:37:01 +04:00
|
|
|
tty_init_colors (disable_colors, force_colors);
|
2009-05-30 21:39:02 +04:00
|
|
|
dlg_set_default_colors ();
|
|
|
|
|
2009-05-02 14:45:48 +04:00
|
|
|
/* create home directory */
|
|
|
|
/* do it after the screen library initialization to show the error message */
|
|
|
|
mc_dir = concat_dir_and_file (home_dir, MC_BASE);
|
|
|
|
canonicalize_pathname (mc_dir);
|
|
|
|
if ((stat (mc_dir, &s) != 0) && (errno == ENOENT)
|
2009-05-02 16:28:35 +04:00
|
|
|
&& mkdir (mc_dir, 0700) != 0)
|
2009-05-02 14:45:48 +04:00
|
|
|
message (D_ERROR, _("Warning"),
|
|
|
|
_("Cannot create %s directory"), mc_dir);
|
|
|
|
g_free (mc_dir);
|
|
|
|
|
2001-09-15 20:54:40 +04:00
|
|
|
init_xterm_support ();
|
|
|
|
|
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)
|
2002-10-31 07:31:52 +03:00
|
|
|
init_subshell ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Removing this from the X code let's us type C-c */
|
|
|
|
load_key_defs ();
|
|
|
|
|
|
|
|
/* Also done after init_subshell, to save any shell init file messages */
|
|
|
|
if (console_flag)
|
|
|
|
handle_console (CONSOLE_SAVE);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
1998-04-01 02:36:24 +04:00
|
|
|
if (alternate_plus_minus)
|
2002-10-31 07:31:52 +03:00
|
|
|
application_keypad_mode ();
|
1999-03-30 10:09:56 +04:00
|
|
|
|
2001-09-08 01:15:04 +04:00
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
2002-10-31 07:31:52 +03:00
|
|
|
if (use_subshell) {
|
|
|
|
prompt = strip_ctrl_codes (subshell_prompt);
|
|
|
|
if (!prompt)
|
|
|
|
prompt = "";
|
|
|
|
} else
|
|
|
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Virtual File System shutdown */
|
|
|
|
vfs_shut ();
|
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
flush_extension_file (); /* does only free memory */
|
1998-02-27 07:54:42 +03: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))
|
2003-06-22 13:32:52 +04:00
|
|
|
handle_console (CONSOLE_RESTORE);
|
1998-04-01 02:36:24 +04:00
|
|
|
if (alternate_plus_minus)
|
2002-10-31 07:31:52 +03:00
|
|
|
numeric_keypad_mode ();
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-10-31 07:31:52 +03:00
|
|
|
signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (console_flag)
|
|
|
|
handle_console (CONSOLE_DONE);
|
2002-10-31 07:31:52 +03:00
|
|
|
putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-11-01 23:24:07 +03:00
|
|
|
if (last_wd_file && last_wd_string && !print_last_revert
|
|
|
|
&& !edit_one_file && !view_one_file) {
|
|
|
|
int last_wd_fd =
|
|
|
|
open (last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
|
|
|
|
S_IRUSR | S_IWUSR);
|
2002-10-31 07:31:52 +03:00
|
|
|
|
|
|
|
if (last_wd_fd != -1) {
|
|
|
|
write (last_wd_fd, last_wd_string, strlen (last_wd_string));
|
|
|
|
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 ();
|
|
|
|
#endif
|
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 ();
|
|
|
|
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (this_dir);
|
|
|
|
g_free (other_dir);
|
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;
|
|
|
|
}
|