summaryrefslogtreecommitdiff
path: root/content/content.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 /content/content.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 'content/content.c')
-rw-r--r--content/content.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/content/content.c b/content/content.c
index 1a92e408b..3533d943c 100644
--- a/content/content.c
+++ b/content/content.c
@@ -475,6 +475,26 @@ void content_mouse_action(hlcache_handle *h, struct browser_window *bw,
/**
+ * Handle keypresses.
+ *
+ * \param h Content handle
+ * \param key The UCS4 character codepoint
+ * \return true if key handled, false otherwise
+ */
+
+bool content_keypress(struct hlcache_handle *h, uint32_t key)
+{
+ struct content *c = hlcache_handle_get_content(h);
+ assert(c != NULL);
+
+ if (c->handler->keypress != NULL)
+ return c->handler->keypress(c, key);
+
+ return false;
+}
+
+
+/**
* Request a redraw of an area of a content
*
* \param h high-level cache handle
@@ -738,10 +758,26 @@ void content_close(hlcache_handle *h)
/**
- * Find this content's selection context, if it has one.
+ * Tell a content that any selection it has, or one of its objects has, must be
+ * cleared.
+ */
+
+void content_clear_selection(hlcache_handle *h)
+{
+ struct content *c = hlcache_handle_get_content(h);
+ assert(c != 0);
+
+ if (c->handler->get_selection != NULL)
+ c->handler->clear_selection(c);
+}
+
+
+/**
+ * Get a text selection from a content. Ownership is passed to the caller,
+ * who must free() it.
*/
-struct selection *content_get_selection(hlcache_handle *h)
+char * content_get_selection(hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);