ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/BeOS/clip_beos.cpp
Revision: 1.1.1.1 (vendor branch)
Committed: 1999-10-03T14:16:25Z (25 years, 1 month ago) by cebix
Branch: cebix
CVS Tags: release-0_7-2, snapshot-21101999, start, snapshot-22121999, release-0_8-1, snapshot-02111999
Changes since 1.1: +0 -0 lines
Log Message:
Imported sources

File Contents

# Content
1 /*
2 * clip_beos.cpp - Clipboard handling, BeOS implementation
3 *
4 * Basilisk II (C) 1997-1999 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include <AppKit.h>
22 #include <support/UTF8.h>
23
24 #include "sysdeps.h"
25 #include "clip.h"
26
27 #define DEBUG 1
28 #include "debug.h"
29
30
31 /*
32 * Initialization
33 */
34
35 void ClipInit(void)
36 {
37 }
38
39
40 /*
41 * Deinitialization
42 */
43
44 void ClipExit(void)
45 {
46 }
47
48
49 /*
50 * Mac application wrote to clipboard
51 */
52
53 void PutScrap(uint32 type, void *scrap, int32 length)
54 {
55 D(bug("PutScrap type %08lx, data %08lx, length %ld\n", type, scrap, length));
56 if (length <= 0)
57 return;
58
59 switch (type) {
60 case 'TEXT':
61 D(bug(" clipping TEXT\n"));
62 if (be_clipboard->Lock()) {
63 be_clipboard->Clear();
64 BMessage *clipper = be_clipboard->Data();
65
66 // Convert text from Mac charset to UTF-8
67 int32 dest_length = length*3;
68 int32 state = 0;
69 char *buf = new char[dest_length];
70 if (convert_to_utf8(B_MAC_ROMAN_CONVERSION, (char *)scrap, &length, buf, &dest_length, &state) == B_OK) {
71 for (int i=0; i<dest_length; i++)
72 if (buf[i] == 13)
73 buf[i] = 10;
74
75 // Add text to Be clipboard
76 clipper->AddData("text/plain", B_MIME_TYPE, buf, dest_length);
77 be_clipboard->Commit();
78 }
79 delete[] buf;
80 be_clipboard->Unlock();
81 }
82 break;
83 }
84 }