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

File mc-4.8.19-terminal-cwd.patch, 5.8 KB (added by egmont, 7 years ago)

updated to current git, plus minor cleanups

  • doc/man/mc.1.in

    diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in
    index da3c9720c..3d152451f 100644
    a b unintentionally becomes more difficult. The default selection in the 
    19671967confirmation dialogs for deletion changes from "Yes" to "No". 
    19681968This option is disabled by default. 
    19691969.PP 
     1970.I Auto cd new terminal. 
     1971If this option is enabled, mc tells its current directory to the terminal. 
     1972Some graphical terminal emulators use this information to open new windows 
     1973or tabs in that directory. 
     1974.PP 
    19701975.I Auto save setup. 
    19711976If this option is enabled, when you exit Midnight Commander, the 
    19721977configurable options of Midnight Commander are saved in the 
  • src/execute.c

    diff --git a/src/execute.c b/src/execute.c
    index 5bb017f00..f6544f26a 100644
    a b do_executev (const char *shell, int flags, char *const argv[]) 
    371371    { 
    372372        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    373373        update_xterm_title_path (); 
     374        update_terminal_cwd (); 
    374375    } 
    375376 
    376377    do_refresh (); 
    toggle_panels (void) 
    551552    { 
    552553        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    553554        update_xterm_title_path (); 
     555        update_terminal_cwd (); 
    554556    } 
    555557 
    556558    if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) 
  • src/filemanager/boxes.c

    diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
    index 90dc6e052..0f164d5ce 100644
    a b configure_box (void) 
    546546                    QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL), 
    547547                    QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL), 
    548548                    QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL), 
     549                    QUICK_CHECKBOX (N_("Auto cd new terminal"), &auto_cd_new_terminal, NULL),  // TODO: shortcut key! 
    549550                    QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL), 
    550551                    QUICK_SEPARATOR (FALSE), 
    551552                    QUICK_SEPARATOR (FALSE), 
    552                     QUICK_SEPARATOR (FALSE), 
    553553                QUICK_STOP_GROUPBOX, 
    554554            QUICK_STOP_COLUMNS, 
    555555            QUICK_BUTTONS_OK_CANCEL, 
  • src/filemanager/layout.c

    diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c
    index 10f06643c..d9194ea11 100644
    a b setup_panels (void) 
    791791        widget_set_size (WIDGET (the_hint), 0, 0, 0, 0); 
    792792 
    793793    update_xterm_title_path (); 
     794    update_terminal_cwd (); 
    794795} 
    795796 
    796797/* --------------------------------------------------------------------------------------------- */ 
    update_xterm_title_path (void) 
    14371438} 
    14381439 
    14391440/* --------------------------------------------------------------------------------------------- */ 
     1441 
     1442/** Tell the current directory to the terminal so it can open new tabs there */ 
     1443void 
     1444update_terminal_cwd (void) 
     1445{ 
     1446    if (mc_global.tty.xterm_flag && auto_cd_new_terminal && vfs_current_is_local ()) 
     1447    { 
     1448        const gchar *host; 
     1449        char *path; 
     1450        int pathlen, i; 
     1451        unsigned char c; 
     1452 
     1453        host = g_get_host_name (); 
     1454        path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_NONE); 
     1455        pathlen = strlen (path); 
     1456 
     1457        fprintf (stdout, "\33]7;file://%s", host); 
     1458        for (i = 0; i < pathlen; i++) { 
     1459            c = path[i]; 
     1460            if ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z') || index("/_.-()~", c) != NULL) 
     1461                fprintf(stdout, "%c", c); 
     1462            else 
     1463                fprintf(stdout, "%%%02X", c); 
     1464        } 
     1465        fprintf (stdout, "\7"); 
     1466        (void) fflush (stdout); 
     1467        g_free (path); 
     1468    } 
     1469} 
     1470 
     1471/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/layout.h

    diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h
    index a8658382a..5d281c024 100644
    a b int load_prompt (int fd, void *unused); 
    9090#endif 
    9191 
    9292void update_xterm_title_path (void); 
     93void update_terminal_cwd (void); 
    9394 
    9495void title_path_prepare (char **path, char **login); 
    9596 
  • src/filemanager/panel.c

    diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
    index 039ec7ccc..9107d5312 100644
    a b _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_ 
    33113311    load_hint (FALSE); 
    33123312    panel->dirty = 1; 
    33133313    update_xterm_title_path (); 
     3314    update_terminal_cwd (); 
    33143315 
    33153316    vfs_path_free (olddir_vpath); 
    33163317 
    panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d 
    36913692            subshell_chdir (panel->cwd_vpath); 
    36923693 
    36933694        update_xterm_title_path (); 
     3695        update_terminal_cwd (); 
    36943696        select_item (panel); 
    36953697 
    36963698        bb = find_buttonbar (w->owner); 
  • src/setup.c

    diff --git a/src/setup.c b/src/setup.c
    index 430075ced..f0e0d7788 100644
    a b gboolean confirm_view_dir = FALSE; 
    114114/* Ask file name before start the editor */ 
    115115gboolean editor_ask_filename_before_edit = FALSE; 
    116116 
     117/* Tell cwd to the terminal so it can open new tabs there */ 
     118gboolean auto_cd_new_terminal = 0; 
     119 
    117120panel_view_mode_t startup_left_mode; 
    118121panel_view_mode_t startup_right_mode; 
    119122 
    static const struct 
    352355    { "mcview_remember_file_position", &mcview_remember_file_position }, 
    353356    { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, 
    354357    { "copymove_persistent_attr", &copymove_persistent_attr }, 
     358    { "auto_cd_new_terminal", &auto_cd_new_terminal }, 
    355359    { NULL, NULL } 
    356360}; 
    357361 
  • src/setup.h

    diff --git a/src/setup.h b/src/setup.h
    index b483d7da9..13729fe06 100644
    a b extern gboolean output_starts_shell; 
    9898extern gboolean use_file_to_check_type; 
    9999extern gboolean file_op_compute_totals; 
    100100extern gboolean editor_ask_filename_before_edit; 
     101extern gboolean auto_cd_new_terminal; 
    101102 
    102103extern panels_options_t panels_options; 
    103104