Ticket #2678: mc-4.8.0-prompt.patch

File mc-4.8.0-prompt.patch, 1.7 KB (added by egmont, 12 years ago)

fix - please review :)

  • src/main.c

    http://www.midnight-commander.org/ticket/2678
    
    diff -ur mc-4.8.0.orig/src/main.c mc-4.8.0/src/main.c
    old new  
    288288int 
    289289load_prompt (int fd, void *unused) 
    290290{ 
     291    char *tmp_prompt; 
     292    int prompt_len; 
     293 
    291294    (void) fd; 
    292295    (void) unused; 
    293296 
    294297    if (!read_subshell_prompt ()) 
    295298        return 0; 
    296299 
     300    tmp_prompt = strip_ctrl_codes (subshell_prompt); 
     301    prompt_len = str_term_width1 (tmp_prompt); 
     302 
     303    /* Check for prompts too big */ 
     304    if (COLS > 8 && prompt_len > COLS - 8) 
     305    { 
     306        prompt_len = COLS - 8; 
     307        tmp_prompt[prompt_len] = '\0'; 
     308    } 
     309    mc_prompt = tmp_prompt; 
     310    label_set_text (the_prompt, mc_prompt); 
     311    input_set_origin ((WInput *) cmdline, prompt_len, COLS - prompt_len); 
     312 
    297313    /* Don't actually change the prompt if it's invisible */ 
    298314    if (((Dlg_head *) top_dlg->data == midnight_dlg) && command_prompt) 
    299315    { 
    300         char *tmp_prompt; 
    301         int prompt_len; 
    302  
    303         tmp_prompt = strip_ctrl_codes (subshell_prompt); 
    304         prompt_len = str_term_width1 (tmp_prompt); 
    305  
    306         /* Check for prompts too big */ 
    307         if (COLS > 8 && prompt_len > COLS - 8) 
    308         { 
    309             prompt_len = COLS - 8; 
    310             tmp_prompt[prompt_len] = '\0'; 
    311         } 
    312         mc_prompt = tmp_prompt; 
    313         label_set_text (the_prompt, mc_prompt); 
    314         input_set_origin ((WInput *) cmdline, prompt_len, COLS - prompt_len); 
    315  
    316316        /* since the prompt has changed, and we are called from one of the 
    317317         * tty_get_event channels, the prompt updating does not take place 
    318318         * automatically: force a cursor update and a screen refresh