1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Introduce ACTION_REQUIRE_FORM and use it for link-form-menu

... since it asserts it is dealing with a link.
This commit is contained in:
Jonas Fonseca 2005-12-26 22:22:03 +01:00 committed by Jonas Fonseca
parent 74a0a7b174
commit b82a38ab28
3 changed files with 14 additions and 1 deletions

View File

@ -46,7 +46,7 @@ ACTION_(MAIN, "link-external-command", LINK_EXTERNAL_COMMAND, N__("Pass URI of c
ACTION_(MAIN, "link-follow", LINK_FOLLOW, N__("Follow the current link"), ACTION_REQUIRE_VIEW_STATE | ACTION_REQUIRE_LOCATION | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK),
ACTION_(MAIN, "link-follow-reload", LINK_FOLLOW_RELOAD, N__("Follow the current link, forcing reload of the target"), ACTION_REQUIRE_VIEW_STATE | ACTION_REQUIRE_LOCATION | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK),
ACTION_(MAIN, "link-menu", LINK_MENU, N__("Open the link context menu"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK),
ACTION_(MAIN, "link-form-menu", LINK_FORM_MENU, N__("Open the form fields menu"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK),
ACTION_(MAIN, "link-form-menu", LINK_FORM_MENU, N__("Open the form fields menu"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK | ACTION_REQUIRE_FORM),
ACTION_(MAIN, "lua-console", LUA_CONSOLE, N__("Open a Lua console"), ACTION_RESTRICT_ANONYMOUS),
ACTION_(MAIN, "mark-goto", MARK_GOTO, N__("Go at a specified mark"), ACTION_REQUIRE_VIEW_STATE),
ACTION_(MAIN, "mark-set", MARK_SET, N__("Set a mark"), ACTION_REQUIRE_VIEW_STATE),

View File

@ -43,6 +43,7 @@ enum action_flags {
ACTION_REQUIRE_LOCATION = (1 << 18),
ACTION_JUMP_TO_LINK = (1 << 19),
ACTION_REQUIRE_LINK = (1 << 20),
ACTION_REQUIRE_FORM = (1 << 21),
ACTION_FLAGS_MASK = (0xFF << 16),
};
@ -166,6 +167,14 @@ action_requires_link(enum keymap_id keymap_id, action_id_T action_id)
return action && (action->flags & ACTION_REQUIRE_LINK);
}
static inline unsigned int
action_requires_form(enum keymap_id keymap_id, action_id_T action_id)
{
struct action *action = get_action(keymap_id, action_id);
return action && (action->flags & ACTION_REQUIRE_FORM);
}
long read_key(unsigned char *);
unsigned char *get_keymap_name(enum keymap_id);

View File

@ -91,6 +91,10 @@ do_action(struct session *ses, enum main_action action_id, int verbose)
&& !link)
goto ignore_action;
if (action_requires_form(KEYMAP_MAIN, action_id)
&& (!link || !link_is_form(link)))
goto ignore_action;
if (!action_is_anonymous_safe(KEYMAP_MAIN, action_id)
&& get_cmd_opt_bool("anonymous"))
goto ignore_action;