2008-10-26 02:22:34 +03:00
|
|
|
/*
|
2012-02-12 21:56:25 +04:00
|
|
|
* Copyright 2008-2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-10-26 02:22:34 +03:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "desktop/gui.h"
|
2012-08-13 17:43:04 +04:00
|
|
|
#include "desktop/plotters.h"
|
2010-07-24 20:39:37 +04:00
|
|
|
#include "desktop/selection.h"
|
2010-07-24 23:57:27 +04:00
|
|
|
#include "desktop/textinput.h"
|
2012-03-27 00:25:10 +04:00
|
|
|
#include "utils/utf8.h"
|
2010-07-24 20:39:37 +04:00
|
|
|
|
2011-07-23 18:06:13 +04:00
|
|
|
#include "amiga/bitmap.h"
|
2011-04-29 22:15:20 +04:00
|
|
|
#include "amiga/clipboard.h"
|
2011-07-23 18:06:13 +04:00
|
|
|
#include "amiga/drag.h"
|
|
|
|
#include "amiga/filetype.h"
|
2008-10-26 02:22:34 +03:00
|
|
|
#include "amiga/gui.h"
|
2011-07-23 18:06:13 +04:00
|
|
|
#include "amiga/iff_cset.h"
|
2009-05-19 11:23:56 +04:00
|
|
|
#include "amiga/iff_dr2d.h"
|
2010-07-24 20:39:37 +04:00
|
|
|
#include "amiga/menu.h"
|
2012-03-22 13:34:34 +04:00
|
|
|
#include "desktop/options.h"
|
2011-07-23 18:06:13 +04:00
|
|
|
#include "amiga/utf8.h"
|
2010-07-24 20:39:37 +04:00
|
|
|
|
|
|
|
#include <proto/iffparse.h>
|
|
|
|
#include <proto/intuition.h>
|
|
|
|
#include <proto/exec.h>
|
|
|
|
#include <proto/datatypes.h>
|
2010-05-04 00:49:15 +04:00
|
|
|
#include <proto/diskfont.h>
|
2010-07-24 20:39:37 +04:00
|
|
|
|
2010-05-04 00:49:15 +04:00
|
|
|
#include <diskfont/diskfonttag.h>
|
2010-07-24 20:39:37 +04:00
|
|
|
#include <datatypes/textclass.h>
|
|
|
|
#include <datatypes/pictureclass.h>
|
2008-10-26 02:22:34 +03:00
|
|
|
|
2012-08-03 21:33:49 +04:00
|
|
|
#define ID_UTF8 MAKE_ID('U','T','F','8')
|
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
struct IFFHandle *iffh = NULL;
|
|
|
|
|
2012-08-04 00:02:29 +04:00
|
|
|
static LONG ami_clipboard_iffp_do_nothing(struct Hook *hook, void *object, LONG *cmd)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_clipboard_iffp_clear_stopchunk(struct IFFHandle *iffh, ULONG iff_type, ULONG iff_chunk)
|
|
|
|
{
|
|
|
|
static struct Hook entry_hook;
|
|
|
|
|
|
|
|
entry_hook.h_Entry = (void *)ami_clipboard_iffp_do_nothing;
|
|
|
|
entry_hook.h_Data = 0;
|
|
|
|
|
|
|
|
EntryHandler(iffh, iff_type, iff_chunk, IFFSLI_TOP, &entry_hook, NULL);
|
|
|
|
}
|
|
|
|
|
2010-10-24 22:07:11 +04:00
|
|
|
struct IFFHandle *ami_clipboard_init_internal(int unit)
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2010-10-24 22:07:11 +04:00
|
|
|
struct IFFHandle *iffhandle = NULL;
|
|
|
|
|
|
|
|
if(iffhandle = AllocIFF())
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2010-10-24 22:07:11 +04:00
|
|
|
if(iffhandle->iff_Stream = (ULONG)OpenClipboard(unit))
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2010-10-24 22:07:11 +04:00
|
|
|
InitIFFasClip(iffhandle);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
}
|
2010-10-24 22:07:11 +04:00
|
|
|
|
|
|
|
return iffhandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_clipboard_init(void)
|
|
|
|
{
|
|
|
|
iffh = ami_clipboard_init_internal(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_clipboard_free_internal(struct IFFHandle *iffhandle)
|
|
|
|
{
|
|
|
|
if(iffhandle->iff_Stream) CloseClipboard((struct ClipboardHandle *)iffhandle->iff_Stream);
|
|
|
|
if(iffhandle) FreeIFF(iffhandle);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ami_clipboard_free(void)
|
|
|
|
{
|
2010-10-24 22:07:11 +04:00
|
|
|
ami_clipboard_free_internal(iffh);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_start_selection(struct gui_window *g)
|
|
|
|
{
|
2010-07-24 20:39:37 +04:00
|
|
|
if(!g) return;
|
|
|
|
if(!g->shared->win) return;
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_bool(kiosk_mode) == true) return;
|
2010-07-24 20:39:37 +04:00
|
|
|
|
|
|
|
OnMenu(g->shared->win, AMI_MENU_CLEAR);
|
|
|
|
OnMenu(g->shared->win, AMI_MENU_COPY);
|
|
|
|
|
2011-07-13 17:38:38 +04:00
|
|
|
if(selection_read_only(browser_window_get_selection(g->shared->bw)) == false)
|
2010-07-24 20:39:37 +04:00
|
|
|
OnMenu(g->shared->win, AMI_MENU_CUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_clear_selection(struct gui_window *g)
|
|
|
|
{
|
|
|
|
if(!g) return;
|
|
|
|
if(!g->shared->win) return;
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_bool(kiosk_mode) == true) return;
|
2010-07-24 20:39:37 +04:00
|
|
|
|
|
|
|
OffMenu(g->shared->win, AMI_MENU_CLEAR);
|
|
|
|
OffMenu(g->shared->win, AMI_MENU_CUT);
|
|
|
|
OffMenu(g->shared->win, AMI_MENU_COPY);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
|
2012-08-03 22:19:04 +04:00
|
|
|
bool ami_clipboard_check_for_utf8(struct IFFHandle *iffh) {
|
|
|
|
struct ContextNode *cn;
|
|
|
|
ULONG error;
|
|
|
|
bool utf8_chunk = false;
|
|
|
|
|
|
|
|
if(OpenIFF(iffh, IFFF_READ)) return false;
|
2012-08-04 00:02:29 +04:00
|
|
|
|
|
|
|
ami_clipboard_iffp_clear_stopchunk(iffh, ID_FTXT, ID_CSET);
|
|
|
|
ami_clipboard_iffp_clear_stopchunk(iffh, ID_FTXT, ID_CHRS);
|
|
|
|
|
2012-08-03 22:19:04 +04:00
|
|
|
if(!StopChunk(iffh, ID_FTXT, ID_UTF8)) {
|
|
|
|
error = ParseIFF(iffh, IFFPARSE_SCAN);
|
|
|
|
if(error != IFFERR_EOF)
|
|
|
|
utf8_chunk = true; /* or a real error, but that'll get caught later */
|
|
|
|
}
|
|
|
|
CloseIFF(iffh);
|
|
|
|
|
|
|
|
return utf8_chunk;
|
|
|
|
}
|
|
|
|
|
2013-01-09 03:44:13 +04:00
|
|
|
char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
|
|
|
|
{
|
|
|
|
struct CollectionItem *ci_curr = ci;
|
|
|
|
size_t len = 0;
|
|
|
|
char *text = NULL, *p, *clip;
|
|
|
|
|
|
|
|
/* Scan the collected chunks to find out the total size */
|
|
|
|
do {
|
|
|
|
len += ci_curr->ci_Size;
|
|
|
|
} while (ci_curr = ci_curr->ci_Next);
|
|
|
|
|
|
|
|
text = malloc(len);
|
|
|
|
|
|
|
|
if(text == NULL) return NULL;
|
|
|
|
|
|
|
|
/* p points to the end of the buffer. This is because the chunks are
|
|
|
|
* in the list in reverse order. */
|
|
|
|
p = text + len;
|
|
|
|
ci_curr = ci;
|
|
|
|
|
|
|
|
do {
|
|
|
|
p -= ci_curr->ci_Size;
|
|
|
|
|
|
|
|
switch(codeset) {
|
|
|
|
case 106:
|
|
|
|
memcpy(p, ci_curr->ci_Data, ci_curr->ci_Size);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* If codeset isn't 106 (UTF-8) we need to convert to UTF-8.
|
|
|
|
* TODO: ensure buffer is big enough for converted text */
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
utf8_from_local_encoding(ci_curr->ci_Data, ci_curr->ci_Size, &clip);
|
|
|
|
memcpy(p, clip, ci_curr->ci_Size);
|
|
|
|
free(clip);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
utf8_from_enc(ci_curr->ci_Data,
|
|
|
|
(const char *)ObtainCharsetInfo(DFCS_NUMBER,
|
|
|
|
codeset, DFCS_MIMENAME),
|
|
|
|
ci_curr->ci_Size, &clip);
|
|
|
|
memcpy(p, clip, ci_curr->ci_Size);
|
|
|
|
free(clip);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (ci_curr = ci_curr->ci_Next);
|
|
|
|
|
|
|
|
*text_length = len;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
void gui_get_clipboard(char **buffer, size_t *length)
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
|
|
|
struct ContextNode *cn;
|
2013-01-09 03:44:13 +04:00
|
|
|
struct CollectionItem *ci = NULL;
|
2008-10-26 02:22:34 +03:00
|
|
|
ULONG rlen=0,error;
|
|
|
|
struct CSet cset;
|
2012-01-15 19:58:26 +04:00
|
|
|
LONG codeset = 0;
|
2008-10-26 02:22:34 +03:00
|
|
|
char *clip;
|
2012-08-03 22:19:04 +04:00
|
|
|
bool utf8_chunks = false;
|
2008-11-02 03:21:49 +03:00
|
|
|
STRPTR readbuf = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR);
|
2008-10-26 02:22:34 +03:00
|
|
|
|
|
|
|
cset.CodeSet = 0;
|
|
|
|
|
|
|
|
if(OpenIFF(iffh,IFFF_READ)) return;
|
2012-08-03 22:19:04 +04:00
|
|
|
|
2013-01-09 03:44:13 +04:00
|
|
|
if(CollectionChunk(iffh,ID_FTXT,ID_CHRS)) return;
|
|
|
|
if(StopChunk(iffh,ID_FTXT,ID_CSET)) return;
|
|
|
|
if(CollectionChunk(iffh,ID_FTXT,ID_UTF8)) return;
|
2012-08-03 22:19:04 +04:00
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
error = ParseIFF(iffh,IFFPARSE_SCAN);
|
|
|
|
if(error == IFFERR_EOC) continue;
|
|
|
|
else if(error) break;
|
|
|
|
|
|
|
|
cn = CurrentChunk(iffh);
|
|
|
|
|
2013-01-09 03:44:13 +04:00
|
|
|
if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == ID_CSET))
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2013-01-09 03:44:13 +04:00
|
|
|
/* Ideally when we stop here, we need to convert all CHRS chunks up to this
|
|
|
|
* point based on the previous codeset. However, for simplicity, we just
|
|
|
|
* assume only one CSET chunk is present and only take note of the last
|
|
|
|
* CSET chunk if there is more than one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
rlen = ReadChunkBytes(iffh, &cset, 32);
|
2012-01-15 19:58:26 +04:00
|
|
|
if(cset.CodeSet == 1) codeset = 106;
|
|
|
|
else codeset = cset.CodeSet;
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
2013-01-09 03:44:13 +04:00
|
|
|
}
|
2008-10-26 02:22:34 +03:00
|
|
|
|
2013-01-09 03:44:13 +04:00
|
|
|
if(ci = FindCollection(iffh, ID_FTXT, ID_UTF8)) {
|
|
|
|
*buffer = ami_clipboard_cat_collection(ci, 106, length);
|
|
|
|
} else if(ci = FindCollection(iffh, ID_FTXT, ID_CHRS)) {
|
|
|
|
*buffer = ami_clipboard_cat_collection(ci, codeset, length);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
2013-01-09 03:44:13 +04:00
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
CloseIFF(iffh);
|
|
|
|
}
|
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
void gui_set_clipboard(const char *buffer, size_t length,
|
|
|
|
nsclipboard_styles styles[], int n_styles)
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2013-01-08 23:58:44 +04:00
|
|
|
char *text;
|
2010-07-24 23:57:27 +04:00
|
|
|
struct CSet cset = {0};
|
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
if(buffer == NULL) return;
|
|
|
|
|
|
|
|
if(!(OpenIFF(iffh, IFFF_WRITE)))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2013-01-08 23:58:44 +04:00
|
|
|
if(!(PushChunk(iffh, ID_FTXT, ID_FORM, IFFSIZE_UNKNOWN)))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2012-08-04 00:04:38 +04:00
|
|
|
if(nsoption_bool(utf8_clipboard))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2013-01-08 23:58:44 +04:00
|
|
|
if(!(PushChunk(iffh, 0, ID_CSET, 32)))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
|
|
|
cset.CodeSet = 106; // UTF-8
|
2013-01-08 23:58:44 +04:00
|
|
|
WriteChunkBytes(iffh, &cset, 32);
|
2010-07-24 23:57:27 +04:00
|
|
|
PopChunk(iffh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PopChunk(iffh);
|
|
|
|
}
|
2011-04-30 14:54:02 +04:00
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
if(!(PushChunk(iffh, 0, ID_CHRS, IFFSIZE_UNKNOWN))) {
|
|
|
|
if(nsoption_bool(utf8_clipboard)) {
|
|
|
|
WriteChunkBytes(iffh, buffer, length);
|
|
|
|
} else {
|
|
|
|
if(utf8_to_local_encoding(buffer, length, &text) == UTF8_CONVERT_OK) {
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = text;
|
|
|
|
|
|
|
|
while(*p != '\0') {
|
|
|
|
if(*p == 0xa0) *p = 0x20;
|
|
|
|
p++;
|
|
|
|
}
|
2013-01-09 00:07:46 +04:00
|
|
|
WriteChunkBytes(iffh, text, strlen(text));
|
2013-01-08 23:58:44 +04:00
|
|
|
ami_utf8_free(text);
|
2012-08-03 21:15:16 +04:00
|
|
|
}
|
2011-04-30 14:54:02 +04:00
|
|
|
}
|
2008-10-26 02:22:34 +03:00
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
PopChunk(iffh);
|
|
|
|
} else {
|
|
|
|
PopChunk(iffh);
|
|
|
|
}
|
2012-08-03 21:33:49 +04:00
|
|
|
|
2013-01-08 23:58:44 +04:00
|
|
|
if(!(PushChunk(iffh, 0, ID_UTF8, IFFSIZE_UNKNOWN))) {
|
|
|
|
WriteChunkBytes(iffh, buffer, length);
|
|
|
|
PopChunk(iffh);
|
|
|
|
} else {
|
|
|
|
PopChunk(iffh);
|
|
|
|
}
|
|
|
|
CloseIFF(iffh);
|
2012-08-03 21:33:49 +04:00
|
|
|
}
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
|
2011-04-29 22:15:20 +04:00
|
|
|
struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
|
|
|
|
{
|
|
|
|
struct ami_text_selection *sel;
|
2012-08-13 20:42:23 +04:00
|
|
|
int len;
|
|
|
|
char *ss;
|
2011-04-29 22:15:20 +04:00
|
|
|
|
|
|
|
sel = AllocVec(sizeof(struct ami_text_selection),
|
|
|
|
MEMF_PRIVATE | MEMF_CLEAR);
|
|
|
|
|
2012-08-13 20:42:23 +04:00
|
|
|
if (sel) {
|
|
|
|
/* Get selection string */
|
|
|
|
ss = selection_get_copy(browser_window_get_selection(gwin->bw));
|
|
|
|
if (ss == NULL)
|
|
|
|
return sel;
|
2011-04-29 22:15:20 +04:00
|
|
|
|
2012-08-13 20:42:23 +04:00
|
|
|
len = strlen(ss);
|
2011-04-29 22:15:20 +04:00
|
|
|
|
2012-08-13 20:42:23 +04:00
|
|
|
if (len > sizeof(sel->text))
|
|
|
|
len = sizeof(sel->text) - 1;
|
2011-04-29 22:15:20 +04:00
|
|
|
|
2012-08-13 20:42:23 +04:00
|
|
|
memcpy(sel->text, ss, len);
|
|
|
|
sel->length = len;
|
|
|
|
sel->text[sel->length] = '\0';
|
2011-04-29 22:15:20 +04:00
|
|
|
|
2012-08-13 20:42:23 +04:00
|
|
|
free(ss);
|
|
|
|
}
|
|
|
|
return sel;
|
2011-04-29 22:15:20 +04:00
|
|
|
}
|
|
|
|
|
2010-07-24 23:57:27 +04:00
|
|
|
void ami_drag_selection(struct selection *s)
|
|
|
|
{
|
2011-04-29 22:15:20 +04:00
|
|
|
int x;
|
|
|
|
int y;
|
2011-04-30 15:11:34 +04:00
|
|
|
char *utf8text;
|
2011-04-29 22:15:20 +04:00
|
|
|
struct ami_text_selection *sel;
|
2010-10-24 22:07:11 +04:00
|
|
|
struct IFFHandle *old_iffh = iffh;
|
2011-12-02 17:24:40 +04:00
|
|
|
struct gui_window_2 *gwin = ami_window_at_pointer(AMINS_WINDOW);
|
2010-07-24 23:57:27 +04:00
|
|
|
|
2010-07-28 01:41:21 +04:00
|
|
|
if(!gwin)
|
|
|
|
{
|
|
|
|
DisplayBeep(scrn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = gwin->win->MouseX;
|
|
|
|
y = gwin->win->MouseY;
|
|
|
|
|
2012-08-21 01:03:59 +04:00
|
|
|
if(ami_text_box_at_point(gwin, (ULONG *)&x, (ULONG *)&y))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2010-10-24 22:07:11 +04:00
|
|
|
iffh = ami_clipboard_init_internal(1);
|
2013-01-09 03:01:57 +04:00
|
|
|
|
|
|
|
if(selection_copy_to_clipboard(s))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2010-07-28 01:41:21 +04:00
|
|
|
browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
|
|
|
|
browser_window_key_press(gwin->bw, KEY_PASTE);
|
2010-07-24 23:57:27 +04:00
|
|
|
}
|
2013-01-09 03:01:57 +04:00
|
|
|
|
2010-10-24 22:07:11 +04:00
|
|
|
ami_clipboard_free_internal(iffh);
|
|
|
|
iffh = old_iffh;
|
2010-07-24 23:57:27 +04:00
|
|
|
}
|
2010-07-28 01:41:21 +04:00
|
|
|
else
|
|
|
|
{
|
2011-04-29 22:15:20 +04:00
|
|
|
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))
|
|
|
|
{
|
2011-04-30 15:11:34 +04:00
|
|
|
utf8text = ami_utf8_easy(sel->text);
|
2011-04-29 22:15:20 +04:00
|
|
|
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
|
2011-04-30 15:11:34 +04:00
|
|
|
gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
|
2011-04-29 22:15:20 +04:00
|
|
|
FreeVec(sel);
|
2011-04-30 15:11:34 +04:00
|
|
|
ami_utf8_free(utf8text);
|
2011-04-29 22:15:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
|
|
|
|
{
|
|
|
|
if(sel = ami_selection_to_text(gwin))
|
|
|
|
{
|
2011-04-30 15:11:34 +04:00
|
|
|
utf8text = ami_utf8_easy(sel->text);
|
2011-04-29 22:15:20 +04:00
|
|
|
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
|
2011-04-30 15:11:34 +04:00
|
|
|
gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
|
2011-04-29 22:15:20 +04:00
|
|
|
FreeVec(sel);
|
2011-04-30 15:11:34 +04:00
|
|
|
ami_utf8_free(utf8text);
|
2011-04-29 22:15:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayBeep(scrn);
|
|
|
|
}
|
2010-07-28 01:41:21 +04:00
|
|
|
}
|
2010-07-24 23:57:27 +04:00
|
|
|
}
|
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
bool ami_easy_clipboard(char *text)
|
|
|
|
{
|
2013-01-08 23:58:44 +04:00
|
|
|
gui_set_clipboard(text, strlen(text), NULL, 0);
|
2010-07-25 00:18:56 +04:00
|
|
|
return true;
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
2009-05-16 18:50:30 +04:00
|
|
|
|
2009-05-16 21:04:28 +04:00
|
|
|
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap)
|
2009-05-16 18:50:30 +04:00
|
|
|
{
|
2009-05-16 21:04:28 +04:00
|
|
|
Object *dto = NULL;
|
2009-05-16 18:50:30 +04:00
|
|
|
|
2009-05-16 21:04:28 +04:00
|
|
|
if(dto = ami_datatype_object_from_bitmap(bitmap))
|
2009-05-16 18:50:30 +04:00
|
|
|
{
|
2009-05-16 21:04:28 +04:00
|
|
|
DoDTMethod(dto,NULL,NULL,DTM_COPY,NULL);
|
|
|
|
DisposeDTObject(dto);
|
2009-05-16 18:50:30 +04:00
|
|
|
}
|
|
|
|
}
|
2009-05-19 11:23:56 +04:00
|
|
|
|
2009-05-19 11:30:00 +04:00
|
|
|
#ifdef WITH_NS_SVG
|
2010-03-28 19:51:05 +04:00
|
|
|
bool ami_easy_clipboard_svg(struct hlcache_handle *c)
|
2009-05-19 11:23:56 +04:00
|
|
|
{
|
2011-07-23 18:06:13 +04:00
|
|
|
const char *source_data;
|
2010-03-28 19:51:05 +04:00
|
|
|
ULONG source_size;
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
if(ami_mime_compare(c, "svg") == false) return false;
|
2010-03-28 19:51:05 +04:00
|
|
|
if((source_data = content_get_source_data(c, &source_size)) == NULL) return false;
|
2009-05-19 11:23:56 +04:00
|
|
|
|
|
|
|
if(!(OpenIFF(iffh,IFFF_WRITE)))
|
|
|
|
{
|
2011-12-04 18:55:23 +04:00
|
|
|
ami_svg_to_dr2d(iffh, source_data, source_size, nsurl_access(hlcache_handle_get_url(c)));
|
2009-05-19 11:23:56 +04:00
|
|
|
CloseIFF(iffh);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-05-19 11:30:00 +04:00
|
|
|
#endif
|