mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Add an "open" command to the "file" (now "session") menu on the Mac to
open an existing saved session. This has entailed adding an extra hook to settings.c to allow for loading settings other than by name. [originally from svn r2387]
This commit is contained in:
parent
d5d52933dd
commit
71d699c28c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: mac.c,v 1.9 2002/12/29 19:14:56 ben Exp $ */
|
/* $Id: mac.c,v 1.10 2002/12/30 18:21:17 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Ben Harris
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -413,6 +413,9 @@ static void mac_menucommand(long result) {
|
|||||||
case iNew:
|
case iNew:
|
||||||
mac_newsession();
|
mac_newsession();
|
||||||
goto done;
|
goto done;
|
||||||
|
case iOpen:
|
||||||
|
mac_opensession();
|
||||||
|
goto done;
|
||||||
case iClose:
|
case iClose:
|
||||||
mac_closewindow(window);
|
mac_closewindow(window);
|
||||||
goto done;
|
goto done;
|
||||||
|
36
mac/mac.h
36
mac/mac.h
@ -6,6 +6,7 @@
|
|||||||
#define PUTTY_MAC_H
|
#define PUTTY_MAC_H
|
||||||
|
|
||||||
#include <MacTypes.h>
|
#include <MacTypes.h>
|
||||||
|
#include <Controls.h>
|
||||||
#include <Events.h>
|
#include <Events.h>
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
#include <MacWindows.h>
|
#include <MacWindows.h>
|
||||||
@ -25,21 +26,6 @@ extern struct mac_gestalts mac_gestalts;
|
|||||||
|
|
||||||
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
|
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
|
||||||
|
|
||||||
/* from macterm.c */
|
|
||||||
extern void mac_newsession(void);
|
|
||||||
extern void mac_activateterm(WindowPtr, Boolean);
|
|
||||||
extern void mac_adjusttermcursor(WindowPtr, Point, RgnHandle);
|
|
||||||
extern void mac_adjusttermmenus(WindowPtr);
|
|
||||||
extern void mac_updateterm(WindowPtr);
|
|
||||||
extern void mac_clickterm(WindowPtr, EventRecord *);
|
|
||||||
extern void mac_growterm(WindowPtr, EventRecord *);
|
|
||||||
extern void mac_keyterm(WindowPtr, EventRecord *);
|
|
||||||
extern void mac_menuterm(WindowPtr, short, short);
|
|
||||||
/* from maccfg.c */
|
|
||||||
extern void mac_loadconfig(Config *);
|
|
||||||
/* from macnet.c */
|
|
||||||
extern void macnet_eventcheck(void);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Config that created this session */
|
/* Config that created this session */
|
||||||
Config cfg;
|
Config cfg;
|
||||||
@ -69,6 +55,26 @@ typedef struct {
|
|||||||
UnicodeToTextInfo uni_to_font;
|
UnicodeToTextInfo uni_to_font;
|
||||||
} Session;
|
} Session;
|
||||||
|
|
||||||
|
/* from macterm.c */
|
||||||
|
extern void mac_newsession(void);
|
||||||
|
extern void mac_opensession(void);
|
||||||
|
extern void mac_startsession(Session *);
|
||||||
|
extern void mac_activateterm(WindowPtr, Boolean);
|
||||||
|
extern void mac_adjusttermcursor(WindowPtr, Point, RgnHandle);
|
||||||
|
extern void mac_adjusttermmenus(WindowPtr);
|
||||||
|
extern void mac_updateterm(WindowPtr);
|
||||||
|
extern void mac_clickterm(WindowPtr, EventRecord *);
|
||||||
|
extern void mac_growterm(WindowPtr, EventRecord *);
|
||||||
|
extern void mac_keyterm(WindowPtr, EventRecord *);
|
||||||
|
extern void mac_menuterm(WindowPtr, short, short);
|
||||||
|
/* from macstore.c */
|
||||||
|
OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID);
|
||||||
|
extern void *open_settings_r_fsp(FSSpec *);
|
||||||
|
/* from maccfg.c */
|
||||||
|
extern void mac_loadconfig(Config *);
|
||||||
|
/* from macnet.c */
|
||||||
|
extern void macnet_eventcheck(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: mac_res.r,v 1.5 2002/12/30 14:17:51 ben Exp $ */
|
/* $Id: mac_res.r,v 1.6 2002/12/30 18:21:17 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Ben Harris
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -360,7 +360,7 @@ resource 'MENU' (mApple, preload) {
|
|||||||
enabled,
|
enabled,
|
||||||
apple,
|
apple,
|
||||||
{
|
{
|
||||||
"About PuTTYÉ", noicon, nokey, nomark, plain,
|
"About PuTTY\0xc9", noicon, nokey, nomark, plain,
|
||||||
"-", noicon, nokey, nomark, plain,
|
"-", noicon, nokey, nomark, plain,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -368,11 +368,12 @@ resource 'MENU' (mApple, preload) {
|
|||||||
resource 'MENU' (mFile, preload) {
|
resource 'MENU' (mFile, preload) {
|
||||||
mFile,
|
mFile,
|
||||||
textMenuProc,
|
textMenuProc,
|
||||||
0b11111111111111111111111111111011,
|
0b11111111111111111111111111110111,
|
||||||
enabled,
|
enabled,
|
||||||
"File",
|
"Session",
|
||||||
{
|
{
|
||||||
"New Session", noicon, "N", nomark, plain,
|
"New", noicon, "N", nomark, plain,
|
||||||
|
"Open\0xc9", noicon, "O", nomark, plain,
|
||||||
"Close", noicon, "W", nomark, plain,
|
"Close", noicon, "W", nomark, plain,
|
||||||
"-", noicon, nokey, nomark, plain,
|
"-", noicon, nokey, nomark, plain,
|
||||||
"Quit", noicon, "Q", nomark, plain,
|
"Quit", noicon, "Q", nomark, plain,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macresid.h,v 1.1 2002/11/19 02:13:46 ben Exp $ */
|
/* $Id: macresid.h,v 1.2 2002/12/30 18:21:17 ben Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* macresid.h -- Mac resource IDs
|
* macresid.h -- Mac resource IDs
|
||||||
@ -20,8 +20,9 @@
|
|||||||
#define iAbout 1
|
#define iAbout 1
|
||||||
/* File menu */
|
/* File menu */
|
||||||
#define iNew 1
|
#define iNew 1
|
||||||
#define iClose 2
|
#define iOpen 2
|
||||||
#define iQuit 4
|
#define iClose 3
|
||||||
|
#define iQuit 5
|
||||||
/* Edit menu */
|
/* Edit menu */
|
||||||
#define iUndo 1
|
#define iUndo 1
|
||||||
#define iCut 3
|
#define iCut 3
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macstore.c,v 1.5 2002/12/28 22:44:27 ben Exp $ */
|
/* $Id: macstore.c,v 1.6 2002/12/30 18:21:17 ben Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* macstore.c: Macintosh-specific impementation of the interface
|
* macstore.c: Macintosh-specific impementation of the interface
|
||||||
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
#include "mac.h"
|
||||||
|
|
||||||
#define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY')
|
#define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY')
|
||||||
#define SESS_TYPE FOUR_CHAR_CODE('Sess')
|
#define SESS_TYPE FOUR_CHAR_CODE('Sess')
|
||||||
|
|
||||||
|
|
||||||
OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID);
|
|
||||||
OSErr FSpGetDirID(FSSpec *f, long *idp, Boolean makeit);
|
OSErr FSpGetDirID(FSSpec *f, long *idp, Boolean makeit);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -191,21 +191,32 @@ void close_settings_w(void *handle) {
|
|||||||
safefree(handle);
|
safefree(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *open_settings_r(char *sessionname) {
|
void *open_settings_r(char *sessionname)
|
||||||
|
{
|
||||||
short sessVRefNum;
|
short sessVRefNum;
|
||||||
long sessDirID;
|
long sessDirID;
|
||||||
FSSpec sessfile;
|
FSSpec sessfile;
|
||||||
OSErr error;
|
OSErr error;
|
||||||
Str255 psessionname;
|
Str255 psessionname;
|
||||||
int fd;
|
|
||||||
int *handle;
|
|
||||||
|
|
||||||
error = get_session_dir(kDontCreateFolder, &sessVRefNum, &sessDirID);
|
error = get_session_dir(kDontCreateFolder, &sessVRefNum, &sessDirID);
|
||||||
|
|
||||||
c2pstrcpy(psessionname, sessionname);
|
c2pstrcpy(psessionname, sessionname);
|
||||||
error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &sessfile);
|
error = FSMakeFSSpec(sessVRefNum, sessDirID, psessionname, &sessfile);
|
||||||
if (error != noErr) goto out;
|
if (error != noErr) goto out;
|
||||||
fd = FSpOpenResFile(&sessfile, fsRdPerm);
|
return open_settings_r_fsp(&sessfile);
|
||||||
|
|
||||||
|
out:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *open_settings_r_fsp(FSSpec *sessfile)
|
||||||
|
{
|
||||||
|
OSErr error;
|
||||||
|
int fd;
|
||||||
|
int *handle;
|
||||||
|
|
||||||
|
fd = FSpOpenResFile(sessfile, fsRdPerm);
|
||||||
if (fd == 0) {error = ResError(); goto out;}
|
if (fd == 0) {error = ResError(); goto out;}
|
||||||
|
|
||||||
handle = safemalloc(sizeof *handle);
|
handle = safemalloc(sizeof *handle);
|
||||||
@ -216,7 +227,6 @@ void *open_settings_r(char *sessionname) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *read_setting_s(void *handle, char *key, char *buffer, int buflen) {
|
char *read_setting_s(void *handle, char *key, char *buffer, int buflen) {
|
||||||
int fd;
|
int fd;
|
||||||
Handle h;
|
Handle h;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.25 2002/12/28 22:25:31 ben Exp $ */
|
/* $Id: macterm.c,v 1.26 2002/12/30 18:21:17 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
@ -46,6 +46,7 @@
|
|||||||
#include <Scrap.h>
|
#include <Scrap.h>
|
||||||
#include <Script.h>
|
#include <Script.h>
|
||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
|
#include <StandardFile.h>
|
||||||
#include <TextCommon.h>
|
#include <TextCommon.h>
|
||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
#include <ToolUtils.h>
|
#include <ToolUtils.h>
|
||||||
@ -60,6 +61,7 @@
|
|||||||
#include "macresid.h"
|
#include "macresid.h"
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
|
#include "storage.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
#define NCOLOURS (lenof(((Config *)0)->colours))
|
#define NCOLOURS (lenof(((Config *)0)->colours))
|
||||||
@ -138,15 +140,45 @@ static void display_resource(Session *s, unsigned long type, short id) {
|
|||||||
|
|
||||||
void mac_newsession(void) {
|
void mac_newsession(void) {
|
||||||
Session *s;
|
Session *s;
|
||||||
UInt32 starttime;
|
|
||||||
char msg[128];
|
|
||||||
|
|
||||||
/* This should obviously be initialised by other means */
|
/* This should obviously be initialised by other means */
|
||||||
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->back = &loop_backend;
|
||||||
|
mac_startsession(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mac_opensession(void) {
|
||||||
|
Session *s;
|
||||||
|
StandardFileReply sfr;
|
||||||
|
static const OSType sftypes[] = { 'Sess', 0, 0, 0 };
|
||||||
|
void *sesshandle;
|
||||||
|
|
||||||
|
s = smalloc(sizeof(*s));
|
||||||
|
memset(s, 0, sizeof(*s));
|
||||||
|
|
||||||
|
StandardGetFile(NULL, 1, sftypes, &sfr);
|
||||||
|
if (!sfr.sfGood) goto fail;
|
||||||
|
|
||||||
|
sesshandle = open_settings_r_fsp(&sfr.sfFile);
|
||||||
|
if (sesshandle == NULL) goto fail;
|
||||||
|
load_open_settings(sesshandle, TRUE, &s->cfg);
|
||||||
|
close_settings_r(sesshandle);
|
||||||
|
s->back = &loop_backend;
|
||||||
|
mac_startsession(s);
|
||||||
|
return;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
sfree(s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mac_startsession(Session *s)
|
||||||
|
{
|
||||||
|
UInt32 starttime;
|
||||||
|
char msg[128];
|
||||||
|
|
||||||
/* 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);
|
||||||
|
1
putty.h
1
putty.h
@ -465,6 +465,7 @@ void random_destroy_seed(void);
|
|||||||
*/
|
*/
|
||||||
void save_settings(char *section, int do_host, Config * cfg);
|
void save_settings(char *section, int do_host, Config * cfg);
|
||||||
void load_settings(char *section, int do_host, Config * cfg);
|
void load_settings(char *section, int do_host, Config * cfg);
|
||||||
|
void load_open_settings(void *sesskey, int do_host, Config *cfg);
|
||||||
void get_sesslist(struct sesslist *, int allocate);
|
void get_sesslist(struct sesslist *, int allocate);
|
||||||
void do_defaults(char *, Config *);
|
void do_defaults(char *, Config *);
|
||||||
void registry_cleanup(void);
|
void registry_cleanup(void);
|
||||||
|
12
settings.c
12
settings.c
@ -321,11 +321,17 @@ void save_settings(char *section, int do_host, Config * cfg)
|
|||||||
|
|
||||||
void load_settings(char *section, int do_host, Config * cfg)
|
void load_settings(char *section, int do_host, Config * cfg)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
char prot[10];
|
|
||||||
void *sesskey;
|
void *sesskey;
|
||||||
|
|
||||||
sesskey = open_settings_r(section);
|
sesskey = open_settings_r(section);
|
||||||
|
load_open_settings(sesskey, do_host, cfg);
|
||||||
|
close_settings_r(sesskey);
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_open_settings(void *sesskey, int do_host, Config *cfg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char prot[10];
|
||||||
|
|
||||||
cfg->ssh_subsys = 0; /* FIXME: load this properly */
|
cfg->ssh_subsys = 0; /* FIXME: load this properly */
|
||||||
cfg->remote_cmd_ptr = cfg->remote_cmd;
|
cfg->remote_cmd_ptr = cfg->remote_cmd;
|
||||||
@ -637,8 +643,6 @@ void load_settings(char *section, int do_host, Config * cfg)
|
|||||||
gppi(sesskey, "ScrollbarOnLeft", 0, &cfg->scrollbar_on_left);
|
gppi(sesskey, "ScrollbarOnLeft", 0, &cfg->scrollbar_on_left);
|
||||||
gpps(sesskey, "BoldFont", "", cfg->boldfont, sizeof(cfg->boldfont));
|
gpps(sesskey, "BoldFont", "", cfg->boldfont, sizeof(cfg->boldfont));
|
||||||
gppi(sesskey, "ShadowBoldOffset", 1, &cfg->shadowboldoffset);
|
gppi(sesskey, "ShadowBoldOffset", 1, &cfg->shadowboldoffset);
|
||||||
|
|
||||||
close_settings_r(sesskey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_defaults(char *session, Config * cfg)
|
void do_defaults(char *session, Config * cfg)
|
||||||
|
Loading…
Reference in New Issue
Block a user