X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/c31f6c61a6c4229643515407981f90cae6b0cf89..1dfd2cd6e4b2b02f19f7b3d418f8a31e634d88ce:/mac/macterm.c diff --git a/mac/macterm.c b/mac/macterm.c index 4e844bdc..b24e3d46 100644 --- a/mac/macterm.c +++ b/mac/macterm.c @@ -1,4 +1,4 @@ -/* $Id: macterm.c,v 1.49 2003/01/14 19:42:00 ben Exp $ */ +/* $Id: macterm.c,v 1.52 2003/01/18 20:09:21 ben Exp $ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999, 2002 Ben Harris @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -46,9 +47,7 @@ #include #include #include -#include #include -#include #include #include @@ -62,7 +61,6 @@ #include "putty.h" #include "charset.h" #include "mac.h" -#include "storage.h" #include "terminal.h" #define NCOLOURS (lenof(((Config *)0)->colours)) @@ -109,45 +107,6 @@ static RoutineDescriptor do_text_for_device_upp = #define do_text_for_device_upp do_text_for_device #endif /* not TARGET_RT_MAC_CFM */ -void mac_opensession(void) { - Session *s; - StandardFileReply sfr; - static const OSType sftypes[] = { 'Sess', 0, 0, 0 }; - void *sesshandle; - int i; - - s = smalloc(sizeof(*s)); - memset(s, 0, sizeof(*s)); - - StandardGetFile(NULL, 1, sftypes, &sfr); - if (!sfr.sfGood) goto fail; - - sesshandle = open_settings_r_fsp(&sfr.sfFile); - if (sesshandle == NULL) goto fail; - load_open_settings(sesshandle, TRUE, &s->cfg); - close_settings_r(sesshandle); - - /* - * Select protocol. This is farmed out into a table in a - * separate file to enable an ssh-free variant. - */ - s->back = NULL; - for (i = 0; backends[i].backend != NULL; i++) - if (backends[i].protocol == s->cfg.protocol) { - s->back = backends[i].backend; - break; - } - if (s->back == NULL) { - fatalbox("Unsupported protocol number found"); - } - mac_startsession(s); - return; - - fail: - sfree(s); - return; -} - void mac_startsession(Session *s) { char *errmsg; @@ -190,7 +149,7 @@ void mac_startsession(Session *s) ShowWindow(s->window); s->next = sesslist; - s->prev = s->next->prev; + s->prev = &sesslist; if (s->next != NULL) s->next->prev = &s->next; sesslist = s; @@ -441,6 +400,9 @@ void mac_adjusttermmenus(WindowPtr window) { long offset; s = (Session *)GetWRefCon(window); + menu = GetMenuHandle(mFile); + DisableItem(menu, iSave); /* XXX enable if modified */ + EnableItem(menu, iSaveAs); menu = GetMenuHandle(mEdit); EnableItem(menu, 0); DisableItem(menu, iUndo); @@ -917,6 +879,25 @@ static pascal void mac_growtermdraghook(void) SetPort(portsave); } +void mac_closeterm(WindowPtr window) +{ + Session *s = (Session *)GetWRefCon(window); + + /* XXX warn on close */ + HideWindow(s->window); + *s->prev = s->next; + s->next->prev = s->prev; + ldisc_free(s->ldisc); + s->back->free(s->backhandle); + log_free(s->logctx); + if (s->uni_to_font != NULL) + DisposeUnicodeToTextInfo(&s->uni_to_font); + term_free(s->term); + DisposeWindow(s->window); + DisposePalette(s->palette); + sfree(s); +} + void mac_activateterm(WindowPtr window, Boolean active) { Session *s;