Ticket #3088: mc-4.8.13-terminal-cwd.patch

File mc-4.8.13-terminal-cwd.patch, 6.3 KB (added by egmont, 10 years ago)

updated to newest mc

  • doc/man/mc.1.in

    diff -urp mc-4.8.13.orig/doc/man/mc.1.in mc-4.8.13/doc/man/mc.1.in
    old new unintentionally becomes more difficult. 
    19571957confirmation dialogs for deletion changes from "Yes" to "No". 
    19581958This option is disabled by default. 
    19591959.PP 
     1960.I Auto cd new terminal. 
     1961If this option is enabled, mc tells its current directory to the terminal. 
     1962Some graphical terminals use this information to open new windows or tabs 
     1963in that directory. 
     1964.PP 
    19601965.I Auto save setup. 
    19611966If this option is enabled, when you exit the Midnight Commander the 
    19621967configurable options of the Midnight Commander are saved in the 
  • src/execute.c

    diff -urp mc-4.8.13.orig/src/execute.c mc-4.8.13/src/execute.c
    old new do_executev (const char *shell, int flag 
    370370    { 
    371371        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    372372        update_xterm_title_path (); 
     373        update_terminal_cwd (); 
    373374    } 
    374375 
    375376    do_refresh (); 
    toggle_panels (void) 
    558559    { 
    559560        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    560561        update_xterm_title_path (); 
     562        update_terminal_cwd (); 
    561563    } 
    562564 
    563565    if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) 
  • src/filemanager/boxes.c

    diff -urp mc-4.8.13.orig/src/filemanager/boxes.c mc-4.8.13/src/filemanager/boxes.c
    old new configure_box (void) 
    478478                    QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL), 
    479479                    QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL), 
    480480                    QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL), 
     481                    QUICK_CHECKBOX (N_("Auto cd new terminal"), &auto_cd_new_terminal, NULL),  // TODO: shortcut key! 
    481482                    QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL), 
    482483                    QUICK_SEPARATOR (FALSE), 
    483484                    QUICK_SEPARATOR (FALSE), 
  • src/filemanager/layout.c

    diff -urp mc-4.8.13.orig/src/filemanager/layout.c mc-4.8.13/src/filemanager/layout.c
    old new setup_panels (void) 
    753753        widget_set_size (WIDGET (the_hint), 0, 0, 0, 0); 
    754754 
    755755    update_xterm_title_path (); 
     756    update_terminal_cwd (); 
    756757} 
    757758 
    758759/* --------------------------------------------------------------------------------------------- */ 
    update_xterm_title_path (void) 
    14061407    } 
    14071408} 
    14081409 
     1410/* --------------------------------------------------------------------------------------------- */ 
     1411 
     1412/** Tell the current directory to the terminal, so it can open a new tab there */ 
     1413void 
     1414update_terminal_cwd (void) 
     1415{ 
     1416    if (mc_global.tty.xterm_flag && auto_cd_new_terminal && vfs_current_is_local ()) 
     1417    { 
     1418        char host[BUF_TINY]; 
     1419        int res = 0; 
     1420        char *path; 
     1421        int pathlen, i; 
     1422        unsigned char c; 
     1423 
     1424        path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_NONE); 
     1425        pathlen = strlen (path); 
     1426 
     1427        res = gethostname (host, sizeof (host)); 
     1428        if (res != 0) 
     1429            host[0] = '\0'; 
     1430        else 
     1431            host[sizeof (host) - 1] = '\0'; 
     1432 
     1433        fprintf (stdout, "\33]7;file://%s", host); 
     1434        for (i = 0; i < pathlen; i++) { 
     1435            c = path[i]; 
     1436            if ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z') || index("/_.-()~", c) != NULL) 
     1437                fprintf(stdout, "%c", c); 
     1438            else 
     1439                fprintf(stdout, "%%%02X", c); 
     1440        } 
     1441        fprintf (stdout, "\7"); 
     1442        (void) fflush (stdout); 
     1443        g_free (path); 
     1444    } 
     1445} 
     1446 
    14091447/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/layout.h

    diff -urp mc-4.8.13.orig/src/filemanager/layout.h mc-4.8.13/src/filemanager/layout.h
    old new int load_prompt (int fd, void *unused); 
    8787#endif 
    8888 
    8989void update_xterm_title_path (void); 
     90void update_terminal_cwd (void); 
    9091 
    9192void title_path_prepare (char **path, char **login); 
    9293 
  • src/filemanager/panel.c

    diff -urp mc-4.8.13.orig/src/filemanager/panel.c mc-4.8.13/src/filemanager/panel.c
    old new _do_panel_cd (WPanel * panel, const vfs_ 
    32023202    load_hint (0); 
    32033203    panel->dirty = 1; 
    32043204    update_xterm_title_path (); 
     3205    update_terminal_cwd (); 
    32053206 
    32063207    vfs_path_free (olddir_vpath); 
    32073208 
    panel_callback (Widget * w, Widget * sen 
    35663567            subshell_chdir (panel->cwd_vpath); 
    35673568 
    35683569        update_xterm_title_path (); 
     3570        update_terminal_cwd (); 
    35693571        select_item (panel); 
    35703572        show_dir (panel); 
    35713573        paint_dir (panel); 
  • src/setup.c

    diff -urp mc-4.8.13.orig/src/setup.c mc-4.8.13/src/setup.c
    old new int confirm_view_dir = 0; 
    114114/* Ask file name before start the editor */ 
    115115int editor_ask_filename_before_edit = 0; 
    116116 
     117/* Tell cwd to the terminal so it can open new tabs there */ 
     118int auto_cd_new_terminal = 0; 
     119 
    117120panel_view_mode_t startup_left_mode; 
    118121panel_view_mode_t startup_right_mode; 
    119122 
    static const struct 
    363366    { "mcview_remember_file_position", &mcview_remember_file_position }, 
    364367    { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, 
    365368    { "copymove_persistent_attr", &setup_copymove_persistent_attr }, 
     369    { "auto_cd_new_terminal", &auto_cd_new_terminal }, 
    366370    { NULL, NULL } 
    367371}; 
    368372 
  • src/setup.h

    diff -urp mc-4.8.13.orig/src/setup.h mc-4.8.13/src/setup.h
    old new extern int output_starts_shell; 
    9797extern int use_file_to_check_type; 
    9898extern int file_op_compute_totals; 
    9999extern int editor_ask_filename_before_edit; 
     100extern int auto_cd_new_terminal; 
    100101 
    101102extern panels_options_t panels_options; 
    102103