1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

Add support for "Duplicate Session", moving back-end selection into

mac_startsession() in the process.

[originally from svn r2718]
This commit is contained in:
Ben Harris 2003-01-25 15:15:40 +00:00
parent 2aa3b8e154
commit 9812db5f1f
6 changed files with 49 additions and 25 deletions

View File

@ -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 * Copyright (c) 1999 Ben Harris
* All rights reserved. * All rights reserved.
@ -492,6 +492,9 @@ static void mac_menucommand(long result) {
case iSaveAs: case iSaveAs:
mac_savesessionas(); mac_savesessionas();
goto done; goto done;
case iDuplicate:
mac_dupsession();
goto done;
case iQuit: case iQuit:
cleanup_exit(0); cleanup_exit(0);
goto done; goto done;
@ -591,6 +594,7 @@ static void mac_adjustmenus(void) {
case wSettings: case wSettings:
DisableItem(menu, iSave); /* XXX enable if modified */ DisableItem(menu, iSave); /* XXX enable if modified */
EnableItem(menu, iSaveAs); EnableItem(menu, iSaveAs);
EnableItem(menu, iDuplicate);
menu = GetMenuHandle(mEdit); menu = GetMenuHandle(mEdit);
DisableItem(menu, 0); DisableItem(menu, 0);
break; break;
@ -600,6 +604,7 @@ static void mac_adjustmenus(void) {
default: default:
DisableItem(menu, iSave); DisableItem(menu, iSave);
DisableItem(menu, iSaveAs); DisableItem(menu, iSaveAs);
DisableItem(menu, iDuplicate);
menu = GetMenuHandle(mEdit); menu = GetMenuHandle(mEdit);
DisableItem(menu, 0); DisableItem(menu, 0);
break; break;

View File

@ -86,6 +86,7 @@ extern Session *sesslist;
/* from macdlg.c */ /* from macdlg.c */
extern void mac_newsession(void); extern void mac_newsession(void);
extern void mac_dupsession(void);
extern void mac_savesession(void); extern void mac_savesession(void);
extern void mac_savesessionas(void); extern void mac_savesessionas(void);
extern void mac_clickdlg(WindowPtr, EventRecord *); extern void mac_clickdlg(WindowPtr, EventRecord *);

View 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 * Copyright (c) 1999, 2002 Ben Harris
* All rights reserved. * All rights reserved.
@ -893,15 +893,17 @@ resource 'MENU' (mApple, preload) {
resource 'MENU' (mFile, preload) { resource 'MENU' (mFile, preload) {
mFile, mFile,
textMenuProc, textMenuProc,
0b11111111111111111111111111011111, 0b11111111111111111111111101111011,
enabled, enabled,
"Session", "Session",
{ {
"New", noicon, "N", nomark, plain, "New", noicon, "N", nomark, plain,
"Open\0xc9", noicon, "O", nomark, plain, "Open\0xc9", noicon, "O", nomark, plain,
"-", noicon, nokey, nomark, plain,
"Close", noicon, "W", nomark, plain, "Close", noicon, "W", nomark, plain,
"Save", noicon, "S", nomark, plain, "Save", noicon, "S", nomark, plain,
"Save As\0xc9", noicon, nokey, nomark, plain, "Save As\0xc9", noicon, nokey, nomark, plain,
"Duplicate", noicon, "D", nomark, plain,
"-", noicon, nokey, nomark, plain, "-", noicon, nokey, nomark, plain,
"Quit", noicon, "Q", nomark, plain, "Quit", noicon, "Q", nomark, plain,
} }

View 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 * Copyright (c) 2002 Ben Harris
* All rights reserved. * All rights reserved.
@ -53,7 +53,6 @@ void mac_newsession(void)
s = smalloc(sizeof(*s)); s = smalloc(sizeof(*s));
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
do_defaults(NULL, &s->cfg); do_defaults(NULL, &s->cfg);
s->back = &loop_backend;
s->hasfile = FALSE; s->hasfile = FALSE;
s->settings_window = GetNewDialog(wSettings, NULL, (WindowPtr)-1); s->settings_window = GetNewDialog(wSettings, NULL, (WindowPtr)-1);
@ -62,12 +61,25 @@ void mac_newsession(void)
ShowWindow(s->settings_window); 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) static OSErr mac_opensessionfrom(FSSpec *fss)
{ {
FInfo fi; FInfo fi;
Session *s; Session *s;
void *sesshandle; void *sesshandle;
int i;
OSErr err; OSErr err;
s = smalloc(sizeof(*s)); s = smalloc(sizeof(*s));
@ -91,19 +103,6 @@ static OSErr mac_opensessionfrom(FSSpec *fss)
load_open_settings(sesshandle, TRUE, &s->cfg); load_open_settings(sesshandle, TRUE, &s->cfg);
close_settings_r(sesshandle); 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); mac_startsession(s);
return noErr; return noErr;

View 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 * macresid.h -- Mac resource IDs
@ -23,10 +23,11 @@
/* File menu */ /* File menu */
#define iNew 1 #define iNew 1
#define iOpen 2 #define iOpen 2
#define iClose 3 #define iClose 4
#define iSave 4 #define iSave 5
#define iSaveAs 5 #define iSaveAs 6
#define iQuit 7 #define iDuplicate 7
#define iQuit 9
/* Edit menu */ /* Edit menu */
#define iUndo 1 #define iUndo 1
#define iCut 3 #define iCut 3

View 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 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris * Copyright (c) 1999, 2002 Ben Harris
@ -110,8 +110,23 @@ static RoutineDescriptor do_text_for_device_upp =
void mac_startsession(Session *s) void mac_startsession(Session *s)
{ {
char *errmsg; char *errmsg;
int i;
init_ucs(s); 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? */ /* XXX: Own storage management? */
if (HAVE_COLOR_QD()) if (HAVE_COLOR_QD())
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1); s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
@ -403,6 +418,7 @@ void mac_adjusttermmenus(WindowPtr window) {
menu = GetMenuHandle(mFile); menu = GetMenuHandle(mFile);
DisableItem(menu, iSave); /* XXX enable if modified */ DisableItem(menu, iSave); /* XXX enable if modified */
EnableItem(menu, iSaveAs); EnableItem(menu, iSaveAs);
EnableItem(menu, iDuplicate);
menu = GetMenuHandle(mEdit); menu = GetMenuHandle(mEdit);
EnableItem(menu, 0); EnableItem(menu, 0);
DisableItem(menu, iUndo); DisableItem(menu, iUndo);