From daa6f36e83894197c6466b41dce2db0b795b742e Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 13 Nov 2011 04:15:11 +0000 Subject: [PATCH] Perform the work of try_form_insert_mode in enter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/viewer/text/link.c | 5 +++++ src/viewer/text/view.c | 26 -------------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 529f17f9..f8038534 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1092,6 +1092,11 @@ enter(struct session *ses, struct document_view *doc_view, int do_reload) link = get_current_link(doc_view); 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)) return FRAME_EVENT_REFRESH; diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 1fb25a8f..8eb422d3 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -1078,28 +1078,6 @@ try_prefix_key(struct session *ses, struct document_view *doc_view, 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 try_form_action(struct session *ses, struct document_view *doc_view, 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); 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); if (status != FRAME_EVENT_IGNORED) return status;