1 |
|
/* |
2 |
|
* clip_beos.cpp - Clipboard handling, BeOS implementation |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 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 |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
*/ |
20 |
|
|
21 |
+ |
#include "sysdeps.h" |
22 |
+ |
|
23 |
|
#include <AppKit.h> |
24 |
|
#include <support/UTF8.h> |
25 |
|
|
24 |
– |
#include "sysdeps.h" |
26 |
|
#include "clip.h" |
27 |
+ |
#include "prefs.h" |
28 |
|
|
29 |
|
#define DEBUG 1 |
30 |
|
#include "debug.h" |
31 |
|
|
32 |
|
|
33 |
+ |
// Flag: Don't convert clipboard text |
34 |
+ |
static bool no_clip_conversion; |
35 |
+ |
|
36 |
+ |
|
37 |
|
/* |
38 |
|
* Initialization |
39 |
|
*/ |
40 |
|
|
41 |
|
void ClipInit(void) |
42 |
|
{ |
43 |
+ |
no_clip_conversion = PrefsFindBool("noclipconversion"); |
44 |
|
} |
45 |
|
|
46 |
|
|
70 |
|
be_clipboard->Clear(); |
71 |
|
BMessage *clipper = be_clipboard->Data(); |
72 |
|
|
73 |
< |
// Convert text from Mac charset to UTF-8 |
74 |
< |
int32 dest_length = length*3; |
75 |
< |
int32 state = 0; |
76 |
< |
char *buf = new char[dest_length]; |
77 |
< |
if (convert_to_utf8(B_MAC_ROMAN_CONVERSION, (char *)scrap, &length, buf, &dest_length, &state) == B_OK) { |
78 |
< |
for (int i=0; i<dest_length; i++) |
72 |
< |
if (buf[i] == 13) |
73 |
> |
if (no_clip_conversion) { |
74 |
> |
|
75 |
> |
// Only convert CR->LF |
76 |
> |
char *buf = new char[length]; |
77 |
> |
for (int i=0; i<length; i++) { |
78 |
> |
if (i[(char *)scrap] == 13) |
79 |
|
buf[i] = 10; |
80 |
< |
|
80 |
> |
else |
81 |
> |
buf[i] = i[(char *)scrap]; |
82 |
> |
} |
83 |
> |
|
84 |
|
// Add text to Be clipboard |
85 |
< |
clipper->AddData("text/plain", B_MIME_TYPE, buf, dest_length); |
85 |
> |
clipper->AddData("text/plain", B_MIME_TYPE, buf, length); |
86 |
|
be_clipboard->Commit(); |
87 |
+ |
delete[] buf; |
88 |
+ |
|
89 |
+ |
} else { |
90 |
+ |
|
91 |
+ |
// Convert text from Mac charset to UTF-8 |
92 |
+ |
int32 dest_length = length*3; |
93 |
+ |
int32 state = 0; |
94 |
+ |
char *buf = new char[dest_length]; |
95 |
+ |
if (convert_to_utf8(B_MAC_ROMAN_CONVERSION, (char *)scrap, &length, buf, &dest_length, &state) == B_OK) { |
96 |
+ |
for (int i=0; i<dest_length; i++) |
97 |
+ |
if (buf[i] == 13) |
98 |
+ |
buf[i] = 10; |
99 |
+ |
|
100 |
+ |
// Add text to Be clipboard |
101 |
+ |
clipper->AddData("text/plain", B_MIME_TYPE, buf, dest_length); |
102 |
+ |
be_clipboard->Commit(); |
103 |
+ |
} |
104 |
+ |
delete[] buf; |
105 |
|
} |
79 |
– |
delete[] buf; |
106 |
|
be_clipboard->Unlock(); |
107 |
|
} |
108 |
|
break; |