diff --git a/PuTTY.make b/PuTTY.make index 7f3d483f..fe2d3b0a 100644 --- a/PuTTY.make +++ b/PuTTY.make @@ -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. # Users of non-Mac systems will see some pretty strange characters around. @@ -12,6 +12,7 @@ COptions = {Includes} {Sym Objects¥68K = ¶ "{ObjDir¥68K}mac.c.o" ¶ + "{ObjDir¥68K}maccfg.c.o" ¶ "{ObjDir¥68K}macterm.c.o" ¶ "{ObjDir¥68K}misc.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 {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 {C} macterm.c -o {Targ} {COptions} diff --git a/mac.c b/mac.c index 4310212e..25ac2ce9 100644 --- a/mac.c +++ b/mac.c @@ -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 */ @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -29,11 +30,13 @@ QDGlobals qd; static int cold = 1; long mac_qdversion; +long mac_apprversion; static void mac_startup(void); static void mac_eventloop(void); static void mac_event(EventRecord *); static void mac_contentclick(WindowPtr, EventRecord *); +static void mac_activatewindow(WindowPtr, Boolean); static void mac_updatewindow(WindowPtr); static void mac_keypress(EventRecord *); static int mac_windowtype(WindowPtr); @@ -72,6 +75,16 @@ static void mac_startup(void) { /* Find out if we've got Color Quickdraw */ if (Gestalt(gestaltQuickdrawVersion, &mac_qdversion) != noErr) 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); if (menuBar == NULL) @@ -142,7 +155,8 @@ static void mac_event(EventRecord *event) { mac_keypress(event); break; case activateEvt: - /* FIXME: Do something */ + mac_activatewindow((WindowPtr)event->message, + (event->modifiers & activeFlag) != 0); break; case updateEvt: 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) { switch (mac_windowtype(window)) { case wTerminal: - BeginUpdate(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); + mac_updateterm(window); break; case wAbout: BeginUpdate(window); diff --git a/mac.h b/mac.h index ba0aaed7..ce1cef0e 100644 --- a/mac.h +++ b/mac.h @@ -5,7 +5,16 @@ #ifndef _PUTTY_MAC_H #define _PUTTY_MAC_H +#include +#include + extern long mac_qdversion; + +/* from macterm.c */ extern void mac_newsession(void); +extern void mac_activateterm(WindowPtr, Boolean); +extern void mac_updateterm(WindowPtr); + +extern void mac_loadconfig(Config *); #endif diff --git a/mac_res.r b/mac_res.r index d20a4bc2..e9b83582 100644 --- a/mac_res.r +++ b/mac_res.r @@ -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 */ -#define PICT_RezTemplateVersion 1 - #include "Types.r" +#include "Dialogs.r" #include "Palettes.r" /* Get resource IDs we share with C code */ @@ -13,7 +12,7 @@ * Finder-related resources */ -/* For now, PuTTY uses the signature "pTTY" */ +/* 'pTTY' is now registered with Apple as PuTTY's signature */ type 'pTTY' as 'STR '; @@ -26,7 +25,8 @@ resource 'vers' (1, purgeable) { development, 0, /* Status and pre-release */ 2, /* Region code (2 = UK) */ "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) { @@ -87,23 +87,23 @@ resource 'BNDL' (128, purgeable) { resource 'ICN#' (128, purgeable) { { /* array: 2 elements */ /* [1] */ - $"0000 3FFE 0000 4001 0000 4FF9 0000 5005" - $"0000 5355 0000 4505 0000 5A05 0000 2405" - $"0000 4A85 0001 9005 0002 23F9 0004 7C01" - $"0018 0201 7FA0 0C7D 801F 1001 9FE2 2001" - $"A00C DFFE AA89 2002 A012 3FFE A82C 0000" - $"A052 0000 AA6A 0000 A00A 0000 9FF2 0000" - $"8002 0000 8002 0000 80FA 0000 8002 0000" - $"8002 0000 7FFC 0000 4004 0000 7FFC", + $"00003FFE 00004001 00004FF9 00005005" + $"00005355 00004505 00005A05 00002405" + $"00004A85 00019005 000223F9 00047C01" + $"00180201 7FA00C7D 801F1001 9FE22001" + $"A00CDFFE AA892002 A0123FFE A82C0000" + $"A0520000 AA6A0000 A00A0000 9FF20000" + $"80020000 80020000 80FA0000 80020000" + $"80020000 7FFC0000 40040000 7FFC", /* [2] */ - $"0000 3FFE 0000 7FFF 0000 7FFF 0000 7FFF" - $"0000 7FFF 0000 7FFF 0000 7FFF 0000 7FFF" - $"0000 7FFF 0000 7FFF 0000 7FFF 0000 7FFF" - $"0000 7FFF 7FFC 7FFF FFFE 7FFF FFFE 7FFF" - $"FFFE 3FFE FFFE 3FFE FFFE 3FFE FFFE 0000" - $"FFFE 0000 FFFE 0000 FFFE 0000 FFFE 0000" - $"FFFE 0000 FFFE 0000 FFFE 0000 FFFE 0000" - $"FFFE 0000 7FFC 0000 7FFC 0000 7FFC" + $"00003FFE 00007FFF 0000 7FFF 00007FFF" + $"00007FFF 00007FFF 0000 7FFF 00007FFF" + $"00007FFF 00007FFF 0000 7FFF 00007FFF" + $"00007FFF 7FFC7FFF FFFE 7FFF FFFE7FFF" + $"FFFE3FFE FFFE3FFE FFFE 3FFE FFFE0000" + $"FFFE0000 FFFE0000 FFFE 0000 FFFE0000" + $"FFFE0000 FFFE0000 FFFE 0000 FFFE0000" + $"FFFE0000 7FFC0000 7FFC 0000 7FFC" } }; resource 'ics#' (128, purgeable) { @@ -121,124 +121,93 @@ resource 'ics#' (128, purgeable) { resource 'ICN#' (130, purgeable) { { /* array: 2 elements */ /* [1] */ - $"1FFF FC00 1000 0600 1000 0500 1FFF FC80" - $"1000 0440 1000 0420 1FFF FFF0 1000 0010" - $"13FC 0F90 1C03 F0F0 15FA 8090 150A 8090" - $"1D0B 80F0 150A 8050 15FA 8050 1C03 8070" - $"143A 8050 1402 8050 1FFF ABF0 1204 8110" - $"13FC FF10 1AAA AAB0 1000 0010 17FF FFD0" - $"1400 0050 1525 2250 1555 5550 1525 2250" - $"1400 0050 17FF FFD0 1000 0010 1FFF FFF0", + $"1FFFFC00 10000600 10000500 1FFFFC80" + $"10000440 10000420 1FFFFFF0 10000010" + $"13FC0F90 1C03F0F0 15FA8090 150A8090" + $"1D0B80F0 150A8050 15FA8050 1C038070" + $"143A8050 14028050 1FFFABF0 12048110" + $"13FCFF10 1AAAAAB0 10000010 17FFFFD0" + $"14000050 15252250 15555550 15252250" + $"14000050 17FFFFD0 10000010 1FFFFFF0", /* [2] */ - $"1FFF FC00 1FFF FE00 1FFF FF00 1FFF FF80" - $"1FFF FFC0 1FFF FFE0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" - $"1FFF FFF0 1FFF FFF0 1FFF FFF0 1FFF FFF0" + $"1FFFFC00 1FFFFE00 1FFFFF00 1FFFFF80" + $"1FFFFFC0 1FFFFFE0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" + $"1FFFFFF0 1FFFFFF0 1FFFFFF0 1FFFFFF0" } }; + resource 'icl4' (130, purgeable) { - $"000F FFFF FFFF FFFF FFFF FF00 0000 0000" - $"000F 0000 0000 0000 0000 0FF0 0000 0000" - $"000F 0000 0000 0000 0000 0FCF 0000 0000" - $"000F FFFF FFFF FFFF FFFF FFCC F000 0000" - $"000F 0000 0000 0000 0000 0FCC CF00 0000" - $"000F 0000 0000 0000 0000 0FCC CCF0 0000" - $"000F FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"000F 0000 0000 0000 0000 0000 000F 0000" - $"000F 00FF FFFF FF00 0000 FFFF F00F 0000" - $"000F FFCC CCCC CCFF FFFF CCCC FFFF 0000" - $"000F 0FCE EEEE CCF0 FCCC CCCC F00F 0000" - $"000F 0FCE 0D0D 0CF0 FCCC CCCC F00F 0000" - $"000F FFCE D0D0 CCFF FCCC CCCC FFFF 0000" - $"000F 0FCE 0D0D 0CF0 FCCC CCCC CF0F 0000" - $"000F 0FCC C0C0 CCF0 FCCC CCCC CF0F 0000" - $"000F FFCC CCCC CCFF FCCC CCCC CFFF 0000" - $"000F 0FCC CCFF FCF0 FCCC CCCC CF0F 0000" - $"000F 0FCC CCCC CCF0 FCCC CCCC CF0F 0000" - $"000F FFFF FFFF FFFF FDDD DDDF FFFF 0000" - $"000F 00FC CDDE EF00 FDDD DDDF 000F 0000" - $"000F 00FF FFFF FF00 FFFF FFFF 000F 0000" - $"000F 0C0C 0C0C 0C0C 0C0C 0C0C 0C0F 0000" - $"000F C0C0 C0C0 C0C0 C0C0 C0C0 C0CF 0000" - $"000F 0FFF FFFF FFFF FFFF FFFF FF0F 0000" - $"000F CF00 0000 0000 0000 0000 0FCF 0000" - $"000F 0F0F 00F0 0F0F 00F0 00F0 0F0F 0000" - $"000F CF0F 0F0F 0F0F 0F0F 0F0F 0FCF 0000" - $"000F 0F0F 00F0 0F0F 00F0 00F0 0F0F 0000" - $"000F CF00 0000 0000 0000 0000 0FCF 0000" - $"000F 0FFF FFFF FFFF FFFF FFFF FF0F 0000" - $"000F C0C0 C0C0 C0C0 C0C0 C0C0 C0CF 0000" - $"000F FFFF FFFF FFFF FFFF FFFF FFFF" + $"000FFFFFFFFFFFFFFFFFFF0000000000" + $"000F00000000000000000FF000000000" + $"000F00000000000000000FCF00000000" + $"000FFFFFFFFFFFFFFFFFFFCCF0000000" + $"000F00000000000000000FCCCF000000" + $"000F00000000000000000FCCCCF00000" + $"000FFFFFFFFFFFFFFFFFFFFFFFFF0000" + $"000F00000000000000000000000F0000" + $"000F00FFFFFFFF000000FFFFF00F0000" + $"000FFFCCCCCCCCFFFFFFCCCCFFFF0000" + $"000F0FCEEEEECCF0FCCCCCCCF00F0000" + $"000F0FCE0D0D0CF0FCCCCCCCF00F0000" + $"000FFFCED0D0CCFFFCCCCCCCFFFF0000" + $"000F0FCE0D0D0CF0FCCCCCCCCF0F0000" + $"000F0FCCC0C0CCF0FCCCCCCCCF0F0000" + $"000FFFCCCCCCCCFFFCCCCCCCCFFF0000" + $"000F0FCCCCFFFCF0FCCCCCCCCF0F0000" + $"000F0FCCCCCCCCF0FCCCCCCCCF0F0000" + $"000FFFFFFFFFFFFFFDDDDDDFFFFF0000" + $"000F00FCCDDEEF00FDDDDDDF000F0000" + $"000F00FFFFFFFF00FFFFFFFF000F0000" + $"000F0C0C0C0C0C0C0C0C0C0C0C0F0000" + $"000FC0C0C0C0C0C0C0C0C0C0C0CF0000" + $"000F0FFFFFFFFFFFFFFFFFFFFF0F0000" + $"000FCF0000000000000000000FCF0000" + $"000F0F0F00F00F0F00F000F00F0F0000" + $"000FCF0F0F0F0F0F0F0F0F0F0FCF0000" + $"000F0F0F00F00F0F00F000F00F0F0000" + $"000FCF0000000000000000000FCF0000" + $"000F0FFFFFFFFFFFFFFFFFFFFF0F0000" + $"000FC0C0C0C0C0C0C0C0C0C0C0CF0000" + $"000FFFFFFFFFFFFFFFFFFFFFFFFF" }; resource 'icl8' (130, purgeable) { - $"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF 0000 0000 0000 0000 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 00FF FF00 0000 0000 0000 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 00FF F6FF 0000 0000 0000 0000" - $"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF F6F6 FF00 0000 0000 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 00FF F6F6 F6FF 0000 0000 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 00FF F6F6 F6F6 FF00 0000 0000" - $"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF 0000 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 00FF 0000 0000" - $"0000 00FF 0000 FFFF FFFF FFFF FFFF 0000" - $"0000 0000 FFFF FFFF FF00 00FF 0000 0000" - $"0000 00FF FFFF 2B2B 2B2B 2B2B 2B2B FFFF" - $"FFFF FFFF 2B2B 2B2B FFFF FFFF 0000 0000" - $"0000 00FF 00FF 2BFC FCFC FCFC F82B FF00" - $"FF2B 2B2B 2B2B 2B2B FF00 00FF 0000 0000" - $"0000 00FF 00FF 2BFC 2A2A 2A2A 002B FF00" - $"FF2B 2B2B 2B2B 2B2B FF00 00FF 0000 0000" - $"0000 00FF FFFF 2BFC 2A2A 2A2A 002B FFFF" - $"FF2B 2B2B 2B2B 2B2B FFFF FFFF 0000 0000" - $"0000 00FF 00FF 2BFC 2A2A 2A2A 002B FF00" - $"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000" - $"0000 00FF 00FF 2BF8 0000 0000 002B FF00" - $"FF2B 2B2B 2B2B 2B2B 2BFF 00FF 0000 0000" - $"0000 00FF FFFF 2B2B 2B2B 2B2B 2B2B FFFF" - $"FF2B 2B2B 2B2B 2B2B 2BFF FFFF 0000 0000" - $"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" + $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000" + $"000000FF0000000000000000000000000000000000FFFF000000000000000000" + $"000000FF0000000000000000000000000000000000FFF6FF0000000000000000" + $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6F6FF00000000000000" + $"000000FF0000000000000000000000000000000000FFF6F6F6FF000000000000" + $"000000FF0000000000000000000000000000000000FFF6F6F6F6FF0000000000" + $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000" + $"000000FF0000000000000000000000000000000000000000000000FF00000000" + $"000000FF0000FFFFFFFFFFFFFFFF000000000000FFFFFFFFFF0000FF00000000" + $"000000FFFFFF2B2B2B2B2B2B2B2BFFFFFFFFFFFF2B2B2B2BFFFFFFFF00000000" + $"000000FF00FF2BFCFCFCFCFCF82BFF00FF2B2B2B2B2B2B2BFF0000FF00000000" + $"000000FF00FF2BFC2A2A2A2A002BFF00FF2B2B2B2B2B2B2BFF0000FF00000000" + $"000000FFFFFF2BFC2A2A2A2A002BFFFFFF2B2B2B2B2B2B2BFFFFFFFF00000000" + $"000000FF00FF2BFC2A2A2A2A002BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000" + $"000000FF00FF2BF800000000002BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000" + $"000000FFFFFF2B2B2B2B2B2B2B2BFFFFFF2B2B2B2B2B2B2B2BFFFFFF00000000" + $"000000FF00FF2B2B2B2BFFFFFF2BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000" + $"000000FF00FF2B2B2B2B2B2B2B2BFF00FF2B2B2B2B2B2B2B2BFF00FF00000000" + $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F9F9F9F9F9FFFFFFFFFF00000000" + $"000000FF0000FFF7F8F9FAFBFCFF0000FFF9F9F9F9F9F9FF000000FF00000000" + $"000000FF0000FFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF000000FF00000000" + $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000" + $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000" + $"000000FFF5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FF00000000" + $"000000FFF5FF00000000000000000000000000000000000000FFF5FF00000000" + $"000000FFF5FF00FF0000FF0000FF00FF0000FF000000FF0000FFF5FF00000000" + $"000000FFF5FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FFF5FF00000000" + $"000000FFF5FF00FF0000FF0000FF00FF0000FF000000FF0000FFF5FF00000000" + $"000000FFF5FF00000000000000000000000000000000000000FFF5FF00000000" + $"000000FFF5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FF00000000" + $"000000FFF5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5FF00000000" + $"000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" }; @@ -322,33 +291,10 @@ resource 'WIND' (wTerminal, "terminal", purgeable) { staggerParentWindowScreen }; -resource 'pltt' (PREF_pltt_ID, "terminal", 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 */ - } +resource 'CNTL' (cVScroll, "vscroll", purgeable) { + { 0, 0, 48, 16 }, + 0, invisible, 0, 0, + scrollBarProc, 0, "" }; /* "About" box */ @@ -364,6 +310,12 @@ resource 'DLOG' (wAbout, "about", purgeable) { alertPositionMainScreen }; +resource 'dlgx' (wAbout, "about", purgeable) { + versionZero { + kDialogFlagsUseThemeBackground | kDialogFlagsUseThemeControls + } +}; + resource 'DITL' (wAbout, "about", purgeable) { { { 87, 13, 107, 173 }, @@ -371,7 +323,8 @@ resource 'DITL' (wAbout, "about", purgeable) { { 13, 13, 29, 173 }, StaticText { disabled, "PuTTY"}, { 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 " "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 */ + } +}; + diff --git a/maccfg.c b/maccfg.c new file mode 100644 index 00000000..58c56054 --- /dev/null +++ b/maccfg.c @@ -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 +#include + +#include + +#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); +} diff --git a/macresid.h b/macresid.h index f1ea8db9..941708f8 100644 --- a/macresid.h +++ b/macresid.h @@ -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 @@ -31,6 +31,10 @@ #define wTerminal 130 #define wLicence 131 +/* Controls */ +#define cVScroll 128 /* Preferences */ -#define PREF_pltt_ID 1024 +#define PREF_wordness_type 'wORD' + +#define PREF_settings 1024 diff --git a/macterm.c b/macterm.c index 08179aac..54ab1b1e 100644 --- a/macterm.c +++ b/macterm.c @@ -11,6 +11,7 @@ #include #include +#include #include #include "macresid.h" @@ -22,10 +23,12 @@ struct mac_session { int font_ascent; WindowPtr window; PaletteHandle palette; + ControlHandle scrollbar; }; static void mac_initfont(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 */ @@ -46,28 +49,8 @@ void mac_newsession(void) { int i; /* This should obviously be initialised by other means */ + mac_loadconfig(&cfg); 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; /* XXX: Own storage management? */ @@ -76,6 +59,7 @@ void mac_newsession(void) { else s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1); SetWRefCon(s->window, (long)s); + s->scrollbar = GetNewControl(cVScroll, s->window); term_init(); term_size(24, 80, 100); mac_initfont(s); @@ -113,11 +97,29 @@ static void mac_initfont(struct mac_session *s) { font_width = fi.widMax; font_height = fi.ascent + fi.descent + fi.leading; 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) { - + WinCTab ct; + if (mac_qdversion == gestaltOriginalQD) return; s->palette = NewPalette((*cfg.colours)->pmEntries, NULL, pmCourteous, 0); @@ -126,6 +128,61 @@ static void mac_initpalette(struct mac_session *s) { 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 * diff --git a/putty.h b/putty.h index fb300a17..49f02307 100644 --- a/putty.h +++ b/putty.h @@ -154,7 +154,9 @@ typedef struct { unsigned char colours[22][3]; #endif /* not macintosh */ /* Selection options */ +#ifndef macintosh int mouse_is_xterm; +#endif short wordness[256]; } Config;