SCO ACS part 2 (ESC[12m) apparently puts the top half of CP437 into
[u/mdw/putty] / mac / mac.c
index 7cbe8c7..89cbc1d 100644 (file)
--- a/mac/mac.c
+++ b/mac/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.8 2002/12/28 22:22:43 ben Exp $ */
+/* $Id: mac.c,v 1.12 2002/12/31 01:40:14 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -40,6 +40,7 @@
 #include <Devices.h>
 #include <DiskInit.h>
 #include <Gestalt.h>
+#include <LowMem.h>
 #include <Resources.h>
 #include <Script.h>
 #include <TextCommon.h>
@@ -174,6 +175,17 @@ static void mac_startup(void) {
     windows.about = NULL;
     windows.licence = NULL;
 
+    {
+       short vol;
+       long dirid;
+
+       /* Set the default directory for loading and saving settings. */
+       /* XXX Should we create it? */
+       if (get_session_dir(FALSE, &vol, &dirid) == noErr) {
+           LMSetSFSaveDisk(-vol);
+           LMSetCurDirStore(dirid);
+       }
+    }
     init_ucs();
 }
 
@@ -268,6 +280,9 @@ static void mac_contentclick(WindowPtr window, EventRecord *event) {
                break;
            }
        break;
+      case wSettings:
+       mac_clickdlg(window, event);
+       break;
     }
 }
 
@@ -288,6 +303,9 @@ static void mac_activatewindow(WindowPtr window, EventRecord *event) {
       case wTerminal:
        mac_activateterm(window, active);
        break;
+      case wSettings:
+       mac_activatedlg(window, event);
+       break;
       case wAbout:
        mac_activateabout(window, event);
        break;
@@ -314,6 +332,7 @@ static void mac_updatewindow(WindowPtr window) {
        mac_updateterm(window);
        break;
       case wAbout:
+      case wSettings:
        BeginUpdate(window);
        UpdateDialog(window, window->visRgn);
        EndUpdate(window);
@@ -351,6 +370,7 @@ static void mac_updatelicence(WindowPtr window)
  */
 static int mac_windowtype(WindowPtr window) {
     int kind;
+    long refcon;
 
     if (window == NULL)
        return wNone;
@@ -359,7 +379,11 @@ static int mac_windowtype(WindowPtr window) {
        return wDA;
     if (GetWVariant(window) == zoomDocProc)
        return wTerminal;
-    return GetWRefCon(window);
+    refcon = GetWRefCon(window);
+    if (refcon < 1024)
+       return refcon;
+    else
+       return wSettings;
 }
 
 /*
@@ -413,6 +437,9 @@ static void mac_menucommand(long result) {
           case iNew:
             mac_newsession();
             goto done;
+         case iOpen:
+           mac_opensession();
+           goto done;
           case iClose:
             mac_closewindow(window);
             goto done;
@@ -559,8 +586,10 @@ static void mac_adjustcursor(RgnHandle cursrgn) {
 
 static void mac_shutdown(void) {
 
+#if !TARGET_RT_MAC_CFM
     if (mac_gestalts.encvvers != 0)
        TerminateUnicodeConverter();
+#endif
     exit(0);
 }