summaryrefslogtreecommitdiff
path: root/riscos/save.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 /riscos/save.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 'riscos/save.c')
-rw-r--r--riscos/save.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/riscos/save.c b/riscos/save.c
index 12af6ab22..549a2ab3e 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -79,7 +79,7 @@
static gui_save_type gui_save_current_type;
static hlcache_handle *gui_save_content = NULL;
-static struct selection *gui_save_selection = NULL;
+static char *gui_save_selection = NULL;
static const char *gui_save_url = NULL;
static const char *gui_save_title = NULL;
static int gui_save_filetype;
@@ -246,7 +246,7 @@ void ro_gui_saveas_quit(void)
*/
void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
- struct selection *s, const char *url, const char *title)
+ char *s, const char *url, const char *title)
{
char name_buf[FILENAME_MAX];
size_t leaf_offset = 0;
@@ -259,6 +259,9 @@ void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
(save_type == GUI_SAVE_HISTORY_EXPORT_HTML) ||
(save_type == GUI_SAVE_TEXT_SELECTION) || h);
+ if (gui_save_selection == NULL)
+ free(gui_save_selection);
+
gui_save_selection = s;
gui_save_url = url;
gui_save_title = title;
@@ -414,7 +417,11 @@ void gui_drag_save_selection(struct selection *s, struct gui_window *g)
return;
}
- gui_save_selection = s;
+
+ if (gui_save_selection == NULL)
+ free(gui_save_selection);
+
+ gui_save_selection = selection_get_copy(s);
ro_gui_save_set_state(NULL, GUI_SAVE_TEXT_SELECTION, NULL,
save_leafname, LEAFNAME_MAX,
@@ -890,8 +897,15 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite)
break;
case GUI_SAVE_TEXT_SELECTION:
- if (!selection_save_text(gui_save_selection, path))
+ if (gui_save_selection == NULL)
+ return false;
+ if (!utf8_save_text(gui_save_selection, path)) {
+ free(gui_save_selection);
+ gui_save_selection = NULL;
return false;
+ }
+ free(gui_save_selection);
+ gui_save_selection = NULL;
xosfile_set_type(path, 0xfff);
break;