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, MC_FILEPOS_FILE */
48 #include "lib/tty/tty.h"
49 #include "lib/tty/key.h" /* KEY_M_* masks */
52 #include "lib/vfs/vfs.h"
55 #ifdef ENABLE_SUBSHELL
56 #include "src/subshell/subshell.h"
58 #include "src/execute.h" /* toggle_subshell */
59 #include "src/setup.h" /* variables */
60 #include "src/learn.h" /* learn_keys() */
61 #include "src/keymap.h"
62 #include "src/usermenu.h" /* user_file_menu_cmd() */
64 #include "lib/keybind.h"
65 #include "lib/event.h"
68 #include "boxes.h" /* sort_box(), tree_box() */
70 #include "cmd.h" /* commands */
73 #include "command.h" /* cmdline */
74 #include "dir.h" /* dir_list_clean() */
76 #ifdef USE_INTERNAL_EDIT
77 #include "src/editor/edit.h"
81 #include "src/diffviewer/ydiff.h"
84 #include "src/consaver/cons.saver.h" /* show_console_contents */
85 #include "src/file_history.h" /* show_file_history() */
87 #include "filemanager.h"
89 /*** global variables ****************************************************************************/
91 /* When the modes are active, left_panel, right_panel and tree_panel */
92 /* point to a proper data structure. You should check with the functions */
93 /* get_current_type and get_other_type the types of the panels before using */
94 /* this pointer variables */
96 /* The structures for the panels */
97 WPanel
*left_panel
= NULL
;
98 WPanel
*right_panel
= NULL
;
99 /* Pointer to the selected and unselected panel */
100 WPanel
*current_panel
= NULL
;
103 WMenuBar
*the_menubar
= NULL
;
104 /* The widget where we draw the prompt */
112 const char *mc_prompt
= NULL
;
114 /*** file scope macro definitions ****************************************************************/
118 * Don't restrict the output on the screen manager level,
119 * the translation tables take care of it.
121 #endif /* !HAVE_CHARSET */
123 /*** file scope type declarations ****************************************************************/
125 /*** forward declarations (file scope functions) *************************************************/
127 /*** file scope variables ************************************************************************/
129 static menu_t
*left_menu
, *right_menu
;
131 /* --------------------------------------------------------------------------------------------- */
132 /*** file scope functions ************************************************************************/
133 /* --------------------------------------------------------------------------------------------- */
135 /** Stop MC main dialog and the current dialog if it exists.
136 * Needed to provide fast exit from MC viewer or editor on shell exit */
140 dlg_close (filemanager
);
143 dlg_close (DIALOG (top_dlg
->data
));
146 /* --------------------------------------------------------------------------------------------- */
151 const file_entry_t
*fe
;
154 fe
= panel_current_entry (current_panel
);
158 sel_dir
= tree_box (fe
->fname
->str
);
161 vfs_path_t
*sel_vdir
;
163 sel_vdir
= vfs_path_from_str (sel_dir
);
164 panel_cd (current_panel
, sel_vdir
, cd_exact
);
165 vfs_path_free (sel_vdir
, TRUE
);
170 /* --------------------------------------------------------------------------------------------- */
172 #ifdef LISTMODE_EDITOR
178 if (get_current_type () != view_listing
)
181 newmode
= listmode_edit (current_panel
->user_format
);
185 g_free (current_panel
->user_format
);
186 current_panel
->list_format
= list_user
;
187 current_panel
->user_format
= newmode
;
188 set_panel_formats (current_panel
);
192 #endif /* LISTMODE_EDITOR */
194 /* --------------------------------------------------------------------------------------------- */
197 create_panel_menu (void)
199 GList
*entries
= NULL
;
201 entries
= g_list_prepend (entries
, menu_entry_new (_("File listin&g"), CK_PanelListing
));
202 entries
= g_list_prepend (entries
, menu_entry_new (_("&Quick view"), CK_PanelQuickView
));
203 entries
= g_list_prepend (entries
, menu_entry_new (_("&Info"), CK_PanelInfo
));
204 entries
= g_list_prepend (entries
, menu_entry_new (_("&Tree"), CK_PanelTree
));
205 entries
= g_list_prepend (entries
, menu_separator_new ());
207 g_list_prepend (entries
, menu_entry_new (_("&Listing format..."), CK_SetupListingFormat
));
208 entries
= g_list_prepend (entries
, menu_entry_new (_("&Sort order..."), CK_Sort
));
209 entries
= g_list_prepend (entries
, menu_entry_new (_("&Filter..."), CK_Filter
));
211 entries
= g_list_prepend (entries
, menu_entry_new (_("&Encoding..."), CK_SelectCodepage
));
213 entries
= g_list_prepend (entries
, menu_separator_new ());
214 #ifdef ENABLE_VFS_FTP
215 entries
= g_list_prepend (entries
, menu_entry_new (_("FT&P link..."), CK_ConnectFtp
));
217 #ifdef ENABLE_VFS_SHELL
218 entries
= g_list_prepend (entries
, menu_entry_new (_("S&hell link..."), CK_ConnectShell
));
220 #ifdef ENABLE_VFS_SFTP
221 entries
= g_list_prepend (entries
, menu_entry_new (_("SFTP li&nk..."), CK_ConnectSftp
));
223 entries
= g_list_prepend (entries
, menu_entry_new (_("Paneli&ze"), CK_Panelize
));
224 entries
= g_list_prepend (entries
, menu_separator_new ());
225 entries
= g_list_prepend (entries
, menu_entry_new (_("&Rescan"), CK_Reread
));
227 return g_list_reverse (entries
);
230 /* --------------------------------------------------------------------------------------------- */
233 create_file_menu (void)
235 GList
*entries
= NULL
;
237 entries
= g_list_prepend (entries
, menu_entry_new (_("&View"), CK_View
));
238 entries
= g_list_prepend (entries
, menu_entry_new (_("Vie&w file..."), CK_ViewFile
));
239 entries
= g_list_prepend (entries
, menu_entry_new (_("&Filtered view"), CK_ViewFiltered
));
240 entries
= g_list_prepend (entries
, menu_entry_new (_("&Edit"), CK_Edit
));
241 entries
= g_list_prepend (entries
, menu_entry_new (_("&Copy"), CK_Copy
));
242 entries
= g_list_prepend (entries
, menu_entry_new (_("C&hmod"), CK_ChangeMode
));
243 entries
= g_list_prepend (entries
, menu_entry_new (_("&Link"), CK_Link
));
244 entries
= g_list_prepend (entries
, menu_entry_new (_("&Symlink"), CK_LinkSymbolic
));
246 g_list_prepend (entries
, menu_entry_new (_("Relative symlin&k"), CK_LinkSymbolicRelative
));
247 entries
= g_list_prepend (entries
, menu_entry_new (_("Edit s&ymlink"), CK_LinkSymbolicEdit
));
248 entries
= g_list_prepend (entries
, menu_entry_new (_("Ch&own"), CK_ChangeOwn
));
249 entries
= g_list_prepend (entries
, menu_entry_new (_("&Advanced chown"), CK_ChangeOwnAdvanced
));
250 #ifdef ENABLE_EXT2FS_ATTR
251 entries
= g_list_prepend (entries
, menu_entry_new (_("Cha&ttr"), CK_ChangeAttributes
));
253 entries
= g_list_prepend (entries
, menu_entry_new (_("&Rename/Move"), CK_Move
));
254 entries
= g_list_prepend (entries
, menu_entry_new (_("&Mkdir"), CK_MakeDir
));
255 entries
= g_list_prepend (entries
, menu_entry_new (_("&Delete"), CK_Delete
));
256 entries
= g_list_prepend (entries
, menu_entry_new (_("&Quick cd"), CK_CdQuick
));
257 entries
= g_list_prepend (entries
, menu_separator_new ());
258 entries
= g_list_prepend (entries
, menu_entry_new (_("Select &group"), CK_Select
));
259 entries
= g_list_prepend (entries
, menu_entry_new (_("U&nselect group"), CK_Unselect
));
260 entries
= g_list_prepend (entries
, menu_entry_new (_("&Invert selection"), CK_SelectInvert
));
261 entries
= g_list_prepend (entries
, menu_separator_new ());
262 entries
= g_list_prepend (entries
, menu_entry_new (_("E&xit"), CK_Quit
));
264 return g_list_reverse (entries
);
267 /* --------------------------------------------------------------------------------------------- */
270 create_command_menu (void)
272 /* I know, I'm lazy, but the tree widget when it's not running
273 * as a panel still has some problems, I have not yet finished
274 * the WTree widget port, sorry.
276 GList
*entries
= NULL
;
278 entries
= g_list_prepend (entries
, menu_entry_new (_("&User menu"), CK_UserMenu
));
279 entries
= g_list_prepend (entries
, menu_entry_new (_("&Directory tree"), CK_Tree
));
280 entries
= g_list_prepend (entries
, menu_entry_new (_("&Find file"), CK_Find
));
281 entries
= g_list_prepend (entries
, menu_entry_new (_("S&wap panels"), CK_Swap
));
282 entries
= g_list_prepend (entries
, menu_entry_new (_("Switch &panels on/off"), CK_Shell
));
283 entries
= g_list_prepend (entries
, menu_entry_new (_("&Compare directories"), CK_CompareDirs
));
285 entries
= g_list_prepend (entries
, menu_entry_new (_("C&ompare files"), CK_CompareFiles
));
288 g_list_prepend (entries
, menu_entry_new (_("E&xternal panelize"), CK_ExternalPanelize
));
289 entries
= g_list_prepend (entries
, menu_entry_new (_("Show directory s&izes"), CK_DirSize
));
290 entries
= g_list_prepend (entries
, menu_separator_new ());
291 entries
= g_list_prepend (entries
, menu_entry_new (_("Command &history"), CK_History
));
293 g_list_prepend (entries
,
294 menu_entry_new (_("Viewed/edited files hi&story"), CK_EditorViewerHistory
));
295 entries
= g_list_prepend (entries
, menu_entry_new (_("Di&rectory hotlist"), CK_HotList
));
297 entries
= g_list_prepend (entries
, menu_entry_new (_("&Active VFS list"), CK_VfsList
));
299 #ifdef ENABLE_BACKGROUND
300 entries
= g_list_prepend (entries
, menu_entry_new (_("&Background jobs"), CK_Jobs
));
302 entries
= g_list_prepend (entries
, menu_entry_new (_("Screen lis&t"), CK_ScreenList
));
303 entries
= g_list_prepend (entries
, menu_separator_new ());
304 #ifdef ENABLE_VFS_UNDELFS
306 g_list_prepend (entries
, menu_entry_new (_("&Undelete files (ext2fs only)"), CK_Undelete
));
308 #ifdef LISTMODE_EDITOR
309 entries
= g_list_prepend (entries
, menu_entry_new (_("&Listing format edit"), CK_ListMode
));
311 #if defined (ENABLE_VFS_UNDELFS) || defined (LISTMODE_EDITOR)
312 entries
= g_list_prepend (entries
, menu_separator_new ());
315 g_list_prepend (entries
, menu_entry_new (_("Edit &extension file"), CK_EditExtensionsFile
));
316 entries
= g_list_prepend (entries
, menu_entry_new (_("Edit &menu file"), CK_EditUserMenu
));
318 g_list_prepend (entries
,
319 menu_entry_new (_("Edit hi&ghlighting group file"),
320 CK_EditFileHighlightFile
));
322 return g_list_reverse (entries
);
325 /* --------------------------------------------------------------------------------------------- */
328 create_options_menu (void)
330 GList
*entries
= NULL
;
332 entries
= g_list_prepend (entries
, menu_entry_new (_("&Configuration..."), CK_Options
));
333 entries
= g_list_prepend (entries
, menu_entry_new (_("&Layout..."), CK_OptionsLayout
));
334 entries
= g_list_prepend (entries
, menu_entry_new (_("&Panel options..."), CK_OptionsPanel
));
335 entries
= g_list_prepend (entries
, menu_entry_new (_("C&onfirmation..."), CK_OptionsConfirm
));
336 entries
= g_list_prepend (entries
, menu_entry_new (_("&Appearance..."), CK_OptionsAppearance
));
338 g_list_prepend (entries
, menu_entry_new (_("&Display bits..."), CK_OptionsDisplayBits
));
339 entries
= g_list_prepend (entries
, menu_entry_new (_("Learn &keys..."), CK_LearnKeys
));
341 entries
= g_list_prepend (entries
, menu_entry_new (_("&Virtual FS..."), CK_OptionsVfs
));
343 entries
= g_list_prepend (entries
, menu_separator_new ());
344 entries
= g_list_prepend (entries
, menu_entry_new (_("&Save setup"), CK_SaveSetup
));
346 return g_list_reverse (entries
);
349 /* --------------------------------------------------------------------------------------------- */
354 left_menu
= menu_new ("", create_panel_menu (), "[Left and Right Menus]");
355 menubar_add_menu (the_menubar
, left_menu
);
356 menubar_add_menu (the_menubar
, menu_new (_("&File"), create_file_menu (), "[File Menu]"));
357 menubar_add_menu (the_menubar
,
358 menu_new (_("&Command"), create_command_menu (), "[Command Menu]"));
359 menubar_add_menu (the_menubar
,
360 menu_new (_("&Options"), create_options_menu (), "[Options Menu]"));
361 right_menu
= menu_new ("", create_panel_menu (), "[Left and Right Menus]");
362 menubar_add_menu (the_menubar
, right_menu
);
366 /* --------------------------------------------------------------------------------------------- */
369 menu_last_selected_cmd (void)
371 menubar_activate (the_menubar
, drop_menus
, -1);
374 /* --------------------------------------------------------------------------------------------- */
381 if ((get_current_index () == 0) == current_panel
->active
)
384 selected
= g_list_length (the_menubar
->menu
) - 1;
386 menubar_activate (the_menubar
, drop_menus
, selected
);
389 /* --------------------------------------------------------------------------------------------- */
395 const panel_field_t
*sort_order
;
397 if (!SELECTED_IS_PANEL
)
401 sort_order
= sort_box (&p
->sort_info
, p
->sort_field
);
402 panel_set_sort_order (p
, sort_order
);
405 /* --------------------------------------------------------------------------------------------- */
408 midnight_get_shortcut (long command
)
411 const char *shortcut
= NULL
;
413 shortcut
= keybind_lookup_keymap_shortcut (filemanager_map
, command
);
414 if (shortcut
!= NULL
)
415 return g_strdup (shortcut
);
417 shortcut
= keybind_lookup_keymap_shortcut (panel_map
, command
);
418 if (shortcut
!= NULL
)
419 return g_strdup (shortcut
);
421 ext_map
= keybind_lookup_keymap_shortcut (filemanager_map
, CK_ExtendedKeyMap
);
423 shortcut
= keybind_lookup_keymap_shortcut (filemanager_x_map
, command
);
424 if (shortcut
!= NULL
)
425 return g_strdup_printf ("%s %s", ext_map
, shortcut
);
430 /* --------------------------------------------------------------------------------------------- */
433 midnight_get_title (const WDialog
*h
, size_t len
)
441 title_path_prepare (&path
, &login
);
443 p
= g_strdup_printf ("%s [%s]:%s", _("Panels:"), login
, path
);
446 path
= g_strdup (str_trunc (p
, len
- 4));
452 /* --------------------------------------------------------------------------------------------- */
455 toggle_panels_split (void)
457 panels_layout
.horizontal_split
= !panels_layout
.horizontal_split
;
462 /* --------------------------------------------------------------------------------------------- */
467 check_panel_timestamp (const WPanel
*panel
, panel_view_mode_t mode
, const struct vfs_class
*vclass
,
470 return (mode
!= view_listing
|| (vfs_path_get_last_path_vfs (panel
->cwd_vpath
) == vclass
471 && vfs_getid (panel
->cwd_vpath
) == id
));
474 /* --------------------------------------------------------------------------------------------- */
478 check_current_panel_timestamp (const gchar
*event_group_name
, const gchar
*event_name
,
479 gpointer init_data
, gpointer data
)
481 ev_vfs_stamp_create_t
*event_data
= (ev_vfs_stamp_create_t
*) data
;
483 (void) event_group_name
;
488 check_panel_timestamp (current_panel
, get_current_type (), event_data
->vclass
,
490 return !event_data
->ret
;
493 /* --------------------------------------------------------------------------------------------- */
497 check_other_panel_timestamp (const gchar
*event_group_name
, const gchar
*event_name
,
498 gpointer init_data
, gpointer data
)
500 ev_vfs_stamp_create_t
*event_data
= (ev_vfs_stamp_create_t
*) data
;
502 (void) event_group_name
;
507 check_panel_timestamp (other_panel
, get_other_type (), event_data
->vclass
, event_data
->id
);
508 return !event_data
->ret
;
510 #endif /* ENABLE_VFS */
512 /* --------------------------------------------------------------------------------------------- */
516 print_vfs_message (const gchar
*event_group_name
, const gchar
*event_name
,
517 gpointer init_data
, gpointer data
)
519 ev_vfs_print_message_t
*event_data
= (ev_vfs_print_message_t
*) data
;
521 (void) event_group_name
;
525 if (mc_global
.midnight_shutdown
)
528 if (!mc_global
.message_visible
|| the_hint
== NULL
|| WIDGET (the_hint
)->owner
== NULL
)
532 if (!nice_rotating_dash
|| (ok_to_refresh
<= 0))
535 /* Preserve current cursor position */
536 tty_getyx (&row
, &col
);
539 tty_setcolor (NORMAL_COLOR
);
540 tty_print_string (str_fit_to_term (event_data
->msg
, COLS
- 1, J_LEFT
));
542 /* Restore cursor position */
543 tty_gotoyx (row
, col
);
548 if (mc_global
.message_visible
)
549 set_hintbar (event_data
->msg
);
552 MC_PTR_FREE (event_data
->msg
);
556 /* --------------------------------------------------------------------------------------------- */
561 int current_index
, other_index
;
562 panel_view_mode_t current_mode
, other_mode
;
563 char *current_dir
, *other_dir
;
564 vfs_path_t
*original_dir
;
567 * Following cases from command line are possible:
568 * 'mc' (no arguments): mc_run_param0 == NULL, mc_run_param1 == NULL
569 * active panel uses current directory
570 * passive panel uses "other_dir" from panels.ini
572 * 'mc dir1 dir2' (two arguments): mc_run_param0 != NULL, mc_run_param1 != NULL
573 * active panel uses mc_run_param0
574 * passive panel uses mc_run_param1
576 * 'mc dir1' (single argument): mc_run_param0 != NULL, mc_run_param1 == NULL
577 * active panel uses mc_run_param0
578 * passive panel uses "other_dir" from panels.ini
581 /* Set up panel directories */
582 if (boot_current_is_left
)
584 /* left panel is active */
587 current_mode
= startup_left_mode
;
588 other_mode
= startup_right_mode
;
590 if (mc_run_param0
== NULL
&& mc_run_param1
== NULL
)
593 current_dir
= NULL
; /* assume current dir */
594 other_dir
= saved_other_dir
; /* from ini */
596 else if (mc_run_param0
!= NULL
&& mc_run_param1
!= NULL
)
599 current_dir
= (char *) mc_run_param0
;
600 other_dir
= mc_run_param1
;
602 else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
605 current_dir
= (char *) mc_run_param0
;
606 other_dir
= saved_other_dir
; /* from ini */
611 /* right panel is active */
614 current_mode
= startup_right_mode
;
615 other_mode
= startup_left_mode
;
617 if (mc_run_param0
== NULL
&& mc_run_param1
== NULL
)
620 current_dir
= NULL
; /* assume current dir */
621 other_dir
= saved_other_dir
; /* from ini */
623 else if (mc_run_param0
!= NULL
&& mc_run_param1
!= NULL
)
626 current_dir
= (char *) mc_run_param0
;
627 other_dir
= mc_run_param1
;
629 else /* mc_run_param0 != NULL && mc_run_param1 == NULL */
632 current_dir
= (char *) mc_run_param0
;
633 other_dir
= saved_other_dir
; /* from ini */
637 /* 1. Get current dir */
638 original_dir
= vfs_path_clone (vfs_get_raw_current_dir ());
640 /* 2. Create passive panel */
641 if (other_dir
!= NULL
)
645 if (g_path_is_absolute (other_dir
))
646 vpath
= vfs_path_from_str (other_dir
);
648 vpath
= vfs_path_append_new (original_dir
, other_dir
, (char *) NULL
);
650 vfs_path_free (vpath
, TRUE
);
652 create_panel (other_index
, other_mode
);
654 /* 3. Create active panel */
655 if (current_dir
== NULL
)
656 mc_chdir (original_dir
);
661 if (g_path_is_absolute (current_dir
))
662 vpath
= vfs_path_from_str (current_dir
);
664 vpath
= vfs_path_append_new (original_dir
, current_dir
, (char *) NULL
);
666 vfs_path_free (vpath
, TRUE
);
668 create_panel (current_index
, current_mode
);
670 if (startup_left_mode
== view_listing
)
671 current_panel
= left_panel
;
672 else if (right_panel
!= NULL
)
673 current_panel
= right_panel
;
675 current_panel
= left_panel
;
677 vfs_path_free (original_dir
, TRUE
);
680 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_timestamp", check_other_panel_timestamp
, NULL
, NULL
);
681 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_timestamp", check_current_panel_timestamp
, NULL
, NULL
);
682 #endif /* ENABLE_VFS */
684 mc_event_add (MCEVENT_GROUP_CORE
, "vfs_print_message", print_vfs_message
, NULL
, NULL
);
687 /* --------------------------------------------------------------------------------------------- */
690 midnight_put_panel_path (WPanel
*panel
)
692 vfs_path_t
*cwd_vpath
;
693 const char *cwd_vpath_str
;
699 cwd_vpath
= remove_encoding_from_path (panel
->cwd_vpath
);
701 cwd_vpath
= vfs_path_clone (panel
->cwd_vpath
);
704 cwd_vpath_str
= vfs_path_as_str (cwd_vpath
);
706 command_insert (cmdline
, cwd_vpath_str
, FALSE
);
708 if (!IS_PATH_SEP (cwd_vpath_str
[strlen (cwd_vpath_str
) - 1]))
709 command_insert (cmdline
, PATH_SEP_STR
, FALSE
);
711 vfs_path_free (cwd_vpath
, TRUE
);
714 /* --------------------------------------------------------------------------------------------- */
717 put_link (WPanel
*panel
)
719 const file_entry_t
*fe
;
724 fe
= panel_current_entry (panel
);
726 if (fe
!= NULL
&& S_ISLNK (fe
->st
.st_mode
))
728 char buffer
[MC_MAXPATHLEN
];
732 vpath
= vfs_path_append_new (panel
->cwd_vpath
, fe
->fname
->str
, (char *) NULL
);
733 i
= mc_readlink (vpath
, buffer
, sizeof (buffer
) - 1);
734 vfs_path_free (vpath
, TRUE
);
739 command_insert (cmdline
, buffer
, TRUE
);
744 /* --------------------------------------------------------------------------------------------- */
747 put_current_link (void)
749 put_link (current_panel
);
752 /* --------------------------------------------------------------------------------------------- */
755 put_other_link (void)
757 if (get_other_type () == view_listing
)
758 put_link (other_panel
);
761 /* --------------------------------------------------------------------------------------------- */
763 /** Insert the selected file name into the input line */
765 put_current_selected (void)
770 if (get_current_type () == view_tree
)
773 const vfs_path_t
*selected_name
;
775 tree
= (WTree
*) get_panel_widget (get_current_index ());
776 selected_name
= tree_selected_name (tree
);
777 command_insert (cmdline
, vfs_path_as_str (selected_name
), TRUE
);
781 const file_entry_t
*fe
;
783 fe
= panel_current_entry (current_panel
);
785 command_insert (cmdline
, fe
->fname
->str
, TRUE
);
789 /* --------------------------------------------------------------------------------------------- */
792 put_tagged (WPanel
*panel
)
797 input_disable_update (cmdline
);
799 if (panel
->marked
== 0)
801 const file_entry_t
*fe
;
803 fe
= panel_current_entry (current_panel
);
805 command_insert (cmdline
, fe
->fname
->str
, TRUE
);
811 for (i
= 0; i
< panel
->dir
.len
; i
++)
812 if (panel
->dir
.list
[i
].f
.marked
!= 0)
813 command_insert (cmdline
, panel
->dir
.list
[i
].fname
->str
, TRUE
);
816 input_enable_update (cmdline
);
819 /* --------------------------------------------------------------------------------------------- */
822 put_current_tagged (void)
824 put_tagged (current_panel
);
827 /* --------------------------------------------------------------------------------------------- */
830 put_other_tagged (void)
832 if (get_other_type () == view_listing
)
833 put_tagged (other_panel
);
836 /* --------------------------------------------------------------------------------------------- */
843 tty_display_8bit (TRUE
);
845 tty_display_8bit (mc_global
.full_eight_bits
);
846 #endif /* HAVE_CHARSET */
848 #else /* HAVE_SLANG */
851 tty_display_8bit (TRUE
);
853 tty_display_8bit (mc_global
.eight_bit_clean
);
854 #endif /* HAVE_CHARSET */
855 #endif /* HAVE_SLANG */
857 const int baudrate
= tty_baudrate ();
858 if ((baudrate
> 0 && baudrate
< 9600) || mc_global
.tty
.slow_terminal
)
862 /* --------------------------------------------------------------------------------------------- */
865 setup_dummy_mc (void)
873 vpath
= vfs_path_from_str (d
);
874 ret
= mc_chdir (vpath
);
876 vfs_path_free (vpath
, TRUE
);
880 /* --------------------------------------------------------------------------------------------- */
887 * We sync the profiles since the hotlist may have changed, while
888 * we only change the setup data if we have the auto save feature set
891 save_setup (auto_save_setup
, panels_options
.auto_save_setup
);
893 vfs_stamp_path (vfs_get_raw_current_dir ());
896 /* --------------------------------------------------------------------------------------------- */
899 create_file_manager (void)
901 Widget
*w
= WIDGET (filemanager
);
902 WGroup
*g
= GROUP (filemanager
);
904 w
->keymap
= filemanager_map
;
905 w
->ext_keymap
= filemanager_x_map
;
907 filemanager
->get_shortcut
= midnight_get_shortcut
;
908 filemanager
->get_title
= midnight_get_title
;
909 /* allow rebind tab */
910 widget_want_tab (w
, TRUE
);
912 the_menubar
= menubar_new (NULL
);
913 group_add_widget (g
, the_menubar
);
917 group_add_widget (g
, get_panel_widget (0));
918 group_add_widget (g
, get_panel_widget (1));
920 the_hint
= label_new (0, 0, NULL
);
921 the_hint
->transparent
= TRUE
;
922 the_hint
->auto_adjust_cols
= 0;
923 WIDGET (the_hint
)->rect
.cols
= COLS
;
924 group_add_widget (g
, the_hint
);
926 cmdline
= command_new (0, 0, 0);
927 group_add_widget (g
, cmdline
);
929 the_prompt
= label_new (0, 0, mc_prompt
);
930 the_prompt
->transparent
= TRUE
;
931 group_add_widget (g
, the_prompt
);
933 the_bar
= buttonbar_new ();
934 group_add_widget (g
, the_bar
);
935 midnight_set_buttonbar (the_bar
);
937 #ifdef ENABLE_SUBSHELL
938 /* Must be done after creation of cmdline and prompt widgets to avoid potential
939 NULL dereference in load_prompt() -> ... -> setup_cmdline() -> label_set_text(). */
940 if (mc_global
.tty
.use_subshell
)
941 add_select_channel (mc_global
.tty
.subshell_pty
, load_prompt
, NULL
);
942 #endif /* !ENABLE_SUBSHELL */
945 /* --------------------------------------------------------------------------------------------- */
947 /** result must be free'd (I think this should go in util.c) */
949 prepend_cwd_on_local (const char *filename
)
953 vpath
= vfs_path_from_str (filename
);
954 if (!vfs_file_is_local (vpath
) || g_path_is_absolute (filename
))
957 vfs_path_free (vpath
, TRUE
);
959 return vfs_path_append_new (vfs_get_raw_current_dir (), filename
, (char *) NULL
);
962 /* --------------------------------------------------------------------------------------------- */
964 /** Invoke the internal view/edit routine with:
965 * the default processing and forcing the internal viewer/editor
968 mc_maybe_editor_or_viewer (void)
972 switch (mc_global
.mc_run_mode
)
974 #ifdef USE_INTERNAL_EDIT
976 ret
= edit_files ((GList
*) mc_run_param0
);
978 #endif /* USE_INTERNAL_EDIT */
981 vfs_path_t
*vpath
= NULL
;
983 if (mc_run_param0
!= NULL
&& *(char *) mc_run_param0
!= '\0')
984 vpath
= prepend_cwd_on_local ((char *) mc_run_param0
);
986 ret
= view_file (vpath
, FALSE
, TRUE
);
987 vfs_path_free (vpath
, TRUE
);
991 case MC_RUN_DIFFVIEWER
:
992 ret
= dview_diff_cmd (mc_run_param0
, mc_run_param1
);
994 #endif /* USE_DIFF_VIEW */
1002 /* --------------------------------------------------------------------------------------------- */
1005 show_editor_viewer_history (void)
1010 s
= show_file_history (WIDGET (filemanager
), &act
);
1013 vfs_path_t
*s_vpath
;
1018 s_vpath
= vfs_path_from_str (s
);
1019 edit_file_at_line (s_vpath
, use_internal_edit
, 0);
1023 s_vpath
= vfs_path_from_str (s
);
1024 view_file (s_vpath
, use_internal_view
, FALSE
);
1031 d
= g_path_get_dirname (s
);
1032 s_vpath
= vfs_path_from_str (d
);
1033 panel_cd (current_panel
, s_vpath
, cd_exact
);
1034 panel_set_current_by_name (current_panel
, s
);
1040 vfs_path_free (s_vpath
, TRUE
);
1044 /* --------------------------------------------------------------------------------------------- */
1047 quit_cmd_internal (int quiet
)
1052 n
= dialog_switch_num () - 1;
1055 char msg
[BUF_MEDIUM
];
1057 g_snprintf (msg
, sizeof (msg
),
1058 ngettext ("You have %zu opened screen. Quit anyway?",
1059 "You have %zu opened screens. Quit anyway?", n
), n
);
1061 if (query_dialog (_("The Midnight Commander"), msg
, D_NORMAL
, 2, _("&Yes"), _("&No")) != 0)
1065 else if (quiet
|| !confirm_exit
)
1067 else if (query_dialog (_("The Midnight Commander"),
1068 _("Do you really want to quit the Midnight Commander?"),
1069 D_NORMAL
, 2, _("&Yes"), _("&No")) == 0)
1074 #ifdef ENABLE_SUBSHELL
1075 if (!mc_global
.tty
.use_subshell
)
1077 else if ((q
= exit_subshell ()? 1 : 0) != 0)
1087 /* --------------------------------------------------------------------------------------------- */
1092 return quit_cmd_internal (0);
1095 /* --------------------------------------------------------------------------------------------- */
1098 * Repaint the contents of the panels without frames. To schedule panel
1099 * for repainting, set panel->dirty to TRUE. There are many reasons why
1100 * the panels need to be repainted, and this is a costly operation, so
1101 * it's done once per event.
1105 update_dirty_panels (void)
1107 if (get_current_type () == view_listing
&& current_panel
->dirty
)
1108 widget_draw (WIDGET (current_panel
));
1110 if (get_other_type () == view_listing
&& other_panel
->dirty
)
1111 widget_draw (WIDGET (other_panel
));
1114 /* --------------------------------------------------------------------------------------------- */
1117 toggle_show_hidden (void)
1119 panels_options
.show_dot_files
= !panels_options
.show_dot_files
;
1120 update_panels (UP_RELOAD
, UP_KEEPSEL
);
1121 /* redraw panels forced */
1122 update_dirty_panels ();
1125 /* --------------------------------------------------------------------------------------------- */
1128 midnight_execute_cmd (Widget
*sender
, long command
)
1130 cb_ret_t res
= MSG_HANDLED
;
1134 /* stop quick search before executing any command */
1135 send_message (current_panel
, NULL
, MSG_ACTION
, CK_SearchStop
, NULL
);
1139 case CK_ChangePanel
:
1140 (void) change_panel ();
1143 add2hotlist_cmd (current_panel
);
1145 case CK_SetupListingFormat
:
1146 setup_listing_format_cmd ();
1149 chmod_cmd (current_panel
);
1152 chown_cmd (current_panel
);
1154 case CK_ChangeOwnAdvanced
:
1155 advanced_chown_cmd (current_panel
);
1157 #ifdef ENABLE_EXT2FS_ATTR
1158 case CK_ChangeAttributes
:
1159 chattr_cmd (current_panel
);
1162 case CK_CompareDirs
:
1163 compare_dirs_cmd ();
1170 configure_vfs_box ();
1173 case CK_OptionsConfirm
:
1177 copy_cmd (current_panel
);
1179 case CK_PutCurrentPath
:
1180 midnight_put_panel_path (current_panel
);
1182 case CK_PutCurrentSelected
:
1183 put_current_selected ();
1185 case CK_PutCurrentFullSelected
:
1186 midnight_put_panel_path (current_panel
);
1187 put_current_selected ();
1189 case CK_PutCurrentLink
:
1190 put_current_link ();
1192 case CK_PutCurrentTagged
:
1193 put_current_tagged ();
1195 case CK_PutOtherPath
:
1196 if (get_other_type () == view_listing
)
1197 midnight_put_panel_path (other_panel
);
1199 case CK_PutOtherLink
:
1202 case CK_PutOtherTagged
:
1203 put_other_tagged ();
1206 delete_cmd (current_panel
);
1209 dialog_switch_list ();
1211 #ifdef USE_DIFF_VIEW
1212 case CK_CompareFiles
:
1216 case CK_OptionsDisplayBits
:
1217 display_bits_box ();
1220 edit_cmd (current_panel
);
1222 #ifdef USE_INTERNAL_EDIT
1223 case CK_EditForceInternal
:
1224 edit_cmd_force_internal (current_panel
);
1227 case CK_EditExtensionsFile
:
1230 case CK_EditFileHighlightFile
:
1233 case CK_EditUserMenu
:
1234 edit_mc_menu_cmd ();
1236 case CK_LinkSymbolicEdit
:
1237 edit_symlink_cmd ();
1239 case CK_ExternalPanelize
:
1240 external_panelize_cmd ();
1242 case CK_ViewFiltered
:
1243 view_filtered_cmd (current_panel
);
1246 find_cmd (current_panel
);
1248 #ifdef ENABLE_VFS_SHELL
1249 case CK_ConnectShell
:
1253 #ifdef ENABLE_VFS_FTP
1258 #ifdef ENABLE_VFS_SFTP
1259 case CK_ConnectSftp
:
1264 panel_panelize_cd ();
1270 /* show the history of command line widget */
1271 send_message (cmdline
, NULL
, MSG_ACTION
, CK_History
, NULL
);
1274 if (sender
== WIDGET (the_menubar
))
1275 info_cmd (); /* menu */
1277 info_cmd_no_menu (); /* shortcut or buttonbar */
1279 #ifdef ENABLE_BACKGROUND
1284 case CK_OptionsLayout
:
1287 case CK_OptionsAppearance
:
1294 link_cmd (LINK_HARDLINK
);
1296 case CK_PanelListing
:
1299 #ifdef LISTMODE_EDITOR
1307 case CK_MenuLastSelected
:
1308 menu_last_selected_cmd ();
1311 mkdir_cmd (current_panel
);
1313 case CK_OptionsPanel
:
1314 panel_options_box ();
1317 case CK_SelectCodepage
:
1322 quick_cd_cmd (current_panel
);
1325 hotlist_cmd (current_panel
);
1327 case CK_PanelQuickView
:
1328 if (sender
== WIDGET (the_menubar
))
1329 quick_view_cmd (); /* menu */
1331 quick_cmd_no_menu (); /* shortcut or buttonabr */
1339 case CK_LinkSymbolicRelative
:
1340 link_cmd (LINK_SYMLINK_RELATIVE
);
1343 rename_cmd (current_panel
);
1350 vfs_list (current_panel
);
1358 case CK_SelectInvert
:
1360 res
= send_message (current_panel
, filemanager
, MSG_ACTION
, command
, NULL
);
1366 smart_dirsize_cmd (current_panel
);
1371 case CK_ExtendedKeyMap
:
1372 WIDGET (filemanager
)->ext_mode
= TRUE
;
1375 mc_event_raise (MCEVENT_GROUP_CORE
, "suspend", NULL
);
1380 case CK_LinkSymbolic
:
1381 link_cmd (LINK_SYMLINK_ABSOLUTE
);
1384 toggle_show_hidden ();
1386 case CK_SplitVertHoriz
:
1387 toggle_panels_split ();
1390 panels_split_equal ();
1393 panels_split_more ();
1396 panels_split_less ();
1404 #ifdef ENABLE_VFS_UNDELFS
1410 user_file_menu_cmd ();
1413 view_cmd (current_panel
);
1416 view_file_cmd (current_panel
);
1418 case CK_EditorViewerHistory
:
1419 show_editor_viewer_history ();
1422 /* don't close panels due to SIGINT */
1425 res
= MSG_NOT_HANDLED
;
1431 /* --------------------------------------------------------------------------------------------- */
1434 * Whether the command-line should not respond to key events.
1436 * This is TRUE if a QuickView or TreeView have the focus, as they're going
1437 * to consume some keys and there's no sense in passing to the command-line
1438 * just the leftovers.
1441 is_cmdline_mute (void)
1443 /* When one of panels is other than view_listing,
1444 current_panel points to view_listing panel all time independently of
1445 it's activity. Thus, we can't use get_current_type() here.
1446 current_panel should point to actually current active panel
1447 independently of it's type. */
1448 return (!current_panel
->active
1449 && (get_other_type () == view_quick
|| get_other_type () == view_tree
));
1452 /* --------------------------------------------------------------------------------------------- */
1455 * Handles the Enter key on the command-line.
1457 * Returns TRUE if non-whitespace was indeed processed.
1460 handle_cmdline_enter (void)
1464 for (s
= input_get_ctext (cmdline
); *s
!= '\0' && whitespace (*s
); s
++)
1469 send_message (cmdline
, NULL
, MSG_KEY
, '\n', NULL
);
1473 input_insert (cmdline
, "", FALSE
);
1479 /* --------------------------------------------------------------------------------------------- */
1482 midnight_callback (Widget
*w
, Widget
*sender
, widget_msg_t msg
, int parm
, void *data
)
1495 group_default_callback (w
, NULL
, MSG_DRAW
, 0, NULL
);
1496 /* We handle the special case of the output lines */
1497 if (mc_global
.tty
.console_flag
!= '\0' && output_lines
!= 0)
1499 unsigned char end_line
;
1501 end_line
= LINES
- (mc_global
.keybar_visible
? 1 : 0) - 1;
1502 show_console_contents (output_start_y
, end_line
- output_lines
, end_line
);
1507 widget_adjust_position (w
->pos_flags
, &w
->rect
);
1509 menubar_arrange (the_menubar
);
1513 /* We only need the first idle event to show user menu after start */
1514 widget_idle (w
, FALSE
);
1516 if (boot_current_is_left
)
1517 widget_select (get_panel_widget (0));
1519 widget_select (get_panel_widget (1));
1522 midnight_execute_cmd (NULL
, CK_UserMenu
);
1528 command
= widget_lookup_key (w
, parm
);
1529 if (command
!= CK_IgnoreKey
)
1530 return midnight_execute_cmd (NULL
, command
);
1533 /* FIXME: should handle all menu shortcuts before this point */
1534 if (widget_get_state (WIDGET (the_menubar
), WST_FOCUSED
))
1535 return MSG_NOT_HANDLED
;
1537 if (parm
== '\n' && !is_cmdline_mute ())
1539 if (handle_cmdline_enter ())
1541 /* Else: the panel will handle it. */
1544 if ((!mc_global
.tty
.alternate_plus_minus
1545 || !(mc_global
.tty
.console_flag
!= '\0' || mc_global
.tty
.xterm_flag
)) && !quote
1546 && !current_panel
->quick_search
.active
)
1548 if (!only_leading_plus_minus
)
1550 /* Special treatment, since the input line will eat them */
1552 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Select
, NULL
);
1554 if (parm
== '\\' || parm
== '-')
1555 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Unselect
, NULL
);
1558 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_SelectInvert
,
1561 else if (!command_prompt
|| input_is_empty (cmdline
))
1563 /* Special treatment '+', '-', '\', '*' only when this is
1564 * first char on input line
1567 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Select
, NULL
);
1569 if (parm
== '\\' || parm
== '-')
1570 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_Unselect
, NULL
);
1573 return send_message (current_panel
, filemanager
, MSG_ACTION
, CK_SelectInvert
,
1577 return MSG_NOT_HANDLED
;
1579 case MSG_HOTKEY_HANDLED
:
1580 if ((get_current_type () == view_listing
) && current_panel
->quick_search
.active
)
1582 current_panel
->dirty
= TRUE
; /* FIXME: unneeded? */
1583 send_message (current_panel
, NULL
, MSG_ACTION
, CK_SearchStop
, NULL
);
1587 case MSG_UNHANDLED_KEY
:
1589 cb_ret_t v
= MSG_NOT_HANDLED
;
1591 command
= widget_lookup_key (w
, parm
);
1592 if (command
!= CK_IgnoreKey
)
1593 v
= midnight_execute_cmd (NULL
, command
);
1595 if (v
== MSG_NOT_HANDLED
&& command_prompt
&& !is_cmdline_mute ())
1596 v
= send_message (cmdline
, NULL
, MSG_KEY
, parm
, NULL
);
1602 if (!widget_get_state (WIDGET (the_menubar
), WST_FOCUSED
))
1603 update_dirty_panels ();
1607 /* Handle shortcuts, menu, and buttonbar. */
1608 return midnight_execute_cmd (sender
, parm
);
1615 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
1619 /* --------------------------------------------------------------------------------------------- */
1620 /*** public functions ****************************************************************************/
1621 /* --------------------------------------------------------------------------------------------- */
1626 menu_set_name (left_menu
, panels_layout
.horizontal_split
? _("&Above") : _("&Left"));
1627 menu_set_name (right_menu
, panels_layout
.horizontal_split
? _("&Below") : _("&Right"));
1628 menubar_arrange (the_menubar
);
1629 widget_set_visibility (WIDGET (the_menubar
), menubar_visible
);
1632 /* --------------------------------------------------------------------------------------------- */
1635 midnight_set_buttonbar (WButtonBar
*b
)
1637 Widget
*w
= WIDGET (filemanager
);
1639 buttonbar_set_label (b
, 1, Q_ ("ButtonBar|Help"), w
->keymap
, NULL
);
1640 buttonbar_set_label (b
, 2, Q_ ("ButtonBar|Menu"), w
->keymap
, NULL
);
1641 buttonbar_set_label (b
, 3, Q_ ("ButtonBar|View"), w
->keymap
, NULL
);
1642 buttonbar_set_label (b
, 4, Q_ ("ButtonBar|Edit"), w
->keymap
, NULL
);
1643 buttonbar_set_label (b
, 5, Q_ ("ButtonBar|Copy"), w
->keymap
, NULL
);
1644 buttonbar_set_label (b
, 6, Q_ ("ButtonBar|RenMov"), w
->keymap
, NULL
);
1645 buttonbar_set_label (b
, 7, Q_ ("ButtonBar|Mkdir"), w
->keymap
, NULL
);
1646 buttonbar_set_label (b
, 8, Q_ ("ButtonBar|Delete"), w
->keymap
, NULL
);
1647 buttonbar_set_label (b
, 9, Q_ ("ButtonBar|PullDn"), w
->keymap
, NULL
);
1648 buttonbar_set_label (b
, 10, Q_ ("ButtonBar|Quit"), w
->keymap
, NULL
);
1651 /* --------------------------------------------------------------------------------------------- */
1653 * Return a random hint. If force is TRUE, ignore the timeout.
1657 get_random_hint (gboolean force
)
1659 static const gint64 update_period
= 60 * G_USEC_PER_SEC
;
1660 static gint64 tv
= 0;
1662 char *data
, *result
, *eop
;
1666 /* Do not change hints more often than one minute */
1667 if (!force
&& !mc_time_elapsed (&tv
, update_period
))
1668 return g_strdup ("");
1670 data
= load_mc_home_file (mc_global
.share_data_dir
, MC_HINT
, NULL
, &len
);
1674 /* get a random entry */
1675 srand ((unsigned int) (tv
/ G_USEC_PER_SEC
));
1676 start
= ((size_t) rand ()) % (len
- 1);
1678 /* Search the start of paragraph */
1679 for (; start
!= 0; start
--)
1680 if (data
[start
] == '\n' && data
[start
+ 1] == '\n')
1686 /* Search the end of paragraph */
1687 for (eop
= data
+ start
; *eop
!= '\0'; eop
++)
1689 if (*eop
== '\n' && *(eop
+ 1) == '\n')
1698 /* hint files are stored in utf-8 */
1699 /* try convert hint file from utf-8 to terminal encoding */
1700 conv
= str_crt_conv_from ("UTF-8");
1701 if (conv
== INVALID_CONV
)
1702 result
= g_strndup (data
+ start
, len
- start
);
1708 buffer
= g_string_sized_new (len
- start
);
1709 nok
= (str_convert (conv
, data
+ start
, buffer
) == ESTR_FAILURE
);
1710 result
= g_string_free (buffer
, nok
);
1711 str_close_conv (conv
);
1719 /* --------------------------------------------------------------------------------------------- */
1721 * Load new hint and display it.
1722 * IF force is not 0, ignore the timeout.
1726 load_hint (gboolean force
)
1730 if (WIDGET (the_hint
)->owner
== NULL
)
1733 if (!mc_global
.message_visible
)
1735 label_set_text (the_hint
, NULL
);
1739 hint
= get_random_hint (force
);
1749 char text
[BUF_SMALL
];
1751 g_snprintf (text
, sizeof (text
), _("GNU Midnight Commander %s\n"), mc_global
.mc_version
);
1756 /* --------------------------------------------------------------------------------------------- */
1758 * Change current panel in the file manager.
1760 * @return current_panel
1766 input_complete_free (cmdline
);
1767 group_select_next_widget (GROUP (filemanager
));
1768 return current_panel
;
1771 /* --------------------------------------------------------------------------------------------- */
1773 /** Save current stat of directories to avoid reloading the panels
1774 * when no modifications have taken place
1777 save_cwds_stat (void)
1779 if (panels_options
.fast_reload
)
1781 mc_stat (current_panel
->cwd_vpath
, &(current_panel
->dir_stat
));
1782 if (get_other_type () == view_listing
)
1783 mc_stat (other_panel
->cwd_vpath
, &(other_panel
->dir_stat
));
1787 /* --------------------------------------------------------------------------------------------- */
1790 quiet_quit_cmd (void)
1792 print_last_revert
= TRUE
;
1793 return quit_cmd_internal (1);
1796 /* --------------------------------------------------------------------------------------------- */
1798 /** Run the main dialog that occupies the whole screen */
1804 #ifdef USE_INTERNAL_EDIT
1808 filemanager
= dlg_create (FALSE
, 0, 0, 1, 1, WPOS_FULLSCREEN
, FALSE
, dialog_colors
,
1809 midnight_callback
, NULL
, "[main]", NULL
);
1811 /* Check if we were invoked as an editor or file viewer */
1812 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
1815 ret
= mc_maybe_editor_or_viewer ();
1819 /* We only need the first idle event to show user menu after start */
1820 widget_idle (WIDGET (filemanager
), TRUE
);
1823 mc_filehighlight
= mc_fhl_new (TRUE
);
1825 create_file_manager ();
1826 (void) dlg_run (filemanager
);
1828 mc_fhl_free (&mc_filehighlight
);
1832 /* widget_destroy destroys even current_panel->cwd_vpath, so we have to save a copy :) */
1833 if (mc_args__last_wd_file
!= NULL
&& vfs_current_is_local ())
1834 last_wd_string
= g_strdup (vfs_path_as_str (current_panel
->cwd_vpath
));
1836 /* don't handle VFS timestamps for dirs opened in panels */
1837 mc_event_destroy (MCEVENT_GROUP_CORE
, "vfs_timestamp");
1841 mc_global
.midnight_shutdown
= TRUE
;
1842 dialog_switch_shutdown ();
1844 widget_destroy (WIDGET (filemanager
));
1845 current_panel
= NULL
;
1847 #ifdef USE_INTERNAL_EDIT
1851 if ((quit
& SUBSHELL_EXIT
) == 0)
1852 tty_clear_screen ();
1857 /* --------------------------------------------------------------------------------------------- */