1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Perform the work of try_form_insert_mode in enter

Currently, the function try_form_insert_mode checks whether the current
link is a text area, insert mode is off, and the current action is enter,
and if so, it sets insert mode on.  Perform this work in enter instead,
and delete try_form_insert_mode.

The old code works as follows: send_kbd_event → send_to_frame
→ frame_ev → frame_ev_kbd → try_form_insert_mode.  The new code works
as follows: send_kbd_event → do_action → enter.
This commit is contained in:
Miciah Dashiel Butler Masters 2011-11-13 04:15:11 +00:00
parent a3918d8c30
commit daa6f36e83
2 changed files with 5 additions and 26 deletions

View File

@ -1092,6 +1092,11 @@ enter(struct session *ses, struct document_view *doc_view, int do_reload)
link = get_current_link(doc_view); link = get_current_link(doc_view);
if (!link) return FRAME_EVENT_REFRESH; if (!link) return FRAME_EVENT_REFRESH;
if (link_is_textinput(link)
&& ses->insert_mode == INSERT_MODE_OFF) {
ses->insert_mode = INSERT_MODE_ON;
return FRAME_EVENT_REFRESH;
}
if (!current_link_evhook(doc_view, SEVHOOK_ONCLICK)) if (!current_link_evhook(doc_view, SEVHOOK_ONCLICK))
return FRAME_EVENT_REFRESH; return FRAME_EVENT_REFRESH;

View File

@ -1078,28 +1078,6 @@ try_prefix_key(struct session *ses, struct document_view *doc_view,
return FRAME_EVENT_IGNORED; return FRAME_EVENT_IGNORED;
} }
static enum frame_event_status
try_form_insert_mode(struct session *ses, struct document_view *doc_view,
struct link *link, struct term_event *ev)
{
enum frame_event_status status = FRAME_EVENT_IGNORED;
enum edit_action action_id;
if (!link_is_textinput(link))
return FRAME_EVENT_IGNORED;
action_id = kbd_action(KEYMAP_EDIT, ev, NULL);
if (ses->insert_mode == INSERT_MODE_OFF) {
if (action_id == ACT_EDIT_ENTER) {
ses->insert_mode = INSERT_MODE_ON;
status = FRAME_EVENT_REFRESH;
}
}
return status;
}
static enum frame_event_status static enum frame_event_status
try_form_action(struct session *ses, struct document_view *doc_view, try_form_action(struct session *ses, struct document_view *doc_view,
struct link *link, struct term_event *ev) struct link *link, struct term_event *ev)
@ -1129,10 +1107,6 @@ frame_ev_kbd(struct session *ses, struct document_view *doc_view, struct term_ev
struct link *link = get_current_link(doc_view); struct link *link = get_current_link(doc_view);
if (link) { if (link) {
status = try_form_insert_mode(ses, doc_view, link, ev);
if (status != FRAME_EVENT_IGNORED)
return status;
status = try_form_action(ses, doc_view, link, ev); status = try_form_action(ses, doc_view, link, ev);
if (status != FRAME_EVENT_IGNORED) if (status != FRAME_EVENT_IGNORED)
return status; return status;