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

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

first version

  • doc/man/mc.1.in

    diff -urp mc-4.8.10.orig/doc/man/mc.1.in mc-4.8.10/doc/man/mc.1.in
    old new unintentionally becomes more difficult. 
    19501950confirmation dialogs for deletion changes from "Yes" to "No". 
    19511951This option is disabled by default. 
    19521952.PP 
     1953.I Auto cd new terminal. 
     1954If this option is enabled, mc tells its current directory to the terminal. 
     1955Some graphical terminals use this information to open new windows or tabs 
     1956in that directory. 
     1957.PP 
    19531958.I Auto save setup. 
    19541959If this option is enabled, when you exit the Midnight Commander the 
    19551960configurable options of the Midnight Commander are saved in the 
  • src/execute.c

    diff -urp mc-4.8.10.orig/src/execute.c mc-4.8.10/src/execute.c
    old new do_executev (const char *shell, int flag 
    363363    { 
    364364        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    365365        update_xterm_title_path (); 
     366        update_terminal_cwd (); 
    366367    } 
    367368 
    368369    do_refresh (); 
    toggle_panels (void) 
    548549    { 
    549550        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    550551        update_xterm_title_path (); 
     552        update_terminal_cwd (); 
    551553    } 
    552554 
    553555    if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) 
  • src/filemanager/boxes.c

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

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

    diff -urp mc-4.8.10.orig/src/filemanager/layout.h mc-4.8.10/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.10.orig/src/filemanager/panel.c mc-4.8.10/src/filemanager/panel.c
    old new _do_panel_cd (WPanel * panel, const vfs_ 
    30723072    load_hint (0); 
    30733073    panel->dirty = 1; 
    30743074    update_xterm_title_path (); 
     3075    update_terminal_cwd (); 
    30753076 
    30763077    vfs_path_free (olddir_vpath); 
    30773078 
    panel_callback (Widget * w, Widget * sen 
    34363437            subshell_chdir (panel->cwd_vpath); 
    34373438 
    34383439        update_xterm_title_path (); 
     3440        update_terminal_cwd (); 
    34393441        select_item (panel); 
    34403442        show_dir (panel); 
    34413443        paint_dir (panel); 
  • src/setup.c

    diff -urp mc-4.8.10.orig/src/setup.c mc-4.8.10/src/setup.c
    old new int confirm_view_dir = 0; 
    117117/* Ask file name before start the editor */ 
    118118int editor_ask_filename_before_edit = 0; 
    119119 
     120/* Tell cwd to the terminal so it can open new tabs there */ 
     121int auto_cd_new_terminal = 0; 
     122 
    120123panel_view_mode_t startup_left_mode; 
    121124panel_view_mode_t startup_right_mode; 
    122125 
    static const struct 
    365368    { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, 
    366369    { "copymove_persistent_attr", &setup_copymove_persistent_attr }, 
    367370    { "select_flags", &select_flags }, 
     371    { "auto_cd_new_terminal", &auto_cd_new_terminal }, 
    368372    { NULL, NULL } 
    369373}; 
    370374 
  • src/setup.h

    diff -urp mc-4.8.10.orig/src/setup.h mc-4.8.10/src/setup.h
    old new extern int output_starts_shell; 
    9898extern int use_file_to_check_type; 
    9999extern int file_op_compute_totals; 
    100100extern int editor_ask_filename_before_edit; 
     101extern int auto_cd_new_terminal; 
    101102 
    102103extern panels_options_t panels_options; 
    103104