X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/3aca9c70c657dc4cf67c998126d6e3ef81758c04..d9fffe93f4b699fa925c82f483c98ea8cc399981:/mac/macterm.c diff --git a/mac/macterm.c b/mac/macterm.c index 220fa2c8..1f14b423 100644 --- a/mac/macterm.c +++ b/mac/macterm.c @@ -1,4 +1,4 @@ -/* $Id: macterm.c,v 1.35 2003/01/05 11:31:51 ben Exp $ */ +/* $Id: macterm.c,v 1.45 2003/01/12 16:25:58 ben Exp $ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999, 2002 Ben Harris @@ -109,35 +109,6 @@ static RoutineDescriptor do_text_for_device_upp = #define do_text_for_device_upp do_text_for_device #endif /* not TARGET_RT_MAC_CFM */ -static void inbuf_putc(Session *s, int c) { - char ch = c; - - from_backend(s->term, 0, &ch, 1); -} - -static void inbuf_putstr(Session *s, const char *c) { - - from_backend(s->term, 0, (char *)c, strlen(c)); -} - -static void display_resource(Session *s, unsigned long type, short id) { - Handle h; - int len; - char *t; - - h = GetResource(type, id); - if (h == NULL) - fatalbox("Can't get test resource"); - len = GetResourceSizeOnDisk(h); - DetachResource(h); - HNoPurge(h); - HLock(h); - t = *h; - from_backend(s->term, 0, t, len); - term_out(s->term); - DisposeHandle(h); -} - void mac_opensession(void) { Session *s; StandardFileReply sfr; @@ -179,8 +150,6 @@ void mac_opensession(void) { void mac_startsession(Session *s) { - UInt32 starttime; - char msg[128]; char *errmsg; /* XXX: Own storage management? */ @@ -200,14 +169,15 @@ void mac_startsession(Session *s) ActivatePalette(s->window); } - s->logctx = log_init(s); + s->logctx = log_init(s, &s->cfg); term_provide_logctx(s->term, s->logctx); - errmsg = s->back->init(s->term, &s->backhandle, s->cfg.host, s->cfg.port, - &s->realhost, s->cfg.tcp_nodelay); + errmsg = s->back->init(s->term, &s->backhandle, &s->cfg, s->cfg.host, + s->cfg.port, &s->realhost, s->cfg.tcp_nodelay); if (errmsg != NULL) - inbuf_putstr(s, errmsg); + fatalbox("%s", errmsg); s->back->provide_logctx(s->backhandle, s->logctx); + set_title(s, s->realhost); term_provide_resize_fn(s->term, s->back->size, s->backhandle); @@ -218,11 +188,11 @@ void mac_startsession(Session *s) ldisc_send(s->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */ ShowWindow(s->window); - starttime = TickCount(); - display_resource(s, 'pTST', 128); - sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime); - inbuf_putstr(s, msg); - term_out(s->term); + s->next = sesslist; + s->prev = s->next->prev; + if (s->next != NULL) + s->next->prev = &s->next; + sesslist = s; } static UnicodeToTextFallbackUPP uni_to_font_fallback_upp; @@ -234,7 +204,7 @@ static void mac_initfont(Session *s) { OptionBits fbflags; SetPort(s->window); - macfont[0] = sprintf((char *)&macfont[1], "%s", s->cfg.font); + c2pstrcpy(macfont, s->cfg.font); GetFNum(macfont, &s->fontnum); TextFont(s->fontnum); TextFace(s->cfg.fontisbold ? bold : 0); @@ -300,6 +270,18 @@ static pascal OSStatus uni_to_font_fallback(UniChar *ucp, return noErr; } +/* + * Called every time round the event loop. + */ +void mac_pollterm(void) +{ + Session *s; + + for (s = sesslist; s != NULL; s = s->next) { + term_out(s->term); + term_update(s->term); + } +} /* * To be called whenever the window size changes. @@ -869,6 +851,7 @@ static pascal void mac_growtermdraghook(void) GrafPtr portsave; Point mouse; char buf[20]; + unsigned char pbuf[20]; int newrows, newcols; GetMouse(&mouse); @@ -880,13 +863,13 @@ static pascal void mac_growtermdraghook(void) if (strcmp(buf, growterm_state.oldmsg) == 0) return; strcpy(growterm_state.oldmsg, buf); - c2pstr(buf); + c2pstrcpy(pbuf, buf); GetPort(&portsave); SetPort(growterm_state.s->window); EraseRect(&growterm_state.msgrect); MoveTo(growterm_state.msgorigin.h, growterm_state.msgorigin.v); - DrawString((StringPtr)buf); + DrawString(pbuf); SetPort(portsave); } @@ -1252,7 +1235,7 @@ void set_title(void *frontend, char *title) { Session *s = frontend; Str255 mactitle; - mactitle[0] = sprintf((char *)&mactitle[1], "%s", title); + c2pstrcpy(mactitle, title); SetWTitle(s->window, mactitle); } @@ -1385,9 +1368,12 @@ void get_window_pixels(void *frontend, int *x, int *y) char *get_window_title(void *frontend, int icon) { Session *s = frontend; + Str255 ptitle; + static char title[256]; - /* Erm, we don't save this at the moment */ - return ""; + GetWTitle(s->window, ptitle); + p2cstrcpy(title, ptitle); + return title; } /*