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
* 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;

View File

@ -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 *);

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
* 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,
}

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
* 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;

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
@ -23,10 +23,11 @@
/* 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

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, 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);