summaryrefslogtreecommitdiff
path: root/render/box_textarea.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-02-22 12:19:35 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-02-22 12:19:35 +0000
commitc2a718075ad321a9cf4678e72645acda5c3471a9 (patch)
treea634c4c47c579aab35839ee3861ef90f92d89b48 /render/box_textarea.c
parent2b0cc398bb5b8e5dc90fcc0a71a9a154dd9f2d74 (diff)
downloadnetsurf-c2a718075ad321a9cf4678e72645acda5c3471a9.tar.gz
netsurf-c2a718075ad321a9cf4678e72645acda5c3471a9.tar.bz2
A load of refactoring of how content selection and input work.
Keypresses now go via content interface. Contents don't shove the selection object into browser windows any more. Contents report selection existence by sending message. HTML content keeps track of where selections in it exist. Contents report whether they have input focus via caret setting msg. Caret can be hidden (can still input/paste) or removed. Consolidate textarea selection handling. Make textarea report its selection status changes to client. Various textarea fixes. Changed how we decide when to clear selections, and give focus.
Diffstat (limited to 'render/box_textarea.c')
-rw-r--r--render/box_textarea.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/render/box_textarea.c b/render/box_textarea.c
index 3109904d0..3d9838fa1 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -31,14 +31,11 @@
#include "utils/log.h"
-static bool box_textarea_browser_caret_callback(struct browser_window *bw,
- uint32_t key, void *p1, void *p2)
+bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
{
- struct box *box = p1;
struct form_control *gadget = box->gadget;
struct textarea *ta = gadget->data.text.ta;
struct form* form = box->gadget->form;
- html_content *html = p2;
struct content *c = (struct content *) html;
assert(ta != NULL);
@@ -104,21 +101,6 @@ static bool box_textarea_browser_caret_callback(struct browser_window *bw,
}
-static void box_textarea_browser_move_callback(struct browser_window *bw,
- void *p1, void *p2)
-{
-}
-
-
-static bool box_textarea_browser_paste_callback(struct browser_window *bw,
- const char *utf8, unsigned utf8_len, bool last,
- void *p1, void *p2)
-{
- printf("AWWOOOOOGA!\n");
- return true;
-}
-
-
/**
* Callback for html form textareas.
*/
@@ -175,23 +157,43 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
html__redraw_a_box(html, box);
break;
- case TEXTAREA_MSG_MOVED_CARET:
+ case TEXTAREA_MSG_SELECTION_REPORT:
+ if (msg->data.selection.have_selection) {
+ /* Textarea now has a selection */
+ union html_selection_owner sel_owner;
+ sel_owner.textarea = box;
+
+ html_set_selection(d->html, HTML_SELECTION_TEXTAREA,
+ sel_owner,
+ msg->data.selection.read_only);
+ } else {
+ /* The textarea now has no selection */
+ union html_selection_owner sel_owner;
+ sel_owner.none = true;
+
+ html_set_selection(d->html, HTML_SELECTION_NONE,
+ sel_owner, true);
+ }
+ break;
+
+ case TEXTAREA_MSG_CARET_UPDATE:
if (html->bw == NULL)
break;
- if (msg->data.caret.hidden) {
- browser_window_remove_caret(html->bw);
+ if (msg->data.caret.type == TEXTAREA_CARET_HIDE) {
+ union html_focus_owner focus_owner;
+ focus_owner.textarea = box;
+ html_set_focus(d->html, HTML_FOCUS_TEXTAREA,
+ focus_owner, true, 0, 0, 0, NULL);
} else {
- int x, y;
- box_coords(box, &x, &y);
- browser_window_place_caret(html->bw,
- x + msg->data.caret.x,
- y + msg->data.caret.y,
- msg->data.caret.height,
- box_textarea_browser_caret_callback,
- box_textarea_browser_paste_callback,
- box_textarea_browser_move_callback,
- box, html);
+ union html_focus_owner focus_owner;
+ focus_owner.textarea = box;
+ html_set_focus(d->html, HTML_FOCUS_TEXTAREA,
+ focus_owner, false,
+ msg->data.caret.pos.x,
+ msg->data.caret.pos.y,
+ msg->data.caret.pos.height,
+ msg->data.caret.pos.clip);
}
break;
}