2 User Menu implementation
4 Copyright (C) 1994-2023
5 Free Software Foundation, Inc.
8 Slava Zanko <slavazanko@gmail.com>, 2013
9 Andrew Borodin <aborodin@vmail.ru>, 2013
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 * \brief Source: user menu implementation
39 #include "lib/global.h"
40 #include "lib/fileloc.h"
41 #include "lib/tty/tty.h"
43 #include "lib/search.h"
44 #include "lib/vfs/vfs.h"
45 #include "lib/strutil.h"
48 #ifdef USE_INTERNAL_EDIT
49 #include "src/editor/edit.h" /* WEdit */
51 #include "src/viewer/mcviewer.h" /* for default_* externs */
53 #include "src/args.h" /* mc_run_param0 */
54 #include "src/execute.h"
55 #include "src/setup.h"
56 #include "src/history.h"
58 #include "src/filemanager/dir.h"
59 #include "src/filemanager/filemanager.h"
60 #include "src/filemanager/layout.h"
64 /*** global variables ****************************************************************************/
66 /*** file scope macro definitions ****************************************************************/
68 #define MAX_ENTRIES 16
69 #define MAX_ENTRY_LEN 60
71 /*** file scope type declarations ****************************************************************/
73 /*** forward declarations (file scope functions) *************************************************/
75 /*** file scope variables ************************************************************************/
77 static gboolean debug_flag
= FALSE
;
78 static gboolean debug_error
= FALSE
;
79 static char *menu
= NULL
;
81 /* --------------------------------------------------------------------------------------------- */
82 /*** file scope functions ************************************************************************/
83 /* --------------------------------------------------------------------------------------------- */
85 /** strip file's extension */
96 if (IS_PATH_SEP (*s
) && e
!= NULL
)
97 e
= NULL
; /* '.' in *directory* name */
105 /* --------------------------------------------------------------------------------------------- */
107 * Check for the "shell_patterns" directive. If it's found and valid,
108 * interpret it and move the pointer past the directive. Return the
113 check_patterns (char *p
)
115 static const char def_name
[] = "shell_patterns=";
118 if (strncmp (p
, def_name
, sizeof (def_name
) - 1) != 0)
121 p
+= sizeof (def_name
) - 1;
123 easy_patterns
= TRUE
;
125 easy_patterns
= FALSE
;
131 while (whiteness (*p
))
136 /* --------------------------------------------------------------------------------------------- */
137 /** Copies a whitespace separated argument from p to arg. Returns the
138 point after argument. */
141 extract_arg (char *p
, char *arg
, int size
)
143 while (*p
!= '\0' && whiteness (*p
))
146 /* support quote space .mnu */
147 while (*p
!= '\0' && (*p
!= ' ' || *(p
- 1) == '\\') && *p
!= '\t' && *p
!= '\n')
151 np
= str_get_next_char (p
);
154 memcpy (arg
, p
, np
- p
);
160 if (*p
== '\0' || *p
== '\n')
165 /* --------------------------------------------------------------------------------------------- */
166 /* Tests whether the selected file in the panel is of any of the types
167 specified in argument. */
170 test_type (WPanel
* panel
, char *arg
)
172 int result
= 0; /* False by default */
175 st_mode
= panel_current_entry (panel
)->st
.st_mode
;
177 for (; *arg
!= '\0'; arg
++)
181 case 'n': /* Not a directory */
182 result
|= !S_ISDIR (st_mode
);
184 case 'r': /* Regular file */
185 result
|= S_ISREG (st_mode
);
187 case 'd': /* Directory */
188 result
|= S_ISDIR (st_mode
);
191 result
|= S_ISLNK (st_mode
);
193 case 'c': /* Character special */
194 result
|= S_ISCHR (st_mode
);
196 case 'b': /* Block special */
197 result
|= S_ISBLK (st_mode
);
199 case 'f': /* Fifo (named pipe) */
200 result
|= S_ISFIFO (st_mode
);
202 case 's': /* Socket */
203 result
|= S_ISSOCK (st_mode
);
205 case 'x': /* Executable */
206 result
|= (st_mode
& 0111) != 0 ? 1 : 0;
209 result
|= panel
->marked
!= 0 ? 1 : 0;
217 return (result
!= 0);
220 /* --------------------------------------------------------------------------------------------- */
221 /** Calculates the truth value of the next condition starting from
222 p. Returns the point after condition. */
225 test_condition (const Widget
* edit_widget
, char *p
, gboolean
* condition
)
228 const mc_search_type_t search_type
= easy_patterns
? MC_SEARCH_T_GLOB
: MC_SEARCH_T_REGEX
;
229 #ifdef USE_INTERNAL_EDIT
230 const WEdit
*e
= CONST_EDIT (edit_widget
);
233 /* Handle one condition */
234 for (; *p
!= '\n' && *p
!= '&' && *p
!= '|'; p
++)
236 WPanel
*panel
= NULL
;
238 /* support quote space .mnu */
239 if ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
242 panel
= current_panel
;
243 else if (get_other_type () == view_listing
)
251 p
= test_condition (edit_widget
, p
, condition
);
252 *condition
= !*condition
;
255 case 'f': /* file name pattern */
256 p
= extract_arg (p
, arg
, sizeof (arg
));
257 #ifdef USE_INTERNAL_EDIT
260 const char *edit_filename
;
262 edit_filename
= edit_get_file_name (e
);
263 *condition
= mc_search (arg
, DEFAULT_CHARSET
, edit_filename
, search_type
);
267 *condition
= panel
!= NULL
&&
268 mc_search (arg
, DEFAULT_CHARSET
, panel_current_entry (panel
)->fname
->str
,
271 case 'y': /* syntax pattern */
272 #ifdef USE_INTERNAL_EDIT
275 const char *syntax_type
;
277 syntax_type
= edit_get_syntax_type (e
);
278 if (syntax_type
!= NULL
)
280 p
= extract_arg (p
, arg
, sizeof (arg
));
281 *condition
= mc_search (arg
, DEFAULT_CHARSET
, syntax_type
, MC_SEARCH_T_NORMAL
);
287 p
= extract_arg (p
, arg
, sizeof (arg
));
288 *condition
= panel
!= NULL
289 && mc_search (arg
, DEFAULT_CHARSET
, vfs_path_as_str (panel
->cwd_vpath
),
293 p
= extract_arg (p
, arg
, sizeof (arg
));
294 *condition
= panel
!= NULL
&& test_type (panel
, arg
);
296 case 'x': /* executable */
300 p
= extract_arg (p
, arg
, sizeof (arg
));
301 *condition
= stat (arg
, &status
) == 0 && is_exe (status
.st_mode
);
312 /* --------------------------------------------------------------------------------------------- */
313 /** General purpose condition debug output handler */
316 debug_out (char *start
, char *end
, gboolean condition
)
318 static char *msg
= NULL
;
320 if (start
== NULL
&& end
== NULL
)
323 if (debug_flag
&& msg
!= NULL
)
330 message (D_NORMAL
, _("Debug"), "%s", msg
);
341 /* Save debug info for later output */
344 /* Save the result of the condition */
354 /* This is for debugging, don't need to be super efficient. */
356 p
= g_strdup_printf ("%s %s %c \n", msg
? msg
: "", type
, *start
);
358 p
= g_strdup_printf ("%s %s %.*s \n", msg
? msg
: "", type
, (int) (end
- start
), start
);
364 /* --------------------------------------------------------------------------------------------- */
365 /** Calculates the truth value of one lineful of conditions. Returns
366 the point just before the end of line. */
369 test_line (const Widget
* edit_widget
, char *p
, gboolean
* result
)
373 /* Repeat till end of line */
374 while (*p
!= '\0' && *p
!= '\n')
376 char *debug_start
, *debug_end
;
377 gboolean condition
= TRUE
;
379 /* support quote space .mnu */
380 while ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
382 if (*p
== '\0' || *p
== '\n')
390 /* support quote space .mnu */
391 while ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
393 if (*p
== '\0' || *p
== '\n')
397 p
= test_condition (edit_widget
, p
, &condition
);
399 /* Add one debug statement */
400 debug_out (debug_start
, debug_end
, condition
);
409 case '&': /* Logical and */
410 *result
= *result
&& condition
;
412 case '|': /* Logical or */
413 *result
= *result
|| condition
;
419 /* Add one debug statement */
420 debug_out (&operator, NULL
, *result
);
422 } /* while (*p != '\n') */
423 /* Report debug message */
424 debug_out (NULL
, NULL
, TRUE
);
426 if (*p
== '\0' || *p
== '\n')
431 /* --------------------------------------------------------------------------------------------- */
432 /** FIXME: recode this routine on version 3.0, it could be cleaner */
435 execute_menu_command (const Widget
* edit_widget
, const char *commands
, gboolean show_prompt
)
439 gboolean expand_prefix_found
= FALSE
;
440 char *parameter
= NULL
;
441 gboolean do_quote
= FALSE
;
444 vfs_path_t
*file_name_vpath
;
445 gboolean run_view
= FALSE
;
448 /* Skip menu entry title line */
449 commands
= strchr (commands
, '\n');
450 if (commands
== NULL
)
453 cmd_file_fd
= mc_mkstemps (&file_name_vpath
, "mcusr", SCRIPT_SUFFIX
);
455 if (cmd_file_fd
== -1)
457 message (D_ERROR
, MSG_ERROR
, _("Cannot create temporary command file\n%s"),
458 unix_error_string (errno
));
462 cmd_file
= fdopen (cmd_file_fd
, "w");
463 fputs ("#! /bin/sh\n", cmd_file
);
466 for (col
= 0; *commands
!= '\0'; commands
++)
470 if (!whitespace (*commands
))
472 while (whitespace (*commands
))
474 if (*commands
== '\0')
478 if (*commands
== '\n')
480 if (parameter
!= NULL
)
482 if (*commands
== '}')
486 input_dialog (_("Parameter"), lc_prompt
, MC_HISTORY_FM_MENU_EXEC_PARAM
, "",
487 INPUT_COMPLETE_FILENAMES
| INPUT_COMPLETE_CD
|
488 INPUT_COMPLETE_HOSTNAMES
| INPUT_COMPLETE_VARIABLES
|
489 INPUT_COMPLETE_USERNAMES
);
490 if (parameter
== NULL
|| *parameter
== '\0')
495 mc_unlink (file_name_vpath
);
496 vfs_path_free (file_name_vpath
, TRUE
);
503 tmp
= name_quote (parameter
, FALSE
);
504 fputs (tmp
, cmd_file
);
508 fputs (parameter
, cmd_file
);
510 MC_PTR_FREE (parameter
);
512 else if (parameter
< lc_prompt
+ sizeof (lc_prompt
) - 1)
513 *parameter
++ = *commands
;
515 else if (expand_prefix_found
)
517 expand_prefix_found
= FALSE
;
518 if (g_ascii_isdigit ((gchar
) * commands
))
520 do_quote
= (atoi (commands
) != 0);
521 while (g_ascii_isdigit ((gchar
) * commands
))
524 if (*commands
== '{')
525 parameter
= lc_prompt
;
530 text
= expand_format (edit_widget
, *commands
, do_quote
);
531 fputs (text
, cmd_file
);
535 else if (*commands
== '%')
539 i
= check_format_view (commands
+ 1);
547 do_quote
= TRUE
; /* Default: Quote expanded macro */
548 expand_prefix_found
= TRUE
;
552 fputc (*commands
, cmd_file
);
556 mc_chmod (file_name_vpath
, S_IRWXU
);
558 /* Execute the command indirectly to allow execution even on no-exec filesystems. */
559 cmd
= g_strconcat ("/bin/sh ", vfs_path_as_str (file_name_vpath
), (char *) NULL
);
563 mcview_viewer (cmd
, NULL
, 0, 0, 0);
564 dialog_switch_process_pending ();
566 else if (show_prompt
)
567 shell_execute (cmd
, EXECUTE_HIDE
);
572 /* Prepare the terminal by setting its flag to the initial ones. This will cause \r
573 * to work as expected, instead of being ignored. */
574 tty_reset_shell_mode ();
576 ok
= (system (cmd
) != -1);
578 /* Restore terminal configuration. */
581 /* Redraw the original screen's contents. */
586 message (D_ERROR
, MSG_ERROR
, "%s", _("Error calling program"));
591 mc_unlink (file_name_vpath
);
592 vfs_path_free (file_name_vpath
, TRUE
);
595 /* --------------------------------------------------------------------------------------------- */
597 ** Check owner of the menu file. Using menu file is allowed, if
598 ** owner of the menu is root or the actual user. In either case
599 ** file should not be group and word-writable.
601 ** Q. Should we apply this routine to system and home menu (and .ext files)?
605 menu_file_own (char *path
)
609 if (stat (path
, &st
) == 0 && (st
.st_uid
== 0 || (st
.st_uid
== geteuid ()) != 0)
610 && ((st
.st_mode
& (S_IWGRP
| S_IWOTH
)) == 0))
614 message (D_NORMAL
, _("Warning -- ignoring file"),
615 _("File %s is not owned by root or you or is world writable.\n"
616 "Using it may compromise your security"), path
);
621 /* --------------------------------------------------------------------------------------------- */
622 /*** public functions ****************************************************************************/
623 /* --------------------------------------------------------------------------------------------- */
627 %f The current file in the active panel (if non-local vfs, file will be copied locally
628 and %f will be full path to it) or the opened file in the internal editor.
630 %d The current working directory
631 %s "Selected files"; the tagged files if any, otherwise the current file
633 %u Tagged files (and they are untagged on return from expand_format)
634 %view Runs the commands and pipes standard output to the view command.
635 If %view is immediately followed by '{', recognize keywords
636 ascii, hex, nroff and unform
638 If the format letter is in uppercase, it refers to the other panel.
640 With a number followed the % character you can turn quoting on (default)
641 and off. For example:
642 %f quote expanded macro
644 %0f don't quote expanded macro
646 expand_format returns a memory block that must be free()d.
649 /* Returns how many characters we should advance if %view was found */
651 check_format_view (const char *p
)
655 if (strncmp (p
, "view", 4) == 0)
660 for (q
++; *q
!= '\0' && *q
!= '}'; q
++)
662 if (strncmp (q
, DEFAULT_CHARSET
, 5) == 0)
664 mcview_global_flags
.hex
= FALSE
;
667 else if (strncmp (q
, "hex", 3) == 0)
669 mcview_global_flags
.hex
= TRUE
;
672 else if (strncmp (q
, "nroff", 5) == 0)
674 mcview_global_flags
.nroff
= TRUE
;
677 else if (strncmp (q
, "unform", 6) == 0)
679 mcview_global_flags
.nroff
= FALSE
;
691 /* --------------------------------------------------------------------------------------------- */
694 check_format_cd (const char *p
)
696 return (strncmp (p
, "cd", 2)) != 0 ? 0 : 3;
699 /* --------------------------------------------------------------------------------------------- */
700 /* Check if p has a "^var\{var-name\}" */
701 /* Returns the number of skipped characters (zero on not found) */
702 /* V will be set to the expanded variable name */
705 check_format_var (const char *p
, char **v
)
709 if (strncmp (p
, "var{", 4) == 0)
712 const char *dots
= NULL
;
716 for (q
+= 4; *q
!= '\0' && *q
!= '}'; q
++)
724 if (dots
== NULL
|| dots
== q
+ 5)
727 _("Format error on file Extensions File"),
728 !dots
? _("The %%var macro has no default")
729 : _("The %%var macro has no variable"));
733 /* Copy the variable name */
734 var_name
= g_strndup (p
+ 4, dots
- 2 - (p
+ 3));
735 value
= getenv (var_name
);
739 *v
= g_strdup (value
);
741 *v
= g_strndup (dots
, q
- dots
);
748 /* --------------------------------------------------------------------------------------------- */
751 expand_format (const Widget
* edit_widget
, char c
, gboolean do_quote
)
753 WPanel
*panel
= NULL
;
754 char *(*quote_func
) (const char *, gboolean
);
755 const char *fname
= NULL
;
759 #ifdef USE_INTERNAL_EDIT
760 const WEdit
*e
= CONST_EDIT (edit_widget
);
766 return g_strdup ("%");
768 switch (mc_global
.mc_run_mode
)
771 #ifdef USE_INTERNAL_EDIT
773 fname
= edit_get_file_name (e
);
777 if (g_ascii_islower ((gchar
) c
))
778 panel
= current_panel
;
781 if (get_other_type () != view_listing
)
782 return g_strdup ("");
786 fname
= panel_current_entry (panel
)->fname
->str
;
790 #ifdef USE_INTERNAL_EDIT
792 fname
= edit_get_file_name (e
);
797 /* mc_run_param0 is not NULL here because mcviewer isn't run without input file */
798 fname
= (const char *) mc_run_param0
;
802 /* other modes don't use formats */
803 return g_strdup ("");
807 quote_func
= name_quote
;
809 quote_func
= fake_name_quote
;
811 c_lc
= g_ascii_tolower ((gchar
) c
);
817 result
= quote_func (fname
, FALSE
);
820 result
= quote_func (extension (fname
), FALSE
);
828 cwd
= vfs_path_as_str (panel
->cwd_vpath
);
830 cwd
= vfs_get_current_dir ();
832 qstr
= quote_func (cwd
, FALSE
);
838 #ifdef USE_INTERNAL_EDIT
841 result
= g_strdup_printf ("%u", (unsigned int) edit_get_cursor_offset (e
));
846 case 'i': /* indent equal number cursor position in line */
847 #ifdef USE_INTERNAL_EDIT
850 result
= g_strnfill (edit_get_curs_col (e
), ' ');
855 case 'y': /* syntax type */
856 #ifdef USE_INTERNAL_EDIT
859 const char *syntax_type
;
861 syntax_type
= edit_get_syntax_type (e
);
862 if (syntax_type
!= NULL
)
864 result
= g_strdup (syntax_type
);
870 case 'k': /* block file name */
871 case 'b': /* block file name / strip extension */
872 #ifdef USE_INTERNAL_EDIT
877 file
= mc_config_get_full_path (EDIT_HOME_BLOCK_FILE
);
878 result
= quote_func (file
, FALSE
);
885 result
= strip_ext (quote_func (fname
, FALSE
));
889 case 'n': /* strip extension in editor */
890 #ifdef USE_INTERNAL_EDIT
893 result
= strip_ext (quote_func (fname
, FALSE
));
898 case 'm': /* menu file name */
901 result
= quote_func (menu
, FALSE
);
906 if (panel
== NULL
|| panel
->marked
== 0)
908 result
= quote_func (fname
, FALSE
);
922 result
= g_strdup ("");
926 block
= g_string_sized_new (16);
928 for (i
= 0; i
< panel
->dir
.len
; i
++)
929 if (panel
->dir
.list
[i
].f
.marked
!= 0)
933 tmp
= quote_func (panel
->dir
.list
[i
].fname
->str
, FALSE
);
934 g_string_append (block
, tmp
);
935 g_string_append_c (block
, ' ');
939 do_file_mark (panel
, i
, 0);
941 result
= g_string_free (block
, FALSE
);
943 } /* sub case block */
948 result
= g_strdup ("% ");
954 /* --------------------------------------------------------------------------------------------- */
956 * If edit_widget is NULL then we are called from the mc menu,
957 * otherwise we are called from the mcedit menu.
961 user_menu_cmd (const Widget
* edit_widget
, const char *menu_file
, int selected_entry
)
964 char *data
, **entries
;
965 int max_cols
, menu_lines
, menu_limit
;
967 gboolean accept_entry
= TRUE
;
969 gboolean old_patterns
;
970 gboolean res
= FALSE
;
971 gboolean interactive
= TRUE
;
973 if (!vfs_current_is_local ())
975 message (D_ERROR
, MSG_ERROR
, "%s", _("Cannot execute commands on non-local filesystems"));
978 if (menu_file
!= NULL
)
979 menu
= g_strdup (menu_file
);
981 menu
= g_strdup (edit_widget
!= NULL
? EDIT_LOCAL_MENU
: MC_LOCAL_MENU
);
982 if (!exist_file (menu
) || !menu_file_own (menu
))
984 if (menu_file
!= NULL
)
986 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"), menu
,
987 unix_error_string (errno
));
993 if (edit_widget
!= NULL
)
994 menu
= mc_config_get_full_path (EDIT_HOME_MENU
);
996 menu
= mc_config_get_full_path (MC_USERMENU_FILE
);
998 if (!exist_file (menu
))
1002 mc_build_filename (mc_config_get_home_dir (),
1003 edit_widget
!= NULL
? EDIT_GLOBAL_MENU
: MC_GLOBAL_MENU
,
1005 if (!exist_file (menu
))
1009 mc_build_filename (mc_global
.sysconfig_dir
,
1010 edit_widget
!= NULL
? EDIT_GLOBAL_MENU
: MC_GLOBAL_MENU
,
1012 if (!exist_file (menu
))
1016 mc_build_filename (mc_global
.share_data_dir
,
1017 edit_widget
!= NULL
? EDIT_GLOBAL_MENU
: MC_GLOBAL_MENU
,
1024 if (!g_file_get_contents (menu
, &data
, NULL
, NULL
))
1026 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"), menu
, unix_error_string (errno
));
1036 /* Parse the menu file */
1037 old_patterns
= easy_patterns
;
1038 p
= check_patterns (data
);
1039 for (menu_lines
= col
= 0; *p
!= '\0'; str_next_char (&p
))
1041 if (menu_lines
>= menu_limit
)
1045 menu_limit
+= MAX_ENTRIES
;
1046 new_entries
= g_try_realloc (entries
, sizeof (new_entries
[0]) * menu_limit
);
1047 if (new_entries
== NULL
)
1050 entries
= new_entries
;
1051 new_entries
+= menu_limit
;
1052 while (--new_entries
>= &entries
[menu_lines
])
1053 *new_entries
= NULL
;
1056 if (col
== 0 && entries
[menu_lines
] == NULL
)
1060 /* do not show prompt if first line of external script is #silent */
1061 if (selected_entry
>= 0 && strncmp (p
, "#silent", 7) == 0)
1062 interactive
= FALSE
;
1063 /* A commented menu entry */
1064 accept_entry
= TRUE
;
1068 if (*(p
+ 1) == '=')
1070 /* Combined adding and default */
1071 p
= test_line (edit_widget
, p
+ 1, &accept_entry
);
1072 if (selected
== 0 && accept_entry
)
1073 selected
= menu_lines
;
1077 /* A condition for adding the entry */
1078 p
= test_line (edit_widget
, p
, &accept_entry
);
1083 if (*(p
+ 1) == '+')
1085 /* Combined adding and default */
1086 p
= test_line (edit_widget
, p
+ 1, &accept_entry
);
1087 if (selected
== 0 && accept_entry
)
1088 selected
= menu_lines
;
1092 /* A condition for making the entry default */
1094 p
= test_line (edit_widget
, p
, &i
);
1095 if (selected
== 0 && i
!= 0)
1096 selected
= menu_lines
;
1101 if (!whitespace (*p
) && str_isprint (p
))
1103 /* A menu entry title line */
1105 entries
[menu_lines
] = p
;
1107 accept_entry
= TRUE
;
1114 if (entries
[menu_lines
] != NULL
)
1117 accept_entry
= TRUE
;
1119 max_cols
= MAX (max_cols
, col
);
1130 if (menu_lines
== 0)
1132 message (D_ERROR
, MSG_ERROR
, _("No suitable entries found in %s"), menu
);
1137 if (selected_entry
>= 0)
1138 selected
= selected_entry
;
1143 max_cols
= MIN (MAX (max_cols
, col
), MAX_ENTRY_LEN
);
1145 /* Create listbox */
1146 listbox
= listbox_window_new (menu_lines
, max_cols
+ 2, _("User menu"),
1147 "[Edit Menu File]");
1148 /* insert all the items found */
1149 for (i
= 0; i
< menu_lines
; i
++)
1152 LISTBOX_APPEND_TEXT (listbox
, (unsigned char) p
[0],
1153 extract_line (p
, p
+ MAX_ENTRY_LEN
), p
, FALSE
);
1155 /* Select the default entry */
1156 listbox_set_current (listbox
->list
, selected
);
1158 selected
= listbox_run (listbox
);
1162 execute_menu_command (edit_widget
, entries
[selected
], interactive
);
1169 easy_patterns
= old_patterns
;
1176 /* --------------------------------------------------------------------------------------------- */