ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/clip_unix.cpp
Revision: 1.8
Committed: 2004-06-23T14:30:48Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.7: +6 -4 lines
Log Message:
Initial SDL/video support. Fix VOSF code could lead to a crash on run-time
resolution/depth switching. Rearrange blitter lookup code, aka make it cleaner.

File Contents

# Content
1 /*
2 * clip_unix.cpp - Clipboard handling, Unix implementation
3 *
4 * Basilisk II (C) 1997-2004 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 "sysdeps.h"
22 #include "clip.h"
23 #include "macos_util.h"
24 #include "prefs.h"
25
26 #define DEBUG 0
27 #include "debug.h"
28
29
30 // From video_x.cpp
31 #ifndef USE_SDL_VIDEO
32 #include <X11/Xlib.h>
33 extern Display *x_display;
34 #endif
35
36
37 // Conversion tables
38 static const uint8 mac2iso[0x80] = {
39 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
40 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
41 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
42 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
43 0x2b, 0xb0, 0xa2, 0xa3, 0xa7, 0xb7, 0xb6, 0xdf,
44 0xae, 0xa9, 0x20, 0xb4, 0xa8, 0x23, 0xc6, 0xd8,
45 0x20, 0xb1, 0x3c, 0x3e, 0xa5, 0xb5, 0xf0, 0x53,
46 0x50, 0x70, 0x2f, 0xaa, 0xba, 0x4f, 0xe6, 0xf8,
47 0xbf, 0xa1, 0xac, 0x2f, 0x66, 0x7e, 0x44, 0xab,
48 0xbb, 0x2e, 0x20, 0xc0, 0xc3, 0xd5, 0x4f, 0x6f,
49 0x2d, 0x2d, 0x22, 0x22, 0x60, 0x27, 0xf7, 0x20,
50 0xff, 0x59, 0x2f, 0xa4, 0x3c, 0x3e, 0x66, 0x66,
51 0x23, 0xb7, 0x2c, 0x22, 0x25, 0xc2, 0xca, 0xc1,
52 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
53 0x20, 0xd2, 0xda, 0xdb, 0xd9, 0x69, 0x5e, 0x7e,
54 0xaf, 0x20, 0xb7, 0xb0, 0xb8, 0x22, 0xb8, 0x20
55 };
56
57 // Flag: Don't convert clipboard text
58 static bool no_clip_conversion;
59
60
61 /*
62 * Initialization
63 */
64
65 void ClipInit(void)
66 {
67 no_clip_conversion = PrefsFindBool("noclipconversion");
68 }
69
70
71 /*
72 * Deinitialization
73 */
74
75 void ClipExit(void)
76 {
77 }
78
79
80 /*
81 * Mac application wrote to clipboard
82 */
83
84 void PutScrap(uint32 type, void *scrap, int32 length)
85 {
86 D(bug("PutScrap type %08lx, data %08lx, length %ld\n", type, scrap, length));
87 if (length <= 0)
88 return;
89
90 #ifndef USE_SDL_VIDEO
91 switch (type) {
92 case FOURCC('T','E','X','T'):
93 D(bug(" clipping TEXT\n"));
94
95 // Convert text from Mac charset to ISO-Latin1
96 uint8 *buf = new uint8[length];
97 uint8 *p = (uint8 *)scrap;
98 uint8 *q = buf;
99 for (int i=0; i<length; i++) {
100 uint8 c = *p++;
101 if (c < 0x80) {
102 if (c == 13) // CR -> LF
103 c = 10;
104 } else if (!no_clip_conversion)
105 c = mac2iso[c & 0x7f];
106 *q++ = c;
107 }
108
109 // Put text into cut buffer
110 XStoreBytes(x_display, (const char *)buf, length);
111 delete[] buf;
112 break;
113 }
114 #endif
115 }