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

Use the shiny new character-set library to handle conversion from Unicode

to Mac OS Roman for display if the Unicode Converter isn't around.  Support
for Mac character sets other than Roman (e.g. the variant used by the Apple
VT100 font) is still absent.

[originally from svn r2401]
This commit is contained in:
Ben Harris 2002-12-31 22:49:03 +00:00
parent 720c09f576
commit 491f7be9fc
2 changed files with 21 additions and 11 deletions

2
Recipe
View File

@ -146,4 +146,4 @@ plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC
PuTTY : [M] terminal wcwidth tree234 misc ldisc ldiscucs PuTTY : [M] terminal wcwidth tree234 misc ldisc ldiscucs
+ logging settings be_none mac macdlg macstore macterm macucs + logging settings be_none mac macdlg macstore macterm macucs
+ mac_res.rsrc testback + mac_res.rsrc testback CHARSET

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.28 2002/12/31 20:11:38 ben Exp $ */ /* $Id: macterm.c,v 1.29 2002/12/31 22:49: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
@ -60,6 +60,7 @@
#include "macresid.h" #include "macresid.h"
#include "putty.h" #include "putty.h"
#include "charset.h"
#include "mac.h" #include "mac.h"
#include "storage.h" #include "storage.h"
#include "terminal.h" #include "terminal.h"
@ -951,7 +952,10 @@ void do_text(Context ctx, int x, int y, char *text, int len,
RgnHandle textrgn; RgnHandle textrgn;
char mactextbuf[1024]; char mactextbuf[1024];
UniChar unitextbuf[1024]; UniChar unitextbuf[1024];
wchar_t *unitextptr;
int i; int i;
ByteCount iread, olen;
OSStatus err;
assert(len <= 1024); assert(len <= 1024);
@ -965,23 +969,29 @@ void do_text(Context ctx, int x, int y, char *text, int len,
if (!RectInRgn(&a.textrect, s->window->visRgn)) if (!RectInRgn(&a.textrect, s->window->visRgn))
return; return;
if (s->uni_to_font != NULL) { /* Unpack Unicode from the mad format we get passed */
ByteCount iread, olen; for (i = 0; i < len; i++)
OSStatus err; unitextbuf[i] = (unsigned char)text[i] | (attr & CSET_MASK);
for (i = 0; i < len; i++) if (s->uni_to_font != NULL) {
unitextbuf[i] = (unsigned char)text[i] | (attr & CSET_MASK);
err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar), err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar),
unitextbuf, kUnicodeUseFallbacksMask, unitextbuf, kUnicodeUseFallbacksMask,
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
1024, &iread, &olen, mactextbuf); 1024, &iread, &olen, mactextbuf);
if (err == noErr || err == kTECUsedFallbacksStatus) if (err != noErr && err != kTECUsedFallbacksStatus)
text = mactextbuf; len = olen; /* XXX Should handle this more sensibly */
return;
} else {
/* XXX this is bogus if wchar_t and UniChar are different sizes. */
unitextptr = (wchar_t *)unitextbuf;
/* XXX Should choose charset based on script, font etc. */
olen = charset_from_unicode(&unitextptr, &len, mactextbuf, 1024,
CS_MAC_ROMAN, NULL, ".", 1);
} }
a.s = s; a.s = s;
a.text = text; a.text = mactextbuf;
a.len = len; a.len = olen;
a.attr = attr; a.attr = attr;
a.lattr = lattr; a.lattr = lattr;
a.numer.h = a.numer.v = a.denom.h = a.denom.v = 1; a.numer.h = a.numer.v = a.denom.h = a.denom.v = 1;