2 User Menu implementation
4 Copyright (C) 1994-2024
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 */
95 for (s
= ss
; *s
!= '\0'; s
++)
99 if (IS_PATH_SEP (*s
) && e
!= NULL
)
100 e
= NULL
; /* '.' in *directory* name */
106 return (*ss
== '\0' ? NULL
: ss
);
109 /* --------------------------------------------------------------------------------------------- */
111 * Check for the "shell_patterns" directive. If it's found and valid,
112 * interpret it and move the pointer past the directive. Return the
117 check_patterns (char *p
)
119 static const char def_name
[] = "shell_patterns=";
122 if (strncmp (p
, def_name
, sizeof (def_name
) - 1) != 0)
125 p
+= sizeof (def_name
) - 1;
127 easy_patterns
= TRUE
;
129 easy_patterns
= FALSE
;
135 while (whiteness (*p
))
140 /* --------------------------------------------------------------------------------------------- */
141 /** Copies a whitespace separated argument from p to arg. Returns the
142 point after argument. */
145 extract_arg (char *p
, char *arg
, int size
)
147 while (*p
!= '\0' && whiteness (*p
))
150 /* support quote space .mnu */
151 while (*p
!= '\0' && (*p
!= ' ' || *(p
- 1) == '\\') && *p
!= '\t' && *p
!= '\n')
155 np
= str_get_next_char (p
);
158 memcpy (arg
, p
, np
- p
);
164 if (*p
== '\0' || *p
== '\n')
169 /* --------------------------------------------------------------------------------------------- */
170 /* Tests whether the selected file in the panel is of any of the types
171 specified in argument. */
174 test_type (WPanel
*panel
, char *arg
)
176 int result
= 0; /* False by default */
179 st_mode
= panel_current_entry (panel
)->st
.st_mode
;
181 for (; *arg
!= '\0'; arg
++)
185 case 'n': /* Not a directory */
186 result
|= !S_ISDIR (st_mode
);
188 case 'r': /* Regular file */
189 result
|= S_ISREG (st_mode
);
191 case 'd': /* Directory */
192 result
|= S_ISDIR (st_mode
);
195 result
|= S_ISLNK (st_mode
);
197 case 'c': /* Character special */
198 result
|= S_ISCHR (st_mode
);
200 case 'b': /* Block special */
201 result
|= S_ISBLK (st_mode
);
203 case 'f': /* Fifo (named pipe) */
204 result
|= S_ISFIFO (st_mode
);
206 case 's': /* Socket */
207 result
|= S_ISSOCK (st_mode
);
209 case 'x': /* Executable */
210 result
|= (st_mode
& 0111) != 0 ? 1 : 0;
213 result
|= panel
->marked
!= 0 ? 1 : 0;
221 return (result
!= 0);
224 /* --------------------------------------------------------------------------------------------- */
225 /** Calculates the truth value of the next condition starting from
226 p. Returns the point after condition. */
229 test_condition (const Widget
*edit_widget
, char *p
, gboolean
*condition
)
232 const mc_search_type_t search_type
= easy_patterns
? MC_SEARCH_T_GLOB
: MC_SEARCH_T_REGEX
;
233 #ifdef USE_INTERNAL_EDIT
234 const WEdit
*e
= CONST_EDIT (edit_widget
);
237 /* Handle one condition */
238 for (; *p
!= '\n' && *p
!= '&' && *p
!= '|'; p
++)
240 WPanel
*panel
= NULL
;
242 /* support quote space .mnu */
243 if ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
246 panel
= current_panel
;
247 else if (get_other_type () == view_listing
)
255 p
= test_condition (edit_widget
, p
, condition
);
256 *condition
= !*condition
;
259 case 'f': /* file name pattern */
260 p
= extract_arg (p
, arg
, sizeof (arg
));
261 #ifdef USE_INTERNAL_EDIT
264 const char *edit_filename
;
266 edit_filename
= edit_get_file_name (e
);
267 *condition
= mc_search (arg
, DEFAULT_CHARSET
, edit_filename
, search_type
);
271 *condition
= panel
!= NULL
&&
272 mc_search (arg
, DEFAULT_CHARSET
, panel_current_entry (panel
)->fname
->str
,
275 case 'y': /* syntax pattern */
276 #ifdef USE_INTERNAL_EDIT
279 const char *syntax_type
;
281 syntax_type
= edit_get_syntax_type (e
);
282 if (syntax_type
!= NULL
)
284 p
= extract_arg (p
, arg
, sizeof (arg
));
285 *condition
= mc_search (arg
, DEFAULT_CHARSET
, syntax_type
, MC_SEARCH_T_NORMAL
);
291 p
= extract_arg (p
, arg
, sizeof (arg
));
292 *condition
= panel
!= NULL
293 && mc_search (arg
, DEFAULT_CHARSET
, vfs_path_as_str (panel
->cwd_vpath
),
297 p
= extract_arg (p
, arg
, sizeof (arg
));
298 *condition
= panel
!= NULL
&& test_type (panel
, arg
);
300 case 'x': /* executable */
304 p
= extract_arg (p
, arg
, sizeof (arg
));
305 *condition
= stat (arg
, &status
) == 0 && is_exe (status
.st_mode
);
316 /* --------------------------------------------------------------------------------------------- */
317 /** General purpose condition debug output handler */
320 debug_out (char *start
, char *end
, gboolean condition
)
322 static char *msg
= NULL
;
324 if (start
== NULL
&& end
== NULL
)
327 if (debug_flag
&& msg
!= NULL
)
334 message (D_NORMAL
, _("Debug"), "%s", msg
);
345 /* Save debug info for later output */
348 /* Save the result of the condition */
358 /* This is for debugging, don't need to be super efficient. */
360 p
= g_strdup_printf ("%s %s %c \n", msg
? msg
: "", type
, *start
);
362 p
= g_strdup_printf ("%s %s %.*s \n", msg
? msg
: "", type
, (int) (end
- start
), start
);
368 /* --------------------------------------------------------------------------------------------- */
369 /** Calculates the truth value of one lineful of conditions. Returns
370 the point just before the end of line. */
373 test_line (const Widget
*edit_widget
, char *p
, gboolean
*result
)
377 /* Repeat till end of line */
378 while (*p
!= '\0' && *p
!= '\n')
380 char *debug_start
, *debug_end
;
381 gboolean condition
= TRUE
;
383 /* support quote space .mnu */
384 while ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
386 if (*p
== '\0' || *p
== '\n')
394 /* support quote space .mnu */
395 while ((*p
== ' ' && *(p
- 1) != '\\') || *p
== '\t')
397 if (*p
== '\0' || *p
== '\n')
401 p
= test_condition (edit_widget
, p
, &condition
);
403 /* Add one debug statement */
404 debug_out (debug_start
, debug_end
, condition
);
413 case '&': /* Logical and */
414 *result
= *result
&& condition
;
416 case '|': /* Logical or */
417 *result
= *result
|| condition
;
423 /* Add one debug statement */
424 debug_out (&operator, NULL
, *result
);
426 } /* while (*p != '\n') */
427 /* Report debug message */
428 debug_out (NULL
, NULL
, TRUE
);
430 if (*p
== '\0' || *p
== '\n')
435 /* --------------------------------------------------------------------------------------------- */
436 /** FIXME: recode this routine on version 3.0, it could be cleaner */
439 execute_menu_command (const Widget
*edit_widget
, const char *commands
, gboolean show_prompt
)
443 gboolean expand_prefix_found
= FALSE
;
444 char *parameter
= NULL
;
445 gboolean do_quote
= FALSE
;
448 vfs_path_t
*file_name_vpath
;
449 gboolean run_view
= FALSE
;
452 /* Skip menu entry title line */
453 commands
= strchr (commands
, '\n');
454 if (commands
== NULL
)
457 cmd_file_fd
= mc_mkstemps (&file_name_vpath
, "mcusr", SCRIPT_SUFFIX
);
459 if (cmd_file_fd
== -1)
461 message (D_ERROR
, MSG_ERROR
, _("Cannot create temporary command file\n%s"),
462 unix_error_string (errno
));
466 cmd_file
= fdopen (cmd_file_fd
, "w");
467 fputs ("#! /bin/sh\n", cmd_file
);
470 for (col
= 0; *commands
!= '\0'; commands
++)
474 if (!whitespace (*commands
))
476 while (whitespace (*commands
))
478 if (*commands
== '\0')
482 if (*commands
== '\n')
484 if (parameter
!= NULL
)
486 if (*commands
== '}')
490 input_dialog (_("Parameter"), lc_prompt
, MC_HISTORY_FM_MENU_EXEC_PARAM
, "",
491 INPUT_COMPLETE_FILENAMES
| INPUT_COMPLETE_CD
|
492 INPUT_COMPLETE_HOSTNAMES
| INPUT_COMPLETE_VARIABLES
|
493 INPUT_COMPLETE_USERNAMES
);
494 if (parameter
== NULL
|| *parameter
== '\0')
499 mc_unlink (file_name_vpath
);
500 vfs_path_free (file_name_vpath
, TRUE
);
507 tmp
= name_quote (parameter
, FALSE
);
510 fputs (tmp
, cmd_file
);
515 fputs (parameter
, cmd_file
);
517 MC_PTR_FREE (parameter
);
519 else if (parameter
< lc_prompt
+ sizeof (lc_prompt
) - 1)
520 *parameter
++ = *commands
;
522 else if (expand_prefix_found
)
524 expand_prefix_found
= FALSE
;
525 if (g_ascii_isdigit ((gchar
) * commands
))
527 do_quote
= (atoi (commands
) != 0);
528 while (g_ascii_isdigit ((gchar
) * commands
))
531 if (*commands
== '{')
532 parameter
= lc_prompt
;
537 text
= expand_format (edit_widget
, *commands
, do_quote
);
540 fputs (text
, cmd_file
);
545 else if (*commands
== '%')
549 i
= check_format_view (commands
+ 1);
557 do_quote
= TRUE
; /* Default: Quote expanded macro */
558 expand_prefix_found
= TRUE
;
562 fputc (*commands
, cmd_file
);
566 mc_chmod (file_name_vpath
, S_IRWXU
);
568 /* Execute the command indirectly to allow execution even on no-exec filesystems. */
569 cmd
= g_strconcat ("/bin/sh ", vfs_path_as_str (file_name_vpath
), (char *) NULL
);
573 mcview_viewer (cmd
, NULL
, 0, 0, 0);
574 dialog_switch_process_pending ();
576 else if (show_prompt
)
577 shell_execute (cmd
, EXECUTE_HIDE
);
582 /* Prepare the terminal by setting its flag to the initial ones. This will cause \r
583 * to work as expected, instead of being ignored. */
584 tty_reset_shell_mode ();
586 ok
= (system (cmd
) != -1);
588 /* Restore terminal configuration. */
591 /* Redraw the original screen's contents. */
596 message (D_ERROR
, MSG_ERROR
, "%s", _("Error calling program"));
601 mc_unlink (file_name_vpath
);
602 vfs_path_free (file_name_vpath
, TRUE
);
605 /* --------------------------------------------------------------------------------------------- */
607 ** Check owner of the menu file. Using menu file is allowed, if
608 ** owner of the menu is root or the actual user. In either case
609 ** file should not be group and word-writable.
611 ** Q. Should we apply this routine to system and home menu (and .ext files)?
615 menu_file_own (char *path
)
619 if (stat (path
, &st
) == 0 && (st
.st_uid
== 0 || (st
.st_uid
== geteuid ()) != 0)
620 && ((st
.st_mode
& (S_IWGRP
| S_IWOTH
)) == 0))
624 message (D_NORMAL
, _("Warning -- ignoring file"),
625 _("File %s is not owned by root or you or is world writable.\n"
626 "Using it may compromise your security"), path
);
631 /* --------------------------------------------------------------------------------------------- */
632 /*** public functions ****************************************************************************/
633 /* --------------------------------------------------------------------------------------------- */
637 %f The current file in the active panel (if non-local vfs, file will be copied locally
638 and %f will be full path to it) or the opened file in the internal editor.
640 %d The current working directory
641 %s "Selected files"; the tagged files if any, otherwise the current file
643 %u Tagged files (and they are untagged on return from expand_format)
644 %view Runs the commands and pipes standard output to the view command.
645 If %view is immediately followed by '{', recognize keywords
646 ascii, hex, nroff and unform
648 If the format letter is in uppercase, it refers to the other panel.
650 With a number followed the % character you can turn quoting on (default)
651 and off. For example:
652 %f quote expanded macro
654 %0f don't quote expanded macro
656 expand_format returns a memory block that must be free()d.
659 /* Returns how many characters we should advance if %view was found */
661 check_format_view (const char *p
)
665 if (strncmp (p
, "view", 4) == 0)
670 for (q
++; *q
!= '\0' && *q
!= '}'; q
++)
672 if (strncmp (q
, DEFAULT_CHARSET
, 5) == 0)
674 mcview_global_flags
.hex
= FALSE
;
677 else if (strncmp (q
, "hex", 3) == 0)
679 mcview_global_flags
.hex
= TRUE
;
682 else if (strncmp (q
, "nroff", 5) == 0)
684 mcview_global_flags
.nroff
= TRUE
;
687 else if (strncmp (q
, "unform", 6) == 0)
689 mcview_global_flags
.nroff
= FALSE
;
701 /* --------------------------------------------------------------------------------------------- */
704 check_format_cd (const char *p
)
706 return (strncmp (p
, "cd", 2)) != 0 ? 0 : 3;
709 /* --------------------------------------------------------------------------------------------- */
710 /* Check if p has a "^var\{var-name\}" */
711 /* Returns the number of skipped characters (zero on not found) */
712 /* V will be set to the expanded variable name */
715 check_format_var (const char *p
, char **v
)
719 if (strncmp (p
, "var{", 4) == 0)
722 const char *dots
= NULL
;
726 for (q
+= 4; *q
!= '\0' && *q
!= '}'; q
++)
734 if (dots
== NULL
|| dots
== q
+ 5)
737 _("Format error on file Extensions File"),
738 !dots
? _("The %%var macro has no default")
739 : _("The %%var macro has no variable"));
743 /* Copy the variable name */
744 var_name
= g_strndup (p
+ 4, dots
- 2 - (p
+ 3));
745 value
= getenv (var_name
);
749 *v
= g_strdup (value
);
751 *v
= g_strndup (dots
, q
- dots
);
758 /* --------------------------------------------------------------------------------------------- */
761 expand_format (const Widget
*edit_widget
, char c
, gboolean do_quote
)
763 WPanel
*panel
= NULL
;
764 char *(*quote_func
) (const char *, gboolean
);
765 const char *fname
= NULL
;
769 #ifdef USE_INTERNAL_EDIT
770 const WEdit
*e
= CONST_EDIT (edit_widget
);
776 return g_strdup ("%");
778 switch (mc_global
.mc_run_mode
)
781 #ifdef USE_INTERNAL_EDIT
783 fname
= edit_get_file_name (e
);
787 if (g_ascii_islower ((gchar
) c
))
788 panel
= current_panel
;
791 if (get_other_type () != view_listing
)
796 fname
= panel_current_entry (panel
)->fname
->str
;
800 #ifdef USE_INTERNAL_EDIT
802 fname
= edit_get_file_name (e
);
807 /* mc_run_param0 is not NULL here because mcviewer isn't run without input file */
808 fname
= (const char *) mc_run_param0
;
812 /* other modes don't use formats */
817 quote_func
= name_quote
;
819 quote_func
= fake_name_quote
;
821 c_lc
= g_ascii_tolower ((gchar
) c
);
827 result
= quote_func (fname
, FALSE
);
830 result
= quote_func (extension (fname
), FALSE
);
837 cwd
= vfs_path_as_str (panel
->cwd_vpath
);
839 cwd
= vfs_get_current_dir ();
841 result
= quote_func (cwd
, FALSE
);
845 #ifdef USE_INTERNAL_EDIT
848 result
= g_strdup_printf ("%u", (unsigned int) edit_get_cursor_offset (e
));
853 case 'i': /* indent equal number cursor position in line */
854 #ifdef USE_INTERNAL_EDIT
857 result
= g_strnfill (edit_get_curs_col (e
), ' ');
862 case 'y': /* syntax type */
863 #ifdef USE_INTERNAL_EDIT
866 const char *syntax_type
;
868 syntax_type
= edit_get_syntax_type (e
);
869 if (syntax_type
!= NULL
)
871 result
= g_strdup (syntax_type
);
877 case 'k': /* block file name */
878 case 'b': /* block file name / strip extension */
879 #ifdef USE_INTERNAL_EDIT
884 file
= mc_config_get_full_path (EDIT_HOME_BLOCK_FILE
);
885 result
= quote_func (file
, FALSE
);
892 result
= strip_ext (quote_func (fname
, FALSE
));
896 case 'n': /* strip extension in editor */
897 #ifdef USE_INTERNAL_EDIT
900 result
= strip_ext (quote_func (fname
, FALSE
));
905 case 'm': /* menu file name */
908 result
= quote_func (menu
, FALSE
);
913 if (panel
== NULL
|| panel
->marked
== 0)
915 result
= quote_func (fname
, FALSE
);
924 GString
*block
= NULL
;
933 for (i
= 0; i
< panel
->dir
.len
; i
++)
934 if (panel
->dir
.list
[i
].f
.marked
!= 0)
938 tmp
= quote_func (panel
->dir
.list
[i
].fname
->str
, FALSE
);
942 block
= g_string_new_take (tmp
);
945 g_string_append (block
, tmp
);
948 g_string_append_c (block
, ' ');
952 do_file_mark (panel
, i
, 0);
954 result
= block
== NULL
? NULL
: g_string_free (block
, block
->len
== 0);
956 } /* sub case block */
961 result
= g_strdup ("% ");
967 /* --------------------------------------------------------------------------------------------- */
969 * If edit_widget is NULL then we are called from the mc menu,
970 * otherwise we are called from the mcedit menu.
974 user_menu_cmd (const Widget
*edit_widget
, const char *menu_file
, int selected_entry
)
977 GPtrArray
*entries
= NULL
;
982 gboolean accept_entry
= TRUE
;
984 gboolean old_patterns
;
985 gboolean res
= FALSE
;
986 gboolean interactive
= TRUE
;
988 if (!vfs_current_is_local ())
990 message (D_ERROR
, MSG_ERROR
, "%s", _("Cannot execute commands on non-local filesystems"));
994 menu
= g_strdup (menu_file
!= NULL
? menu_file
: edit_widget
!= NULL
?
995 EDIT_LOCAL_MENU
: MC_LOCAL_MENU
);
997 if (!exist_file (menu
) || !menu_file_own (menu
))
999 if (menu_file
!= NULL
)
1001 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"), menu
,
1002 unix_error_string (errno
));
1008 menu
= mc_config_get_full_path (edit_widget
!= NULL
? EDIT_HOME_MENU
: MC_USERMENU_FILE
);
1009 if (!exist_file (menu
))
1011 const char *global_menu
;
1013 global_menu
= edit_widget
!= NULL
? EDIT_GLOBAL_MENU
: MC_GLOBAL_MENU
;
1016 menu
= mc_build_filename (mc_config_get_home_dir (), global_menu
, (char *) NULL
);
1017 if (!exist_file (menu
))
1020 menu
= mc_build_filename (mc_global
.sysconfig_dir
, global_menu
, (char *) NULL
);
1021 if (!exist_file (menu
))
1024 menu
= mc_build_filename (mc_global
.share_data_dir
, global_menu
, (char *) NULL
);
1030 if (!g_file_get_contents (menu
, &data
, NULL
, NULL
))
1032 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"), menu
, unix_error_string (errno
));
1037 old_patterns
= easy_patterns
;
1039 /* Parse the menu file */
1040 for (p
= check_patterns (data
); *p
!= '\0'; str_next_char (&p
))
1042 int menu_lines
= entries
== NULL
? 0 : entries
->len
;
1044 if (col
== 0 && (entries
== NULL
|| menu_lines
== entries
->len
))
1048 /* do not show prompt if first line of external script is #silent */
1049 if (selected_entry
>= 0 && strncmp (p
, "#silent", 7) == 0)
1050 interactive
= FALSE
;
1051 /* A commented menu entry */
1052 accept_entry
= TRUE
;
1056 if (*(p
+ 1) == '=')
1058 /* Combined adding and default */
1059 p
= test_line (edit_widget
, p
+ 1, &accept_entry
);
1060 if (selected
== 0 && accept_entry
)
1061 selected
= menu_lines
;
1065 /* A condition for adding the entry */
1066 p
= test_line (edit_widget
, p
, &accept_entry
);
1071 if (*(p
+ 1) == '+')
1073 /* Combined adding and default */
1074 p
= test_line (edit_widget
, p
+ 1, &accept_entry
);
1075 if (selected
== 0 && accept_entry
)
1076 selected
= menu_lines
;
1080 /* A condition for making the entry default */
1082 p
= test_line (edit_widget
, p
, &i
);
1083 if (selected
== 0 && i
!= 0)
1084 selected
= menu_lines
;
1089 if (!whitespace (*p
) && str_isprint (p
))
1091 /* A menu entry title line */
1094 if (entries
== NULL
)
1095 entries
= g_ptr_array_new ();
1096 g_ptr_array_add (entries
, p
);
1099 accept_entry
= TRUE
;
1106 if (entries
!= NULL
&& entries
->len
> menu_lines
)
1107 accept_entry
= TRUE
;
1108 max_cols
= MAX (max_cols
, col
);
1119 if (entries
== NULL
)
1120 message (D_ERROR
, MSG_ERROR
, _("No suitable entries found in %s"), menu
);
1123 if (selected_entry
>= 0)
1124 selected
= selected_entry
;
1129 max_cols
= MIN (MAX (max_cols
, col
), MAX_ENTRY_LEN
);
1131 /* Create listbox */
1132 listbox
= listbox_window_new (entries
->len
, max_cols
+ 2, _("User menu"),
1133 "[Edit Menu File]");
1134 /* insert all the items found */
1135 for (i
= 0; i
< entries
->len
; i
++)
1137 p
= g_ptr_array_index (entries
, i
);
1138 LISTBOX_APPEND_TEXT (listbox
, (unsigned char) p
[0],
1139 extract_line (p
, p
+ MAX_ENTRY_LEN
, NULL
), p
, FALSE
);
1141 /* Select the default entry */
1142 listbox_set_current (listbox
->list
, selected
);
1144 selected
= listbox_run (listbox
);
1149 execute_menu_command (edit_widget
, g_ptr_array_index (entries
, selected
), interactive
);
1153 g_ptr_array_free (entries
, TRUE
);
1158 easy_patterns
= old_patterns
;
1164 /* --------------------------------------------------------------------------------------------- */