Ticket #2661: mc-4.8.10-editor-bracketed-paste.patch

File mc-4.8.10-editor-bracketed-paste.patch, 7.1 KB (added by egmont, 9 years ago)

enable bracketed paste

  • lib/tty/key.c

    diff -ur mc-4.8.10.orig/lib/tty/key.c mc-4.8.10/lib/tty/key.c
    old new  
    9292int old_esc_mode_timeout = 1000000;     /* settable via env */ 
    9393int use_8th_bit_as_meta = 0; 
    9494 
     95gboolean bracketed_pasting_in_progress = FALSE; 
     96 
    9597/* This table is a mapping between names and the constants we use 
    9698 * We use this to allow users to define alternate definitions for 
    9799 * certain keys that may be missing from the terminal database 
     
    275277static key_define_t mc_default_keys[] = { 
    276278    {ESC_CHAR, ESC_STR, MCKEY_ESCAPE}, 
    277279    {ESC_CHAR, ESC_STR ESC_STR, MCKEY_NOACTION}, 
     280    {MCKEY_BRACKETED_PASTING_START, ESC_STR "[200~", MCKEY_NOACTION}, 
     281    {MCKEY_BRACKETED_PASTING_END,   ESC_STR "[201~", MCKEY_NOACTION}, 
    278282    {0, NULL, MCKEY_NOACTION}, 
    279283}; 
    280284 
     
    21482152        return (event->type != 0) ? EV_MOUSE : EV_NONE; 
    21492153    } 
    21502154 
     2155    if (c == MCKEY_BRACKETED_PASTING_START) { 
     2156        bracketed_pasting_in_progress = TRUE; 
     2157        return EV_NONE; 
     2158    } else if (c == MCKEY_BRACKETED_PASTING_END) { 
     2159        bracketed_pasting_in_progress = FALSE; 
     2160        return EV_NONE; 
     2161    } 
     2162 
    21512163    return c; 
    21522164} 
    21532165 
     
    22502262} 
    22512263 
    22522264/* --------------------------------------------------------------------------------------------- */ 
     2265 
     2266void 
     2267enable_bracketed_paste (void) 
     2268{ 
     2269        printf (ESC_STR "[?2004h"); 
     2270        fflush (stdout); 
     2271} 
     2272 
     2273/* --------------------------------------------------------------------------------------------- */ 
     2274 
     2275void 
     2276disable_bracketed_paste (void) 
     2277{ 
     2278        printf (ESC_STR "[?2004l"); 
     2279        fflush (stdout); 
     2280        bracketed_pasting_in_progress = FALSE; 
     2281} 
     2282 
     2283/* --------------------------------------------------------------------------------------------- */ 
  • lib/tty/key.h

    diff -ur mc-4.8.10.orig/lib/tty/key.h mc-4.8.10/lib/tty/key.h
    old new  
    3636/* Return code for the extended mouse sequence */ 
    3737#define MCKEY_EXTENDED_MOUSE     -3 
    3838 
     39/* Return code for brackets of bracketed paste mode */ 
     40#define MCKEY_BRACKETED_PASTING_START -4 
     41#define MCKEY_BRACKETED_PASTING_END   -5 
     42 
    3943/*** enums ***************************************************************************************/ 
    4044 
    4145/*** structures declarations (and typedefs of structures)*****************************************/ 
     
    6165extern int use_8th_bit_as_meta; 
    6266extern int mou_auto_repeat; 
    6367 
     68extern gboolean bracketed_pasting_in_progress; 
     69 
    6470/*** declarations of public functions ************************************************************/ 
    6571 
    6672gboolean define_sequence (int code, const char *seq, int action); 
     
    101107void numeric_keypad_mode (void); 
    102108void application_keypad_mode (void); 
    103109 
     110/* Bracketed paste mode */ 
     111void enable_bracketed_paste (void); 
     112void disable_bracketed_paste (void); 
     113 
    104114/*** inline functions ****************************************************************************/ 
    105115 
    106116static inline gboolean 
  • lib/tty/tty-ncurses.c

    diff -ur mc-4.8.10.orig/lib/tty/tty-ncurses.c mc-4.8.10/lib/tty/tty-ncurses.c
    old new  
    218218tty_shutdown (void) 
    219219{ 
    220220    disable_mouse (); 
     221    disable_bracketed_paste (); 
    221222    tty_reset_shell_mode (); 
    222223    tty_noraw_mode (); 
    223224    tty_keypad (FALSE); 
  • lib/tty/tty-slang.c

    diff -ur mc-4.8.10.orig/lib/tty/tty-slang.c mc-4.8.10/lib/tty/tty-slang.c
    old new  
    347347    char *op_cap; 
    348348 
    349349    disable_mouse (); 
     350    disable_bracketed_paste (); 
    350351    tty_reset_shell_mode (); 
    351352    tty_noraw_mode (); 
    352353    tty_keypad (FALSE); 
  • src/editor/edit.c

    diff -ur mc-4.8.10.orig/src/editor/edit.c mc-4.8.10/src/editor/edit.c
    old new  
    34573457        if (option_auto_para_formatting) 
    34583458        { 
    34593459            edit_double_newline (edit); 
    3460             if (option_return_does_auto_indent) 
     3460            if (option_return_does_auto_indent && !bracketed_pasting_in_progress) 
    34613461                edit_auto_indent (edit); 
    34623462            format_paragraph (edit, FALSE); 
    34633463        } 
    34643464        else 
    34653465        { 
    34663466            edit_insert (edit, '\n'); 
    3467             if (option_return_does_auto_indent) 
     3467            if (option_return_does_auto_indent && !bracketed_pasting_in_progress) 
    34683468                edit_auto_indent (edit); 
    34693469        } 
    34703470        break; 
  • src/editor/editwidget.c

    diff -ur mc-4.8.10.orig/src/editor/editwidget.c mc-4.8.10/src/editor/editwidget.c
    old new  
    10651065                    ret = edit_dialog_command_execute (h, command); 
    10661066            } 
    10671067 
     1068            if (!is_idle()) 
     1069                widget_want_idle (w, TRUE); 
    10681070            return ret; 
    10691071        } 
    10701072 
     
    10801082        edit_dlg_deinit (); 
    10811083        return MSG_HANDLED; 
    10821084 
     1085    case MSG_IDLE: 
     1086        widget_want_idle (w, FALSE); 
     1087        return send_message (h->current->data, NULL, MSG_IDLE, 0, NULL); 
     1088 
    10831089    default: 
    10841090        return dlg_default_callback (w, sender, msg, parm, data); 
    10851091    } 
     
    11511157        edit_clean (e); 
    11521158        return MSG_HANDLED; 
    11531159 
     1160    case MSG_IDLE: 
     1161        edit_update_screen (e); 
     1162        return MSG_HANDLED; 
     1163 
    11541164    default: 
    11551165        return widget_default_callback (w, sender, msg, parm, data); 
    11561166    } 
  • src/execute.c

    diff -ur mc-4.8.10.orig/src/execute.c mc-4.8.10/src/execute.c
    old new  
    8888    tty_raw_mode (); 
    8989    channels_up (); 
    9090    enable_mouse (); 
     91    enable_bracketed_paste (); 
    9192    if (mc_global.tty.alternate_plus_minus) 
    9293        application_keypad_mode (); 
    9394} 
     
    107108 
    108109    channels_down (); 
    109110    disable_mouse (); 
     111    disable_bracketed_paste (); 
    110112 
    111113    tty_reset_shell_mode (); 
    112114    tty_keypad (FALSE); 
     
    455457 
    456458    channels_down (); 
    457459    disable_mouse (); 
     460    disable_bracketed_paste (); 
    458461    if (clear_before_exec) 
    459462        clr_scr (); 
    460463    if (mc_global.tty.alternate_plus_minus) 
     
    518521    } 
    519522 
    520523    enable_mouse (); 
     524    enable_bracketed_paste (); 
    521525    channels_up (); 
    522526    if (mc_global.tty.alternate_plus_minus) 
    523527        application_keypad_mode (); 
  • src/main.c

    diff -ur mc-4.8.10.orig/src/main.c mc-4.8.10/src/main.c
    old new  
    381381       w/o Shift button in subshell in the native console */ 
    382382    init_mouse (); 
    383383 
     384    /* Done after do_enter_ca_mode (tty_init) because in VTE bracketed mode is 
     385       separate for the normal and alternate screens */ 
     386    enable_bracketed_paste (); 
     387 
    384388    /* subshell_prompt is NULL here */ 
    385389    mc_prompt = (geteuid () == 0) ? "# " : "$ "; 
    386390