summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-08-13 17:42:23 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-08-13 17:42:23 +0100
commit4d6ada8c9afbc3aed902e4fb1f7ac93b95d2b30c (patch)
tree5202e6fded30564bacfb9f216578632eea7db22b /amiga
parent86f3e70f1af9130c2f24638fd560804ccb736af8 (diff)
downloadnetsurf-4d6ada8c9afbc3aed902e4fb1f7ac93b95d2b30c.tar.gz
netsurf-4d6ada8c9afbc3aed902e4fb1f7ac93b95d2b30c.tar.bz2
Use selection_get_copy instead of selection_traverse. Note: untested.
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/clipboard.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index b7450886f..83548304e 100755
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -48,11 +48,6 @@
struct IFFHandle *iffh = NULL;
-bool ami_add_to_clipboard(const char *text, size_t length, bool space);
-static bool ami_copy_selection(const char *text, size_t length,
- struct box *box, void *handle, const char *whitespace_text,
- size_t whitespace_length);
-
static LONG ami_clipboard_iffp_do_nothing(struct Hook *hook, void *object, LONG *cmd)
{
return 0;
@@ -322,33 +317,30 @@ bool gui_copy_to_clipboard(struct selection *s)
struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
{
struct ami_text_selection *sel;
+ int len;
+ char *ss;
sel = AllocVec(sizeof(struct ami_text_selection),
MEMF_PRIVATE | MEMF_CLEAR);
- if(sel) selection_traverse(browser_window_get_selection(gwin->bw), ami_copy_selection, sel);
-
- return sel;
-}
-
-static bool ami_copy_selection(const char *text, size_t length,
- struct box *box, void *handle, const char *whitespace_text,
- size_t whitespace_length)
-{
- struct ami_text_selection *sel = handle;
- int len = length;
-
- if((length + (sel->length)) > (sizeof(sel->text)))
- len = sizeof(sel->text) - (sel->length);
+ if (sel) {
+ /* Get selection string */
+ ss = selection_get_copy(browser_window_get_selection(gwin->bw));
+ if (ss == NULL)
+ return sel;
- if(len <= 0) return false;
+ len = strlen(ss);
- memcpy((sel->text) + (sel->length), text, len);
- sel->length += len;
+ if (len > sizeof(sel->text))
+ len = sizeof(sel->text) - 1;
- sel->text[sel->length] = '\0';
+ memcpy(sel->text, ss, len);
+ sel->length = len;
+ sel->text[sel->length] = '\0';
- return true;
+ free(ss);
+ }
+ return sel;
}
void ami_drag_selection(struct selection *s)