Add support for "Duplicate Session", moving back-end selection into
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 25 Jan 2003 15:15:40 +0000 (15:15 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 25 Jan 2003 15:15:40 +0000 (15:15 +0000)
mac_startsession() in the process.

git-svn-id: svn://svn.tartarus.org/sgt/putty@2718 cda61777-01e9-0310-a592-d414129be87e

mac/mac.c
mac/mac.h
mac/mac_res.r
mac/macdlg.c
mac/macresid.h
mac/macterm.c

index 76d202a..3a0f065 100644 (file)
--- a/mac/mac.c
+++ b/mac/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.36 2003/01/24 00:25:33 ben Exp $ */
+/* $Id: mac.c,v 1.37 2003/01/25 15:15:40 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -492,6 +492,9 @@ static void mac_menucommand(long result) {
          case iSaveAs:
            mac_savesessionas();
            goto done;
+         case iDuplicate:
+           mac_dupsession();
+           goto done;
           case iQuit:
             cleanup_exit(0);
             goto done;
@@ -591,6 +594,7 @@ static void mac_adjustmenus(void) {
       case wSettings:
        DisableItem(menu, iSave); /* XXX enable if modified */
        EnableItem(menu, iSaveAs);
+       EnableItem(menu, iDuplicate);
        menu = GetMenuHandle(mEdit);
        DisableItem(menu, 0);
        break;
@@ -600,6 +604,7 @@ static void mac_adjustmenus(void) {
       default:
        DisableItem(menu, iSave);
        DisableItem(menu, iSaveAs);
+       DisableItem(menu, iDuplicate);
        menu = GetMenuHandle(mEdit);
        DisableItem(menu, 0);
        break;
index 5e29c50..50ed142 100644 (file)
--- a/mac/mac.h
+++ b/mac/mac.h
@@ -86,6 +86,7 @@ extern Session *sesslist;
 
 /* from macdlg.c */
 extern void mac_newsession(void);
+extern void mac_dupsession(void);
 extern void mac_savesession(void);
 extern void mac_savesessionas(void);
 extern void mac_clickdlg(WindowPtr, EventRecord *);
index 2668b3f..b38f429 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mac_res.r,v 1.22 2003/01/25 14:09:47 ben Exp $ */
+/* $Id: mac_res.r,v 1.23 2003/01/25 15:15:40 ben Exp $ */
 /*
  * Copyright (c) 1999, 2002 Ben Harris
  * All rights reserved.
@@ -893,15 +893,17 @@ resource 'MENU' (mApple, preload) {
 resource 'MENU' (mFile, preload) {
     mFile,
     textMenuProc,
-    0b11111111111111111111111111011111,
+    0b11111111111111111111111101111011,
     enabled,
     "Session",
     {
        "New",                  noicon, "N",   nomark, plain,
        "Open\0xc9",            noicon, "O",   nomark, plain,
+       "-",                    noicon, nokey, nomark, plain,
        "Close",                noicon, "W",   nomark, plain,
        "Save",                 noicon, "S",   nomark, plain,
        "Save As\0xc9",         noicon, nokey, nomark, plain,
+       "Duplicate",            noicon, "D",   nomark, plain,
        "-",                    noicon, nokey, nomark, plain,
        "Quit",                 noicon, "Q",   nomark, plain,
     }
index 2606f0b..e8970d4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macdlg.c,v 1.7 2003/01/25 14:04:47 ben Exp $ */
+/* $Id: macdlg.c,v 1.8 2003/01/25 15:15:40 ben Exp $ */
 /*
  * Copyright (c) 2002 Ben Harris
  * All rights reserved.
@@ -53,7 +53,6 @@ void mac_newsession(void)
     s = smalloc(sizeof(*s));
     memset(s, 0, sizeof(*s));
     do_defaults(NULL, &s->cfg);
-    s->back = &loop_backend;
     s->hasfile = FALSE;
 
     s->settings_window = GetNewDialog(wSettings, NULL, (WindowPtr)-1);
@@ -62,12 +61,25 @@ void mac_newsession(void)
     ShowWindow(s->settings_window);
 }
 
+void mac_dupsession(void)
+{
+    Session *s1 = (Session *)GetWRefCon(FrontWindow());
+    Session *s2;
+
+    s2 = smalloc(sizeof(*s2));
+    memset(s2, 0, sizeof(*s2));
+    s2->cfg = s1->cfg;
+    s2->hasfile = s1->hasfile;
+    s2->savefile = s1->savefile;
+
+    mac_startsession(s2);
+}
+
 static OSErr mac_opensessionfrom(FSSpec *fss)
 {
     FInfo fi;
     Session *s;
     void *sesshandle;
-    int i;
     OSErr err;
 
     s = smalloc(sizeof(*s));
@@ -91,19 +103,6 @@ static OSErr mac_opensessionfrom(FSSpec *fss)
     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 noErr;
 
index 983832f..7a1ab8c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macresid.h,v 1.5 2003/01/18 17:14:34 ben Exp $ */
+/* $Id: macresid.h,v 1.6 2003/01/25 15:15:40 ben Exp $ */
 
 /*
  * macresid.h -- Mac resource IDs
 /* File menu */
 #define iNew           1
 #define iOpen          2
-#define iClose         3
-#define iSave          4
-#define iSaveAs                5
-#define iQuit          7
+#define iClose         4
+#define iSave          5
+#define iSaveAs                6
+#define iDuplicate     7
+#define iQuit          9
 /* Edit menu */
 #define iUndo          1
 #define iCut           3
index b24e3d4..4f4a9db 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.52 2003/01/18 20:09:21 ben Exp $ */
+/* $Id: macterm.c,v 1.53 2003/01/25 15:15:40 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999, 2002 Ben Harris
@@ -110,8 +110,23 @@ static RoutineDescriptor do_text_for_device_upp =
 void mac_startsession(Session *s)
 {
     char *errmsg;
+    int i;
 
     init_ucs(s);
+
+    /*
+     * 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");
+
     /* XXX: Own storage management? */
     if (HAVE_COLOR_QD())
        s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
@@ -403,6 +418,7 @@ void mac_adjusttermmenus(WindowPtr window) {
     menu = GetMenuHandle(mFile);
     DisableItem(menu, iSave); /* XXX enable if modified */
     EnableItem(menu, iSaveAs);
+    EnableItem(menu, iDuplicate);
     menu = GetMenuHandle(mEdit);
     EnableItem(menu, 0);
     DisableItem(menu, iUndo);