X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f854b482e4de775e380033bbea7436732311d1ce..bf1e6912b12754fd79a48dfe6d77760532598dc3:/mac/macterm.c diff --git a/mac/macterm.c b/mac/macterm.c index d04abd33..f308808f 100644 --- a/mac/macterm.c +++ b/mac/macterm.c @@ -1,4 +1,4 @@ -/* $Id: macterm.c,v 1.71 2003/02/15 16:22:15 ben Exp $ */ +/* $Id$ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999, 2002 Ben Harris @@ -105,7 +105,7 @@ void post_paint(Session *s); void mac_startsession(Session *s) { - char *errmsg; + const char *errmsg; int i; WinInfo *wi; @@ -129,7 +129,7 @@ void mac_startsession(Session *s) s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1); else s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1); - wi = smalloc(sizeof(*wi)); + wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->s = s; wi->wtype = wTerminal; @@ -157,8 +157,9 @@ void mac_startsession(Session *s) s->logctx = log_init(s->term, &s->cfg); term_provide_logctx(s->term, s->logctx); - errmsg = s->back->init(s->term, &s->backhandle, &s->cfg, s->cfg.host, - s->cfg.port, &s->realhost, s->cfg.tcp_nodelay); + errmsg = s->back->init(s, &s->backhandle, &s->cfg, s->cfg.host, + s->cfg.port, &s->realhost, s->cfg.tcp_nodelay, + s->cfg.tcp_keepalives); if (errmsg != NULL) fatalbox("%s", errmsg); s->back->provide_logctx(s->backhandle, s->logctx); @@ -193,9 +194,9 @@ static void mac_workoutfontscale(Session *s, int wantwidth, const char text = 'W'; FontInfo fi; #if TARGET_API_MAC_CARBON - CQDProcsPtr gp = GetPortGrafProcs(GetWindowPort(s->window));; + CQDProcsPtr gp = GetPortGrafProcs(GetWindowPort(s->window)); #else - QDProcsPtr gp = s->window->grafProcs;; + QDProcsPtr gp = s->window->grafProcs; #endif numer.v = denom.v = 1; /* always */ @@ -313,7 +314,6 @@ void mac_pollterm(void) Session *s; for (s = sesslist; s != NULL; s = s->next) { - term_out(s->term); term_update(s->term); } } @@ -629,7 +629,7 @@ void write_clip(void *cookie, wchar_t *data, int len, int must_deselect) if (data[i] == 0x2028) data[i] = 0x000d; - mactextbuf = smalloc(len); /* XXX DBCS */ + mactextbuf = snewn(len, char); /* XXX DBCS */ if (s->uni_to_font != NULL) { err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar), (UniChar *)data, @@ -702,7 +702,7 @@ void get_clip(void *frontend, wchar_t **p, int *lenp) texth = NewHandle(0); textlen = GetScrap(texth, kScrapFlavorTypeText, &offset); HLock(texth); - data = smalloc(textlen * 2); + data = snewn(textlen, wchar_t); /* XXX should use 'styl' scrap if it's there. */ if (mac_gestalts.encvvers != 0 && UpgradeScriptInfoToTextEncoding(smSystemScript, @@ -1042,7 +1042,7 @@ static void mac_activateterm(WindowPtr window, EventRecord *event) Boolean active = (event->modifiers & activeFlag) != 0; s = mac_windowsession(window); - s->term->has_focus = active; + term_set_focus(s->term, active); term_update(s->term); if (active) ShowControl(s->scrollbar); @@ -1138,7 +1138,7 @@ struct do_text_args { * * x and y are text row and column (zero-based) */ -void do_text(Context ctx, int x, int y, char *text, int len, +void do_text(Context ctx, int x, int y, wchar_t *text, int len, unsigned long attr, int lattr) { Session *s = ctx; @@ -1149,7 +1149,6 @@ void do_text(Context ctx, int x, int y, char *text, int len, RgnHandle visrgn; #endif char mactextbuf[1024]; - UniChar unitextbuf[1024]; wchar_t *unitextptr; int i, fontwidth; ByteCount iread, olen; @@ -1158,6 +1157,11 @@ void do_text(Context ctx, int x, int y, char *text, int len, assert(len <= 1024); + /* SGT, 2004-10-14: I don't know how to support combining characters + * on the Mac. Hopefully the first person to fail this assertion will + * know how to do it better than me... */ + assert(!(attr & TATTR_COMBINING)); + SetPort((GrafPtr)GetWindowPort(s->window)); fontwidth = s->font_width; @@ -1184,20 +1188,16 @@ void do_text(Context ctx, int x, int y, char *text, int len, return; #endif - /* Unpack Unicode from the mad format we get passed */ - for (i = 0; i < len; i++) - unitextbuf[i] = (unsigned char)text[i] | (attr & CSET_MASK); - if (s->uni_to_font != NULL) { err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar), - unitextbuf, kUnicodeUseFallbacksMask, + text, kUnicodeUseFallbacksMask, 0, NULL, NULL, NULL, 1024, &iread, &olen, mactextbuf); if (err != noErr && err != kTECUsedFallbacksStatus) olen = 0; } else if (s->font_charset != CS_NONE) { /* XXX this is bogus if wchar_t and UniChar are different sizes. */ - unitextptr = (wchar_t *)unitextbuf; + unitextptr = (wchar_t *)text; olen = charset_from_unicode(&unitextptr, &len, mactextbuf, 1024, s->font_charset, NULL, ".", 1); } else @@ -1847,6 +1847,13 @@ int askappend(void *frontend, Filename filename) return 2; } +int from_backend(void *frontend, int is_stderr, const char *data, int len) +{ + Session *s = frontend; + + return term_data(s->term, is_stderr, data, len); +} + /* * Emacs magic: * Local Variables: