summaryrefslogtreecommitdiff
path: root/desktop/browser.h
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 /desktop/browser.h
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 'desktop/browser.h')
-rw-r--r--desktop/browser.h48
1 files changed, 17 insertions, 31 deletions
diff --git a/desktop/browser.h b/desktop/browser.h
index cad8bf706..39f2253bf 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -40,14 +40,6 @@ struct history;
struct selection;
struct fetch_multipart_data;
-typedef bool (*browser_caret_callback)(struct browser_window *bw, uint32_t key,
- void *p1, void *p2);
-typedef void (*browser_move_callback)(struct browser_window *bw,
- void *p1, void *p2);
-typedef bool (*browser_paste_callback)(struct browser_window *bw,
- const char *utf8, unsigned utf8_len, bool last,
- void *p1, void *p2);
-
typedef enum {
DRAGGING_NONE,
@@ -60,6 +52,13 @@ typedef enum {
DRAGGING_OTHER
} browser_drag_type;
+typedef enum {
+ BW_EDITOR_NONE = 0, /**< No selection, no editing */
+ BW_EDITOR_CAN_COPY = (1 << 0), /**< Have selection */
+ BW_EDITOR_CAN_CUT = (1 << 1), /**< Selection not read-only */
+ BW_EDITOR_CAN_PASTE = (1 << 2) /**< Can paste, input */
+} browser_editor_flags;
+
extern bool browser_reformat_pending;
/** flags to browser window go */
@@ -206,15 +205,9 @@ bool browser_window_stop_available(struct browser_window *bw);
/* In desktop/textinput.c */
void browser_window_place_caret(struct browser_window *bw,
- int x, int y, int height,
- browser_caret_callback caret_cb,
- browser_paste_callback paste_cb,
- browser_move_callback move_cb,
- void *p1, void *p2);
-void browser_window_remove_caret(struct browser_window *bw);
+ int x, int y, int height);
+void browser_window_remove_caret(struct browser_window *bw, bool only_hide);
bool browser_window_key_press(struct browser_window *bw, uint32_t key);
-bool browser_window_paste_text(struct browser_window *bw, const char *utf8,
- unsigned utf8_len, bool last);
/**
@@ -327,29 +320,22 @@ browser_drag_type browser_window_get_drag_type(struct browser_window *bw);
struct browser_window * browser_window_get_root(struct browser_window *bw);
/**
- * Check whether browser window contains a selection
- *
- * \param bw The browser window
- * \return true if browser window contains a selection
- */
-bool browser_window_has_selection(struct browser_window *bw);
-
-/**
- * Set pointer to current selection. Clears any existing selection.
+ * Check whether browser window can accept a cut/copy/paste, or has a selection
+ * that could be saved.
*
* \param bw The browser window
- * \param s The new selection
+ * \return flags indicating editor flags
*/
-void browser_window_set_selection(struct browser_window *bw,
- struct selection *s);
+browser_editor_flags browser_window_get_editor_flags(struct browser_window *bw);
/**
- * Get the current selection context from a root browser window
+ * Get the current selection from a root browser window, ownership passed to
+ * caller, who must free() it.
*
* \param bw The browser window
- * \return the selection context, or NULL
+ * \return the selected text string, or NULL
*/
-struct selection *browser_window_get_selection(struct browser_window *bw);
+char * browser_window_get_selection(struct browser_window *bw);
/**