2009-07-31 18:40:04 +00:00
|
|
|
diff -up mc-4.6.99/src/execute.c.prompt mc-4.6.99/src/execute.c
|
|
|
|
--- mc-4.6.99/src/execute.c.prompt 2009-07-31 14:57:10.000000000 +0200
|
|
|
|
+++ mc-4.6.99/src/execute.c 2009-07-31 14:58:21.000000000 +0200
|
|
|
|
@@ -146,6 +146,8 @@ do_execute (const char *shell, const cha
|
2007-06-20 14:39:18 +00:00
|
|
|
printf ("\r\n");
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
+ update_prompt = TRUE;
|
|
|
|
+ do_update_prompt ();
|
|
|
|
if (console_flag) {
|
|
|
|
if (output_lines && keybar_visible) {
|
|
|
|
putchar ('\n');
|
2009-07-31 18:40:04 +00:00
|
|
|
diff -up mc-4.6.99/src/main.c.prompt mc-4.6.99/src/main.c
|
|
|
|
--- mc-4.6.99/src/main.c.prompt 2009-07-31 14:57:10.000000000 +0200
|
|
|
|
+++ mc-4.6.99/src/main.c 2009-07-31 14:58:21.000000000 +0200
|
|
|
|
@@ -459,7 +459,7 @@ void
|
2007-06-12 14:49:42 +00:00
|
|
|
do_update_prompt (void)
|
|
|
|
{
|
|
|
|
if (update_prompt) {
|
|
|
|
- printf ("%s", subshell_prompt);
|
2007-06-20 14:39:18 +00:00
|
|
|
+ printf ("\r\n%s", original_subshell_prompt);
|
|
|
|
fflush (stdout);
|
2007-06-12 14:49:42 +00:00
|
|
|
update_prompt = 0;
|
|
|
|
}
|
2009-07-31 18:40:04 +00:00
|
|
|
diff -up mc-4.6.99/src/subshell.c.prompt mc-4.6.99/src/subshell.c
|
|
|
|
--- mc-4.6.99/src/subshell.c.prompt 2009-07-31 14:57:11.000000000 +0200
|
|
|
|
+++ mc-4.6.99/src/subshell.c 2009-07-31 15:02:35.000000000 +0200
|
|
|
|
@@ -114,6 +114,9 @@ enum subshell_state_enum subshell_state;
|
2007-06-20 14:39:18 +00:00
|
|
|
/* Holds the latest prompt captured from the subshell */
|
|
|
|
char *subshell_prompt = NULL;
|
|
|
|
|
|
|
|
+/* Holds the latest prompt captured from the subshell with terminal codes */
|
|
|
|
+char *original_subshell_prompt = NULL;
|
|
|
|
+
|
|
|
|
/* Initial length of the buffer for the subshell's prompt */
|
|
|
|
#define INITIAL_PROMPT_SIZE 10
|
|
|
|
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -160,6 +163,7 @@ static struct termios raw_mode;
|
2007-06-20 14:39:18 +00:00
|
|
|
/* This counter indicates how many characters of prompt we have read */
|
|
|
|
/* FIXME: try to figure out why this had to become global */
|
|
|
|
static int prompt_pos;
|
|
|
|
+static int original_prompt_pos;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -598,6 +602,7 @@ int invoke_subshell (const char *command
|
2007-06-20 14:39:18 +00:00
|
|
|
init_subshell ();
|
|
|
|
|
|
|
|
prompt_pos = 0;
|
|
|
|
+ original_prompt_pos = 0;
|
|
|
|
|
|
|
|
return quit;
|
2007-06-12 14:49:42 +00:00
|
|
|
}
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -607,6 +612,7 @@ int
|
2007-06-20 14:39:18 +00:00
|
|
|
read_subshell_prompt (void)
|
|
|
|
{
|
|
|
|
static int prompt_size = INITIAL_PROMPT_SIZE;
|
|
|
|
+ static int original_prompt_size = INITIAL_PROMPT_SIZE;
|
|
|
|
int bytes = 0, i, rc = 0;
|
|
|
|
struct timeval timeleft = { 0, 0 };
|
|
|
|
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -617,7 +623,10 @@ read_subshell_prompt (void)
|
2007-06-20 14:39:18 +00:00
|
|
|
if (subshell_prompt == NULL) { /* First time through */
|
|
|
|
subshell_prompt = g_malloc (prompt_size);
|
|
|
|
*subshell_prompt = '\0';
|
|
|
|
+ original_subshell_prompt = g_malloc (original_prompt_size);
|
|
|
|
+ *original_subshell_prompt = '\0';
|
|
|
|
prompt_pos = 0;
|
|
|
|
+ original_prompt_pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (subshell_alive
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -638,20 +647,27 @@ read_subshell_prompt (void)
|
2007-06-20 14:39:18 +00:00
|
|
|
|
|
|
|
/* Extract the prompt from the shell output */
|
|
|
|
|
|
|
|
- for (i = 0; i < bytes; ++i)
|
|
|
|
+ for (i = 0; i < bytes; ++i) {
|
|
|
|
+ if (!pty_buffer[i])
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ original_subshell_prompt[original_prompt_pos++] = pty_buffer[i];
|
|
|
|
+ if (original_prompt_pos == original_prompt_size)
|
|
|
|
+ original_subshell_prompt =
|
|
|
|
+ g_realloc (original_subshell_prompt, original_prompt_size *= 2);
|
|
|
|
+
|
|
|
|
if (pty_buffer[i] == '\n' || pty_buffer[i] == '\r') {
|
|
|
|
prompt_pos = 0;
|
|
|
|
} else {
|
|
|
|
- if (!pty_buffer[i])
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
subshell_prompt[prompt_pos++] = pty_buffer[i];
|
|
|
|
if (prompt_pos == prompt_size)
|
|
|
|
subshell_prompt =
|
|
|
|
g_realloc (subshell_prompt, prompt_size *= 2);
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
subshell_prompt[prompt_pos] = '\0';
|
|
|
|
+ original_subshell_prompt[original_prompt_pos] = '\0';
|
|
|
|
}
|
|
|
|
if (rc == 0 && bytes == 0)
|
|
|
|
return FALSE;
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -792,6 +808,7 @@ do_subshell_chdir (const char *directory
|
|
|
|
char *pcwd;
|
|
|
|
char *temp;
|
|
|
|
char *translate;
|
2007-06-20 14:39:18 +00:00
|
|
|
+ static char *old_subshell_prompt = NULL;
|
2009-07-31 18:40:04 +00:00
|
|
|
|
|
|
|
pcwd = vfs_translate_path_n (current_panel->cwd);
|
|
|
|
|
|
|
|
@@ -802,8 +819,14 @@ do_subshell_chdir (const char *directory
|
2007-06-20 14:39:18 +00:00
|
|
|
* the main program. Please note that in the code after this
|
|
|
|
* if, the cd command that is sent will make the subshell
|
|
|
|
* repaint the prompt, so we don't have to paint it. */
|
|
|
|
- if (do_update)
|
|
|
|
- do_update_prompt ();
|
|
|
|
+ if (do_update) {
|
|
|
|
+ if (old_subshell_prompt == NULL
|
|
|
|
+ || strcmp (old_subshell_prompt, original_subshell_prompt)) {
|
2009-07-31 18:40:04 +00:00
|
|
|
+ g_free (old_subshell_prompt);
|
|
|
|
+ old_subshell_prompt = g_strdup (original_subshell_prompt);
|
|
|
|
+ do_update_prompt ();
|
2007-06-20 14:39:18 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2009-07-31 18:40:04 +00:00
|
|
|
g_free (pcwd);
|
2007-06-20 14:39:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-07-31 18:40:04 +00:00
|
|
|
@@ -861,8 +884,10 @@ do_subshell_chdir (const char *directory
|
2007-06-20 14:39:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (reset_prompt)
|
|
|
|
+ if (reset_prompt) {
|
|
|
|
prompt_pos = 0;
|
|
|
|
+ original_prompt_pos = 0;
|
|
|
|
+ }
|
|
|
|
update_prompt = FALSE;
|
2009-07-31 18:40:04 +00:00
|
|
|
|
|
|
|
g_free (pcwd);
|
|
|
|
diff -up mc-4.6.99/src/subshell.h.prompt mc-4.6.99/src/subshell.h
|
|
|
|
--- mc-4.6.99/src/subshell.h.prompt 2009-07-31 14:57:10.000000000 +0200
|
|
|
|
+++ mc-4.6.99/src/subshell.h 2009-07-31 14:58:21.000000000 +0200
|
|
|
|
@@ -25,6 +25,9 @@ extern enum subshell_state_enum subshell
|
|
|
|
/* Holds the latest prompt captured from the subshell */
|
|
|
|
extern char *subshell_prompt;
|
|
|
|
|
|
|
|
+/* Holds the latest prompt captured from the subshell with terminal codes */
|
|
|
|
+extern char *original_subshell_prompt;
|
|
|
|
+
|
|
|
|
/* For the `how' argument to various functions */
|
|
|
|
enum {QUIETLY, VISIBLY};
|
|
|
|
|