mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
option for running external commands in the foreground
This commit is contained in:
parent
1570b6f0c5
commit
69d52ced31
@ -852,21 +852,32 @@ static union option_info config_options_info[] = {
|
|||||||
"link and tab menu will have a submenu of items for each "
|
"link and tab menu will have a submenu of items for each "
|
||||||
"rule.\n"
|
"rule.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Note, this is mostly useful for launching graphical viewers, "
|
"The action and submenus are also available by binding keys "
|
||||||
"since there is no support for releasing the terminal while "
|
"to the frame-external-command, the link-external-command, "
|
||||||
"the command runs. The action and submenus are also available "
|
"and the tab-external-command actions.\n"
|
||||||
"by binding keys to the frame-external-command, the "
|
"\n"
|
||||||
"link-external-command, and the tab-external-command "
|
"Commands run in the background by default: elinks is still "
|
||||||
"actions.")),
|
"active, and they do not receive standard input. "
|
||||||
|
"The \"foreground\" suboption reverses this behaviour: "
|
||||||
|
"the command receives standard input "
|
||||||
|
"and elinks is blocked.\n")),
|
||||||
|
|
||||||
INIT_OPT_STRING("document.uri_passing", NULL,
|
INIT_OPT_TREE("document.uri_passing", NULL,
|
||||||
"_template_", 0, "",
|
"_template_", 0,
|
||||||
N_("A rule for passing URI to an external command. "
|
N_("A rule for passing URI to an external command.")),
|
||||||
|
|
||||||
|
INIT_OPT_STRING("document.uri_passing._template_", NULL,
|
||||||
|
"command", 0, "",
|
||||||
|
N_("The external command. "
|
||||||
"The format is:\n"
|
"The format is:\n"
|
||||||
"%c in the string means the current URL\n"
|
"%c in the string means the current URL\n"
|
||||||
"%% in the string means '%'\n"
|
"%% in the string means '%'\n"
|
||||||
"Do _not_ put single- or double-quotes around %c.")),
|
"Do _not_ put single- or double-quotes around %c.")),
|
||||||
|
|
||||||
|
INIT_OPT_BOOL("document.uri_passing._template_", NULL,
|
||||||
|
"foreground", 0, 0,
|
||||||
|
N_("Run command in the foreground.")),
|
||||||
|
|
||||||
/* Keep options in alphabetical order. */
|
/* Keep options in alphabetical order. */
|
||||||
|
|
||||||
|
|
||||||
|
@ -762,8 +762,9 @@ static void
|
|||||||
do_pass_uri_to_command(struct terminal *term, void *command_, void *xxx)
|
do_pass_uri_to_command(struct terminal *term, void *command_, void *xxx)
|
||||||
{
|
{
|
||||||
char *command = command_;
|
char *command = command_;
|
||||||
|
int block = command[0] == 'b' ? TERM_EXEC_BG : TERM_EXEC_FG;
|
||||||
|
|
||||||
exec_on_terminal(term, command, "", TERM_EXEC_BG);
|
exec_on_terminal(term, command + 1, "", block);
|
||||||
mem_free(command);
|
mem_free(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +821,7 @@ pass_uri_to_command(struct session *ses, struct document_view *doc_view,
|
|||||||
NULL);
|
NULL);
|
||||||
enum pass_uri_type type = which_type;
|
enum pass_uri_type type = which_type;
|
||||||
struct menu_item *items;
|
struct menu_item *items;
|
||||||
struct option *option;
|
struct option *option, *sub;
|
||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
int commands = 0;
|
int commands = 0;
|
||||||
|
|
||||||
@ -856,7 +857,8 @@ pass_uri_to_command(struct session *ses, struct document_view *doc_view,
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (option, *tree) {
|
foreach (option, *tree) {
|
||||||
char *text, *data;
|
char *text, *command, *data;
|
||||||
|
int block;
|
||||||
|
|
||||||
if (!strcmp(option->name, "_template_"))
|
if (!strcmp(option->name, "_template_"))
|
||||||
continue;
|
continue;
|
||||||
@ -864,11 +866,26 @@ pass_uri_to_command(struct session *ses, struct document_view *doc_view,
|
|||||||
text = stracpy(option->name);
|
text = stracpy(option->name);
|
||||||
if (!text) continue;
|
if (!text) continue;
|
||||||
|
|
||||||
data = format_command(option->value.string, uri);
|
command = NULL;
|
||||||
|
block = 0;
|
||||||
|
|
||||||
|
foreach (sub, *option->value.tree) {
|
||||||
|
if (!strcmp(sub->name, "command"))
|
||||||
|
command = sub->value.string;
|
||||||
|
if (!strcmp(sub->name, "foreground"))
|
||||||
|
block = sub->value.number;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!command)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
data = format_command(command, uri);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
mem_free(text);
|
mem_free(text);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
insert_in_string(&data, 0, " ", 1);
|
||||||
|
data[0] = block ? 'f' : 'b';
|
||||||
|
|
||||||
add_to_menu(&items, text, NULL, ACT_MAIN_NONE,
|
add_to_menu(&items, text, NULL, ACT_MAIN_NONE,
|
||||||
do_pass_uri_to_command, data, 0);
|
do_pass_uri_to_command, data, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user