--- mc-4.6.1-20041124/src/subshell.c.promptfix 2004-11-03 20:43:17.000000000 +0100 +++ mc-4.6.1-20041124/src/subshell.c 2004-11-24 10:24:49.760461024 +0100 @@ -596,19 +596,15 @@ bytes = read (subshell_pty, pty_buffer, pty_buffer_size); /* Extract the prompt from the shell output */ - - for (i = 0; i < bytes; ++i) - 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); - } + for (i = 0; i < bytes; ++i) { + if (pty_buffer[i] == '\n' || pty_buffer[i] == '\r' || + !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'; } --- mc-4.6.1-20041124/src/main.c.promptfix 2004-10-22 07:47:25.000000000 +0200 +++ mc-4.6.1-20041124/src/main.c 2004-11-24 10:28:29.172105384 +0100 @@ -433,8 +433,14 @@ void do_update_prompt (void) { + static int prompt_size = 0; + if (update_prompt) { - printf ("%s", subshell_prompt); + if ( !prompt_size || prompt_size > COLS ) { + printf (!prompt_size ? "\r%*c\r%s" : "\n\r%*c\r%s", COLS, ' ', + subshell_prompt); + } else + printf ("\r%*c\r%s", prompt_size, ' ', subshell_prompt); fflush (stdout); update_prompt = 0; } @@ -699,15 +705,11 @@ prompt = strip_ctrl_codes (subshell_prompt); prompt_len = strlen (prompt); - /* Check for prompts too big */ - if (COLS > 8 && prompt_len > COLS - 8) { - prompt[COLS - 8] = 0; - prompt_len = COLS - 8; - } - label_set_text (the_prompt, prompt); - winput_set_origin ((WInput *) cmdline, prompt_len, - COLS - prompt_len); - + /* Shrink the prompt if it's too big */ + label_set_text (the_prompt, name_trunc (prompt, COLS - 8)); + prompt_len = prompt_len <= COLS - 8 ? prompt_len : COLS - 8; + winput_set_origin ((WInput *) cmdline, prompt_len, + COLS - prompt_len); /* since the prompt has changed, and we are called from one of the * get_event channels, the prompt updating does not take place * automatically: force a cursor update and a screen refresh