summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorAdrian Lees <adrian@aemulor.com>2005-07-20 23:27:28 +0000
committerAdrian Lees <adrian@aemulor.com>2005-07-20 23:27:28 +0000
commit1a1901d19b07ea265840962877b34b1205f6b092 (patch)
treef839d3b9687660d1b26556ba1944496aff10d8f5 /riscos
parent5e148741154019d69338c0f8781ed8a084cdd53d (diff)
downloadnetsurf-1a1901d19b07ea265840962877b34b1205f6b092.tar.gz
netsurf-1a1901d19b07ea265840962877b34b1205f6b092.tar.bz2
[project @ 2005-07-20 23:27:27 by adrianl]
2D scrolling of text areas/frames; First cut at selection in textareas; Further text editing actions (Word left/right; Page up/down; Cut block; Delete line start/end) svn path=/import/netsurf/; revision=1812
Diffstat (limited to 'riscos')
-rw-r--r--riscos/search.c4
-rw-r--r--riscos/textselection.c96
-rw-r--r--riscos/window.c61
3 files changed, 135 insertions, 26 deletions
diff --git a/riscos/search.c b/riscos/search.c
index 16f174a45..1efa976ac 100644
--- a/riscos/search.c
+++ b/riscos/search.c
@@ -78,6 +78,10 @@ void ro_gui_search_prepare(struct gui_window *g)
assert(g != NULL);
+ /* if the search dialogue is reopened over a new window, we still
+ need to cancel the previous search */
+ ro_gui_search_end();
+
search_current_window = g;
ro_gui_set_icon_string(dialog_search, ICON_SEARCH_TEXT, "");
diff --git a/riscos/textselection.c b/riscos/textselection.c
index cb3be1e75..2a7762887 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -171,20 +171,61 @@ void ro_gui_selection_drag_end(struct gui_window *g, wimp_dragged *drag)
bool copy_handler(struct box *box, int offset, size_t length, void *handle)
{
size_t len = min(length, box->length - offset);
- size_t new_length;
const char *text;
- int space = 0;
+ bool space = false;
if (box) {
text = box->text + offset;
- if (box->space && length > len) space = 1;
+ if (box->space && length > len) space = true;
}
else {
text = "\n";
len = 1;
}
- new_length = clip_length + len + space;
+ return gui_add_to_clipboard(text, len, space);
+}
+
+
+/**
+ * Empty the clipboard, called prior to gui_add_to_clipboard and
+ * gui_commit_clipboard
+ *
+ * \return true iff successful
+ */
+
+bool gui_empty_clipboard(void)
+{
+ const int init_size = 1024;
+
+ if (!clip_alloc) {
+ clipboard = malloc(init_size);
+ if (!clipboard) {
+ LOG(("out of memory"));
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ clip_alloc = init_size;
+ }
+
+ clip_length = 0;
+
+ return true;
+}
+
+
+/**
+ * Add some text to the clipboard, optionally appending a trailing space.
+ *
+ * \param text text to be added
+ * \param length length of text in bytes
+ * \param space indicates whether a trailing space should be appended also
+ * \return true iff successful
+ */
+
+bool gui_add_to_clipboard(const char *text, size_t length, bool space)
+{
+ size_t new_length = clip_length + length + (space ? 1 : 0);
if (new_length > clip_alloc) {
size_t new_alloc = clip_alloc + (clip_alloc / 4);
@@ -199,8 +240,8 @@ bool copy_handler(struct box *box, int offset, size_t length, void *handle)
clip_alloc = new_alloc;
}
- memcpy(clipboard + clip_length, text, len);
- clip_length += len;
+ memcpy(clipboard + clip_length, text, length);
+ clip_length += length;
if (space) clipboard[clip_length++] = ' ';
return true;
@@ -208,33 +249,16 @@ bool copy_handler(struct box *box, int offset, size_t length, void *handle)
/**
- * Copy the selected contents to the global clipboard,
- * and claim ownership of the clipboard from other apps.
+ * Commit the changes made by gui_empty_clipboard and gui_add_to_clipboard.
*
- * \param s selection
- * \return true iff successful, ie. cut operation can proceed without losing data
+ * \return true iff successful
*/
-bool gui_copy_to_clipboard(struct selection *s)
+bool gui_commit_clipboard(void)
{
- const int init_size = 1024;
utf8_convert_ret res;
char *new_cb;
-
- if (!clip_alloc) {
- clipboard = malloc(init_size);
- if (!clipboard) {
- LOG(("out of memory"));
- warn_user("NoMemory", 0);
- return false;
- }
- clip_alloc = init_size;
- }
-
- clip_length = 0;
- selection_traverse(s, copy_handler, NULL);
-
res = utf8_to_local_encoding(clipboard, clip_length, &new_cb);
if (res == UTF8_CONVERT_OK) {
free(clipboard);
@@ -270,6 +294,26 @@ bool gui_copy_to_clipboard(struct selection *s)
}
+
+/**
+ * Copy the selected contents to the global clipboard,
+ * and claim ownership of the clipboard from other apps.
+ *
+ * \param s selection
+ * \return true iff successful, ie. cut operation can proceed without losing data
+ */
+
+bool gui_copy_to_clipboard(struct selection *s)
+{
+ if (!gui_empty_clipboard())
+ return false;
+
+ selection_traverse(s, copy_handler, NULL);
+
+ return gui_commit_clipboard();
+}
+
+
/**
* Request to paste the clipboard contents into a textarea/input field
* at a given position. Note that the actual operation may take place
diff --git a/riscos/window.c b/riscos/window.c
index 867382565..74033a740 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -2439,6 +2439,23 @@ void gui_window_set_pointer(gui_pointer_shape shape)
/**
+ * Remove the mouse pointer from the screen
+ */
+
+void gui_window_hide_pointer(void)
+{
+ os_error *error;
+
+ error = xwimpspriteop_set_pointer_shape(NULL, 0x30, 0, 0, 0, 0);
+ if (error) {
+ LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+}
+
+
+/**
* Called when the gui_window has new content.
*
* \param g the gui_window that has new content
@@ -2533,6 +2550,50 @@ bool ro_gui_ctrl_pressed(void)
/**
+ * Platform-dependent part of starting a box scrolling operation,
+ * for frames and textareas.
+ *
+ * \param x0 minimum x ordinate of box relative to mouse pointer
+ * \param y0 minimum y ordinate
+ * \param x1 maximum x ordinate
+ * \param y1 maximum y ordinate
+ * \return true iff succesful
+ */
+
+bool gui_window_box_scroll_start(struct gui_window *g, int x0, int y0, int x1, int y1)
+{
+ wimp_pointer pointer;
+ os_error *error;
+ wimp_drag drag;
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ LOG(("xwimp_get_pointer_info 0x%x : %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return false;
+ }
+
+ drag.type = wimp_DRAG_USER_POINT;
+ drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->option.scale);
+ drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->option.scale);
+ drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->option.scale);
+ drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->option.scale);
+
+ error = xwimp_drag_box(&drag);
+ if (error) {
+ LOG(("xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return false;
+ }
+
+ gui_current_drag_type = GUI_DRAG_SCROLL;
+ return true;
+}
+
+
+/**
* Starts drag scrolling of a browser window
*
* \param gw gui window