Add support for copying non-Unicode text to the clipboard. We also send a

simple 'styl' record along with it to specify the font and suchlike.  I'm
not sure it's worth making this optional in the way the RTF is in Windows.

[originally from svn r2724]
This commit is contained in:
Ben Harris 2003-01-25 17:20:54 +00:00
Родитель 063469571a
Коммит 787fcd3eb7
2 изменённых файлов: 59 добавлений и 8 удалений

Просмотреть файл

@ -1,4 +1,4 @@
$Id: README.mac,v 1.19 2003/01/25 15:21:54 ben Exp $
$Id: README.mac,v 1.20 2003/01/25 17:20:54 ben Exp $
Information about PuTTY for the Mac OS
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@ -54,6 +54,12 @@ Known bugs:
"-opt none" works around this.
* When the last terminal window closes, the Edit menu doesn't get disabled
immediately, which it should.
* When using the "VT100" font, text copied to the clipboard doesn't
get newlines in it, because that font has a graphic character at
position 0x0d. Even if we did insert 0x0d manually, TextEdit
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
the need to switch fonts to get odd characters.
Unimplemented features (should be done before release):
* TCP urgent data.
@ -61,7 +67,7 @@ Unimplemented features (should be done before release):
* Clipping host resize requests to screen size.
* Changing font size in reponse to resize requests.
* Full screen mode.
* TEXT copy/paste.
* TEXT paste.
* Catching up with current keyboard mapping in other ports.
* Session configuration.
* Filename abstraction (we want to use alias records).
@ -78,7 +84,7 @@ Unimplemented features (should be done before release):
Wishlist (after release):
* SFTP client (GUI?)
* Carbon compatibility (requires Open Transport and Navigation Services).
* 'styl' copy (and paste, for script codes?).
* 'styl' paste, for script codes?
* Handle 'gurl' Apple Events.
Local Variables:

Просмотреть файл

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.54 2003/01/25 16:16:44 ben Exp $ */
/* $Id: macterm.c,v 1.55 2003/01/25 17:20:54 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
@ -530,19 +530,64 @@ static void text_click(Session *s, EventRecord *event) {
lastwhen = TickCount();
}
void write_clip(void *cookie, wchar_t *data, int len, int must_deselect) {
void write_clip(void *cookie, wchar_t *data, int len, int must_deselect)
{
Session *s = cookie;
char *mactextbuf;
ByteCount iread, olen;
wchar_t *unitextptr;
StScrpRec *stsc;
size_t stsz;
OSErr err;
int i;
/*
* See "Programming with the Text Encoding Conversion Manager"
* Appendix E for Unicode scrap conventions.
*
* XXX Need to support TEXT/styl scrap as well.
* See STScrpRec in TextEdit (Inside Macintosh: Text) for styl details.
* XXX Maybe PICT scrap too.
*/
if (ZeroScrap() != noErr)
return;
PutScrap(len * sizeof(*data), 'utxt', data);
/* Replace LINE SEPARATORs with CR for TEXT output. */
for (i = 0; i < len; i++)
if (data[i] == 0x2028)
data[i] = 0x000d;
mactextbuf = smalloc(len); /* XXX DBCS */
if (s->uni_to_font != NULL) {
err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar),
(UniChar *)data,
kUnicodeUseFallbacksMask,
0, NULL, NULL, NULL,
len, &iread, &olen, mactextbuf);
if (err != noErr && err != kTECUsedFallbacksStatus)
return;
} else if (s->font_charset != CS_NONE) {
unitextptr = data;
olen = charset_from_unicode(&unitextptr, &len, mactextbuf, 1024,
s->font_charset, NULL, ".", 1);
} else
return;
PutScrap(olen, 'TEXT', mactextbuf);
sfree(mactextbuf);
stsz = offsetof(StScrpRec, scrpStyleTab) + sizeof(ScrpSTElement);
stsc = smalloc(stsz);
stsc->scrpNStyles = 1;
stsc->scrpStyleTab[0].scrpStartChar = 0;
stsc->scrpStyleTab[0].scrpHeight = s->font_height;
stsc->scrpStyleTab[0].scrpAscent = s->font_ascent;
stsc->scrpStyleTab[0].scrpFont = s->fontnum;
stsc->scrpStyleTab[0].scrpFace = 0;
stsc->scrpStyleTab[0].scrpSize = s->cfg.fontheight;
stsc->scrpStyleTab[0].scrpColor.red = 0;
stsc->scrpStyleTab[0].scrpColor.green = 0;
stsc->scrpStyleTab[0].scrpColor.blue = 0;
PutScrap(stsz, 'styl', stsc);
sfree(stsc);
}
void get_clip(void *frontend, wchar_t **p, int *lenp) {