1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 18:07:59 +00:00

Support for pasting 'TEXT', ie text in the local character set. At the moment,

we assume it's in the system script -- later we should check for 'styl' scrap
in case it isn't.

[originally from svn r2726]
This commit is contained in:
Ben Harris 2003-01-25 19:23:03 +00:00
parent 58c9d21f58
commit 146ff8f190
2 changed files with 59 additions and 9 deletions

View File

@ -1,4 +1,4 @@
$Id: README.mac,v 1.20 2003/01/25 17:20:54 ben Exp $ $Id: README.mac,v 1.21 2003/01/25 19:23:03 ben Exp $
Information about PuTTY for the Mac OS Information about PuTTY for the Mac OS
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@ -60,6 +60,7 @@ Known bugs:
insists on displaying the graphic version, so I think we need a insists on displaying the graphic version, so I think we need a
font switch at this point. This can be seen as a special case of font switch at this point. This can be seen as a special case of
the need to switch fonts to get odd characters. the need to switch fonts to get odd characters.
* Pasting large blocks of text doesn't work.
Unimplemented features (should be done before release): Unimplemented features (should be done before release):
* TCP urgent data. * TCP urgent data.
@ -67,7 +68,6 @@ Unimplemented features (should be done before release):
* Clipping host resize requests to screen size. * Clipping host resize requests to screen size.
* Changing font size in reponse to resize requests. * Changing font size in reponse to resize requests.
* Full screen mode. * Full screen mode.
* TEXT paste.
* Catching up with current keyboard mapping in other ports. * Catching up with current keyboard mapping in other ports.
* Session configuration. * Session configuration.
* Filename abstraction (we want to use alias records). * Filename abstraction (we want to use alias records).
@ -84,7 +84,7 @@ Unimplemented features (should be done before release):
Wishlist (after release): Wishlist (after release):
* SFTP client (GUI?) * SFTP client (GUI?)
* Carbon compatibility (requires Open Transport and Navigation Services). * Carbon compatibility (requires Open Transport and Navigation Services).
* 'styl' paste, for script codes? * 'styl' paste, for script codes.
* Handle 'gurl' Apple Events. * Handle 'gurl' Apple Events.
Local Variables: Local Variables:

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.55 2003/01/25 17:20:54 ben Exp $ */ /* $Id: macterm.c,v 1.56 2003/01/25 19:23:03 ben Exp $ */
/* /*
* Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris * Copyright (c) 1999, 2002 Ben Harris
@ -593,26 +593,76 @@ void write_clip(void *cookie, wchar_t *data, int len, int must_deselect)
void get_clip(void *frontend, wchar_t **p, int *lenp) { void get_clip(void *frontend, wchar_t **p, int *lenp) {
Session *s = frontend; Session *s = frontend;
static Handle h = NULL; static Handle h = NULL;
static wchar_t *data = NULL;
Handle texth;
long offset; long offset;
int textlen;
TextEncoding enc;
TextToUnicodeInfo scrap_to_uni;
ByteCount iread, olen;
int charset;
char *tptr;
OSErr err;
if (p == NULL) { if (p == NULL) {
/* release memory */ /* release memory */
if (h != NULL) if (h != NULL)
DisposeHandle(h); DisposeHandle(h);
h = NULL; h = NULL;
} else if (data != NULL)
/* XXX Support TEXT-format scrap as well. */ sfree(data);
data = NULL;
} else {
if (GetScrap(NULL, 'utxt', &offset) > 0) { if (GetScrap(NULL, 'utxt', &offset) > 0) {
h = NewHandle(0); if (h == NULL)
h = NewHandle(0);
*lenp = GetScrap(h, 'utxt', &offset) / sizeof(**p); *lenp = GetScrap(h, 'utxt', &offset) / sizeof(**p);
HLock(h); HLock(h);
*p = (wchar_t *)*h; *p = (wchar_t *)*h;
if (*p == NULL || *lenp <= 0) } else if (GetScrap(NULL, 'TEXT', &offset) > 0) {
fatalbox("Empty scrap"); texth = NewHandle(0);
textlen = GetScrap(texth, 'TEXT', &offset);
HLock(texth);
data = smalloc(textlen * 2);
/* XXX should use 'styl' scrap if it's there. */
if (mac_gestalts.encvvers != 0 &&
UpgradeScriptInfoToTextEncoding(smSystemScript,
kTextLanguageDontCare,
kTextRegionDontCare, NULL,
&enc) == noErr &&
CreateTextToUnicodeInfoByEncoding(enc, &scrap_to_uni) ==
noErr) {
err = ConvertFromTextToUnicode(scrap_to_uni, textlen,
*texth, 0, 0, NULL, NULL, NULL,
textlen * 2,
&iread, &olen, data);
DisposeTextToUnicodeInfo(&scrap_to_uni);
if (err == noErr) {
*p = data;
*lenp = olen / sizeof(**p);
} else {
*p = NULL;
*lenp = 0;
}
} else {
charset =
charset_from_macenc(GetScriptManagerVariable(smSysScript),
GetScriptManagerVariable(smRegionCode),
mac_gestalts.sysvers, NULL);
if (charset != CS_NONE) {
tptr = *texth;
*lenp = charset_to_unicode(&tptr, &textlen, data,
textlen * 2, charset, NULL,
NULL, 0);
}
*p = data;
}
DisposeHandle(texth);
} else { } else {
*p = NULL; *p = NULL;
*lenp = 0; *lenp = 0;
} }
}
} }
static pascal void mac_scrolltracker(ControlHandle control, short part) { static pascal void mac_scrolltracker(ControlHandle control, short part) {