Merge branch '3380_mcedit_subshell'

* 3380_mcedit_subshell:
  Ticket #3380: enable subshell in standalone mceditor, mcviewer, and mcdiffviewer.
This commit is contained in:
Andrew Borodin 2019-10-20 18:00:03 +03:00
commit 35b3192f41
5 changed files with 27 additions and 23 deletions

View File

@ -548,6 +548,8 @@ toggle_subshell (void)
#ifdef ENABLE_SUBSHELL
if (mc_global.tty.use_subshell)
{
if (mc_global.mc_run_mode == MC_RUN_FULL)
{
do_load_prompt ();
if (new_dir_vpath != NULL)
@ -557,6 +559,9 @@ toggle_subshell (void)
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);
#endif /* ENABLE_SUBSHELL */

View File

@ -331,10 +331,6 @@ main (int argc, char *argv[])
handle_console (CONSOLE_INIT);
#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)
subshell_get_console_attributes ();
#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 */
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 (subshell_state == INACTIVE)
{
subshell_state = ACTIVE;
/* FIXME: possibly take out this hack; the user can
re-play it by hitting C-hyphen a few times! */
if (subshell_ready)
/* FIXME: possibly take out this hack; the user can re-play it by hitting C-hyphen a few times! */
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 */
}
}
@ -1173,7 +1173,7 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
{
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)
*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;
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))
{
@ -1370,9 +1370,7 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt)
{
char *cwd;
cwd =
vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0,
VPF_STRIP_PASSWORD);
cwd = vfs_path_to_str_flags (subshell_get_cwd (), 0, VPF_STRIP_PASSWORD);
vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd);
g_free (cwd);
}

View File

@ -17,7 +17,7 @@
/*** 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);
int subshell_get_mainloop_quit (void);

View File

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