2 Main dialog (file panels) of the Midnight Commander
4 Copyright (C) 1994-2024
5 Free Software Foundation, Inc.
8 Miguel de Icaza, 1994, 1995, 1996, 1997
9 Janne Kukonlehto, 1994, 1995
11 Andrew Borodin <aborodin@vmail.ru>, 2009-2022
12 Slava Zanko <slavazanko@gmail.com>, 2013
14 This file is part of the Midnight Commander.
16 The Midnight Commander is free software: you can redistribute it
17 and/or modify it under the terms of the GNU General Public License as
18 published by the Free Software Foundation, either version 3 of the License,
19 or (at your option) any later version.
21 The Midnight Commander is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 /** \file filemanager.c
31 * \brief Source: main dialog (file panels) of the Midnight Commander
41 #include <sys/types.h>
44 #include <pwd.h> /* for username in xterm title */
46 #include "lib/global.h"
47 #include "lib/fileloc.h" /* MC_HINT */
49 #include "lib/tty/tty.h"
50 #include "lib/tty/key.h" /* KEY_M_* masks */
54 #include "lib/vfs/vfs.h"
57 #ifdef ENABLE_SUBSHELL
58 #include "src/subshell/subshell.h"
60 #include "src/execute.h" /* toggle_subshell */
61 #include "src/setup.h" /* variables */
62 #include "src/learn.h" /* learn_keys() */
63 #include "src/keymap.h"
64 #include "src/usermenu.h" /* user_file_menu_cmd() */
65 #include "lib/fileloc.h" /* MC_FILEPOS_FILE */
66 #include "lib/keybind.h"
67 #include "lib/event.h"
70 #include "boxes.h" /* sort_box(), tree_box() */
72 #include "cmd.h" /* commands */
75 #include "command.h" /* cmdline */
76 #include "dir.h" /* dir_list_clean() */
78 #ifdef USE_INTERNAL_EDIT
79 #include "src/editor/edit.h"
83 #include "src/diffviewer/ydiff.h"
86 #include "src/consaver/cons.saver.h" /* show_console_contents */
87 #include "src/file_history.h" /* show_file_history() */
89 #include "filemanager.h"
91 /*** global variables ****************************************************************************/
93 /* When the modes are active, left_panel, right_panel and tree_panel */
94 /* point to a proper data structure. You should check with the functions */
95 /* get_current_type and get_other_type the types of the panels before using */
96 /* this pointer variables */
98 /* The structures for the panels */
99 WPanel
*left_panel
= NULL
;
100 WPanel
*right_panel
= NULL
;
101 /* Pointer to the selected and unselected panel */
102 WPanel
*current_panel
= NULL
;
105 WMenuBar
*the_menubar
= NULL
;
106 /* The widget where we draw the prompt */
114 const char *mc_prompt
= NULL
;
116 /*** file scope macro definitions ****************************************************************/
120 * Don't restrict the output on the screen manager level,
121 * the translation tables take care of it.
123 #endif /* !HAVE_CHARSET */
125 /*** file scope type declarations ****************************************************************/
127 /*** forward declarations (file scope functions) *************************************************/
129 /*** file scope variables ************************************************************************/
131 static menu_t
*left_menu
, *right_menu
;
133 /* --------------------------------------------------------------------------------------------- */
134 /*** file scope functions ************************************************************************/
135 /* --------------------------------------------------------------------------------------------- */
137 /** Stop MC main dialog and the current dialog if it exists.
138 * Needed to provide fast exit from MC viewer or editor on shell exit */
142 dlg_close (filemanager
);
145 dlg_close (DIALOG (top_dlg
->data
));
148 /* --------------------------------------------------------------------------------------------- */
153 const file_entry_t
*fe
;
156 fe
= panel_current_entry (current_panel
);
160 sel_dir
= tree_box (fe
->fname
->str
);
163 vfs_path_t
*sel_vdir
;
165 sel_vdir
= vfs_path_from_str (sel_dir
);
166 panel_cd (current_panel
, sel_vdir
, cd_exact
);
167 vfs_path_free (sel_vdir
, TRUE
);
172 /* --------------------------------------------------------------------------------------------- */
174 #ifdef LISTMODE_EDITOR
180 if (get_current_type () != view_listing
)
183 newmode
= listmode_edit (current_panel
->user_format
);
187 g_free (current_panel
->user_format
);
188 current_panel
->list_format
= list_user
;
189 current_panel
->user_format
= newmode
;
190 set_panel_formats (current_panel
);
194 #endif /* LISTMODE_EDITOR */
196 /* --------------------------------------------------------------------------------------------- */
199 create_panel_menu (void)
201 GList
*entries
= NULL
;
203 entries
= g_list_prepend (entries
, menu_entry_new (_("File listin&g"), CK_PanelListing
));
204 entries
= g_list_prepend (entries
, menu_entry_new (_("&Quick view"), CK_PanelQuickView
));
205 entries
= g_list_prepend (entries
, menu_entry_new (_("&Info"), CK_PanelInfo
));
206 entries
= g_list_prepend (entries
, menu_entry_new (_("&Tree"), CK_PanelTree
));
207 entries
= g_list_prepend (entries
, menu_separator_new ());
209 g_list_prepend (entries
, menu_entry_new (_("&Listing format..."), CK_SetupListingFormat
));
210 entries
= g_list_prepend (entries
, menu_entry_new (_("&Sort order..."), CK_Sort
));
211 entries
= g_list_prepend (entries
, menu_entry_new (_("&Filter..."), CK_Filter
));
213 entries
= g_list_prepend (entries
, menu_entry_new (_("&Encoding..."), CK_SelectCodepage
));
215 entries
= g_list_prepend (entries
, menu_separator_new ());
216 #ifdef ENABLE_VFS_FTP
217 entries
= g_list_prepend (entries
, menu_entry_new (_("FT&P link..."), CK_ConnectFtp
));
219 #ifdef ENABLE_VFS_SHELL
220 entries
= g_list_prepend (entries
, menu_entry_new (_("S&hell link..."), CK_ConnectShell
));
222 #ifdef ENABLE_VFS_SFTP
223 entries
= g_list_prepend (entries
, menu_entry_new (_("SFTP li&nk..."), CK_ConnectSftp
));
225 entries
= g_list_prepend (entries
, menu_entry_new (_("Paneli&ze"), CK_Panelize
));
226 entries
= g_list_prepend (entries
, menu_separator_new ());
227 entries
= g_list_prepend (entries
, menu_entry_new (_("&Rescan"), CK_Reread
));
229 return g_list_reverse (entries
);
232 /* --------------------------------------------------------------------------------------------- */
235 create_file_menu (void)
237 GList
*entries
= NULL
;
239 entries
= g_list_prepend (entries
, menu_entry_new (_("&View"), CK_View
));
240 entries
= g_list_prepend (entries
, menu_entry_new (_("Vie&w file..."), CK_ViewFile
));
241 entries
= g_list_prepend (entries
, menu_entry_new (_("&Filtered view"), CK_ViewFiltered
));
242 entries
= g_list_prepend (entries
, menu_entry_new (_("&Edit"), CK_Edit
));
243 entries
= g_list_prepend (entries
, menu_entry_new (_("&Copy"), CK_Copy
));
244 entries
= g_list_prepend (entries
, menu_entry_new (_("C&hmod"), CK_ChangeMode
));
245 entries
= g_list_prepend (entries
, menu_entry_new (_("&Link"), CK_Link
));
246 entries
= g_list_prepend (entries
, menu_entry_new (_("&Symlink"), CK_LinkSymbolic
));
248 g_list_prepend (entries
, menu_entry_new (_("Relative symlin&k"), CK_LinkSymbolicRelative
));
249 entries
= g_list_prepend (entries
, menu_entry_new (_("Edit s&ymlink"), CK_LinkSymbolicEdit
));
250 entries
= g_list_prepend (entries
, menu_entry_new (_("Ch&own"), CK_ChangeOwn
));
251 entries
= g_list_prepend (entries
, menu_entry_new (_("&Advanced chown"), CK_ChangeOwnAdvanced
));
252 #ifdef ENABLE_EXT2FS_ATTR
253 entries
= g_list_prepend (entries
, menu_entry_new (_("Cha&ttr"), CK_ChangeAttributes
));
255 entries
= g_list_prepend (entries
, menu_entry_new (_("&Rename/Move"), CK_Move
));
256 entries
= g_list_prepend (entries
, menu_entry_new (_("&Mkdir"), CK_MakeDir
));
257 entries
= g_list_prepend (entries
, menu_entry_new (_("&Delete"), CK_Delete
));
258 entries
= g_list_prepend (entries
, menu_entry_new (_("&Quick cd"), CK_CdQuick
));
259 entries
= g_list_prepend (entries
, menu_separator_new ());
260 entries
= g_list_prepend (entries
, menu_entry_new (_("Select &group"), CK_Select
));
261 entries
= g_list_prepend (entries
, menu_entry_new (_("U&nselect group"), CK_Unselect
));
262 entries
= g_list_prepend (entries
, menu_entry_new (_("&Invert selection"), CK_SelectInvert
));
263 entries
= g_list_prepend (entries
, menu_separator_new ());
264 entries
= g_list_prepend (entries
, menu_entry_new (_("E&xit"), CK_Quit
));
266 return g_list_reverse (entries
);
269 /* --------------------------------------------------------------------------------------------- */
272 create_command_menu (void)
274 /* I know, I'm lazy, but the tree widget when it's not running
275 * as a panel still has some problems, I have not yet finished
276 * the WTree widget port, sorry.
278 GList
*entries
= NULL
;
280 entries
= g_list_prepend (entries
, menu_entry_new (_("&User menu"), CK_UserMenu
));
281 entries
= g_list_prepend (entries
, menu_entry_new (_("&Directory tree"), CK_Tree
));
282 entries
= g_list_prepend (entries
, menu_entry_new (_("&Find file"), CK_Find
));
283 entries
= g_list_prepend (entries
, menu_entry_new (_("S&wap panels"), CK_Swap
));
284 entries
= g_list_prepend (entries
, menu_entry_new (_("Switch &panels on/off"), CK_Shell
));
285 entries
= g_list_prepend (entries
, menu_entry_new (_("&Compare directories"), CK_CompareDirs
));
287 entries
= g_list_prepend (entries
, menu_entry_new (_("C&ompare files"), CK_CompareFiles
));
290 g_list_prepend (entries
, menu_entry_new (_("E&xternal panelize"), CK_ExternalPanelize
));
291 entries
= g_list_prepend (entries
, menu_entry_new (_("Show directory s&izes"), CK_DirSize
));
292 entries
= g_list_prepend (entries
, menu_separator_new ());
293 entries
= g_list_prepend (entries
, menu_entry_new (_("Command &history"), CK_History
));
295 g_list_prepend (entries
,
296 menu_entry_new (_("Viewed/edited files hi&story"), CK_EditorViewerHistory
));
297 entries
= g_list_prepend (entries
, menu_entry_new (_("Di&rectory hotlist"), CK_HotList
));
299 entries
= g_list_prepend (entries
, menu_entry_new (_("&Active VFS list"), CK_VfsList
));
301 #ifdef ENABLE_BACKGROUND
302 entries
= g_list_prepend (entries
, menu_entry_new (_("&Background jobs"), CK_Jobs
));
304 entries
= g_list_prepend (entries
, menu_entry_new (_("Screen lis&t"), CK_ScreenList
));
305 entries
= g_list_prepend (entries
, menu_separator_new ());
306 #ifdef ENABLE_VFS_UNDELFS
308 g_list_prepend (entries
, menu_entry_new (_("&Undelete files (ext2fs only)"), CK_Undelete
));
310 #ifdef LISTMODE_EDITOR
311 entries
= g_list_prepend (entries
, menu_entry_new (_("&Listing format edit"), CK_ListMode
));
313 #if defined (ENABLE_VFS_UNDELFS) || defined (LISTMODE_EDITOR)
314 entries
= g_list_prepend (entries
, menu_separator_new ());
317 g_list_prepend (entries
, menu_entry_new (_("Edit &extension file"), CK_EditExtensionsFile
));
318 entries
= g_list_prepend (entries
, menu_entry_new (_("Edit &menu file"), CK_EditUserMenu
));
320 g_list_prepend (entries
,
321 menu_entry_new (_("Edit hi&ghlighting group file"),
322 CK_EditFileHighlightFile
));
324 return g_list_reverse (entries
);
327 /* --------------------------------------------------------------------------------------------- */
330 create_options_menu (void)
332 GList
*entries
= NULL
;
334 entries
= g_list_prepend (entries
, menu_entry_new (_("&Configuration..."), CK_Options
));
335 entries
= g_list_prepend (entries
, menu_entry_new (_("&Layout..."), CK_OptionsLayout
));
336 entries
= g_list_prepend (entries
, menu_entry_new (_("&Panel options..."), CK_OptionsPanel
));
337 entries
= g_list_prepend (entries
, menu_entry_new (_("C&onfirmation..."), CK_OptionsConfirm
));
338 entries
= g_list_prepend (entries
, menu_entry_new (_("&Appearance..."), CK_OptionsAppearance
));
340 g_list_prepend (entries
, menu_entry_new (_("&Display bits..."), CK_OptionsDisplayBits
));
341 entries
= g_list_prepend (entries
, menu_entry_new (_("Learn &keys..."), CK_LearnKeys
));
343 entries
= g_list_prepend (entries
, menu_entry_new (_("&Virtual FS..."), CK_OptionsVfs
));
345 entries
= g_list_prepend (entries
, menu_separator_new ());
346 entries
= g_list_prepend (entries
, menu_entry_new (_("&Save setup"), CK_SaveSetup
));
348 return g_list_reverse (entries
);
351 /* --------------------------------------------------------------------------------------------- */
356 left_menu
= menu_new ("", create_panel_menu (), "[Left and Right Menus]");
357 menubar_add_menu (the_menubar
, left_menu
);
358 menubar_add_menu (the_menubar
, menu_new (_("&File"), create_file_menu (), "[File Menu]"));
359 menubar_add_menu (the_menubar
,
360 menu_new (_("&Command"), create_command_menu (), "[Command Menu]"));
361 menubar_add_menu (the_menubar
,
362 menu_new (_("&Options"), create_options_menu (), "[Options Menu]"));
363 right_menu
= menu_new ("", create_panel_menu (), "[Left and Right Menus]");
364 menubar_add_menu (the_menubar
, right_menu
);
368 /* --------------------------------------------------------------------------------------------- */
371 menu_last_selected_cmd (void)
373 menubar_activate (the_menubar
, drop_menus
, -1);
376 /* --------------------------------------------------------------------------------------------- */
383 if ((get_current_index () == 0) == current_panel
->active
)
386 selected
= g_list_length (the_menubar
->menu
) - 1;
388 menubar_activate (the_menubar
, drop_menus
, selected
);
391 /* --------------------------------------------------------------------------------------------- */
397 const panel_field_t
*sort_order
;
399 if (!SELECTED_IS_PANEL
)
403 sort_order
= sort_box (&p
->sort_info
, p
->sort_field
);
404 panel_set_sort_order (p
, sort_order
);
407 /* --------------------------------------------------------------------------------------------- */
410 midnight_get_shortcut (long command
)
413 const char *shortcut
= NULL
;
415 shortcut
= keybind_lookup_keymap_shortcut (filemanager_map
, command
);
416 if (shortcut
!= NULL
)
417 return g_strdup (shortcut
);
419 shortcut
= keybind_lookup_keymap_shortcut (panel_map
, command
);
420 if (shortcut
!= NULL
)
421 return g_strdup (shortcut
);
423 ext_map
= keybind_lookup_keymap_shortcut (filemanager_map
, CK_ExtendedKeyMap
);
425 shortcut
= keybind_lookup_keymap_shortcut (filemanager_x_map
, command
);
426 if (shortcut
!= NULL
)
427 return g_strdup_printf ("%s %s", ext_map
, shortcut
);
432 /* --------------------------------------------------------------------------------------------- */
435 midnight_get_title (const WDialog
*h
, size_t len
)
443 title_path_prepare (&path
, &login
);
445 p
= g_strdup_printf ("%s [%s]:%s", _("Panels:"), login
, path
);
448 path
= g_strdup (str_trunc (p
, len
- 4));
454 /* --------------------------------------------------------------------------------------------- */
457 toggle_panels_split (void)
459 panels_layout
.horizontal_split
= !panels_layout
.horizontal_split
;
464 /* --------------------------------------------------------------------------------------------- */
469 check_panel_timestamp (const WPanel
*panel
, panel_view_mode_t mode
, const struct vfs_class
*vclass
,
472 return (mode
!= view_listing
|| (vfs_path_get_last_path_vfs (panel
->cwd_vpath
) == vclass
473 && vfs_getid (panel
->cwd_vpath
) == id
));
476 /* --------------------------------------------------------------------------------------------- */
480 check_current_panel_timestamp (const gchar
*event_group_name
, const gchar
*event_name
,
481 gpointer init_data
, gpointer data
)
483 ev_vfs_stamp_create_t
*event_data
= (ev_vfs_stamp_create_t
*) data
;
485 (void) event_group_name
;
490 check_panel_timestamp (current_panel
, get_current_type (), event_data
->vclass
,
492 return !event_data
->ret
;
495 /* --------------------------------------------------------------------------------------------- */
499 check_other_panel_timestamp (const gchar
*event_group_name
, const gchar
*event_name
,
500 gpointer init_data
, gpointer data
)
502 ev_vfs_stamp_create_t
*event_data
= (ev_vfs_stamp_create_t
*) data
;
504 (void) event_group_name
;
509 check_panel_timestamp (other_panel
, get_other_type (), event_data
->vclass
, event_data
->id
);
510 return !event_data
->ret
;
512 #endif /* ENABLE_VFS */
514 /* --------------------------------------------------------------------------------------------- */
518 print_vfs_message (const gchar
*event_group_name
, const gchar
*event_name
,
519 gpointer init_data
, gpointer data
)
521 ev_vfs_print_message_t
*event_data
= (ev_vfs_print_message_t
*) data
;
523 (void) event_group_name
;
527 if (mc_global
.midnight_shutdown
)
530 if (!mc_global
.message_visible
|| the_hint
== NULL
|| WIDGET (the_hint
)->owner
== NULL
)
534 if (!nice_rotating_dash
|| (ok_to_refresh
<= 0))
537 /* Preserve current cursor position */
538 tty_getyx (&row
, &col
);
541 tty_setcolor (NORMAL_COLOR
);
542 tty_print_string (str_fit_to_term (event_data
->msg
, COLS
- 1, J_LEFT
));
544 /* Restore cursor position */
545 tty_gotoyx (row
, col
);
550 if (mc_global
.message_visible
)
551 set_hintbar (event_data
->msg
);
554 MC_PTR_FREE (event_data
->msg
);
558 /* --------------------------------------------------------------------------------------------- */
563 int current_index
, other_index
;
564 panel_view_mode_t current_mode
, other_mode
;
565 char *current_dir
, *other_dir
;
566 vfs_path_t
*original_dir
;
569 * Following cases from command line are possible:
570 * 'mc' (no arguments): mc_run_param0 == NULL, mc_run_param1 == NULL
571 * active panel uses current directory
572 * passive panel uses "other_dir" from panels.ini
574 * 'mc dir1 dir2' (two arguments): mc_run_param0 != NULL, mc_run_param1 != NULL
575 * active panel uses mc_run_param0
576 * passive panel uses mc_run_param1
578 * 'mc dir1' (single argument): mc_run_param0 != NULL, mc_run_param1 == NULL
579 * active panel uses mc_run_param0
580 * passive panel uses "other_dir" from panels.ini
583 /* Set up panel directories */
584 if (boot_current_is_left
)
586 /* left panel is active */
589 current_mode
= startup_left_mode
;
590 other_mode
= startup_right_mode
;
592 if (mc_run_param0
== NULL
&& mc_run_param1
== NULL
)
595 current_dir
= NULL
; /* assume current dir */
596 other_dir
= saved_other_dir
; /* from ini */
598 else if (mc_run_param0
!= NULL
&& mc_run_param1
!= NULL
)
601 current_dir
= (char *) mc_run_param0
;
602 other_dir
= mc_run_param1
;
604 else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
607 current_dir
= (char *) mc_run_param0
;
608 other_dir
= saved_other_dir
; /* from ini */
613 /* right panel is active */
616 current_mode
= startup_right_mode
;
617 other_mode
= startup_left_mode
;
619 if (mc_run_param0
== NULL
&& mc_run_param1
== NULL
)
622 current_dir
= NULL
; /* assume current dir */
623 other_dir
= saved_other_dir
; /* from ini */
625 else if (mc_run_param0
!= NULL
&& mc_run_param1
!= NULL
)
628 current_dir
= (char *) mc_run_param0
;
629 other_dir
= mc_run_param1
;
631 else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
634 current_dir
= (char *) mc_run_param0
;
635 other_dir
= saved_other_dir
; /* from ini */
639 /* 1. Get current dir */
640 original_dir
= vfs_path_clone (vfs_get_raw_current_dir ());
642 /* 2. Create passive panel */
643 if (other_dir
!= NULL
)
647 if (g_path_is_absolute (other_dir
))
648 vpath
= vfs_path_from_str (other_dir
);
650 vpath
= vfs_path_append_new (original_dir
, other_dir
, (char *) NULL
);
652 vfs_path_free (vpath
, TRUE
);
654 create_panel (other_index
, other_mode
);
656 /* 3. Create active panel */
657 if (current_dir
== NULL
)
658 mc_chdir (original_dir
);
663 if (g_path_is_absolute (current_dir
))
664 vpath
= vfs_path_from_str (current_dir
);
666 vpath
= vfs_path_append_new (original_dir
, current_dir
, (char *) NULL
);
668 vfs_path_free (vpath
, TRUE
);
670 create_panel (current_index
, current_mode
);
672 if (startup_left_mode
== view_listing
)
673 current_panel
= left_panel
;
674 else if (right_panel
!= NULL
)
675 current_panel
= right_panel
;
677 current_panel
= left_panel
;
679 vfs_path_free (original_dir
, TRUE
);
682 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_timestamp", check_other_panel_timestamp
, NULL
, NULL
);
683 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_timestamp", check_current_panel_timestamp
, NULL
, NULL
);
684 #endif /* ENABLE_VFS */
686 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_print_message", print_vfs_message
, NULL
, NULL
);
689 /* --------------------------------------------------------------------------------------------- */
692 midnight_put_panel_path (WPanel
*panel
)
694 vfs_path_t
*cwd_vpath
;
695 const char *cwd_vpath_str
;
701 cwd_vpath
= remove_encoding_from_path (panel
->cwd_vpath
);
703 cwd_vpath
= vfs_path_clone (panel
->cwd_vpath
);
706 cwd_vpath_str
= vfs_path_as_str (cwd_vpath
);
708 command_insert (cmdline
, cwd_vpath_str
, FALSE
);
710 if (!IS_PATH_SEP (cwd_vpath_str
[strlen (cwd_vpath_str
) - 1]))
711 command_insert (cmdline
, PATH_SEP_STR
, FALSE
);
713 vfs_path_free (cwd_vpath
, TRUE
);
716 /* --------------------------------------------------------------------------------------------- */
719 put_link (WPanel
*panel
)
721 const file_entry_t
*fe
;
726 fe
= panel_current_entry (panel
);
728 if (fe
!= NULL
&& S_ISLNK (fe
->st
.st_mode
))
730 char buffer
[MC_MAXPATHLEN
];
734 vpath
= vfs_path_append_new (panel
->cwd_vpath
, fe
->fname
->str
, (char *) NULL
);
735 i
= mc_readlink (vpath
, buffer
, sizeof (buffer
) - 1);
736 vfs_path_free (vpath
, TRUE
);
741 command_insert (cmdline
, buffer
, TRUE
);
746 /* --------------------------------------------------------------------------------------------- */
749 put_current_link (void)
751 put_link (current_panel
);
754 /* --------------------------------------------------------------------------------------------- */
757 put_other_link (void)
759 if (get_other_type () == view_listing
)
760 put_link (other_panel
);
763 /* --------------------------------------------------------------------------------------------- */
765 /** Insert the selected file name into the input line */
767 put_current_selected (void)
772 if (get_current_type () == view_tree
)
775 const vfs_path_t
*selected_name
;
777 tree
= (WTree
*) get_panel_widget (get_current_index ());
778 selected_name
= tree_selected_name (tree
);
779 command_insert (cmdline
, vfs_path_as_str (selected_name
), TRUE
);
783 const file_entry_t
*fe
;
785 fe
= panel_current_entry (current_panel
);
787 command_insert (cmdline
, fe
->fname
->str
, TRUE
);
791 /* --------------------------------------------------------------------------------------------- */
794 put_tagged (WPanel
*panel
)
799 input_disable_update (cmdline
);
801 if (panel
->marked
== 0)
803 const file_entry_t
*fe
;
805 fe
= panel_current_entry (current_panel
);
807 command_insert (cmdline
, fe
->fname
->str
, TRUE
);
813 for (i
= 0; i
< panel
->dir
.len
; i
++)
814 if (panel
->dir
.list
[i
].f
.marked
!= 0)
815 command_insert (cmdline
, panel
->dir
.list
[i
].fname
->str
, TRUE
);
818 input_enable_update (cmdline
);
821 /* --------------------------------------------------------------------------------------------- */
824 put_current_tagged (void)
826 put_tagged (current_panel
);
829 /* --------------------------------------------------------------------------------------------- */
832 put_other_tagged (void)
834 if (get_other_type () == view_listing
)
835 put_tagged (other_panel
);
838 /* --------------------------------------------------------------------------------------------- */
845 tty_display_8bit (TRUE
);
847 tty_display_8bit (mc_global
.full_eight_bits
);
848 #endif /* HAVE_CHARSET */
850 #else /* HAVE_SLANG */
853 tty_display_8bit (TRUE
);
855 tty_display_8bit (mc_global
.eight_bit_clean
);
856 #endif /* HAVE_CHARSET */
857 #endif /* HAVE_SLANG */
859 if ((tty_baudrate () < 9600) || mc_global
.tty
.slow_terminal
)
863 /* --------------------------------------------------------------------------------------------- */
866 setup_dummy_mc (void)
874 vpath
= vfs_path_from_str (d
);
875 ret
= mc_chdir (vpath
);
877 vfs_path_free (vpath
, TRUE
);
881 /* --------------------------------------------------------------------------------------------- */
888 * We sync the profiles since the hotlist may have changed, while
889 * we only change the setup data if we have the auto save feature set
892 save_setup (auto_save_setup
, panels_options
.auto_save_setup
);
894 vfs_stamp_path (vfs_get_raw_current_dir ());
897 /* --------------------------------------------------------------------------------------------- */
900 create_file_manager (void)
902 Widget
*w
= WIDGET (filemanager
);
903 WGroup
*g
= GROUP (filemanager
);
905 w
->keymap
= filemanager_map
;
906 w
->ext_keymap
= filemanager_x_map
;
908 filemanager
->get_shortcut
= midnight_get_shortcut
;
909 filemanager
->get_title
= midnight_get_title
;
910 /* allow rebind tab */
911 widget_want_tab (w
, TRUE
);
913 the_menubar
= menubar_new (NULL
);
914 group_add_widget (g
, the_menubar
);
918 group_add_widget (g
, get_panel_widget (0));
919 group_add_widget (g
, get_panel_widget (1));
921 the_hint
= label_new (0, 0, NULL
);
922 the_hint
->transparent
= TRUE
;
923 the_hint
->auto_adjust_cols
= 0;
924 WIDGET (the_hint
)->rect
.cols
= COLS
;
925 group_add_widget (g
, the_hint
);
927 cmdline
= command_new (0, 0, 0);
928 group_add_widget (g
, cmdline
);
930 the_prompt
= label_new (0, 0, mc_prompt
);
931 the_prompt
->transparent
= TRUE
;
932 group_add_widget (g
, the_prompt
);
934 the_bar
= buttonbar_new ();
935 group_add_widget (g
, the_bar
);
936 midnight_set_buttonbar (the_bar
);
938 #ifdef ENABLE_SUBSHELL
939 /* Must be done after creation of cmdline and prompt widgets to avoid potential
940 NULL dereference in load_prompt() -> ... -> setup_cmdline() -> label_set_text(). */
941 if (mc_global
.tty
.use_subshell
)
942 add_select_channel (mc_global
.tty
.subshell_pty
, load_prompt
, NULL
);
943 #endif /* !ENABLE_SUBSHELL */
946 /* --------------------------------------------------------------------------------------------- */
948 /** result must be free'd (I think this should go in util.c) */
950 prepend_cwd_on_local (const char *filename
)
954 vpath
= vfs_path_from_str (filename
);
955 if (!vfs_file_is_local (vpath
) || g_path_is_absolute (filename
))
958 vfs_path_free (vpath
, TRUE
);
960 return vfs_path_append_new (vfs_get_raw_current_dir (), filename
, (char *) NULL
);
963 /* --------------------------------------------------------------------------------------------- */
965 /** Invoke the internal view/edit routine with:
966 * the default processing and forcing the internal viewer/editor
969 mc_maybe_editor_or_viewer (void)
973 switch (mc_global
.mc_run_mode
)
975 #ifdef USE_INTERNAL_EDIT
977 ret
= edit_files ((GList
*) mc_run_param0
);
979 #endif /* USE_INTERNAL_EDIT */
982 vfs_path_t
*vpath
= NULL
;
984 if (mc_run_param0
!= NULL
&& *(char *) mc_run_param0
!= '\0')
985 vpath
= prepend_cwd_on_local ((char *) mc_run_param0
);
987 ret
= view_file (vpath
, FALSE
, TRUE
);
988 vfs_path_free (vpath
, TRUE
);
992 case MC_RUN_DIFFVIEWER
:
993 ret
= dview_diff_cmd (mc_run_param0
, mc_run_param1
);
995 #endif /* USE_DIFF_VIEW */
1003 /* --------------------------------------------------------------------------------------------- */
1006 show_editor_viewer_history (void)
1011 s
= show_file_history (WIDGET (filemanager
), &act
);
1014 vfs_path_t
*s_vpath
;
1019 s_vpath
= vfs_path_from_str (s
);
1020 edit_file_at_line (s_vpath
, use_internal_edit
, 0);
1024 s_vpath
= vfs_path_from_str (s
);
1025 view_file (s_vpath
, use_internal_view
, FALSE
);
1032 d
= g_path_get_dirname (s
);
1033 s_vpath
= vfs_path_from_str (d
);
1034 panel_cd (current_panel
, s_vpath
, cd_exact
);
1035 panel_set_current_by_name (current_panel
, s
);
1041 vfs_path_free (s_vpath
, TRUE
);
1045 /* --------------------------------------------------------------------------------------------- */
1048 quit_cmd_internal (int quiet
)
1053 n
= dialog_switch_num () - 1;
1056 char msg
[BUF_MEDIUM
];
1058 g_snprintf (msg
, sizeof (msg
),
1059 ngettext ("You have %zu opened screen. Quit anyway?",
1060 "You have %zu opened screens. Quit anyway?", n
), n
);
1062 if (query_dialog (_("The Midnight Commander"), msg
, D_NORMAL
, 2, _("&Yes"), _("&No")) != 0)
1066 else if (quiet
|| !confirm_exit
)
1068 else if (query_dialog (_("The Midnight Commander"),
1069 _("Do you really want to quit the Midnight Commander?"),
1070 D_NORMAL
, 2, _("&Yes"), _("&No")) == 0)
1075 #ifdef ENABLE_SUBSHELL
1076 if (!mc_global
.tty
.use_subshell
)
1078 else if ((q
= exit_subshell ()? 1 : 0) != 0)
1088 /* --------------------------------------------------------------------------------------------- */
1093 return quit_cmd_internal (0);
1096 /* --------------------------------------------------------------------------------------------- */
1099 * Repaint the contents of the panels without frames. To schedule panel
1100 * for repainting, set panel->dirty to TRUE. There are many reasons why
1101 * the panels need to be repainted, and this is a costly operation, so
1102 * it's done once per event.
1106 update_dirty_panels (void)
1108 if (get_current_type () == view_listing
&& current_panel
->dirty
)
1109 widget_draw (WIDGET (current_panel
));
1111 if (get_other_type () == view_listing
&& other_panel
->dirty
)
1112 widget_draw (WIDGET (other_panel
));
1115 /* --------------------------------------------------------------------------------------------- */
1118 toggle_show_hidden (void)
1120 panels_options
.show_dot_files
= !panels_options
.show_dot_files
;
1121 update_panels (UP_RELOAD
, UP_KEEPSEL
);
1122 /* redraw panels forced */
1123 update_dirty_panels ();
1126 /* --------------------------------------------------------------------------------------------- */
1129 midnight_execute_cmd (Widget
*sender
, long command
)
1131 cb_ret_t res
= MSG_HANDLED
;
1135 /* stop quick search before executing any command */
1136 send_message (current_panel
, NULL
, MSG_ACTION
, CK_SearchStop
, NULL
);
1140 case CK_ChangePanel
:
1141 (void) change_panel ();
1144 add2hotlist_cmd (current_panel
);
1146 case CK_SetupListingFormat
:
1147 setup_listing_format_cmd ();
1150 chmod_cmd (current_panel
);
1153 chown_cmd (current_panel
);
1155 case CK_ChangeOwnAdvanced
:
1156 advanced_chown_cmd (current_panel
);
1158 #ifdef ENABLE_EXT2FS_ATTR
1159 case CK_ChangeAttributes
:
1160 chattr_cmd (current_panel
);
1163 case CK_CompareDirs
:
1164 compare_dirs_cmd ();
1171 configure_vfs_box ();
1174 case CK_OptionsConfirm
:
1178 copy_cmd (current_panel
);
1180 case CK_PutCurrentPath
:
1181 midnight_put_panel_path (current_panel
);
1183 case CK_PutCurrentSelected
:
1184 put_current_selected ();
1186 case CK_PutCurrentFullSelected
:
1187 midnight_put_panel_path (current_panel
);
1188 put_current_selected ();
1190 case CK_PutCurrentLink
:
1191 put_current_link ();
1193 case CK_PutCurrentTagged
:
1194 put_current_tagged ();
1196 case CK_PutOtherPath
:
1197 if (get_other_type () == view_listing
)
1198 midnight_put_panel_path (other_panel
);
1200 case CK_PutOtherLink
:
1203 case CK_PutOtherTagged
:
1204 put_other_tagged ();
1207 delete_cmd (current_panel
);
1210 dialog_switch_list ();
1212 #ifdef USE_DIFF_VIEW
1213 case CK_CompareFiles
:
1217 case CK_OptionsDisplayBits
:
1218 display_bits_box ();
1221 edit_cmd (current_panel
);
1223 #ifdef USE_INTERNAL_EDIT
1224 case CK_EditForceInternal
:
1225 edit_cmd_force_internal (current_panel
);
1228 case CK_EditExtensionsFile
:
1231 case CK_EditFileHighlightFile
:
1234 case CK_EditUserMenu
:
1235 edit_mc_menu_cmd ();
1237 case CK_LinkSymbolicEdit
:
1238 edit_symlink_cmd ();
1240 case CK_ExternalPanelize
:
1241 external_panelize_cmd ();
1243 case CK_ViewFiltered
:
1244 view_filtered_cmd (current_panel
);
1247 find_cmd (current_panel
);
1249 #ifdef ENABLE_VFS_SHELL
1250 case CK_ConnectShell
:
1254 #ifdef ENABLE_VFS_FTP
1259 #ifdef ENABLE_VFS_SFTP
1260 case CK_ConnectSftp
:
1265 panel_panelize_cd ();
1271 /* show the history of command line widget */
1272 send_message (cmdline
, NULL
, MSG_ACTION
, CK_History
, NULL
);
1275 if (sender
== WIDGET (the_menubar
))
1276 info_cmd (); /* menu */
1278 info_cmd_no_menu (); /* shortcut or buttonbar */
1280 #ifdef ENABLE_BACKGROUND
1285 case CK_OptionsLayout
:
1288 case CK_OptionsAppearance
:
1295 link_cmd (LINK_HARDLINK
);
1297 case CK_PanelListing
:
1300 #ifdef LISTMODE_EDITOR
1308 case CK_MenuLastSelected
:
1309 menu_last_selected_cmd ();
1312 mkdir_cmd (current_panel
);
1314 case CK_OptionsPanel
:
1315 panel_options_box ();
1318 case CK_SelectCodepage
:
1323 quick_cd_cmd (current_panel
);
1326 hotlist_cmd (current_panel
);
1328 case CK_PanelQuickView
:
1329 if (sender
== WIDGET (the_menubar
))
1330 quick_view_cmd (); /* menu */
1332 quick_cmd_no_menu (); /* shortcut or buttonabr */
1340 case CK_LinkSymbolicRelative
:
1341 link_cmd (LINK_SYMLINK_RELATIVE
);
1344 rename_cmd (current_panel
);
1351 vfs_list (current_panel
);
1359 case CK_SelectInvert
:
1361 res
= send_message (current_panel
, filemanager
, MSG_ACTION
, command
, NULL
);
1367 smart_dirsize_cmd (current_panel
);
1372 case CK_ExtendedKeyMap
:
1373 WIDGET (filemanager
)->ext_mode
= TRUE
;
1376 mc_event_raise (MCEVENT_GROUP_CORE
, "suspend", NULL
);
1381 case CK_LinkSymbolic
:
1382 link_cmd (LINK_SYMLINK_ABSOLUTE
);
1385 toggle_show_hidden ();
1387 case CK_SplitVertHoriz
:
1388 toggle_panels_split ();
1391 panels_split_equal ();
1394 panels_split_more ();
1397 panels_split_less ();
1405 #ifdef ENABLE_VFS_UNDELFS
1411 user_file_menu_cmd ();
1414 view_cmd (current_panel
);
1417 view_file_cmd (current_panel
);
1419 case CK_EditorViewerHistory
:
1420 show_editor_viewer_history ();
1423 /* don't close panels due to SIGINT */
1426 res
= MSG_NOT_HANDLED
;
1432 /* --------------------------------------------------------------------------------------------- */
1435 * Whether the command-line should not respond to key events.
1437 * This is TRUE if a QuickView or TreeView have the focus, as they're going
1438 * to consume some keys and there's no sense in passing to the command-line
1439 * just the leftovers.
1442 is_cmdline_mute (void)
1444 /* When one of panels is other than view_listing,
1445 current_panel points to view_listing panel all time independently of
1446 it's activity. Thus, we can't use get_current_type() here.
1447 current_panel should point to actually current active panel
1448 independently of it's type. */
1449 return (!current_panel
->active
1450 && (get_other_type () == view_quick
|| get_other_type () == view_tree
));
1453 /* --------------------------------------------------------------------------------------------- */
1456 * Handles the Enter key on the command-line.
1458 * Returns TRUE if non-whitespace was indeed processed.
1461 handle_cmdline_enter (void)
1465 for (s
= input_get_ctext (cmdline
); *s
!= '\0' && whitespace (*s
); s
++)
1470 send_message (cmdline
, NULL
, MSG_KEY
, '\n', NULL
);
1474 input_insert (cmdline
, "", FALSE
);
1480 /* --------------------------------------------------------------------------------------------- */
1483 midnight_callback (Widget
*w
, Widget
*sender
, widget_msg_t msg
, int parm
, void *data
)
1496 group_default_callback (w
, NULL
, MSG_DRAW
, 0, NULL
);
1497 /* We handle the special case of the output lines */
1498 if (mc_global
.tty
.console_flag
!= '\0' && output_lines
!= 0)
1500 unsigned char end_line
;
1502 end_line
= LINES
- (mc_global
.keybar_visible
? 1 : 0) - 1;
1503 show_console_contents (output_start_y
, end_line
- output_lines
, end_line
);
1508 widget_adjust_position (w
->pos_flags
, &w
->rect
);
1510 menubar_arrange (the_menubar
);
1514 /* We only need the first idle event to show user menu after start */
1515 widget_idle (w
, FALSE
);
1517 if (boot_current_is_left
)
1518 widget_select (get_panel_widget (0));
1520 widget_select (get_panel_widget (1));
1523 midnight_execute_cmd (NULL
, CK_UserMenu
);
1529 command
= widget_lookup_key (w
, parm
);
1530 if (command
!= CK_IgnoreKey
)
1531 return midnight_execute_cmd (NULL
, command
);
1534 /* FIXME: should handle all menu shortcuts before this point */
1535 if (widget_get_state (WIDGET (the_menubar
), WST_FOCUSED
))
1536 return MSG_NOT_HANDLED
;
1538 if (parm
== '\n' && !is_cmdline_mute ())
1540 if (handle_cmdline_enter ())
1542 /* Else: the panel will handle it. */
1545 if ((!mc_global
.tty
.alternate_plus_minus
1546 || !(mc_global
.tty
.console_flag
!= '\0' || mc_global
.tty
.xterm_flag
)) && !quote
1547 && !current_panel
->quick_search
.active
)
1549 if (!only_leading_plus_minus
)
1551 /* Special treatment, since the input line will eat them */
1553 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Select
, NULL
);
1555 if (parm
== '\\' || parm
== '-')
1556 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Unselect
, NULL
);
1559 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_SelectInvert
,
1562 else if (!command_prompt
|| input_is_empty (cmdline
))
1564 /* Special treatment '+', '-', '\', '*' only when this is
1565 * first char on input line
1568 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Select
, NULL
);
1570 if (parm
== '\\' || parm
== '-')
1571 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Unselect
, NULL
);
1574 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_SelectInvert
,
1578 return MSG_NOT_HANDLED
;
1580 case MSG_HOTKEY_HANDLED
:
1581 if ((get_current_type () == view_listing
) && current_panel
->quick_search
.active
)
1583 current_panel
->dirty
= TRUE
; /* FIXME: unneeded? */
1584 send_message (current_panel
, NULL
, MSG_ACTION
, CK_SearchStop
, NULL
);
1588 case MSG_UNHANDLED_KEY
:
1590 cb_ret_t v
= MSG_NOT_HANDLED
;
1592 command
= widget_lookup_key (w
, parm
);
1593 if (command
!= CK_IgnoreKey
)
1594 v
= midnight_execute_cmd (NULL
, command
);
1596 if (v
== MSG_NOT_HANDLED
&& command_prompt
&& !is_cmdline_mute ())
1597 v
= send_message (cmdline
, NULL
, MSG_KEY
, parm
, NULL
);
1603 if (!widget_get_state (WIDGET (the_menubar
), WST_FOCUSED
))
1604 update_dirty_panels ();
1608 /* Handle shortcuts, menu, and buttonbar. */
1609 return midnight_execute_cmd (sender
, parm
);
1616 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
1620 /* --------------------------------------------------------------------------------------------- */
1621 /*** public functions ****************************************************************************/
1622 /* --------------------------------------------------------------------------------------------- */
1627 menu_set_name (left_menu
, panels_layout
.horizontal_split
? _("&Above") : _("&Left"));
1628 menu_set_name (right_menu
, panels_layout
.horizontal_split
? _("&Below") : _("&Right"));
1629 menubar_arrange (the_menubar
);
1630 widget_set_visibility (WIDGET (the_menubar
), menubar_visible
);
1633 /* --------------------------------------------------------------------------------------------- */
1636 midnight_set_buttonbar (WButtonBar
*b
)
1638 Widget
*w
= WIDGET (filemanager
);
1640 buttonbar_set_label (b
, 1, Q_ ("ButtonBar|Help"), w
->keymap
, NULL
);
1641 buttonbar_set_label (b
, 2, Q_ ("ButtonBar|Menu"), w
->keymap
, NULL
);
1642 buttonbar_set_label (b
, 3, Q_ ("ButtonBar|View"), w
->keymap
, NULL
);
1643 buttonbar_set_label (b
, 4, Q_ ("ButtonBar|Edit"), w
->keymap
, NULL
);
1644 buttonbar_set_label (b
, 5, Q_ ("ButtonBar|Copy"), w
->keymap
, NULL
);
1645 buttonbar_set_label (b
, 6, Q_ ("ButtonBar|RenMov"), w
->keymap
, NULL
);
1646 buttonbar_set_label (b
, 7, Q_ ("ButtonBar|Mkdir"), w
->keymap
, NULL
);
1647 buttonbar_set_label (b
, 8, Q_ ("ButtonBar|Delete"), w
->keymap
, NULL
);
1648 buttonbar_set_label (b
, 9, Q_ ("ButtonBar|PullDn"), w
->keymap
, NULL
);
1649 buttonbar_set_label (b
, 10, Q_ ("ButtonBar|Quit"), w
->keymap
, NULL
);
1652 /* --------------------------------------------------------------------------------------------- */
1654 * Return a random hint. If force is TRUE, ignore the timeout.
1658 get_random_hint (gboolean force
)
1660 static const gint64 update_period
= 60 * G_USEC_PER_SEC
;
1661 static gint64 tv
= 0;
1663 char *data
, *result
, *eop
;
1667 /* Do not change hints more often than one minute */
1668 if (!force
&& !mc_time_elapsed (&tv
, update_period
))
1669 return g_strdup ("");
1671 data
= load_mc_home_file (mc_global
.share_data_dir
, MC_HINT
, NULL
, &len
);
1675 /* get a random entry */
1676 srand ((unsigned int) (tv
/ G_USEC_PER_SEC
));
1677 start
= ((size_t) rand ()) % (len
- 1);
1679 /* Search the start of paragraph */
1680 for (; start
!= 0; start
--)
1681 if (data
[start
] == '\n' && data
[start
+ 1] == '\n')
1687 /* Search the end of paragraph */
1688 for (eop
= data
+ start
; *eop
!= '\0'; eop
++)
1690 if (*eop
== '\n' && *(eop
+ 1) == '\n')
1699 /* hint files are stored in utf-8 */
1700 /* try convert hint file from utf-8 to terminal encoding */
1701 conv
= str_crt_conv_from ("UTF-8");
1702 if (conv
== INVALID_CONV
)
1703 result
= g_strndup (data
+ start
, len
- start
);
1709 buffer
= g_string_sized_new (len
- start
);
1710 nok
= (str_convert (conv
, data
+ start
, buffer
) == ESTR_FAILURE
);
1711 result
= g_string_free (buffer
, nok
);
1712 str_close_conv (conv
);
1720 /* --------------------------------------------------------------------------------------------- */
1722 * Load new hint and display it.
1723 * IF force is not 0, ignore the timeout.
1727 load_hint (gboolean force
)
1731 if (WIDGET (the_hint
)->owner
== NULL
)
1734 if (!mc_global
.message_visible
)
1736 label_set_text (the_hint
, NULL
);
1740 hint
= get_random_hint (force
);
1750 char text
[BUF_SMALL
];
1752 g_snprintf (text
, sizeof (text
), _("GNU Midnight Commander %s\n"), mc_global
.mc_version
);
1757 /* --------------------------------------------------------------------------------------------- */
1759 * Change current panel in the file manager.
1761 * @return current_panel
1767 input_complete_free (cmdline
);
1768 group_select_next_widget (GROUP (filemanager
));
1769 return current_panel
;
1772 /* --------------------------------------------------------------------------------------------- */
1774 /** Save current stat of directories to avoid reloading the panels
1775 * when no modifications have taken place
1778 save_cwds_stat (void)
1780 if (panels_options
.fast_reload
)
1782 mc_stat (current_panel
->cwd_vpath
, &(current_panel
->dir_stat
));
1783 if (get_other_type () == view_listing
)
1784 mc_stat (other_panel
->cwd_vpath
, &(other_panel
->dir_stat
));
1788 /* --------------------------------------------------------------------------------------------- */
1791 quiet_quit_cmd (void)
1793 print_last_revert
= TRUE
;
1794 return quit_cmd_internal (1);
1797 /* --------------------------------------------------------------------------------------------- */
1799 /** Run the main dialog that occupies the whole screen */
1805 #ifdef USE_INTERNAL_EDIT
1809 filemanager
= dlg_create (FALSE
, 0, 0, 1, 1, WPOS_FULLSCREEN
, FALSE
, dialog_colors
,
1810 midnight_callback
, NULL
, "[main]", NULL
);
1812 /* Check if we were invoked as an editor or file viewer */
1813 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
1816 ret
= mc_maybe_editor_or_viewer ();
1820 /* We only need the first idle event to show user menu after start */
1821 widget_idle (WIDGET (filemanager
), TRUE
);
1824 mc_filehighlight
= mc_fhl_new (TRUE
);
1826 create_file_manager ();
1827 (void) dlg_run (filemanager
);
1829 mc_fhl_free (&mc_filehighlight
);
1833 /* widget_destroy destroys even current_panel->cwd_vpath, so we have to save a copy :) */
1834 if (mc_args__last_wd_file
!= NULL
&& vfs_current_is_local ())
1835 last_wd_string
= g_strdup (vfs_path_as_str (current_panel
->cwd_vpath
));
1837 /* don't handle VFS timestamps for dirs opened in panels */
1838 mc_event_destroy (MCEVENT_GROUP_CORE
, "vfs_timestamp");
1842 mc_global
.midnight_shutdown
= TRUE
;
1843 dialog_switch_shutdown ();
1845 widget_destroy (WIDGET (filemanager
));
1846 current_panel
= NULL
;
1848 #ifdef USE_INTERNAL_EDIT
1852 if ((quit
& SUBSHELL_EXIT
) == 0)
1853 tty_clear_screen ();
1858 /* --------------------------------------------------------------------------------------------- */