Ticket #2601: incorrect TTY layer initialization.
[midnight-commander.git] / src / filemanager / midnight.c
blob8be079831f7441073bb001665b6f4c6393c43f4a
1 /* Main dialog (file panels) of the Midnight Commander
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
5 Written by: 1994, 1995, 1996, 1997 Miguel de Icaza
6 1994, 1995 Janne Kukonlehto
7 1997 Norbert Warmuth
8 2009, 2010 Andrew Borodin
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24 /** \file main.c
25 * \brief Source: main dialog (file panels) of the Midnight Commander
28 #include <config.h>
30 #include <ctype.h>
31 #include <errno.h>
32 #include <locale.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <fcntl.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <sys/wait.h>
40 #include <pwd.h> /* for username in xterm title */
42 #include "lib/global.h"
44 #include "lib/tty/tty.h"
45 #include "lib/tty/mouse.h"
46 #include "lib/tty/key.h" /* For init_key() */
47 #include "lib/tty/win.h" /* xterm_flag */
48 #include "lib/skin.h"
49 #include "lib/util.h"
51 #include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */
53 #include "src/args.h"
54 #include "src/subshell.h"
55 #include "src/setup.h" /* variables */
56 #include "src/learn.h" /* learn_keys() */
57 #include "src/execute.h" /* suspend_cmd() */
58 #include "src/keybind-defaults.h"
59 #include "src/main.h" /* quit */
61 #include "option.h" /* configure_box() */
62 #include "tree.h"
63 #include "boxes.h" /* sort_box(), tree_box() */
64 #include "layout.h"
65 #include "cmd.h" /* commands */
66 #include "hotlist.h"
67 #include "panelize.h"
68 #include "command.h" /* cmdline */
69 #include "lib/keybind.h"
71 #include "chmod.h"
72 #include "chown.h"
73 #include "achown.h"
75 #ifdef USE_INTERNAL_EDIT
76 #include "src/editor/edit.h"
77 #endif
79 #ifdef USE_DIFF_VIEW
80 #include "src/diffviewer/ydiff.h"
81 #endif
83 #include "src/consaver/cons.saver.h" /* console_flag */
85 #include "midnight.h"
87 /* TODO: merge content of layout.c here */
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;
102 /* Set if the command is being run from the "Right" menu */
103 int is_right = 0;
105 /* The Menubar */
106 WMenuBar *the_menubar = NULL;
107 /* The widget where we draw the prompt */
108 WLabel *the_prompt;
109 /* The hint bar */
110 WLabel *the_hint;
111 /* The button bar */
112 WButtonBar *the_bar;
114 /* The dialog handle for the main program */
115 Dlg_head *midnight_dlg = NULL;
117 /*** file scope macro definitions ****************************************************************/
119 #ifdef HAVE_CHARSET
121 * Don't restrict the output on the screen manager level,
122 * the translation tables take care of it.
124 #define full_eight_bits (1)
125 #define eight_bit_clean (1)
126 #endif /* !HAVE_CHARSET */
128 /*** file scope type declarations ****************************************************************/
130 /*** file scope variables ************************************************************************/
132 static Menu *left_menu, *right_menu;
134 static gboolean ctl_x_map_enabled = FALSE;
136 /*** file scope functions ************************************************************************/
138 /** Stop MC main dialog and the current dialog if it exists.
139 * Needed to provide fast exit from MC viewer or editor on shell exit */
140 static void
141 stop_dialogs (void)
143 midnight_dlg->state = DLG_CLOSED;
145 if ((top_dlg != NULL) && (top_dlg->data != NULL))
146 ((Dlg_head *) top_dlg->data)->state = DLG_CLOSED;
149 /* --------------------------------------------------------------------------------------------- */
151 static void
152 treebox_cmd (void)
154 char *sel_dir;
156 sel_dir = tree_box (selection (current_panel)->fname);
157 if (sel_dir)
159 do_cd (sel_dir, cd_exact);
160 g_free (sel_dir);
164 /* --------------------------------------------------------------------------------------------- */
166 #ifdef LISTMODE_EDITOR
167 static void
168 listmode_cmd (void)
170 char *newmode;
172 if (get_current_type () != view_listing)
173 return;
175 newmode = listmode_edit (current_panel->user_format);
176 if (!newmode)
177 return;
179 g_free (current_panel->user_format);
180 current_panel->list_type = list_user;
181 current_panel->user_format = newmode;
182 set_panel_formats (current_panel);
184 do_refresh ();
186 #endif /* LISTMODE_EDITOR */
188 /* --------------------------------------------------------------------------------------------- */
190 static GList *
191 create_panel_menu (void)
193 GList *entries = NULL;
195 entries = g_list_append (entries, menu_entry_create (_("File listin&g"), CK_ListingCmd));
196 entries = g_list_append (entries, menu_entry_create (_("&Quick view"), CK_QuickViewCmd));
197 entries = g_list_append (entries, menu_entry_create (_("&Info"), CK_InfoCmd));
198 entries = g_list_append (entries, menu_entry_create (_("&Tree"), CK_TreeCmd));
199 entries = g_list_append (entries, menu_separator_create ());
200 entries =
201 g_list_append (entries, menu_entry_create (_("&Listing mode..."), CK_ChangeListingCmd));
202 entries = g_list_append (entries, menu_entry_create (_("&Sort order..."), CK_Sort));
203 entries = g_list_append (entries, menu_entry_create (_("&Filter..."), CK_FilterCmd));
204 #ifdef HAVE_CHARSET
205 entries =
206 g_list_append (entries, menu_entry_create (_("&Encoding..."), CK_PanelSetPanelEncoding));
207 #endif
208 #ifdef ENABLE_VFS_NET
209 entries = g_list_append (entries, menu_separator_create ());
210 #ifdef ENABLE_VFS_FTP
211 entries = g_list_append (entries, menu_entry_create (_("FT&P link..."), CK_FtplinkCmd));
212 #endif
213 #ifdef ENABLE_VFS_FISH
214 entries = g_list_append (entries, menu_entry_create (_("S&hell link..."), CK_FishlinkCmd));
215 #endif
216 #ifdef ENABLE_VFS_SMB
217 entries = g_list_append (entries, menu_entry_create (_("SM&B link..."), CK_SmblinkCmd));
218 #endif
219 #endif /* ENABLE_VFS_NET */
220 entries = g_list_append (entries, menu_separator_create ());
221 entries = g_list_append (entries, menu_entry_create (_("&Rescan"), CK_RereadCmd));
223 return entries;
226 /* --------------------------------------------------------------------------------------------- */
228 static GList *
229 create_file_menu (void)
231 GList *entries = NULL;
233 entries = g_list_append (entries, menu_entry_create (_("&View"), CK_ViewCmd));
234 entries = g_list_append (entries, menu_entry_create (_("Vie&w file..."), CK_ViewFileCmd));
235 entries = g_list_append (entries, menu_entry_create (_("&Filtered view"), CK_FilteredViewCmd));
236 entries = g_list_append (entries, menu_entry_create (_("&Edit"), CK_EditCmd));
237 entries = g_list_append (entries, menu_entry_create (_("&Copy"), CK_CopyCmd));
238 entries = g_list_append (entries, menu_entry_create (_("C&hmod"), CK_ChmodCmd));
239 entries = g_list_append (entries, menu_entry_create (_("&Link"), CK_LinkCmd));
240 entries = g_list_append (entries, menu_entry_create (_("&Symlink"), CK_SymlinkCmd));
241 entries =
242 g_list_append (entries, menu_entry_create (_("Relative symlin&k"), CK_RelativeSymlinkCmd));
243 entries = g_list_append (entries, menu_entry_create (_("Edit s&ymlink"), CK_EditSymlinkCmd));
244 entries = g_list_append (entries, menu_entry_create (_("Ch&own"), CK_ChownCmd));
245 entries =
246 g_list_append (entries, menu_entry_create (_("&Advanced chown"), CK_ChownAdvancedCmd));
247 entries = g_list_append (entries, menu_entry_create (_("&Rename/Move"), CK_RenameCmd));
248 entries = g_list_append (entries, menu_entry_create (_("&Mkdir"), CK_MkdirCmd));
249 entries = g_list_append (entries, menu_entry_create (_("&Delete"), CK_DeleteCmd));
250 entries = g_list_append (entries, menu_entry_create (_("&Quick cd"), CK_QuickCdCmd));
251 entries = g_list_append (entries, menu_separator_create ());
252 entries = g_list_append (entries, menu_entry_create (_("Select &group"), CK_SelectCmd));
253 entries = g_list_append (entries, menu_entry_create (_("U&nselect group"), CK_UnselectCmd));
254 entries =
255 g_list_append (entries,
256 menu_entry_create (_("Reverse selec&tion"), CK_ReverseSelectionCmd));
257 entries = g_list_append (entries, menu_separator_create ());
258 entries = g_list_append (entries, menu_entry_create (_("E&xit"), CK_QuitCmd));
260 return entries;
263 /* --------------------------------------------------------------------------------------------- */
265 static GList *
266 create_command_menu (void)
268 /* I know, I'm lazy, but the tree widget when it's not running
269 * as a panel still has some problems, I have not yet finished
270 * the WTree widget port, sorry.
272 GList *entries = NULL;
274 entries = g_list_append (entries, menu_entry_create (_("&User menu"), CK_UserMenuCmd));
275 entries = g_list_append (entries, menu_entry_create (_("&Directory tree"), CK_TreeBoxCmd));
276 entries = g_list_append (entries, menu_entry_create (_("&Find file"), CK_FindCmd));
277 entries = g_list_append (entries, menu_entry_create (_("S&wap panels"), CK_SwapCmd));
278 entries =
279 g_list_append (entries, menu_entry_create (_("Switch &panels on/off"), CK_ShowCommandLine));
280 entries =
281 g_list_append (entries, menu_entry_create (_("&Compare directories"), CK_CompareDirsCmd));
282 #ifdef USE_DIFF_VIEW
283 entries = g_list_append (entries, menu_entry_create (_("&View diff files"), CK_DiffViewCmd));
284 #endif
285 entries =
286 g_list_append (entries, menu_entry_create (_("E&xternal panelize"), CK_ExternalPanelize));
287 entries =
288 g_list_append (entries,
289 menu_entry_create (_("Show directory s&izes"), CK_SingleDirsizeCmd));
290 entries = g_list_append (entries, menu_separator_create ());
291 entries = g_list_append (entries, menu_entry_create (_("Command &history"), CK_HistoryCmd));
292 entries =
293 g_list_append (entries, menu_entry_create (_("Di&rectory hotlist"), CK_QuickChdirCmd));
294 #ifdef ENABLE_VFS
295 entries = g_list_append (entries, menu_entry_create (_("&Active VFS list"), CK_ReselectVfs));
296 #endif
297 #ifdef WITH_BACKGROUND
298 entries = g_list_append (entries, menu_entry_create (_("&Background jobs"), CK_JobsCmd));
299 #endif
300 entries = g_list_append (entries, menu_entry_create (_("Screen lis&t"), CK_DialogListCmd));
301 entries = g_list_append (entries, menu_separator_create ());
302 #ifdef ENABLE_VFS_UNDELFS
303 entries =
304 g_list_append (entries,
305 menu_entry_create (_("&Undelete files (ext2fs only)"), CK_UndeleteCmd));
306 #endif
307 #ifdef LISTMODE_EDITOR
308 entries =
309 g_list_append (entries, menu_entry_create (_("&Listing format edit"), CK_ListmodeCmd));
310 #endif
311 #if defined (ENABLE_VFS_UNDELFS) || defined (LISTMODE_EDITOR)
312 entries = g_list_append (entries, menu_separator_create ());
313 #endif
314 entries =
315 g_list_append (entries, menu_entry_create (_("Edit &extension file"), CK_EditExtFileCmd));
316 entries = g_list_append (entries, menu_entry_create (_("Edit &menu file"), CK_EditMcMenuCmd));
317 entries =
318 g_list_append (entries,
319 menu_entry_create (_("Edit hi&ghlighting group file"), CK_EditFhlFileCmd));
321 return entries;
324 /* --------------------------------------------------------------------------------------------- */
326 static GList *
327 create_options_menu (void)
329 GList *entries = NULL;
331 entries = g_list_append (entries, menu_entry_create (_("&Configuration..."), CK_ConfigureBox));
332 entries = g_list_append (entries, menu_entry_create (_("&Layout..."), CK_LayoutBox));
333 entries =
334 g_list_append (entries, menu_entry_create (_("&Panel options..."), CK_PanelOptionsBox));
335 entries = g_list_append (entries, menu_entry_create (_("C&onfirmation..."), CK_ConfirmBox));
336 entries = g_list_append (entries, menu_entry_create (_("&Display bits..."), CK_DisplayBitsBox));
337 entries = g_list_append (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
338 #ifdef ENABLE_VFS
339 entries = g_list_append (entries, menu_entry_create (_("&Virtual FS..."), CK_ConfigureVfs));
340 #endif
341 entries = g_list_append (entries, menu_separator_create ());
342 entries = g_list_append (entries, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd));
344 return entries;
347 /* --------------------------------------------------------------------------------------------- */
349 static void
350 init_menu (void)
352 left_menu = create_menu ("", create_panel_menu (), "[Left and Right Menus]");
353 menubar_add_menu (the_menubar, left_menu);
354 menubar_add_menu (the_menubar, create_menu (_("&File"), create_file_menu (), "[File Menu]"));
355 menubar_add_menu (the_menubar,
356 create_menu (_("&Command"), create_command_menu (), "[Command Menu]"));
357 menubar_add_menu (the_menubar,
358 create_menu (_("&Options"), create_options_menu (), "[Options Menu]"));
359 right_menu = create_menu ("", create_panel_menu (), "[Left and Right Menus]");
360 menubar_add_menu (the_menubar, right_menu);
361 update_menu ();
364 /* --------------------------------------------------------------------------------------------- */
366 static void
367 menu_last_selected_cmd (void)
369 the_menubar->is_active = TRUE;
370 the_menubar->is_dropped = (drop_menus != 0);
371 the_menubar->previous_widget = dlg_get_current_widget_id (midnight_dlg);
372 dlg_select_widget (the_menubar);
375 /* --------------------------------------------------------------------------------------------- */
377 static void
378 menu_cmd (void)
380 if (the_menubar->is_active)
381 return;
383 if ((get_current_index () == 0) == (current_panel->active != 0))
384 the_menubar->selected = 0;
385 else
386 the_menubar->selected = g_list_length (the_menubar->menu) - 1;
387 menu_last_selected_cmd ();
390 /* --------------------------------------------------------------------------------------------- */
392 static void
393 sort_cmd (void)
395 WPanel *p;
396 const panel_field_t *sort_order;
398 if (!SELECTED_IS_PANEL)
399 return;
401 p = MENU_PANEL;
402 sort_order = sort_box (&p->sort_info);
403 panel_set_sort_order (p, sort_order);
406 /* --------------------------------------------------------------------------------------------- */
408 static char *
409 midnight_get_shortcut (unsigned long command)
411 const char *ext_map;
412 const char *shortcut = NULL;
414 shortcut = keybind_lookup_keymap_shortcut (main_map, command);
415 if (shortcut != NULL)
416 return g_strdup (shortcut);
418 shortcut = keybind_lookup_keymap_shortcut (panel_map, command);
419 if (shortcut != NULL)
420 return g_strdup (shortcut);
422 ext_map = keybind_lookup_keymap_shortcut (main_map, CK_StartExtMap1);
423 if (ext_map != NULL)
424 shortcut = keybind_lookup_keymap_shortcut (main_x_map, command);
425 if (shortcut != NULL)
426 return g_strdup_printf ("%s %s", ext_map, shortcut);
428 return NULL;
431 /* --------------------------------------------------------------------------------------------- */
433 static char *
434 midnight_get_title (const Dlg_head * h, size_t len)
436 /* TODO: share code with update_xterm_title_path() */
438 const char *path;
439 char host[BUF_TINY];
440 char *p;
441 struct passwd *pw = NULL;
442 char *login = NULL;
443 int res = 0;
445 (void) h;
447 path = strip_home_and_password (current_panel->cwd);
448 res = gethostname (host, sizeof (host));
449 if (res != 0)
450 host[0] = '\0';
451 else
452 host[sizeof (host) - 1] = '\0';
454 pw = getpwuid (getuid ());
455 if (pw != NULL)
456 login = g_strdup_printf ("%s@%s", pw->pw_name, host);
457 else
458 login = g_strdup (host);
460 p = g_strdup_printf ("%s [%s]:%s", _("Panels:"), login, path);
461 path = str_trunc (p, len - 4);
462 g_free (login);
463 g_free (p);
465 return g_strdup (path);
468 /* --------------------------------------------------------------------------------------------- */
470 static void
471 toggle_panels_split (void)
473 horizontal_split = !horizontal_split;
474 layout_change ();
475 do_refresh ();
478 /* --------------------------------------------------------------------------------------------- */
481 * Just a hack for allowing url-like pathnames to be accepted from the
482 * command line.
484 static void
485 translated_mc_chdir (char *dir)
487 char *newdir;
488 int ret;
490 newdir = vfs_translate_url (dir);
491 ret = mc_chdir (newdir);
492 g_free (newdir);
495 /* --------------------------------------------------------------------------------------------- */
497 static void
498 create_panels (void)
500 int current_index;
501 int other_index;
502 panel_view_mode_t current_mode, other_mode;
503 char original_dir[BUF_1K] = "\0";
505 if (boot_current_is_left)
507 current_index = 0;
508 other_index = 1;
509 current_mode = startup_left_mode;
510 other_mode = startup_right_mode;
512 else
514 current_index = 1;
515 other_index = 0;
516 current_mode = startup_right_mode;
517 other_mode = startup_left_mode;
519 /* Creates the left panel */
520 if (mc_run_param0 != NULL)
522 if (mc_run_param1 != NULL)
524 /* Ok, user has specified two dirs, save the original one,
525 * since we may not be able to chdir to the proper
526 * second directory later
528 mc_get_current_wd (original_dir, sizeof (original_dir) - 2);
530 translated_mc_chdir (mc_run_param0);
532 set_display_type (current_index, current_mode);
534 /* The other panel */
535 if (mc_run_param1 != NULL)
537 if (original_dir[0] != '\0')
538 translated_mc_chdir (original_dir);
539 translated_mc_chdir (mc_run_param1);
541 set_display_type (other_index, other_mode);
543 if (startup_left_mode == view_listing)
545 current_panel = left_panel;
547 else
549 if (right_panel)
550 current_panel = right_panel;
551 else
552 current_panel = left_panel;
555 /* Create the nice widgets */
556 cmdline = command_new (0, 0, 0);
557 the_prompt = label_new (0, 0, mc_prompt);
558 the_prompt->transparent = 1;
559 the_bar = buttonbar_new (keybar_visible);
561 the_hint = label_new (0, 0, 0);
562 the_hint->transparent = 1;
563 the_hint->auto_adjust_cols = 0;
564 the_hint->widget.cols = COLS;
566 the_menubar = menubar_new (0, 0, COLS, NULL);
569 /* --------------------------------------------------------------------------------------------- */
571 static void
572 copy_current_pathname (void)
574 char *cwd_path;
575 if (!command_prompt)
576 return;
578 cwd_path = remove_encoding_from_path (current_panel->cwd);
579 command_insert (cmdline, cwd_path, FALSE);
581 if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
582 command_insert (cmdline, PATH_SEP_STR, FALSE);
583 g_free (cwd_path);
586 /* --------------------------------------------------------------------------------------------- */
588 static void
589 copy_other_pathname (void)
591 char *cwd_path;
593 if (get_other_type () != view_listing)
594 return;
596 if (!command_prompt)
597 return;
599 cwd_path = remove_encoding_from_path (other_panel->cwd);
600 command_insert (cmdline, cwd_path, FALSE);
602 if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
603 command_insert (cmdline, PATH_SEP_STR, FALSE);
604 g_free (cwd_path);
607 /* --------------------------------------------------------------------------------------------- */
609 static void
610 copy_readlink (WPanel * panel)
612 if (!command_prompt)
613 return;
614 if (S_ISLNK (selection (panel)->st.st_mode))
616 char buffer[MC_MAXPATHLEN];
617 char *p = concat_dir_and_file (panel->cwd, selection (panel)->fname);
618 int i;
620 i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
621 g_free (p);
622 if (i > 0)
624 buffer[i] = 0;
625 command_insert (cmdline, buffer, TRUE);
630 /* --------------------------------------------------------------------------------------------- */
632 static void
633 copy_current_readlink (void)
635 copy_readlink (current_panel);
638 /* --------------------------------------------------------------------------------------------- */
640 static void
641 copy_other_readlink (void)
643 if (get_other_type () == view_listing)
644 copy_readlink (other_panel);
647 /* --------------------------------------------------------------------------------------------- */
649 /** Insert the selected file name into the input line */
650 static void
651 copy_prog_name (void)
653 char *tmp;
654 if (!command_prompt)
655 return;
657 if (get_current_type () == view_tree)
659 WTree *tree = (WTree *) get_panel_widget (get_current_index ());
660 tmp = tree_selected_name (tree);
662 else
663 tmp = selection (current_panel)->fname;
665 command_insert (cmdline, tmp, TRUE);
668 /* --------------------------------------------------------------------------------------------- */
670 static void
671 copy_tagged (WPanel * panel)
673 int i;
675 if (!command_prompt)
676 return;
677 input_disable_update (cmdline);
678 if (panel->marked)
680 for (i = 0; i < panel->count; i++)
682 if (panel->dir.list[i].f.marked)
683 command_insert (cmdline, panel->dir.list[i].fname, TRUE);
686 else
688 command_insert (cmdline, panel->dir.list[panel->selected].fname, TRUE);
690 input_enable_update (cmdline);
693 /* --------------------------------------------------------------------------------------------- */
695 static void
696 copy_current_tagged (void)
698 copy_tagged (current_panel);
701 /* --------------------------------------------------------------------------------------------- */
703 static void
704 copy_other_tagged (void)
706 if (get_other_type () == view_listing)
707 copy_tagged (other_panel);
710 /* --------------------------------------------------------------------------------------------- */
712 static void
713 ctl_x_cmd (void)
715 ctl_x_map_enabled = TRUE;
718 /* --------------------------------------------------------------------------------------------- */
720 static void
721 setup_mc (void)
723 #ifdef HAVE_SLANG
724 tty_display_8bit (full_eight_bits != 0);
725 #else
726 tty_display_8bit (eight_bit_clean != 0);
727 #endif
729 #ifdef HAVE_SUBSHELL_SUPPORT
730 if (use_subshell)
731 add_select_channel (subshell_pty, load_prompt, 0);
732 #endif /* !HAVE_SUBSHELL_SUPPORT */
734 tty_setup_sigwinch (sigwinch_handler);
736 if ((tty_baudrate () < 9600) || tty_is_slow ())
737 verbose = 0;
740 /* --------------------------------------------------------------------------------------------- */
742 static void
743 setup_dummy_mc (void)
745 char d[MC_MAXPATHLEN];
746 int ret;
748 mc_get_current_wd (d, MC_MAXPATHLEN);
749 setup_mc ();
750 ret = mc_chdir (d);
753 /* --------------------------------------------------------------------------------------------- */
755 static void
756 done_screen (void)
758 if ((quit & SUBSHELL_EXIT) == 0)
759 clr_scr ();
760 tty_reset_shell_mode ();
761 tty_noraw_mode ();
762 tty_keypad (FALSE);
765 /* --------------------------------------------------------------------------------------------- */
767 static void
768 done_mc (void)
770 disable_mouse ();
772 /* Setup shutdown
774 * We sync the profiles since the hotlist may have changed, while
775 * we only change the setup data if we have the auto save feature set
778 save_setup (auto_save_setup, panels_options.auto_save_setup);
779 done_screen ();
781 vfs_stamp_path (vfs_get_current_dir ());
783 if ((current_panel != NULL) && (get_current_type () == view_listing))
784 vfs_stamp_path (current_panel->cwd);
786 if ((other_panel != NULL) && (get_other_type () == view_listing))
787 vfs_stamp_path (other_panel->cwd);
790 /* --------------------------------------------------------------------------------------------- */
792 static void
793 create_panels_and_run_mc (void)
795 midnight_dlg->get_shortcut = midnight_get_shortcut;
796 midnight_dlg->get_title = midnight_get_title;
798 create_panels ();
800 add_widget (midnight_dlg, the_menubar);
801 init_menu ();
803 add_widget (midnight_dlg, get_panel_widget (0));
804 add_widget (midnight_dlg, get_panel_widget (1));
806 add_widget (midnight_dlg, the_hint);
807 add_widget (midnight_dlg, cmdline);
808 add_widget (midnight_dlg, the_prompt);
810 add_widget (midnight_dlg, the_bar);
811 midnight_set_buttonbar (the_bar);
813 /* Run the Midnight Commander if no file was specified in the command line */
814 run_dlg (midnight_dlg);
817 /* --------------------------------------------------------------------------------------------- */
819 /** result must be free'd (I think this should go in util.c) */
820 static char *
821 prepend_cwd_on_local (const char *filename)
823 char *d;
824 size_t l;
826 if (!vfs_file_is_local (filename) || g_path_is_absolute (filename))
827 return g_strdup (filename);
829 d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2);
830 mc_get_current_wd (d, MC_MAXPATHLEN);
831 l = strlen (d);
832 d[l++] = PATH_SEP;
833 strcpy (d + l, filename);
834 canonicalize_pathname (d);
835 return d;
838 /* --------------------------------------------------------------------------------------------- */
840 /** Invoke the internal view/edit routine with:
841 * the default processing and forcing the internal viewer/editor
843 static void
844 mc_maybe_editor_or_viewer (void)
846 switch (mc_run_mode)
848 #ifdef USE_INTERNAL_EDIT
849 case MC_RUN_EDITOR:
850 edit_file (mc_run_param0, mc_args__edit_start_line);
851 break;
852 #endif /* USE_INTERNAL_EDIT */
853 case MC_RUN_VIEWER:
855 char *path;
856 path = prepend_cwd_on_local (mc_run_param0);
857 view_file (path, 0, 1);
858 g_free (path);
859 break;
861 #ifdef USE_DIFF_VIEW
862 case MC_RUN_DIFFVIEWER:
863 diff_view (mc_run_param0, mc_run_param1, mc_run_param0, mc_run_param1);
864 break;
865 #endif /* USE_DIFF_VIEW */
866 default:
867 break;
871 /* --------------------------------------------------------------------------------------------- */
873 static gboolean
874 quit_cmd_internal (int quiet)
876 int q = quit;
877 size_t n;
879 n = dialog_switch_num () - 1;
880 if (n != 0)
882 char msg[BUF_MEDIUM];
884 g_snprintf (msg, sizeof (msg),
885 ngettext ("You have %zd opened screen. Quit anyway?",
886 "You have %zd opened screens. Quit anyway?", n), n);
888 if (query_dialog (_("The Midnight Commander"), msg, D_NORMAL, 2, _("&Yes"), _("&No")) != 0)
889 return FALSE;
890 q = 1;
892 else if (quiet || !confirm_exit)
893 q = 1;
894 else if (query_dialog (_("The Midnight Commander"),
895 _("Do you really want to quit the Midnight Commander?"),
896 D_NORMAL, 2, _("&Yes"), _("&No")) == 0)
897 q = 1;
899 if (q != 0)
901 #ifdef HAVE_SUBSHELL_SUPPORT
902 if (!use_subshell)
903 stop_dialogs ();
904 else if ((q = exit_subshell ()))
905 #endif
906 stop_dialogs ();
909 if (q != 0)
910 quit |= 1;
911 return (quit != 0);
914 /* --------------------------------------------------------------------------------------------- */
916 static gboolean
917 quit_cmd (void)
919 return quit_cmd_internal (0);
922 /* --------------------------------------------------------------------------------------------- */
924 static void
925 toggle_show_hidden (void)
927 panels_options.show_dot_files = !panels_options.show_dot_files;
928 update_panels (UP_RELOAD, UP_KEEPSEL);
931 /* --------------------------------------------------------------------------------------------- */
934 * Repaint the contents of the panels without frames. To schedule panel
935 * for repainting, set panel->dirty to 1. There are many reasons why
936 * the panels need to be repainted, and this is a costly operation, so
937 * it's done once per event.
940 static void
941 update_dirty_panels (void)
943 if (get_current_type () == view_listing && current_panel->dirty)
944 send_message ((Widget *) current_panel, WIDGET_DRAW, 0);
946 if (get_other_type () == view_listing && other_panel->dirty)
947 send_message ((Widget *) other_panel, WIDGET_DRAW, 0);
950 /* --------------------------------------------------------------------------------------------- */
952 static cb_ret_t
953 midnight_execute_cmd (Widget * sender, unsigned long command)
955 cb_ret_t res = MSG_HANDLED;
957 (void) sender;
959 /* stop quick search before executing any command */
960 send_message ((Widget *) current_panel, WIDGET_COMMAND, CK_PanelStopSearch);
962 switch (command)
964 case CK_AddHotlist:
965 add2hotlist_cmd ();
966 break;
967 case CK_ChangeListingCmd:
968 change_listing_cmd ();
969 break;
970 case CK_ChmodCmd:
971 chmod_cmd ();
972 break;
973 case CK_ChownCmd:
974 chown_cmd ();
975 break;
976 case CK_ChownAdvancedCmd:
977 chown_advanced_cmd ();
978 break;
979 case CK_CompareDirsCmd:
980 compare_dirs_cmd ();
981 break;
982 case CK_ConfigureBox:
983 configure_box ();
984 break;
985 #ifdef ENABLE_VFS
986 case CK_ConfigureVfs:
987 configure_vfs ();
988 break;
989 #endif
990 case CK_ConfirmBox:
991 confirm_box ();
992 break;
993 case CK_CopyCmd:
994 copy_cmd ();
995 break;
996 case CK_CopyCurrentPathname:
997 copy_current_pathname ();
998 break;
999 case CK_CopyCurrentReadlink:
1000 copy_current_readlink ();
1001 break;
1002 case CK_CopyCurrentTagged:
1003 copy_current_tagged ();
1004 break;
1005 case CK_CopyOtherPathname:
1006 copy_other_pathname ();
1007 break;
1008 case CK_CopyOtherReadlink:
1009 copy_other_readlink ();
1010 break;
1011 case CK_CopyOtherTagged:
1012 copy_other_tagged ();
1013 break;
1014 case CK_DeleteCmd:
1015 delete_cmd ();
1016 break;
1017 case CK_DialogListCmd:
1018 dialog_switch_list ();
1019 break;
1020 #ifdef USE_DIFF_VIEW
1021 case CK_DiffViewCmd:
1022 diff_view_cmd ();
1023 break;
1024 #endif
1025 case CK_DisplayBitsBox:
1026 display_bits_box ();
1027 break;
1028 case CK_EditCmd:
1029 edit_cmd ();
1030 break;
1031 #ifdef USE_INTERNAL_EDIT
1032 case CK_EditForceInternalCmd:
1033 edit_cmd_force_internal ();
1034 break;
1035 #endif
1036 case CK_EditExtFileCmd:
1037 ext_cmd ();
1038 break;
1039 case CK_EditFhlFileCmd:
1040 edit_fhl_cmd ();
1041 break;
1042 case CK_EditMcMenuCmd:
1043 edit_mc_menu_cmd ();
1044 break;
1045 case CK_EditSymlinkCmd:
1046 edit_symlink_cmd ();
1047 break;
1048 case CK_ExternalPanelize:
1049 external_panelize ();
1050 break;
1051 case CK_FilterCmd:
1052 filter_cmd ();
1053 break;
1054 case CK_FilteredViewCmd:
1055 filtered_view_cmd ();
1056 break;
1057 case CK_FindCmd:
1058 find_cmd ();
1059 break;
1060 #ifdef ENABLE_VFS_FISH
1061 case CK_FishlinkCmd:
1062 fishlink_cmd ();
1063 break;
1064 #endif
1065 #ifdef ENABLE_VFS_FTP
1066 case CK_FtplinkCmd:
1067 ftplink_cmd ();
1068 break;
1069 #endif
1070 case CK_HelpCmd:
1071 help_cmd ();
1072 break;
1073 case CK_HistoryCmd:
1074 history_cmd ();
1075 break;
1076 case CK_InfoCmd:
1077 if (sender == (Widget *) the_menubar)
1078 info_cmd (); /* mwnu */
1079 else
1080 info_cmd_no_menu (); /* shortcut or buttonbar */
1081 break;
1082 #ifdef WITH_BACKGROUND
1083 case CK_JobsCmd:
1084 jobs_cmd ();
1085 break;
1086 #endif
1087 case CK_LayoutBox:
1088 layout_box ();
1089 break;
1090 case CK_LearnKeys:
1091 learn_keys ();
1092 break;
1093 case CK_LinkCmd:
1094 link_cmd (LINK_HARDLINK);
1095 break;
1096 case CK_ListingCmd:
1097 listing_cmd ();
1098 break;
1099 #ifdef LISTMODE_EDITOR
1100 case CK_ListmodeCmd:
1101 listmode_cmd ();
1102 break;
1103 #endif
1104 case CK_MenuCmd:
1105 menu_cmd ();
1106 break;
1107 case CK_MenuLastSelectedCmd:
1108 menu_last_selected_cmd ();
1109 break;
1110 case CK_MkdirCmd:
1111 mkdir_cmd ();
1112 break;
1113 case CK_PanelOptionsBox:
1114 panel_options_box ();
1115 break;
1116 #ifdef HAVE_CHARSET
1117 case CK_PanelSetPanelEncoding:
1118 encoding_cmd ();
1119 break;
1120 #endif
1121 case CK_QuickCdCmd:
1122 quick_cd_cmd ();
1123 break;
1124 case CK_QuickChdirCmd:
1125 quick_chdir_cmd ();
1126 break;
1127 case CK_QuickViewCmd:
1128 if (sender == (Widget *) the_menubar)
1129 quick_view_cmd (); /* menu */
1130 else
1131 quick_cmd_no_menu (); /* shortcut or buttonabr */
1132 break;
1133 case CK_QuietQuitCmd:
1134 quiet_quit_cmd ();
1135 break;
1136 case CK_QuitCmd:
1137 quit_cmd ();
1138 break;
1139 case CK_RelativeSymlinkCmd:
1140 link_cmd (LINK_SYMLINK_RELATIVE);
1141 break;
1142 case CK_RenameCmd:
1143 rename_cmd ();
1144 break;
1145 case CK_RereadCmd:
1146 reread_cmd ();
1147 break;
1148 #ifdef ENABLE_VFS
1149 case CK_ReselectVfs:
1150 reselect_vfs ();
1151 break;
1152 #endif
1153 case CK_ReverseSelectionCmd:
1154 reverse_selection_cmd ();
1155 break;
1156 case CK_SaveSetupCmd:
1157 save_setup_cmd ();
1158 break;
1159 case CK_SelectCmd:
1160 select_cmd ();
1161 break;
1162 case CK_ShowCommandLine:
1163 view_other_cmd ();
1164 break;
1165 case CK_SingleDirsizeCmd:
1166 smart_dirsize_cmd ();
1167 break;
1168 #ifdef ENABLE_VFS_SMB
1169 case CK_SmblinkCmd:
1170 smblink_cmd ();
1171 break;
1172 #endif /* ENABLE_VFS_SMB */
1173 case CK_Sort:
1174 sort_cmd ();
1175 break;
1176 case CK_StartExtMap1:
1177 ctl_x_cmd ();
1178 break;
1179 case CK_SuspendCmd:
1180 suspend_cmd ();
1181 break;
1182 case CK_SwapCmd:
1183 swap_cmd ();
1184 break;
1185 case CK_SymlinkCmd:
1186 link_cmd (LINK_SYMLINK_ABSOLUTE);
1187 break;
1188 case CK_ToggleListingCmd:
1189 toggle_listing_cmd ();
1190 break;
1191 case CK_ToggleShowHidden:
1192 toggle_show_hidden ();
1193 break;
1194 case CK_TogglePanelsSplit:
1195 toggle_panels_split ();
1196 break;
1197 case CK_TreeCmd:
1198 tree_cmd ();
1199 break;
1200 case CK_TreeBoxCmd:
1201 treebox_cmd ();
1202 break;
1203 #ifdef ENABLE_VFS_UNDELFS
1204 case CK_UndeleteCmd:
1205 undelete_cmd ();
1206 break;
1207 #endif
1208 case CK_UnselectCmd:
1209 unselect_cmd ();
1210 break;
1211 case CK_UserMenuCmd:
1212 user_file_menu_cmd ();
1213 break;
1214 case CK_ViewCmd:
1215 view_cmd ();
1216 break;
1217 case CK_ViewFileCmd:
1218 view_file_cmd ();
1219 break;
1220 case CK_DialogCancel:
1221 /* don't close panels due to SIGINT */
1222 break;
1223 default:
1224 res = MSG_NOT_HANDLED;
1227 return res;
1230 /* --------------------------------------------------------------------------------------------- */
1232 static cb_ret_t
1233 midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
1235 unsigned long command;
1237 switch (msg)
1239 case DLG_INIT:
1240 panel_init ();
1241 setup_panels ();
1242 return MSG_HANDLED;
1244 case DLG_DRAW:
1245 load_hint (1);
1246 /* We handle the special case of the output lines */
1247 if (console_flag && output_lines)
1248 show_console_contents (output_start_y,
1249 LINES - output_lines - keybar_visible -
1250 1, LINES - keybar_visible - 1);
1251 return MSG_HANDLED;
1253 case DLG_RESIZE:
1254 setup_panels ();
1255 menubar_arrange (the_menubar);
1256 return MSG_HANDLED;
1258 case DLG_IDLE:
1259 /* We only need the first idle event to show user menu after start */
1260 set_idle_proc (h, 0);
1262 if (boot_current_is_left)
1263 dlg_select_widget (get_panel_widget (0));
1264 else
1265 dlg_select_widget (get_panel_widget (1));
1267 if (auto_menu)
1268 midnight_execute_cmd (NULL, CK_UserMenuCmd);
1269 return MSG_HANDLED;
1271 case DLG_KEY:
1272 if (ctl_x_map_enabled)
1274 ctl_x_map_enabled = FALSE;
1275 command = keybind_lookup_keymap_command (main_x_map, parm);
1276 if (command != CK_Ignore_Key)
1277 return midnight_execute_cmd (NULL, command);
1280 /* FIXME: should handle all menu shortcuts before this point */
1281 if (the_menubar->is_active)
1282 return MSG_NOT_HANDLED;
1284 if (parm == '\t')
1285 input_free_completions (cmdline);
1287 if (parm == '\n')
1289 size_t i;
1291 for (i = 0; cmdline->buffer[i] != '\0' &&
1292 (cmdline->buffer[i] == ' ' || cmdline->buffer[i] == '\t'); i++)
1295 if (cmdline->buffer[i] != '\0')
1297 send_message ((Widget *) cmdline, WIDGET_KEY, parm);
1298 return MSG_HANDLED;
1301 input_insert (cmdline, "", FALSE);
1302 cmdline->point = 0;
1305 /* Ctrl-Enter and Alt-Enter */
1306 if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') && (parm & (KEY_M_CTRL | KEY_M_ALT)))
1308 copy_prog_name ();
1309 return MSG_HANDLED;
1312 /* Ctrl-Shift-Enter */
1313 if (parm == (KEY_M_CTRL | KEY_M_SHIFT | '\n'))
1315 copy_current_pathname ();
1316 copy_prog_name ();
1317 return MSG_HANDLED;
1320 if ((!alternate_plus_minus || !(console_flag || xterm_flag))
1321 && !quote && !current_panel->searching)
1323 if (!only_leading_plus_minus)
1325 /* Special treatement, since the input line will eat them */
1326 if (parm == '+')
1328 select_cmd ();
1329 return MSG_HANDLED;
1332 if (parm == '\\' || parm == '-')
1334 unselect_cmd ();
1335 return MSG_HANDLED;
1338 if (parm == '*')
1340 reverse_selection_cmd ();
1341 return MSG_HANDLED;
1344 else if (!command_prompt || !cmdline->buffer[0])
1346 /* Special treatement '+', '-', '\', '*' only when this is
1347 * first char on input line
1350 if (parm == '+')
1352 select_cmd ();
1353 return MSG_HANDLED;
1356 if (parm == '\\' || parm == '-')
1358 unselect_cmd ();
1359 return MSG_HANDLED;
1362 if (parm == '*')
1364 reverse_selection_cmd ();
1365 return MSG_HANDLED;
1369 return MSG_NOT_HANDLED;
1371 case DLG_HOTKEY_HANDLED:
1372 if ((get_current_type () == view_listing) && current_panel->searching)
1374 current_panel->dirty = 1; /* FIXME: unneeded? */
1375 send_message ((Widget *) current_panel, WIDGET_COMMAND, CK_PanelStopSearch);
1377 return MSG_HANDLED;
1379 case DLG_UNHANDLED_KEY:
1380 if (command_prompt)
1382 cb_ret_t v;
1384 v = send_message ((Widget *) cmdline, WIDGET_KEY, parm);
1385 if (v == MSG_HANDLED)
1386 return MSG_HANDLED;
1389 if (ctl_x_map_enabled)
1391 ctl_x_map_enabled = FALSE;
1392 command = keybind_lookup_keymap_command (main_x_map, parm);
1394 else
1395 command = keybind_lookup_keymap_command (main_map, parm);
1397 return (command == CK_Ignore_Key) ? MSG_NOT_HANDLED : midnight_execute_cmd (NULL, command);
1399 case DLG_POST_KEY:
1400 if (!the_menubar->is_active)
1401 update_dirty_panels ();
1402 return MSG_HANDLED;
1404 case DLG_ACTION:
1405 /* shortcut */
1406 if (sender == NULL)
1407 return midnight_execute_cmd (NULL, parm);
1408 /* message from menu */
1409 if (sender == (Widget *) the_menubar)
1410 return midnight_execute_cmd (sender, parm);
1411 /* message from buttonbar */
1412 if (sender == (Widget *) the_bar)
1414 if (data != NULL)
1415 return send_message ((Widget *) data, WIDGET_COMMAND, parm);
1416 return midnight_execute_cmd (sender, parm);
1418 return MSG_NOT_HANDLED;
1420 case DLG_END:
1421 panel_deinit ();
1422 return MSG_HANDLED;
1424 default:
1425 return default_dlg_callback (h, sender, msg, parm, data);
1429 /* --------------------------------------------------------------------------------------------- */
1430 /*** public functions ****************************************************************************/
1431 /* --------------------------------------------------------------------------------------------- */
1433 void
1434 update_menu (void)
1436 menu_set_name (left_menu, horizontal_split ? _("&Above") : _("&Left"));
1437 menu_set_name (right_menu, horizontal_split ? _("&Below") : _("&Right"));
1438 menubar_arrange (the_menubar);
1439 menubar_set_visible (the_menubar, menubar_visible);
1442 void
1443 midnight_set_buttonbar (WButtonBar * b)
1445 buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), main_map, NULL);
1446 buttonbar_set_label (b, 2, Q_ ("ButtonBar|Menu"), main_map, NULL);
1447 buttonbar_set_label (b, 3, Q_ ("ButtonBar|View"), main_map, NULL);
1448 buttonbar_set_label (b, 4, Q_ ("ButtonBar|Edit"), main_map, NULL);
1449 buttonbar_set_label (b, 5, Q_ ("ButtonBar|Copy"), main_map, NULL);
1450 buttonbar_set_label (b, 6, Q_ ("ButtonBar|RenMov"), main_map, NULL);
1451 buttonbar_set_label (b, 7, Q_ ("ButtonBar|Mkdir"), main_map, NULL);
1452 buttonbar_set_label (b, 8, Q_ ("ButtonBar|Delete"), main_map, NULL);
1453 buttonbar_set_label (b, 9, Q_ ("ButtonBar|PullDn"), main_map, NULL);
1454 buttonbar_set_label (b, 10, Q_ ("ButtonBar|Quit"), main_map, NULL);
1457 /* --------------------------------------------------------------------------------------------- */
1459 * Load new hint and display it.
1460 * IF force is not 0, ignore the timeout.
1463 void
1464 load_hint (gboolean force)
1466 char *hint;
1468 if (the_hint->widget.owner == NULL)
1469 return;
1471 if (!message_visible)
1473 label_set_text (the_hint, NULL);
1474 return;
1477 hint = get_random_hint (force);
1479 if (hint != NULL)
1481 if (*hint != '\0')
1482 set_hintbar (hint);
1483 g_free (hint);
1485 else
1487 char text[BUF_SMALL];
1489 g_snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"), VERSION);
1490 set_hintbar (text);
1494 /* --------------------------------------------------------------------------------------------- */
1496 void
1497 change_panel (void)
1499 input_free_completions (cmdline);
1500 dlg_one_down (midnight_dlg);
1503 /* --------------------------------------------------------------------------------------------- */
1505 /** Save current stat of directories to avoid reloading the panels
1506 * when no modifications have taken place
1508 void
1509 save_cwds_stat (void)
1511 if (panels_options.fast_reload)
1513 mc_stat (current_panel->cwd, &(current_panel->dir_stat));
1514 if (get_other_type () == view_listing)
1515 mc_stat (other_panel->cwd, &(other_panel->dir_stat));
1519 /* --------------------------------------------------------------------------------------------- */
1521 gboolean
1522 quiet_quit_cmd (void)
1524 print_last_revert = TRUE;
1525 return quit_cmd_internal (1);
1528 /* --------------------------------------------------------------------------------------------- */
1530 /** Run the main dialog that occupies the whole screen */
1531 void
1532 do_nc (void)
1534 dlg_colors_t midnight_colors;
1536 midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_");
1537 midnight_colors[DLG_COLOR_FOCUS] = mc_skin_color_get ("dialog", "focus");
1538 midnight_colors[DLG_COLOR_HOT_NORMAL] = mc_skin_color_get ("dialog", "hotnormal");
1539 midnight_colors[DLG_COLOR_HOT_FOCUS] = mc_skin_color_get ("dialog", "hotfocus");
1540 midnight_colors[DLG_COLOR_TITLE] = mc_skin_color_get ("dialog", "title");
1542 #ifdef USE_INTERNAL_EDIT
1543 edit_stack_init ();
1544 #endif
1546 midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback,
1547 "[main]", NULL, DLG_WANT_IDLE);
1549 if (mc_run_mode == MC_RUN_FULL)
1550 setup_mc ();
1551 else
1552 setup_dummy_mc ();
1554 /* Check if we were invoked as an editor or file viewer */
1555 if (mc_run_mode != MC_RUN_FULL)
1556 mc_maybe_editor_or_viewer ();
1557 else
1559 create_panels_and_run_mc ();
1561 /* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */
1562 if (mc_args__last_wd_file != NULL && vfs_current_is_local ())
1563 last_wd_string = g_strdup (current_panel->cwd);
1566 /* Program end */
1567 midnight_shutdown = 1;
1568 dialog_switch_shutdown ();
1569 done_mc ();
1570 destroy_dlg (midnight_dlg);
1571 current_panel = NULL;
1573 #ifdef USE_INTERNAL_EDIT
1574 edit_stack_free ();
1575 #endif
1578 /* --------------------------------------------------------------------------------------------- */