diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/content.c | 40 | ||||
-rw-r--r-- | content/content.h | 25 | ||||
-rw-r--r-- | content/content_protected.h | 4 |
3 files changed, 65 insertions, 4 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); diff --git a/content/content.h b/content/content.h index 2ae0b38be..3f93d603b 100644 --- a/content/content.h +++ b/content/content.h @@ -79,6 +79,8 @@ typedef enum { CONTENT_MSG_DRAGSAVE, /**< Allow drag saving of content */ CONTENT_MSG_SAVELINK, /**< Allow URL to be saved */ CONTENT_MSG_POINTER, /**< Wants a specific mouse pointer set */ + CONTENT_MSG_SELECTION, /**< A selection made or cleared */ + CONTENT_MSG_CARET, /**< Caret movement / hiding */ CONTENT_MSG_DRAG /**< A drag started or ended */ } content_msg; @@ -153,6 +155,25 @@ union content_msg_data { } savelink; /** CONTENT_MSG_POINTER - Mouse pointer to set */ browser_pointer_shape pointer; + /** CONTENT_MSG_SELECTION - Selection made or cleared */ + struct { + bool selection; /**< false for selection cleared */ + bool read_only; + } selection; + /** CONTENT_MSG_CARET - set caret position or, hide caret */ + struct { + enum { + CONTENT_CARET_SET_POS, + CONTENT_CARET_HIDE, + CONTENT_CARET_REMOVE + } type; + struct { + int x; /**< Carret x-coord */ + int y; /**< Carret y-coord */ + int height; /**< Carret height */ + const struct rect *clip; /**< Carret clip rect */ + } pos; /**< With CONTENT_CARET_SET_POS */ + } caret; /** CONTENT_MSG_DRAG - Drag start or end */ struct { enum { @@ -219,12 +240,14 @@ void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y); void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y); +bool content_keypress(struct hlcache_handle *h, uint32_t key); bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx); void content_open(struct hlcache_handle *h, struct browser_window *bw, struct content *page, struct object_params *params); void content_close(struct hlcache_handle *h); -struct selection *content_get_selection(struct hlcache_handle *h); +void content_clear_selection(struct hlcache_handle *h); +char * content_get_selection(struct hlcache_handle *h); void content_get_contextual_content(struct hlcache_handle *h, int x, int y, struct contextual_content *data); bool content_scroll_at_point(struct hlcache_handle *h, diff --git a/content/content_protected.h b/content/content_protected.h index ecbe17fc7..8efe763aa 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -58,13 +58,15 @@ struct content_handler { browser_mouse_state mouse, int x, int y); void (*mouse_action)(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y); + bool (*keypress)(struct content *c, uint32_t key); bool (*redraw)(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx); void (*open)(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params); void (*close)(struct content *c); - struct selection * (*get_selection)(struct content *c); + void (*clear_selection)(struct content *c); + char * (*get_selection)(struct content *c); void (*get_contextual_content)(struct content *c, int x, int y, struct contextual_content *data); bool (*scroll_at_point)(struct content *c, int x, int y, |