summaryrefslogtreecommitdiff
path: root/content/handlers/html/box_textarea.c
diff options
context:
space:
mode:
Diffstat (limited to 'content/handlers/html/box_textarea.c')
-rw-r--r--content/handlers/html/box_textarea.c102
1 files changed, 55 insertions, 47 deletions
diff --git a/content/handlers/html/box_textarea.c b/content/handlers/html/box_textarea.c
index f0ba9f9de..d08660030 100644
--- a/content/handlers/html/box_textarea.c
+++ b/content/handlers/html/box_textarea.c
@@ -21,6 +21,7 @@
* Box tree treeview box replacement (implementation).
*/
+#include <string.h>
#include <dom/dom.h>
#include "utils/config.h"
@@ -29,90 +30,97 @@
#include "netsurf/keypress.h"
#include "netsurf/misc.h"
#include "desktop/textarea.h"
-#include "desktop/gui_internal.h"
-#include "html/html_internal.h"
+#include "html/private.h"
+#include "html/interaction.h"
#include "html/box.h"
+#include "html/box_inspect.h"
#include "html/box_textarea.h"
#include "html/font.h"
#include "html/form_internal.h"
-bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
+nserror box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
{
struct form_control *gadget = box->gadget;
struct textarea *ta = gadget->data.text.ta;
struct form* form = box->gadget->form;
- struct content *c = (struct content *) html;
- nserror res;
+ struct content *c = (struct content *)html;
+ nserror res = NSERROR_OK;
assert(ta != NULL);
- if (gadget->type != GADGET_TEXTAREA) {
- switch (key) {
- case NS_KEY_NL:
- case NS_KEY_CR:
- if (form) {
- res = form_submit(content_get_url(c),
- html->bw,
- form,
- NULL);
- if (res != NSERROR_OK) {
- guit->misc->warning(messages_get_errorcode(res), NULL);
- }
+ if (gadget->type == GADGET_TEXTAREA) {
+ if (textarea_keypress(ta, key)) {
+ return NSERROR_OK;
+ } else {
+ return NSERROR_INVALID;
+ }
+ }
- }
- return true;
+ /* non textarea input */
+ switch (key) {
+ case NS_KEY_NL:
+ case NS_KEY_CR:
+ if (form) {
+ res = form_submit(content_get_url(c),
+ html->bw,
+ form,
+ NULL);
+ }
+ break;
- case NS_KEY_TAB:
+ case NS_KEY_TAB:
{
struct form_control *next_input;
/* Find next text entry field that is actually
* displayed (i.e. has an associated box) */
for (next_input = gadget->next;
- next_input &&
- ((next_input->type != GADGET_TEXTBOX &&
- next_input->type != GADGET_TEXTAREA &&
- next_input->type != GADGET_PASSWORD) ||
- !next_input->box);
- next_input = next_input->next)
+ next_input &&
+ ((next_input->type != GADGET_TEXTBOX &&
+ next_input->type != GADGET_TEXTAREA &&
+ next_input->type != GADGET_PASSWORD) ||
+ !next_input->box);
+ next_input = next_input->next)
;
- if (!next_input)
- return true;
- textarea_set_caret(ta, -1);
- textarea_set_caret(next_input->data.text.ta, 0);
+ if (next_input != NULL) {
+ textarea_set_caret(ta, -1);
+ textarea_set_caret(next_input->data.text.ta, 0);
+ }
}
- return true;
+ break;
- case NS_KEY_SHIFT_TAB:
+ case NS_KEY_SHIFT_TAB:
{
struct form_control *prev_input;
/* Find previous text entry field that is actually
* displayed (i.e. has an associated box) */
for (prev_input = gadget->prev;
- prev_input &&
- ((prev_input->type != GADGET_TEXTBOX &&
- prev_input->type != GADGET_TEXTAREA &&
- prev_input->type != GADGET_PASSWORD) ||
- !prev_input->box);
- prev_input = prev_input->prev)
+ prev_input &&
+ ((prev_input->type != GADGET_TEXTBOX &&
+ prev_input->type != GADGET_TEXTAREA &&
+ prev_input->type != GADGET_PASSWORD) ||
+ !prev_input->box);
+ prev_input = prev_input->prev)
;
- if (!prev_input)
- return true;
- textarea_set_caret(ta, -1);
- textarea_set_caret(prev_input->data.text.ta, 0);
+ if (prev_input != NULL) {
+ textarea_set_caret(ta, -1);
+ textarea_set_caret(prev_input->data.text.ta, 0);
+ }
}
- return true;
+ break;
- default:
- /* Pass to textarea widget */
- break;
+ default:
+ /* Pass to textarea widget */
+ if (!textarea_keypress(ta, key)) {
+ res = NSERROR_INVALID;
}
+ break;
}
- return textarea_keypress(ta, key);
+ return res;
}