summaryrefslogtreecommitdiff
path: root/amiga/clipboard.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2011-04-29 18:15:20 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2011-04-29 18:15:20 +0000
commit1518543c227c61250da14a864ad88c10fc6cd4c4 (patch)
treebbeba98b5faea95ce61ac7676bc7ce1ea8a31430 /amiga/clipboard.c
parent1304964f92249a1f8e685db89aa694f77307d6ae (diff)
downloadnetsurf-1518543c227c61250da14a864ad88c10fc6cd4c4.tar.gz
netsurf-1518543c227c61250da14a864ad88c10fc6cd4c4.tar.bz2
Fix DSI when drag saving
Allow selection drags to URL and search gadgets svn path=/trunk/netsurf/; revision=12259
Diffstat (limited to 'amiga/clipboard.c')
-rwxr-xr-xamiga/clipboard.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index 826f2f2dd..bf0b6f618 100755
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -21,6 +21,7 @@
#include "desktop/selection.h"
#include "desktop/textinput.h"
+#include "amiga/clipboard.h"
#include "amiga/iff_cset.h"
#include "amiga/options.h"
#include "amiga/gui.h"
@@ -43,6 +44,9 @@
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);
struct IFFHandle *ami_clipboard_init_internal(int unit)
{
@@ -275,11 +279,44 @@ bool gui_copy_to_clipboard(struct selection *s)
return false;
}
+struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
+{
+ struct ami_text_selection *sel;
+
+ sel = AllocVec(sizeof(struct ami_text_selection),
+ MEMF_PRIVATE | MEMF_CLEAR);
+
+ if(sel) selection_traverse(gwin->bw->sel, 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(len <= 0) return false;
+
+ memcpy((sel->text) + (sel->length), text, len);
+ sel->length += len;
+
+ sel->text[sel->length] = '\0';
+
+ return true;
+}
+
void ami_drag_selection(struct selection *s)
{
struct box *text_box;
- ULONG x;
- ULONG y;
+ int x;
+ int y;
+ struct ami_text_selection *sel;
struct IFFHandle *old_iffh = iffh;
struct gui_window_2 *gwin = ami_window_at_pointer();
@@ -307,7 +344,31 @@ void ami_drag_selection(struct selection *s)
}
else
{
- DisplayBeep(scrn);
+ x = gwin->win->MouseX;
+ y = gwin->win->MouseY;
+
+ if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
+ {
+ if(sel = ami_selection_to_text(gwin))
+ {
+ RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
+ gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ FreeVec(sel);
+ }
+ }
+ else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
+ {
+ if(sel = ami_selection_to_text(gwin))
+ {
+ RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
+ gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ FreeVec(sel);
+ }
+ }
+ else
+ {
+ DisplayBeep(scrn);
+ }
}
}