Ticket #3088: mc-4.8.30-terminal-cwd-v2.patch

File mc-4.8.30-terminal-cwd-v2.patch, 6.1 KB (added by egmont, 3 months ago)
  • doc/man/mc.1.in

    diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in
    index aad40fe27..06ea6af41 100644
    a b to 
    18761876.BR No . 
    18771877This option is disabled by default. 
    18781878.PP 
     1879.I Auto cd new terminal. 
     1880If this option is enabled, mc tells its current directory to the terminal. 
     1881Some graphical terminal emulators use this information to open new windows 
     1882or tabs in that directory. 
     1883.PP 
    18791884.I Auto save setup. 
    18801885If this option is enabled, when you exit Midnight Commander, the 
    18811886configurable options of Midnight Commander are saved in the 
  • src/execute.c

    diff --git a/po/be.po b/po/be.po
    index d19484333..c7ed014e5 100644
    Binary files a/po/be.po and b/po/be.po differ
    diff --git a/po/br.po b/po/br.po
    index 2811377a7..4de791b06 100644
    Binary files a/po/br.po and b/po/br.po differ
    diff --git a/po/hr.po b/po/hr.po
    index 30389ce2a..de1f722a0 100644
    Binary files a/po/hr.po and b/po/hr.po differ
    diff --git a/src/execute.c b/src/execute.c
    index 21095a20d..ad60ef96b 100644
    a b do_executev (const char *shell, int flags, char *const argv[]) 
    373373    { 
    374374        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    375375        update_xterm_title_path (); 
     376        update_terminal_cwd (); 
    376377    } 
    377378 
    378379    do_refresh (); 
    toggle_subshell (void) 
    567568    { 
    568569        update_panels (UP_OPTIMIZE, UP_KEEPSEL); 
    569570        update_xterm_title_path (); 
     571        update_terminal_cwd (); 
    570572    } 
    571573 
    572574    if (was_sigwinch != 0 || tty_got_winch ()) 
  • src/filemanager/boxes.c

    diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
    index 2dbc75d65..a6fc3f1d5 100644
    a b configure_box (void) 
    580580                                    &mc_global.widget.show_all_if_ambiguous, NULL), 
    581581                    QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash, NULL), 
    582582                    QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global.vfs.cd_symlinks, NULL), 
     583                    QUICK_CHECKBOX (N_("Auto cd new terminal"), &auto_cd_new_terminal, NULL),  /* w/o hotkey */ 
    583584                    QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete, NULL), 
    584585                    QUICK_CHECKBOX (N_("Safe overwrite"), &safe_overwrite, NULL),       /* w/o hotkey */ 
    585586                    QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup, NULL), 
    586587                    QUICK_SEPARATOR (FALSE), 
    587                     QUICK_SEPARATOR (FALSE), 
    588588                QUICK_STOP_GROUPBOX, 
    589589            QUICK_STOP_COLUMNS, 
    590590            QUICK_BUTTONS_OK_CANCEL, 
  • src/filemanager/layout.c

    diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c
    index 11607720d..6d445eb82 100644
    a b setup_panels (void) 
    913913    widget_set_visibility (WIDGET (the_bar), mc_global.keybar_visible); 
    914914 
    915915    update_xterm_title_path (); 
     916    update_terminal_cwd (); 
    916917 
    917918    /* unlock */ 
    918919    if (active) 
    update_xterm_title_path (void) 
    15671568        g_free (login); 
    15681569        g_free (path); 
    15691570 
    1570         fprintf (stdout, "\33]0;%s\7", str_term_form (p)); 
     1571        fprintf (stdout, "\33]0;%s\33\\", str_term_form (p)); 
    15711572        g_free (p); 
    15721573 
    15731574        if (!mc_global.tty.alternate_plus_minus) 
    update_xterm_title_path (void) 
    15771578} 
    15781579 
    15791580/* --------------------------------------------------------------------------------------------- */ 
     1581 
     1582/** Tell the current directory to the terminal so it can open new tabs there */ 
     1583void 
     1584update_terminal_cwd (void) 
     1585{ 
     1586    if (mc_global.tty.xterm_flag && auto_cd_new_terminal && vfs_current_is_local ()) 
     1587    { 
     1588        const gchar *host; 
     1589        char *path, *path_uri; 
     1590 
     1591        host = g_get_host_name (); 
     1592        path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_NONE); 
     1593        path_uri = g_uri_escape_string (path, "/", FALSE); 
     1594 
     1595        fprintf (stdout, "\33]7;file://%s%s\33\\", host, path_uri); 
     1596        (void) fflush (stdout); 
     1597 
     1598        g_free (path_uri); 
     1599        g_free (path); 
     1600    } 
     1601} 
     1602 
     1603/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/layout.h

    diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h
    index 2566cfa32..685f2c371 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 b1174c0bf..f14fd38d7 100644
    a b panel_do_cd_int (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum 
    34363436    load_hint (FALSE); 
    34373437    panel->dirty = TRUE; 
    34383438    update_xterm_title_path (); 
     3439    update_terminal_cwd (); 
    34393440 
    34403441    vfs_path_free (olddir_vpath, TRUE); 
    34413442 
    panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d 
    38233824            subshell_chdir (panel->cwd_vpath); 
    38243825 
    38253826        update_xterm_title_path (); 
     3827        update_terminal_cwd (); 
    38263828        select_item (panel); 
    38273829 
    38283830        bb = buttonbar_find (h); 
  • src/setup.c

    diff --git a/src/setup.c b/src/setup.c
    index 9d6e15348..b188de3e8 100644
    a b gboolean confirm_view_dir = FALSE; 
    112112/* Ask file name before start the editor */ 
    113113gboolean editor_ask_filename_before_edit = FALSE; 
    114114 
     115/* Tell cwd to the terminal so it can open new tabs there */ 
     116gboolean auto_cd_new_terminal = TRUE; 
     117 
    115118panel_view_mode_t startup_left_mode; 
    116119panel_view_mode_t startup_right_mode; 
    117120 
    static const struct 
    366369    { "mcview_remember_file_position", &mcview_remember_file_position }, 
    367370    { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, 
    368371    { "copymove_persistent_attr", &copymove_persistent_attr }, 
     372    { "auto_cd_new_terminal", &auto_cd_new_terminal }, 
    369373    { NULL, NULL } 
    370374}; 
    371375 
  • src/setup.h

    diff --git a/src/setup.h b/src/setup.h
    index b6e675d75..bbee32669 100644
    a b extern gboolean use_file_to_check_type; 
    100100#endif 
    101101extern gboolean file_op_compute_totals; 
    102102extern gboolean editor_ask_filename_before_edit; 
     103extern gboolean auto_cd_new_terminal; 
    103104 
    104105extern panels_options_t panels_options; 
    105106