Support for saving sessions on the Mac. This is slightly useful even in the
[u/mdw/putty] / mac / mac.c
index ffc3fe0..5751ac8 100644 (file)
--- a/mac/mac.c
+++ b/mac/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.26 2003/01/12 14:45:33 ben Exp $ */
+/* $Id: mac.c,v 1.33 2003/01/18 20:09:21 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -200,18 +200,19 @@ static void mac_startup(void) {
     windows.about = NULL;
     windows.licence = NULL;
 
-    default_protocol = DEFAULT_PROTOCOL;
-    default_port = DEFAULT_PORT;
+    default_protocol = be_default_protocol;
+    /* Find the appropriate default port. */
+    {
+       int i;
+       default_port = 0; /* illegal */
+       for (i = 0; backends[i].backend != NULL; i++)
+           if (backends[i].protocol == default_protocol) {
+               default_port = backends[i].backend->default_port;
+               break;
+           }
+    }
     flags = FLAG_INTERACTIVE;
 
-    /*
-     * Really grotty hack to ensure that anything that looks at the
-     * global "cfg" variable gets something vaguely sensible.
-     * Obviously, nothing should actually be using it, but that will
-     * take a while to arrange.
-     */
-    do_defaults(NULL, &cfg);
-
     {
        short vol;
        long dirid;
@@ -223,7 +224,6 @@ static void mac_startup(void) {
            LMSetCurDirStore(dirid);
        }
     }
-    init_ucs();
 }
 
 static void mac_eventloop(void) {
@@ -485,6 +485,12 @@ static void mac_menucommand(long result) {
           case iClose:
             mac_closewindow(window);
             goto done;
+         case iSave:
+           mac_savesession();
+           goto done;
+         case iSaveAs:
+           mac_savesessionas();
+           goto done;
           case iQuit:
             cleanup_exit(0);
             goto done;
@@ -541,18 +547,15 @@ static void mac_closewindow(WindowPtr window) {
        CloseDeskAcc(((WindowPeek)window)->windowKind);
        break;
       case wTerminal:
-       /* FIXME: end session and stuff */
+       mac_closeterm(window);
        break;
       case wAbout:
        windows.about = NULL;
-       CloseWindow(window);
+       DisposeDialog(window);
        break;
       case wLicence:
        windows.licence = NULL;
-       CloseWindow(window);
-       break;
-      default:
-       CloseWindow(window);
+       DisposeWindow(window);
        break;
     }
 }
@@ -584,10 +587,18 @@ static void mac_adjustmenus(void) {
     EnableItem(menu, iQuit);
 
     switch (mac_windowtype(window)) {
+      case wSettings:
+       DisableItem(menu, iSave); /* XXX enable if modified */
+       EnableItem(menu, iSaveAs);
+       menu = GetMenuHandle(mEdit);
+       DisableItem(menu, 0);
+       break;
       case wTerminal:
        mac_adjusttermmenus(window);
        break;
       default:
+       DisableItem(menu, iSave);
+       DisableItem(menu, iSaveAs);
        menu = GetMenuHandle(mEdit);
        DisableItem(menu, 0);
        break;
@@ -710,7 +721,7 @@ void old_keyfile_warning(void)
 
 }
 
-char *platform_default_s(char *name)
+char *platform_default_s(char const *name)
 {
     long smfs;
     Str255 pname;
@@ -732,7 +743,7 @@ char *platform_default_s(char *name)
     return NULL;
 }
 
-int platform_default_i(char *name, int def)
+int platform_default_i(char const *name, int def)
 {
     long smfs;