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