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

Right, we now have:

* The ability to load the configuration from the current resource file (ie the
   application for now).
 * A scroll bar and size box that look right, even if they don't actually _do_
   anything yet.
 * A load of other minor tweaks.

[originally from svn r62]
This commit is contained in:
Ben Harris 1999-02-28 02:38:41 +00:00
parent 013a8acfd0
commit df4ff91c0e
8 changed files with 591 additions and 196 deletions

View File

@ -1,4 +1,4 @@
# $Id: PuTTY.make,v 1.1.2.6 1999/02/21 18:09:41 ben Exp $ # $Id: PuTTY.make,v 1.1.2.7 1999/02/28 02:38:40 ben Exp $
# This is the Makefile for building PuTTY for the Mac OS. # This is the Makefile for building PuTTY for the Mac OS.
# Users of non-Mac systems will see some pretty strange characters around. # Users of non-Mac systems will see some pretty strange characters around.
@ -12,6 +12,7 @@ COptions = {Includes} {Sym
Objects¥68K = ¶ Objects¥68K = ¶
"{ObjDir¥68K}mac.c.o" ¶ "{ObjDir¥68K}mac.c.o" ¶
"{ObjDir¥68K}maccfg.c.o" ¶
"{ObjDir¥68K}macterm.c.o" ¶ "{ObjDir¥68K}macterm.c.o" ¶
"{ObjDir¥68K}misc.c.o" ¶ "{ObjDir¥68K}misc.c.o" ¶
# "{ObjDir¥68K}ssh.c.o" ¶ # "{ObjDir¥68K}ssh.c.o" ¶
@ -47,6 +48,9 @@ PuTTY
"{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c putty.h mac.h macresid.h "{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c putty.h mac.h macresid.h
{C} mac.c -o {Targ} {COptions} {C} mac.c -o {Targ} {COptions}
"{ObjDir¥68K}maccfg.c.o" Ä {¥MondoBuild¥} maccfg.c putty.h mac.h macresid.h
{C} maccfg.c -o {Targ} {COptions}
"{ObjDir¥68K}macterm.c.o" Ä {¥MondoBuild¥} macterm.c mac.h putty.h "{ObjDir¥68K}macterm.c.o" Ä {¥MondoBuild¥} macterm.c mac.h putty.h
{C} macterm.c -o {Targ} {COptions} {C} macterm.c -o {Targ} {COptions}

35
mac.c
View File

@ -1,4 +1,4 @@
/* $Id: mac.c,v 1.1.2.7 1999/02/24 01:29:10 ben Exp $ */ /* $Id: mac.c,v 1.1.2.8 1999/02/28 02:38:40 ben Exp $ */
/* /*
* mac.c -- miscellaneous Mac-specific routines * mac.c -- miscellaneous Mac-specific routines
*/ */
@ -9,6 +9,7 @@
#include <MacWindows.h> #include <MacWindows.h>
#include <Menus.h> #include <Menus.h>
#include <TextEdit.h> #include <TextEdit.h>
#include <Appearance.h>
#include <Dialogs.h> #include <Dialogs.h>
#include <Devices.h> #include <Devices.h>
#include <DiskInit.h> #include <DiskInit.h>
@ -29,11 +30,13 @@ QDGlobals qd;
static int cold = 1; static int cold = 1;
long mac_qdversion; long mac_qdversion;
long mac_apprversion;
static void mac_startup(void); static void mac_startup(void);
static void mac_eventloop(void); static void mac_eventloop(void);
static void mac_event(EventRecord *); static void mac_event(EventRecord *);
static void mac_contentclick(WindowPtr, EventRecord *); static void mac_contentclick(WindowPtr, EventRecord *);
static void mac_activatewindow(WindowPtr, Boolean);
static void mac_updatewindow(WindowPtr); static void mac_updatewindow(WindowPtr);
static void mac_keypress(EventRecord *); static void mac_keypress(EventRecord *);
static int mac_windowtype(WindowPtr); static int mac_windowtype(WindowPtr);
@ -72,6 +75,16 @@ static void mac_startup(void) {
/* Find out if we've got Color Quickdraw */ /* Find out if we've got Color Quickdraw */
if (Gestalt(gestaltQuickdrawVersion, &mac_qdversion) != noErr) if (Gestalt(gestaltQuickdrawVersion, &mac_qdversion) != noErr)
mac_qdversion = gestaltOriginalQD; mac_qdversion = gestaltOriginalQD;
/* ... and the Appearance Manager? */
if (Gestalt(gestaltAppearanceVersion, &mac_apprversion) != noErr)
if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
mac_apprversion = 0x0100;
else
mac_apprversion = 0;
/* We've been tested with the Appearance Manager */
if (mac_apprversion != 0)
RegisterAppearanceClient();
menuBar = GetNewMBar(128); menuBar = GetNewMBar(128);
if (menuBar == NULL) if (menuBar == NULL)
@ -142,7 +155,8 @@ static void mac_event(EventRecord *event) {
mac_keypress(event); mac_keypress(event);
break; break;
case activateEvt: case activateEvt:
/* FIXME: Do something */ mac_activatewindow((WindowPtr)event->message,
(event->modifiers & activeFlag) != 0);
break; break;
case updateEvt: case updateEvt:
mac_updatewindow((WindowPtr)event->message); mac_updatewindow((WindowPtr)event->message);
@ -174,17 +188,20 @@ static void mac_contentclick(WindowPtr window, EventRecord *event) {
} }
} }
static void mac_activatewindow(WindowPtr window, Boolean active) {
switch (mac_windowtype(window)) {
case wTerminal:
mac_activateterm(window, active);
break;
}
}
static void mac_updatewindow(WindowPtr window) { static void mac_updatewindow(WindowPtr window) {
switch (mac_windowtype(window)) { switch (mac_windowtype(window)) {
case wTerminal: case wTerminal:
BeginUpdate(window); mac_updateterm(window);
term_paint((struct mac_session *)GetWRefCon(window),
(*window->visRgn)->rgnBBox.left,
(*window->visRgn)->rgnBBox.top,
(*window->visRgn)->rgnBBox.right,
(*window->visRgn)->rgnBBox.bottom);
EndUpdate(window);
break; break;
case wAbout: case wAbout:
BeginUpdate(window); BeginUpdate(window);

9
mac.h
View File

@ -5,7 +5,16 @@
#ifndef _PUTTY_MAC_H #ifndef _PUTTY_MAC_H
#define _PUTTY_MAC_H #define _PUTTY_MAC_H
#include <MacTypes.h>
#include <MacWindows.h>
extern long mac_qdversion; extern long mac_qdversion;
/* from macterm.c */
extern void mac_newsession(void); extern void mac_newsession(void);
extern void mac_activateterm(WindowPtr, Boolean);
extern void mac_updateterm(WindowPtr);
extern void mac_loadconfig(Config *);
#endif #endif

368
mac_res.r
View File

@ -1,9 +1,8 @@
/* $Id: mac_res.r,v 1.1.2.4 1999/02/24 21:17:05 ben Exp $ */ /* $Id: mac_res.r,v 1.1.2.5 1999/02/28 02:38:40 ben Exp $ */
/* PuTTY resources */ /* PuTTY resources */
#define PICT_RezTemplateVersion 1
#include "Types.r" #include "Types.r"
#include "Dialogs.r"
#include "Palettes.r" #include "Palettes.r"
/* Get resource IDs we share with C code */ /* Get resource IDs we share with C code */
@ -13,7 +12,7 @@
* Finder-related resources * Finder-related resources
*/ */
/* For now, PuTTY uses the signature "pTTY" */ /* 'pTTY' is now registered with Apple as PuTTY's signature */
type 'pTTY' as 'STR '; type 'pTTY' as 'STR ';
@ -26,7 +25,8 @@ resource 'vers' (1, purgeable) {
development, 0, /* Status and pre-release */ development, 0, /* Status and pre-release */
2, /* Region code (2 = UK) */ 2, /* Region code (2 = UK) */
"Mac exp", /* Short version (list views) */ "Mac exp", /* Short version (list views) */
"Mac experimental", /* Long version (get info) */ "Mac experimental version. "
"Copyright Simon Tatham 1997-9", /* Long version (get info) */
}; };
resource 'SIZE' (-1) { resource 'SIZE' (-1) {
@ -140,6 +140,7 @@ resource 'ICN#' (130, purgeable) {
$"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0"
} }
}; };
resource 'icl4' (130, purgeable) { resource 'icl4' (130, purgeable) {
$"000FFFFFFFFFFFFFFFFFFF0000000000" $"000FFFFFFFFFFFFFFFFFFF0000000000"
$"000F00000000000000000FF000000000" $"000F00000000000000000FF000000000"
@ -175,70 +176,38 @@ resource 'icl4' (130, purgeable) {
$"000FFFFFFFFFFFFFFFFFFFFFFFFF" $"000FFFFFFFFFFFFFFFFFFFFFFFFF"
}; };
resource 'icl8' (130, purgeable) { resource 'icl8' (130, purgeable) {
$"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000"
$"FFFF FFFF FFFF 0000 0000 0000 0000 0000" $"000000FF0000000000000000000000000000000000FFFF000000000000000000"
$"0000 00FF 0000 0000 0000 0000 0000 0000" $"000000FF0000000000000000000000000000000000FFF6FF0000000000000000"
$"0000 0000 00FF FF00 0000 0000 0000 0000" $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6F6FF00000000000000"
$"0000 00FF 0000 0000 0000 0000 0000 0000" $"000000FF0000000000000000000000000000000000FFF6F6F6FF000000000000"
$"0000 0000 00FF F6FF 0000 0000 0000 0000" $"000000FF0000000000000000000000000000000000FFF6F6F6F6FF0000000000"
$"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000"
$"FFFF FFFF FFFF F6F6 FF00 0000 0000 0000" $"000000FF0000000000000000000000000000000000000000000000FF00000000"
$"0000 00FF 0000 0000 0000 0000 0000 0000" $"000000FF0000FFFFFFFFFFFFFFFF000000000000FFFFFFFFFF0000FF00000000"
$"0000 0000 00FF F6F6 F6FF 0000 0000 0000" $"000000FFFFFF2B2B2B2B2B2B2B2BFFFFFFFFFFFF2B2B2B2BFFFFFFFF00000000"
$"0000 00FF 0000 0000 0000 0000 0000 0000" $"000000FF00FF2BFCFCFCFCFCF82BFF00FF2B2B2B2B2B2B2BFF0000FF00000000"
$"0000 0000 00FF F6F6 F6F6 FF00 0000 0000" $"000000FF00FF2BFC2A2A2A2A002BFF00FF2B2B2B2B2B2B2BFF0000FF00000000"
$"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" $"000000FFFFFF2BFC2A2A2A2A002BFFFFFF2B2B2B2B2B2B2BFFFFFFFF00000000"
$"FFFF FFFF FFFF FFFF FFFF FFFF 0000 0000" $"000000FF00FF2BFC2A2A2A2A002BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000"
$"0000 00FF 0000 0000 0000 0000 0000 0000" $"000000FF00FF2BF800000000002BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000"
$"0000 0000 0000 0000 0000 00FF 0000 0000" $"000000FFFFFF2B2B2B2B2B2B2B2BFFFFFF2B2B2B2B2B2B2B2BFFFFFF00000000"
$"0000 00FF 0000 FFFF FFFF FFFF FFFF 0000" $"000000FF00FF2B2B2B2BFFFFFF2BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000"
$"0000 0000 FFFF FFFF FF00 00FF 0000 0000" $"000000FF00FF2B2B2B2B2B2B2B2BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000"
$"0000 00FF FFFF 2B2B 2B2B 2B2B 2B2B FFFF" $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F9F9F9F9F9FFFFFFFFFF00000000"
$"FFFF FFFF 2B2B 2B2B FFFF FFFF 0000 0000" $"000000FF0000FFF7F8F9FAFBFCFF0000FFF9F9F9F9F9F9FF000000FF00000000"
$"0000 00FF 00FF 2BFC FCFC FCFC F82B FF00" $"000000FF0000FFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF000000FF00000000"
$"FF2B 2B2B 2B2B 2B2B FF00 00FF 0000 0000" $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000"
$"0000 00FF 00FF 2BFC 2A2A 2A2A 002B FF00" $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000"
$"FF2B 2B2B 2B2B 2B2B FF00 00FF 0000 0000" $"000000FFF5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FF00000000"
$"0000 00FF FFFF 2BFC 2A2A 2A2A 002B FFFF" $"000000FFF5FF00000000000000000000000000000000000000FFF5FF00000000"
$"FF2B 2B2B 2B2B 2B2B FFFF FFFF 0000 0000" $"000000FFF5FF00FF0000FF0000FF00FF0000FF000000FF0000FFF5FF00000000"
$"0000 00FF 00FF 2BFC 2A2A 2A2A 002B FF00" $"000000FFF5FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FFF5FF00000000"
$"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000" $"000000FFF5FF00FF0000FF0000FF00FF0000FF000000FF0000FFF5FF00000000"
$"0000 00FF 00FF 2BF8 0000 0000 002B FF00" $"000000FFF5FF00000000000000000000000000000000000000FFF5FF00000000"
$"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000" $"000000FFF5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FF00000000"
$"0000 00FF FFFF 2B2B 2B2B 2B2B 2B2B FFFF" $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000"
$"FF2B 2B2B 2B2B 2B2B 2BFF FFFF 0000 0000" $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"0000 00FF 00FF 2B2B 2B2B FFFF FF2B FF00"
$"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000"
$"0000 00FF 00FF 2B2B 2B2B 2B2B 2B2B FF00"
$"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000"
$"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF"
$"FFF9 F9F9 F9F9 F9FF FFFF FFFF 0000 0000"
$"0000 00FF 0000 FFF7 F8F9 FAFB FCFF 0000"
$"FFF9 F9F9 F9F9 F9FF 0000 00FF 0000 0000"
$"0000 00FF 0000 FFFF FFFF FFFF FFFF 0000"
$"FFFF FFFF FFFF FFFF 0000 00FF 0000 0000"
$"0000 00FF F5F5 F5F5 F5F5 F5F5 F5F5 F5F5"
$"F5F5 F5F5 F5F5 F5F5 F5F5 F5FF 0000 0000"
$"0000 00FF F5F5 F5F5 F5F5 F5F5 F5F5 F5F5"
$"F5F5 F5F5 F5F5 F5F5 F5F5 F5FF 0000 0000"
$"0000 00FF F5FF FFFF FFFF FFFF FFFF FFFF"
$"FFFF FFFF FFFF FFFF FFFF F5FF 0000 0000"
$"0000 00FF F5FF 0000 0000 0000 0000 0000"
$"0000 0000 0000 0000 00FF F5FF 0000 0000"
$"0000 00FF F5FF 00FF 0000 FF00 00FF 00FF"
$"0000 FF00 0000 FF00 00FF F5FF 0000 0000"
$"0000 00FF F5FF 00FF 00FF 00FF 00FF 00FF"
$"00FF 00FF 00FF 00FF 00FF F5FF 0000 0000"
$"0000 00FF F5FF 00FF 0000 FF00 00FF 00FF"
$"0000 FF00 0000 FF00 00FF F5FF 0000 0000"
$"0000 00FF F5FF 0000 0000 0000 0000 0000"
$"0000 0000 0000 0000 00FF F5FF 0000 0000"
$"0000 00FF F5FF FFFF FFFF FFFF FFFF FFFF"
$"FFFF FFFF FFFF FFFF FFFF F5FF 0000 0000"
$"0000 00FF F5F5 F5F5 F5F5 F5F5 F5F5 F5F5"
$"F5F5 F5F5 F5F5 F5F5 F5F5 F5FF 0000 0000"
$"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF"
$"FFFF FFFF FFFF FFFF FFFF FFFF"
}; };
@ -322,33 +291,10 @@ resource 'WIND' (wTerminal, "terminal", purgeable) {
staggerParentWindowScreen staggerParentWindowScreen
}; };
resource 'pltt' (PREF_pltt_ID, "terminal", purgeable) { resource 'CNTL' (cVScroll, "vscroll", purgeable) {
{ { 0, 0, 48, 16 },
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* black */ 0, invisible, 0, 0,
0x5555, 0x5555, 0x5555, pmTolerant, 0x2000, /* bright black */ scrollBarProc, 0, ""
0xbbbb, 0x0000, 0x0000, pmTolerant, 0x2000, /* red */
0xffff, 0x5555, 0x5555, pmTolerant, 0x2000, /* bright red */
0x0000, 0xbbbb, 0x0000, pmTolerant, 0x2000, /* green */
0x5555, 0xffff, 0x5555, pmTolerant, 0x2000, /* bright green */
0xbbbb, 0xbbbb, 0x0000, pmTolerant, 0x2000, /* yellow */
0xffff, 0xffff, 0x0000, pmTolerant, 0x2000, /* bright yellow */
0x0000, 0x0000, 0xbbbb, pmTolerant, 0x2000, /* blue */
0x5555, 0x5555, 0xffff, pmTolerant, 0x2000, /* bright blue */
0xbbbb, 0x0000, 0xbbbb, pmTolerant, 0x2000, /* magenta */
0xffff, 0x5555, 0xffff, pmTolerant, 0x2000, /* bright magenta */
0x0000, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* cyan */
0x5555, 0xffff, 0xffff, pmTolerant, 0x2000, /* bright cyan */
0xbbbb, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* white */
0xffff, 0xffff, 0xffff, pmTolerant, 0x2000, /* bright white */
0xbbbb, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* default fg */
0xffff, 0xffff, 0xffff, pmTolerant, 0x2000, /* default bold fg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* default bg */
0x5555, 0x5555, 0x5555, pmTolerant, 0x2000, /* default bold bg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* cursor bg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* bold cursor bg */
0x0000, 0xffff, 0x0000, pmTolerant, 0x2000, /* cursor fg */
0x0000, 0xffff, 0x0000, pmTolerant, 0x2000, /* bold cursor fg */
}
}; };
/* "About" box */ /* "About" box */
@ -364,6 +310,12 @@ resource 'DLOG' (wAbout, "about", purgeable) {
alertPositionMainScreen alertPositionMainScreen
}; };
resource 'dlgx' (wAbout, "about", purgeable) {
versionZero {
kDialogFlagsUseThemeBackground | kDialogFlagsUseThemeControls
}
};
resource 'DITL' (wAbout, "about", purgeable) { resource 'DITL' (wAbout, "about", purgeable) {
{ {
{ 87, 13, 107, 173 }, { 87, 13, 107, 173 },
@ -371,7 +323,8 @@ resource 'DITL' (wAbout, "about", purgeable) {
{ 13, 13, 29, 173 }, { 13, 13, 29, 173 },
StaticText { disabled, "PuTTY"}, StaticText { disabled, "PuTTY"},
{ 42, 13, 74, 173 }, { 42, 13, 74, 173 },
StaticText { disabled,"Experimental Mac Port\n© 1997-9 Simon Tatham"}, StaticText { disabled, "Experimental Mac Port\n"
"© 1997-9 Simon Tatham"},
} }
}; };
@ -416,3 +369,224 @@ resource 'TEXT' (wLicence, "licence", purgeable) {
"CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE " "CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE "
"SOFTWARE." "SOFTWARE."
}; };
/* Default Preferences */
type PREF_wordness_type {
wide array [256] {
integer;
};
};
/*
* This resource collects together the various short settings we need.
* Each area of the system gets its own longword for flags, and then
* we have the other settings. Strings are stored as two shorts --
* the id of a STR# or STR resource, and the index if it's a STR# (0
* for STR).
*/
type 'pSET' {
/* Basic boolean options */
boolean dont_close_on_exit, close_on_exit;
align long;
/* SSH options */
boolean use_pty, no_pty;
align long;
/* Telnet options */
boolean bsd_environ, rfc_environ;
align long;
/* Keyboard options */
boolean backspace, delete;
boolean std_home_end, rxvt_home_end;
boolean std_funkeys, linux_funkeys;
boolean normal_cursor, app_cursor;
boolean normal_keypad, app_keypad;
align long;
/* Terminal options */
boolean no_dec_om, dec_om;
boolean no_auto_wrap, auto_wrap;
boolean no_auto_cr, auto_cr;
boolean use_icon_name, win_name_always;
align long;
/* Colour options */
boolean bold_font, bold_colour;
align long;
/* Non-boolean options */
integer; integer; /* host */
longint; /* port */
longint prot_telnet = 0, prot_ssh = 1; /* protocol */
integer; integer; /* termtype */
integer; integer; /* termspeed */
integer; integer; /* environmt */
integer; integer; /* username */
longint; /* width */
longint; /* height */
longint; /* save_lines */
integer; unsigned integer; /* font */
longint; /* font_height */
integer; /* 'pltt' for colours */
integer; /* 'wORD' for wordness */
};
resource 'pSET' (PREF_settings, "settings", purgeable) {
close_on_exit,
use_pty,
rfc_environ,
delete,
std_home_end,
std_funkeys,
normal_cursor,
normal_keypad,
no_dec_om,
auto_wrap,
no_auto_cr,
use_icon_name,
bold_colour,
#define PREF_strings 1024
PREF_strings, 1, /* host 'STR#' */
23, prot_telnet, /* port, protocol */
PREF_strings, 2, /* termtype 'STR#' */
PREF_strings, 3, /* termspeed 'STR#' */
PREF_strings, 4, /* environmt 'STR#' */
PREF_strings, 5, /* username */
80, 24, 200, /* width, height, save_lines */
PREF_strings, 6, /* font 'STR#' */
9, /* font_height */
#define PREF_pltt 1024
PREF_pltt, /* colours 'pltt' */
#define PREF_wordness 1024
PREF_wordness, /* wordness 'wORD */
};
resource 'STR#' (PREF_strings, "strings", purgeable) {
{
"nowhere.loopback.edu",
"xterm",
"38400,38400",
"\000",
"",
"Monaco",
}
};
resource PREF_wordness_type (PREF_wordness, "wordness", purgeable) {
{
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2,
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2
}
};
/*
* and _why_ isn't this provided for us?
*/
type 'TMPL' {
array {
pstring; /* Item name */
literal longint; /* Item type */
};
};
resource 'TMPL' (128, "pSET") {
{
"Close on exit", 'BBIT',
"", 'BBIT', /* Must pad to a multiple of 8 */
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'ALNG',
"No PTY", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'ALNG',
"RFC OLD-ENVIRON", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'ALNG',
"Delete key sends delete", 'BBIT',
"rxvt home/end", 'BBIT',
"Linux function keys", 'BBIT',
"Application cursor keys", 'BBIT',
"Application keypad", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'ALNG',
"Use colour for bold", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'BBIT',
"", 'ALNG',
"Host STR# ID", 'DWRD',
"Host STR# index", 'DWRD',
"Port", 'DLNG',
"Protocol", 'DLNG',
"Termspeed STR# ID", 'DWRD',
"Termspeed STR# index", 'DWRD',
"Environ STR# ID", 'DWRD',
"Environ STR# index", 'DWRD',
"Username STR# ID", 'DWRD',
"Username STR# index", 'DWRD',
"Terminal width", 'DLNG',
"Terminal height", 'DLNG',
"Save lines", 'DLNG',
"Font STR# ID", 'DWRD',
"Font STR# index", 'DWRD',
"Font size", 'DLNG',
"pltt ID", 'DWRD',
"wORD ID", 'DWRD',
};
};
resource 'pltt' (PREF_pltt, purgeable) {
{
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* black */
0x5555, 0x5555, 0x5555, pmTolerant, 0x2000, /* bright black */
0xbbbb, 0x0000, 0x0000, pmTolerant, 0x2000, /* red */
0xffff, 0x5555, 0x5555, pmTolerant, 0x2000, /* bright red */
0x0000, 0xbbbb, 0x0000, pmTolerant, 0x2000, /* green */
0x5555, 0xffff, 0x5555, pmTolerant, 0x2000, /* bright green */
0xbbbb, 0xbbbb, 0x0000, pmTolerant, 0x2000, /* yellow */
0xffff, 0xffff, 0x0000, pmTolerant, 0x2000, /* bright yellow */
0x0000, 0x0000, 0xbbbb, pmTolerant, 0x2000, /* blue */
0x5555, 0x5555, 0xffff, pmTolerant, 0x2000, /* bright blue */
0xbbbb, 0x0000, 0xbbbb, pmTolerant, 0x2000, /* magenta */
0xffff, 0x5555, 0xffff, pmTolerant, 0x2000, /* bright magenta */
0x0000, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* cyan */
0x5555, 0xffff, 0xffff, pmTolerant, 0x2000, /* bright cyan */
0xbbbb, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* white */
0xffff, 0xffff, 0xffff, pmTolerant, 0x2000, /* bright white */
0xbbbb, 0xbbbb, 0xbbbb, pmTolerant, 0x2000, /* default fg */
0xffff, 0xffff, 0xffff, pmTolerant, 0x2000, /* default bold fg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* default bg */
0x5555, 0x5555, 0x5555, pmTolerant, 0x2000, /* default bold bg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* cursor bg */
0x0000, 0x0000, 0x0000, pmTolerant, 0x2000, /* bold cursor bg */
0x0000, 0xffff, 0x0000, pmTolerant, 0x2000, /* cursor fg */
0x0000, 0xffff, 0x0000, pmTolerant, 0x2000, /* bold cursor fg */
}
};

128
maccfg.c Normal file
View File

@ -0,0 +1,128 @@
/* $Id: maccfg.c,v 1.1.2.1 1999/02/28 02:38:40 ben Exp $ */
/*
* maccfg.c -- Mac port configuration
*/
#include <Resources.h>
#include <TextUtils.h>
#include <string.h>
#include "putty.h"
#include "mac.h"
#include "macresid.h"
struct strloc {
short id, idx;
};
static void get_string(struct strloc *l, char *d, size_t maxlen) {
Str255 s;
int i, len;
GetIndString(s, l->id, l->idx);
len = s[0];
/* maxlen includes a terminator */
if (len > maxlen - 1)
len = maxlen - 1;
for (i = 0; i < len; i++)
d[i] = s[i + 1];
d[i] = '\0';
}
static void get_wordness(short id, short *dst) {
Handle h;
h = GetResource(PREF_wordness_type, id);
if (h == NULL || *h == NULL)
fatalbox ("Couldn't get wordness (%d)", ResError());
memcpy(dst, *h, 256 * sizeof(short));
}
struct pSET {
unsigned long basic_flags;
#define CLOSE_ON_EXIT 0x80000000
unsigned long ssh_flags;
#define NO_PTY 0x80000000
unsigned long telnet_flags;
#define RFC_ENVIRON 0x80000000
unsigned long kbd_flags;
#define BKSP_IS_DELETE 0x80000000
#define RXVT_HOMEEND 0x40000000
#define LINUX_FUNKEYS 0x20000000
#define APP_CURSOR 0x10000000
#define APP_KEYPAD 0x08000000
unsigned long term_flags;
#define DEC_OM 0x80000000
#define WRAP_MODE 0x40000000
#define LFHASCR 0x20000000
#define WIN_NAME_ALWAYS 0x10000000
unsigned long colour_flags;
#define BOLD_COLOUR 0x80000000
struct strloc host;
long port;
long protocol;
struct strloc termtype, termspeed;
struct strloc environmt;
struct strloc username;
long width, height, savelines;
struct strloc font;
long font_height;
short colours_id;
short wordness_id;
};
/*
* Load a configuration from the current chain of resource files.
*/
void mac_loadconfig(Config *cfg) {
Handle h;
struct pSET *s;
h = GetResource('pSET', PREF_settings);
if (h == NULL)
fatalbox("Can't load settings");
SetResAttrs(h, GetResAttrs(h) | resLocked);
s = (struct pSET *)*h;
/* Basic */
get_string(&s->host, cfg->host, sizeof(cfg->host));
cfg->port = s->port;
cfg->protocol = s->protocol;
cfg->close_on_exit = (s->basic_flags & CLOSE_ON_EXIT) != 0;
/* SSH */
cfg->nopty = (s->ssh_flags & NO_PTY) != 0;
/* Telnet */
get_string(&s->termtype, cfg->termtype, sizeof(cfg->termtype));
get_string(&s->termspeed, cfg->termspeed, sizeof(cfg->termspeed));
get_string(&s->environmt, cfg->environmt, sizeof(cfg->environmt));
get_string(&s->username, cfg->username, sizeof(cfg->username));
cfg->rfc_environ = (s->telnet_flags & RFC_ENVIRON) != 0;
/* Keyboard */
cfg->bksp_is_delete = (s->kbd_flags & BKSP_IS_DELETE) != 0;
cfg->rxvt_homeend = (s->kbd_flags & RXVT_HOMEEND) != 0;
cfg->linux_funkeys = (s->kbd_flags & LINUX_FUNKEYS) != 0;
cfg->app_cursor = (s->kbd_flags & APP_CURSOR) != 0;
cfg->app_keypad = (s->kbd_flags & APP_KEYPAD) != 0;
/* Terminal */
cfg->savelines = s->savelines;
cfg->dec_om = (s->term_flags & DEC_OM) != 0;
cfg->wrap_mode = (s->term_flags & WRAP_MODE) != 0;
cfg->lfhascr = (s->term_flags & LFHASCR) != 0;
cfg->win_name_always = (s->term_flags & WIN_NAME_ALWAYS) != 0;
cfg->width = s->width;
cfg->height = s->height;
get_string(&s->font, cfg->font, sizeof(cfg->font));
cfg->fontisbold = FALSE; /* XXX */
cfg->fontheight = s->font_height;
cfg->vtmode = VT_POORMAN; /* XXX */
/* Colour */
cfg->try_palette = FALSE; /* XXX */
cfg->bold_colour = (s->colour_flags & BOLD_COLOUR) != 0;
cfg->colours = GetNewPalette(s->colours_id);
if (cfg->colours == NULL)
fatalbox("Failed to get default palette");
/* Selection */
get_wordness(s->wordness_id, cfg->wordness);
SetResAttrs(h, GetResAttrs(h) & ~resLocked);
ReleaseResource(h);
}

View File

@ -1,4 +1,4 @@
/* $Id: macresid.h,v 1.1.2.3 1999/02/24 01:29:10 ben Exp $ */ /* $Id: macresid.h,v 1.1.2.4 1999/02/28 02:38:40 ben Exp $ */
/* /*
* macresid.h -- Mac resource IDs * macresid.h -- Mac resource IDs
@ -31,6 +31,10 @@
#define wTerminal 130 #define wTerminal 130
#define wLicence 131 #define wLicence 131
/* Controls */
#define cVScroll 128
/* Preferences */ /* Preferences */
#define PREF_pltt_ID 1024 #define PREF_wordness_type 'wORD'
#define PREF_settings 1024

101
macterm.c
View File

@ -11,6 +11,7 @@
#include <QuickdrawText.h> #include <QuickdrawText.h>
#include <Sound.h> #include <Sound.h>
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include "macresid.h" #include "macresid.h"
@ -22,10 +23,12 @@ struct mac_session {
int font_ascent; int font_ascent;
WindowPtr window; WindowPtr window;
PaletteHandle palette; PaletteHandle palette;
ControlHandle scrollbar;
}; };
static void mac_initfont(struct mac_session *); static void mac_initfont(struct mac_session *);
static void mac_initpalette(struct mac_session *); static void mac_initpalette(struct mac_session *);
static void mac_adjustsize(struct mac_session *);
/* Temporary hack till I get the terminal emulator supporting multiple sessions */ /* Temporary hack till I get the terminal emulator supporting multiple sessions */
@ -46,28 +49,8 @@ void mac_newsession(void) {
int i; int i;
/* This should obviously be initialised by other means */ /* This should obviously be initialised by other means */
mac_loadconfig(&cfg);
s = smalloc(sizeof(*s)); s = smalloc(sizeof(*s));
cfg.bksp_is_delete = TRUE;
cfg.rxvt_homeend = FALSE;
cfg.linux_funkeys = FALSE;
cfg.app_cursor = FALSE;
cfg.app_keypad = FALSE;
cfg.savelines = 100;
cfg.dec_om = FALSE;
cfg.wrap_mode =
cfg.lfhascr = FALSE;
cfg.win_name_always = FALSE;
cfg.width = 80;
cfg.height = 24;
strcpy(cfg.font, "Monaco");
cfg.fontisbold = 0;
cfg.fontheight = 9;
cfg.vtmode = VT_POORMAN;
cfg.try_palette = FALSE;
cfg.bold_colour = TRUE;
cfg.colours = GetNewPalette(PREF_pltt_ID);
if (cfg.colours == NULL)
fatalbox("Failed to get default palette");
onlysession = s; onlysession = s;
/* XXX: Own storage management? */ /* XXX: Own storage management? */
@ -76,6 +59,7 @@ void mac_newsession(void) {
else else
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1); s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
SetWRefCon(s->window, (long)s); SetWRefCon(s->window, (long)s);
s->scrollbar = GetNewControl(cVScroll, s->window);
term_init(); term_init();
term_size(24, 80, 100); term_size(24, 80, 100);
mac_initfont(s); mac_initfont(s);
@ -113,10 +97,28 @@ static void mac_initfont(struct mac_session *s) {
font_width = fi.widMax; font_width = fi.widMax;
font_height = fi.ascent + fi.descent + fi.leading; font_height = fi.ascent + fi.descent + fi.leading;
s->font_ascent = fi.ascent; s->font_ascent = fi.ascent;
SizeWindow(s->window, cols * font_width, rows * font_height, true); mac_adjustsize(s);
}
/*
* To be called whenever the window size changes.
* rows and cols should be desired values.
* It's assumed the terminal emulator will be or has been informed.
*/
static void mac_adjustsize(struct mac_session *s) {
int winwidth, winheight;
winwidth = cols * font_width + 15;
winheight = rows * font_height;
SizeWindow(s->window, winwidth, winheight, true);
HideControl(s->scrollbar);
MoveControl(s->scrollbar, winwidth - 15, -1);
SizeControl(s->scrollbar, 16, winheight - 13);
ShowControl(s->scrollbar);
} }
static void mac_initpalette(struct mac_session *s) { static void mac_initpalette(struct mac_session *s) {
WinCTab ct;
if (mac_qdversion == gestaltOriginalQD) if (mac_qdversion == gestaltOriginalQD)
return; return;
@ -126,6 +128,61 @@ static void mac_initpalette(struct mac_session *s) {
CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries); CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
} }
/*
* I don't think this is (a) safe or (b) a good way to do this.
*/
static void mac_updatewinbg(struct mac_session *s) {
WinCTab ct;
WCTabPtr ctp = &ct;
WCTabHandle cth = &ctp;
ct.wCSeed = 0;
ct.wCReserved = 0;
ct.ctSize = 1;
ct.ctTable[0].value = wContentColor;
ct.ctTable[0].rgb = (*s->palette)->pmInfo[16].ciRGB;
SetWinColor(s->window, cth);
}
void mac_activateterm(WindowPtr window, Boolean active) {
struct mac_session *s;
s = (struct mac_session *)GetWRefCon(window);
if (active)
ShowControl(s->scrollbar);
else
HideControl(s->scrollbar);
}
void mac_updateterm(WindowPtr window) {
struct mac_session *s;
Rect clip;
s = (struct mac_session *)GetWRefCon(window);
BeginUpdate(window);
term_paint(s,
(*window->visRgn)->rgnBBox.left,
(*window->visRgn)->rgnBBox.top,
(*window->visRgn)->rgnBBox.right,
(*window->visRgn)->rgnBBox.bottom);
/* Restore default colours in case the Window Manager uses them */
PmForeColor(16);
PmBackColor(18);
if (FrontWindow() != window)
EraseRect(&(*s->scrollbar)->contrlRect);
UpdateControls(window, window->visRgn);
/* Stop DrawGrowIcon giving us space for a horizontal scrollbar */
clip.left = window->portRect.right - 15;
clip.right = SHRT_MAX;
clip.top = SHRT_MIN;
clip.bottom = SHRT_MAX;
ClipRect(&clip);
DrawGrowIcon(window);
clip.left = SHRT_MIN;
ClipRect(&clip);
EndUpdate(window);
}
/* /*
* Call from the terminal emulator to draw a bit of text * Call from the terminal emulator to draw a bit of text
* *

View File

@ -154,7 +154,9 @@ typedef struct {
unsigned char colours[22][3]; unsigned char colours[22][3];
#endif /* not macintosh */ #endif /* not macintosh */
/* Selection options */ /* Selection options */
#ifndef macintosh
int mouse_is_xterm; int mouse_is_xterm;
#endif
short wordness[256]; short wordness[256];
} Config; } Config;