From d6478b8b41796479e7d790f5d34663f33f60d25f Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 19 Oct 2012 10:55:15 +0300 Subject: [PATCH] move do_cd from src/main.c to src/filemanager/panel.c Signed-off-by: Slava Zanko --- src/filemanager/ext.c | 2 +- src/filemanager/panel.c | 35 ++++++++++++++++++++++++++++ src/filemanager/panel.h | 1 + src/main.c | 35 ---------------------------- src/main.h | 1 - tests/src/filemanager/do_panel_cd_stub_env.c | 9 ------- 6 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index 1a5203130..80ab38492 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -53,7 +53,6 @@ #include "src/setup.h" /* use_file_to_check_type */ #include "src/execute.h" #include "src/history.h" -#include "src/main.h" /* do_cd */ #include "src/consaver/cons.saver.h" #include "src/viewer/mcviewer.h" @@ -62,6 +61,7 @@ #include "src/selcodepage.h" /* do_set_codepage */ #endif +#include "panel.h" /* do_cd */ #include "usermenu.h" #include "ext.h" diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index f427504d8..288fa9a46 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -4788,3 +4788,38 @@ panel_deinit (void) } /* --------------------------------------------------------------------------------------------- */ + +gboolean +do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum exact) +{ + gboolean res; + const vfs_path_t *_new_dir_vpath = new_dir_vpath; + + if (current_panel->is_panelized) + { + size_t new_vpath_len; + + new_vpath_len = vfs_path_len (new_dir_vpath); + if (vfs_path_ncmp (new_dir_vpath, panelized_panel.root_vpath, new_vpath_len) == 0) + _new_dir_vpath = panelized_panel.root_vpath; + } + + res = do_panel_cd (current_panel, _new_dir_vpath, exact); + +#ifdef HAVE_CHARSET + if (res) + { + const vfs_path_element_t *path_element; + + path_element = vfs_path_get_by_index (current_panel->cwd_vpath, -1); + if (path_element->encoding != NULL) + current_panel->codepage = get_codepage_index (path_element->encoding); + else + current_panel->codepage = SELECT_CHARSET_NO_TRANSLATE; + } +#endif /* HAVE_CHARSET */ + + return res; +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/panel.h b/src/filemanager/panel.h index 8c99e2d18..6b2436df5 100644 --- a/src/filemanager/panel.h +++ b/src/filemanager/panel.h @@ -182,6 +182,7 @@ void panel_set_lwd (WPanel * panel, const char *path_str); void panel_init (void); void panel_deinit (void); +gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type); /*** inline functions ****************************************************************************/ #endif /* MC__PANEL_H */ diff --git a/src/main.c b/src/main.c index 54819ae7a..4222a5eef 100644 --- a/src/main.c +++ b/src/main.c @@ -274,41 +274,6 @@ init_sigchld (void) /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -gboolean -do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum exact) -{ - gboolean res; - const vfs_path_t *_new_dir_vpath = new_dir_vpath; - - if (current_panel->is_panelized) - { - size_t new_vpath_len; - - new_vpath_len = vfs_path_len (new_dir_vpath); - if (vfs_path_ncmp (new_dir_vpath, panelized_panel.root_vpath, new_vpath_len) == 0) - _new_dir_vpath = panelized_panel.root_vpath; - } - - res = do_panel_cd (current_panel, _new_dir_vpath, exact); - -#ifdef HAVE_CHARSET - if (res) - { - const vfs_path_element_t *path_element; - - path_element = vfs_path_get_by_index (current_panel->cwd_vpath, -1); - if (path_element->encoding != NULL) - current_panel->codepage = get_codepage_index (path_element->encoding); - else - current_panel->codepage = SELECT_CHARSET_NO_TRANSLATE; - } -#endif /* HAVE_CHARSET */ - - return res; -} - -/* --------------------------------------------------------------------------------------------- */ - #ifdef HAVE_SUBSHELL_SUPPORT gboolean do_load_prompt (void) diff --git a/src/main.h b/src/main.h index 03800374c..e363ca7ae 100644 --- a/src/main.h +++ b/src/main.h @@ -90,7 +90,6 @@ gboolean do_load_prompt (void); int load_prompt (int fd, void *unused); #endif -gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type); void update_xterm_title_path (void); void title_path_prepare (char **path, char **login); diff --git a/tests/src/filemanager/do_panel_cd_stub_env.c b/tests/src/filemanager/do_panel_cd_stub_env.c index dea3ba2a0..05d227b8c 100644 --- a/tests/src/filemanager/do_panel_cd_stub_env.c +++ b/tests/src/filemanager/do_panel_cd_stub_env.c @@ -47,15 +47,6 @@ command_new (int y, int x, int cols) return cmd; } -int -do_cd (const vfs_path_t *new_dir, enum cd_enum exact) -{ - (void) new_dir; - (void) exact; - - return 0; -} - void do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt) { -- 2.11.4.GIT