diff --git a/src/document/document.h b/src/document/document.h index 4ea7781bb..eef897f77 100644 --- a/src/document/document.h +++ b/src/document/document.h @@ -69,6 +69,7 @@ struct script_event_hook { SEVHOOK_ONFOCUS, SEVHOOK_ONMOUSEOUT, SEVHOOK_ONBLUR, + SEVHOOK_ONCHANGE, } type; unsigned char *src; }; diff --git a/src/document/forms.c b/src/document/forms.c index f862b37ab..c38e32f62 100644 --- a/src/document/forms.c +++ b/src/document/forms.c @@ -155,6 +155,7 @@ done_form_control(struct form_control *fc) mem_free_if(fc->name); mem_free_if(fc->alt); mem_free_if(fc->default_value); + mem_free_if(fc->onchange); for (i = 0; i < fc->nvalues; i++) { mem_free_if(fc->values[i]); diff --git a/src/document/forms.h b/src/document/forms.h index 55934afe9..0d02cce92 100644 --- a/src/document/forms.h +++ b/src/document/forms.h @@ -87,6 +87,8 @@ struct form_control { unsigned char *name; unsigned char *alt; unsigned char *default_value; + /* For FC_SELECT. I have not found better place for it. --witekfl */ + unsigned char *onchange; int default_state; int size; int cols, rows; diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index 51f975d11..cf8581b28 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -481,6 +481,7 @@ end_parse: fc->id = get_attr_val(attr, "id", html_context->options->cp); fc->name = get_attr_val(attr, "name", html_context->options->cp); + fc->onchange = get_attr_val(attr, "onchange", html_context->options->cp); fc->default_state = preselect < 0 ? 0 : preselect; fc->default_value = order ? stracpy(values[fc->default_state]) : stracpy(""); fc->nvalues = order; diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 8430c9620..96590d2f1 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -1169,6 +1169,12 @@ init_link_event_hooks(struct html_context *html_context, struct link *link) add_evhook(link->event_hooks, SEVHOOK_ONMOUSEOUT, format.onmouseout); add_evhook(link->event_hooks, SEVHOOK_ONBLUR, format.onblur); + if (link->type == LINK_SELECT) { + struct form_control *fc = link->data.form_control; + + add_evhook(link->event_hooks, SEVHOOK_ONCHANGE, fc->onchange); + } + #undef add_evhook } diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index f37673ce7..1e2dfd459 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -147,6 +147,7 @@ selected_item(struct terminal *term, void *item_, void *ses_) } refresh_view(ses, doc_view, 0); + select_on_change(doc_view); } static void diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 8c93dec22..4ca0f0546 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -99,6 +99,12 @@ do { \ } while (0) +int +select_on_change(struct document_view *doc_view) +{ + return current_link_evhook(doc_view, SEVHOOK_ONCHANGE); +} + void set_link(struct document_view *doc_view) { diff --git a/src/viewer/text/link.h b/src/viewer/text/link.h index a27c2d26d..1e2043462 100644 --- a/src/viewer/text/link.h +++ b/src/viewer/text/link.h @@ -13,6 +13,8 @@ struct terminal; struct uri; struct conv_table; +int select_on_change(struct document_view *doc_view); + void set_link(struct document_view *doc_view); void clear_link(struct terminal *term, struct document_view *doc_view); void draw_current_link(struct session *ses, struct document_view *doc_view);