1 |
/* |
2 |
* HT Editor |
3 |
* clipboard.cc - BeOS-specific clipboard functions |
4 |
* |
5 |
* Copyright (C) 1999-2002 Stefan Weyergraf |
6 |
* Copyright (C) 2004 Francois Revol (revol@free.fr) |
7 |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 as |
10 |
* published by the Free Software Foundation. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
*/ |
21 |
|
22 |
#include <AppDefs.h> |
23 |
#include <Clipboard.h> |
24 |
|
25 |
#include "system/sys.h" |
26 |
|
27 |
bool sys_write_data_to_native_clipboard(const void *data, int size) |
28 |
{ |
29 |
BMessage *clip; |
30 |
be_clipboard->Lock(); |
31 |
be_clipboard->Clear(); |
32 |
clip = be_clipboard->Data(); |
33 |
clip->AddData("text/plain", B_MIME_TYPE, data, size); |
34 |
be_clipboard->Commit(); |
35 |
be_clipboard->Unlock(); |
36 |
return true; |
37 |
} |
38 |
|
39 |
int sys_get_native_clipboard_data_size() |
40 |
{ |
41 |
return false; |
42 |
} |
43 |
|
44 |
bool sys_read_data_from_native_clipboard(void *data, int max_size) |
45 |
{ |
46 |
BMessage *clip; |
47 |
const void *cdata; |
48 |
ssize_t csize; |
49 |
be_clipboard->Lock(); |
50 |
clip = be_clipboard->Data(); |
51 |
if (clip->FindData("text/plain", B_MIME_TYPE, &cdata, &csize) < B_OK) { |
52 |
be_clipboard->Unlock(); |
53 |
return false; |
54 |
} |
55 |
be_clipboard->Unlock(); |
56 |
memcpy(data, cdata, MIN(max_size, csize)); |
57 |
return true; |
58 |
} |