mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
* user.c (execute_menu_command): Implement %view macro.
This commit is contained in:
parent
c68d1ab16a
commit
6349237830
@ -1,3 +1,7 @@
|
||||
2003-09-04 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* user.c (execute_menu_command): Implement %view macro.
|
||||
|
||||
2003-09-03 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* wtools.c (create_listbox_window): Don't repaint the dialog
|
||||
|
22
src/user.c
22
src/user.c
@ -544,7 +544,7 @@ static char *test_line (WEdit *edit_widget, char *p, int *result)
|
||||
|
||||
/* FIXME: recode this routine on version 3.0, it could be cleaner */
|
||||
static void
|
||||
execute_menu_command (WEdit *edit_widget, char *commands)
|
||||
execute_menu_command (WEdit *edit_widget, const char *commands)
|
||||
{
|
||||
FILE *cmd_file;
|
||||
int cmd_file_fd;
|
||||
@ -554,6 +554,7 @@ execute_menu_command (WEdit *edit_widget, char *commands)
|
||||
char prompt [80];
|
||||
int col;
|
||||
char *file_name;
|
||||
int run_view = 0;
|
||||
|
||||
/* Skip menu entry title line */
|
||||
commands = strchr (commands, '\n');
|
||||
@ -561,7 +562,7 @@ execute_menu_command (WEdit *edit_widget, char *commands)
|
||||
return;
|
||||
}
|
||||
|
||||
cmd_file_fd = mc_mkstemps(&file_name, "mcusr", SCRIPT_SUFFIX);
|
||||
cmd_file_fd = mc_mkstemps (&file_name, "mcusr", SCRIPT_SUFFIX);
|
||||
|
||||
if (cmd_file_fd == -1){
|
||||
message (1, MSG_ERROR, _(" Cannot create temporary command file \n %s "),
|
||||
@ -621,15 +622,26 @@ execute_menu_command (WEdit *edit_widget, char *commands)
|
||||
}
|
||||
} else {
|
||||
if (*commands == '%') {
|
||||
do_quote = 1; /* Default: Quote expanded macro */
|
||||
expand_prefix_found = 1;
|
||||
int i = check_format_view (commands + 1);
|
||||
if (i) {
|
||||
commands += i;
|
||||
run_view = 1;
|
||||
} else {
|
||||
do_quote = 1; /* Default: Quote expanded macro */
|
||||
expand_prefix_found = 1;
|
||||
}
|
||||
} else
|
||||
fputc (*commands, cmd_file);
|
||||
}
|
||||
}
|
||||
fclose (cmd_file);
|
||||
chmod (file_name, S_IRWXU);
|
||||
shell_execute (file_name, 0);
|
||||
if (run_view) {
|
||||
run_view = 0;
|
||||
view (file_name, 0, &run_view, 0);
|
||||
} else {
|
||||
shell_execute (file_name, 0);
|
||||
}
|
||||
unlink (file_name);
|
||||
g_free (file_name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user