summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2010-04-02 16:25:55 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2010-04-02 16:25:55 +0000
commit5bae5edd7b55822261100622e608c7c73ee69a2b (patch)
tree613b3b5ff12d8f97faf001fa542e38768a56517c /amiga
parentd927f70ad7d922d44b08a603bb0d26999a01b34c (diff)
downloadnetsurf-5bae5edd7b55822261100622e608c7c73ee69a2b.tar.gz
netsurf-5bae5edd7b55822261100622e608c7c73ee69a2b.tar.bz2
Use DataTypes to read text files that are dropped into text boxes, this allows more
exotic formats to be read such as IFF FTXT. svn path=/trunk/netsurf/; revision=10229
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/gui.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index b64a7fd01..efc61a40d 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -79,7 +79,7 @@
#include <proto/wb.h>
/* Other OS includes */
-#include <datatypes/pictureclass.h>
+#include <datatypes/textclass.h>
#include <devices/inputevent.h>
#include <graphics/blitattr.h>
#include <libraries/application.h>
@@ -87,7 +87,6 @@
#include <libraries/keymap.h>
#include <intuition/icclass.h>
#include <graphics/rpattr.h>
-#include <workbench/icon.h>
#include <workbench/workbench.h>
/* ReAction libraries */
@@ -1606,24 +1605,45 @@ void ami_handle_appmsg(void)
}
else
{
- browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x,y);
- /* This bit pastes a plain text file into a form. Really we should be using
- Datatypes for this to support more formats */
+ Object *dto;
+ STRPTR buffer;
+ uint32 bufferlen;
- if(fh = FOpen(filename,MODE_OLDFILE,0))
+ browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
+
+ if(dto = NewDTObject(filename,
+ DTA_GroupID, GID_TEXT, TAG_DONE))
{
- while(len = FRead(fh,filename,1,1024))
+ if(GetDTAttrs(dto,
+ TDTA_Buffer, &buffer,
+ TDTA_BufferLen, &bufferlen,
+ TAG_DONE))
{
- if(utf8_from_local_encoding(filename,len,&utf8text) == UTF8_CONVERT_OK)
+ uint32 bufferlen2 = 256;
+ int32 blen;
+
+ blen = bufferlen;
+
+ do
{
- browser_window_paste_text(gwin->bw,utf8text,strlen(utf8text),true);
- free(utf8text);
- }
+ if(blen < 256) bufferlen2 = blen;
+
+ if(utf8_from_local_encoding(buffer,
+ bufferlen2,
+ &utf8text) == UTF8_CONVERT_OK)
+ {
+ browser_window_paste_text(gwin->bw,
+ utf8text, strlen(utf8text),
+ (blen <= 256) ? true : false);
+ free(utf8text);
+ }
+ buffer += 256;
+ blen -= 256;
+ }while(blen > 0);
}
- FClose(fh);
+ DisposeDTObject(dto);
}
}
-
}
FreeVec(filename);
}