Ticket #3380: enable subshell in standalone mceditor, mcviewer, and mcdiffviewer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-09-02 15:00:58 +03:00
parent 994c6a3c18
commit 41abcbf706
5 changed files with 27 additions and 23 deletions

View File

@ -549,13 +549,18 @@ toggle_subshell (void)
#ifdef ENABLE_SUBSHELL #ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
{ {
do_load_prompt (); if (mc_global.mc_run_mode == MC_RUN_FULL)
if (new_dir_vpath != NULL) {
do_possible_cd (new_dir_vpath); do_load_prompt ();
if (mc_global.tty.console_flag != '\0' && output_lines) if (new_dir_vpath != NULL)
show_console_contents (output_start_y, do_possible_cd (new_dir_vpath);
LINES - mc_global.keybar_visible - output_lines - if (mc_global.tty.console_flag != '\0' && output_lines)
1, LINES - mc_global.keybar_visible - 1); show_console_contents (output_start_y,
LINES - mc_global.keybar_visible - output_lines -
1, LINES - mc_global.keybar_visible - 1);
}
else if (new_dir_vpath != NULL && mc_chdir (new_dir_vpath) != -1)
vfs_setup_cwd ();
} }
vfs_path_free (new_dir_vpath); vfs_path_free (new_dir_vpath);

View File

@ -331,10 +331,6 @@ main (int argc, char *argv[])
handle_console (CONSOLE_INIT); handle_console (CONSOLE_INIT);
#ifdef ENABLE_SUBSHELL #ifdef ENABLE_SUBSHELL
/* Don't use subshell when invoked as viewer or editor */
if (mc_global.mc_run_mode != MC_RUN_FULL)
mc_global.tty.use_subshell = FALSE;
if (mc_global.tty.use_subshell) if (mc_global.tty.use_subshell)
subshell_get_console_attributes (); subshell_get_console_attributes ();
#endif /* ENABLE_SUBSHELL */ #endif /* ENABLE_SUBSHELL */

View File

@ -1143,16 +1143,16 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
/* Make the subshell change to MC's working directory */ /* Make the subshell change to MC's working directory */
if (new_dir_vpath != NULL) if (new_dir_vpath != NULL)
do_subshell_chdir (subshell_get_cwd_from_current_panel (), TRUE); do_subshell_chdir (subshell_get_cwd (), TRUE);
if (command == NULL) /* The user has done "C-o" from MC */ if (command == NULL) /* The user has done "C-o" from MC */
{ {
if (subshell_state == INACTIVE) if (subshell_state == INACTIVE)
{ {
subshell_state = ACTIVE; subshell_state = ACTIVE;
/* FIXME: possibly take out this hack; the user can
re-play it by hitting C-hyphen a few times! */ /* FIXME: possibly take out this hack; the user can re-play it by hitting C-hyphen a few times! */
if (subshell_ready) if (subshell_ready && mc_global.mc_run_mode == MC_RUN_FULL)
write_all (mc_global.tty.subshell_pty, " \b", 2); /* Hack to make prompt reappear */ write_all (mc_global.tty.subshell_pty, " \b", 2); /* Hack to make prompt reappear */
} }
} }
@ -1173,7 +1173,7 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
{ {
const char *pcwd; const char *pcwd;
pcwd = vfs_translate_path (vfs_path_as_str (subshell_get_cwd_from_current_panel ())); pcwd = vfs_translate_path (vfs_path_as_str (subshell_get_cwd ()));
if (strcmp (subshell_cwd, pcwd) != 0) if (strcmp (subshell_cwd, pcwd) != 0)
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */ *new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
} }
@ -1299,7 +1299,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
{ {
char *pcwd; char *pcwd;
pcwd = vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0, VPF_RECODE); pcwd = vfs_path_to_str_flags (subshell_get_cwd (), 0, VPF_RECODE);
if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, pcwd) != 0)) if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, pcwd) != 0))
{ {
@ -1370,9 +1370,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
{ {
char *cwd; char *cwd;
cwd = cwd = vfs_path_to_str_flags (subshell_get_cwd (), 0, VPF_STRIP_PASSWORD);
vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0,
VPF_STRIP_PASSWORD);
vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd); vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd);
g_free (cwd); g_free (cwd);
} }

View File

@ -17,7 +17,7 @@
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
const vfs_path_t *subshell_get_cwd_from_current_panel (void); const vfs_path_t *subshell_get_cwd (void);
void subshell_handle_cons_saver (void); void subshell_handle_cons_saver (void);
int subshell_get_mainloop_quit (void); int subshell_get_mainloop_quit (void);

View File

@ -31,6 +31,8 @@
#include "lib/global.h" #include "lib/global.h"
#include "lib/vfs/vfs.h" /* vfs_get_raw_current_dir() */
#include "src/setup.h" /* quit */ #include "src/setup.h" /* quit */
#include "src/filemanager/midnight.h" /* current_panel */ #include "src/filemanager/midnight.h" /* current_panel */
#include "src/consaver/cons.saver.h" /* handle_console() */ #include "src/consaver/cons.saver.h" /* handle_console() */
@ -56,9 +58,12 @@
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
const vfs_path_t * const vfs_path_t *
subshell_get_cwd_from_current_panel (void) subshell_get_cwd (void)
{ {
return current_panel->cwd_vpath; if (mc_global.mc_run_mode == MC_RUN_FULL)
return current_panel->cwd_vpath;
return vfs_get_raw_current_dir ();
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */