-/* $Id: mac_res.r,v 1.1.2.2 1999/02/21 18:09:41 ben Exp $ */
+/* $Id: mac_res.r,v 1.1.2.3 1999/02/24 01:29:10 ben Exp $ */
/* PuTTY resources */
#define PICT_RezTemplateVersion 1
#include "Types.r"
+#include "Palettes.r"
/* Get resource IDs we share with C code */
#include "macresid.h"
{ /* array: 2 elements */
/* [1] */
$"0000 3FFE 0000 4001 0000 4FF9 0000 5005"
- $"0000 5545 0000 5005 0000 5405 0000 5005"
- $"0000 5505 0000 5005 0000 4FF9 0000 4001"
- $"0000 4001 7FFC 407D 8002 4001 9FF2 4001"
- $"A00A 3FFE AA8A 2002 A00A 3FFE A80A 0000"
- $"A00A 0000 AA0A 0000 A00A 0000 9FF2 0000"
+ $"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",
/* [2] */
$"FFFE 0000 7FFC 0000 7FFC 0000 7FFC"
}
};
-
resource 'ics#' (128, purgeable) {
{ /* array: 2 elements */
/* [1] */
/* Terminal window */
-resource 'WIND' (wTerminal, "terminal", purgeable) {
+resource 'WIND' (PREF_pltt_ID, "terminal", purgeable) {
{ 0, 0, 200, 200 },
zoomDocProc,
invisible,
staggerParentWindowScreen
};
+resource 'pltt' (wTerminal, "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 */
+ }
+};
+
/* "About" box */
resource 'DLOG' (wAbout, "about", purgeable) {
resource 'DITL' (wAbout, "about", purgeable) {
{
- { 87, 116, 107, 173 },
- Button { enabled, "Close" },
- { 87, 13, 107, 103 },
+ { 87, 13, 107, 173 },
Button { enabled, "View Licence" },
{ 13, 13, 29, 173 },
StaticText { disabled, "PuTTY"},
{ 42, 13, 74, 173 },
- StaticText { disabled,"Experimantal Mac Port\n© 1997-9 Simon Tatham"},
+ StaticText { disabled,"Experimental Mac Port\n© 1997-9 Simon Tatham"},
}
};
/* Licence box */
-resource 'DLOG' (wLicence, "licence", purgeable) {
+resource 'WIND' (wLicence, "licence", purgeable) {
{ 0, 0, 300, 300 },
noGrowDocProc,
visible,
goAway,
wLicence,
- wLicence,
"PuTTY Licence",
alertPositionParentWindowScreen
};
"CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE "
"SOFTWARE."
};
-
-#if 0
-resource 'DITL' (wLicence, "licence", purgeable) {
- {
- { 13, 23, 287, 277 },
- Picture { enabled, wLicence }
- }
-};
-
-resource 'PICT' (wLicence, "licence", purgeable) {
- { 0, 0, 274, 254 },
- VersionTwo {
- {
- LongText { { 16, 0 }, "Copyright © 1997-9 Simon Tatham" },
- LongText { { 32, 0 }, "Portions copyright Gary S. Brown and Eric Young" },
- }
- }
-};
-#endif
#include <Fonts.h>
#include <Gestalt.h>
#include <MacWindows.h>
+#include <Palettes.h>
#include <Quickdraw.h>
#include <QuickdrawText.h>
#include <Sound.h>
#include "mac.h"
struct mac_session {
- short fontnum;
- int font_ascent;
- WindowPtr(window);
- RGBColor defpal[24];
- RGBColor palette[24];
+ short fontnum;
+ int font_ascent;
+ WindowPtr window;
+ PaletteHandle palette;
};
static void mac_initfont(struct mac_session *);
static struct mac_session *onlysession;
+static void inbuf_putc(int c) {
+ inbuf[inbuf_head] = c;
+ inbuf_head = (inbuf_head+1) & INBUF_MASK;
+}
+
+static void inbuf_putstr(const char *c) {
+ while (*c)
+ inbuf_putc(*c++);
+}
+
void mac_newsession(void) {
struct mac_session *s;
int i;
cfg.vtmode = VT_POORMAN;
cfg.try_palette = FALSE;
cfg.bold_colour = TRUE;
- for (i = 0; i < 22; i++) {
- static char defaults[22][3] = {
- {187, 187, 187}, {255, 255, 255},
- {0, 0, 0}, {85, 85, 85},
- {0, 0, 0}, {0, 255, 0},
- {0, 0, 0}, {85, 85, 85},
- {187, 0, 0}, {255, 85, 85},
- {0, 187, 0}, {85, 255, 85},
- {187, 187, 0}, {255, 255, 85},
- {0, 0, 187}, {85, 85, 255},
- {187, 0, 187}, {255, 85, 255},
- {0, 187, 187}, {85, 255, 255},
- {187, 187, 187}, {255, 255, 255}
- };
- cfg.colours[i][0] = defaults[i][0];
- cfg.colours[i][1] = defaults[i][1];
- cfg.colours[i][2] = defaults[i][2];
- }
+ cfg.colours = GetNewPalette(PREF_pltt_ID);
onlysession = s;
- /* XXX: non-Color-QuickDraw? Own storage management? */
+ /* XXX: Own storage management? */
if (mac_qdversion == gestaltOriginalQD)
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
else
term_size(24, 80, 100);
mac_initfont(s);
mac_initpalette(s);
+ /* Set to TRUE to get palette updates in the background. */
+ SetPalette(s->window, s->palette, FALSE);
ShowWindow(s->window);
-}
-
-static void inbuf_putc(int c) {
- inbuf[inbuf_head] = c;
- inbuf_head = (inbuf_head+1) & INBUF_MASK;
-}
+ inbuf_putstr("\033[1mBold\033[m \033[2mfaint\033[m \033[3mitalic\033[m \033[4mu_line\033[m "
+ "\033[5mslow bl\033[m \033[6mfast bl\033[m \033[7minverse\033[m \033[8mconceal\033[m "
+ "\033[9mstruck\033[m \033[21mdbl ul\033[m\015\012");
+ term_out();
+ inbuf_putstr("\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
+ "\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
+ term_out();
+ inbuf_putstr("\033[1m\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
+ "\033[1m\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
+ term_out();
+ inbuf_putstr("\033[37;44mwhite on blue \033[32;41mgreen on red\015\012");
+ term_out();
-static void inbuf_putstr(const char *c) {
- while (*c)
- inbuf_putc(*c++);
}
static void mac_initfont(struct mac_session *s) {
font_height = fi.ascent + fi.descent + fi.leading;
s->font_ascent = fi.ascent;
SizeWindow(s->window, cols * font_width, rows * font_height, true);
- inbuf_putstr("\033[1mBold\033[m \033[2mfaint\033[m \033[3mitalic\033[m \033[4mu_line\033[m "
- "\033[5mslow bl\033[m \033[6mfast bl\033[m \033[7minverse\033[m \033[8mconceal\033[m "
- "\033[9mstruck\033[m \033[21mdbl ul\033[m\015\012");
- term_out();
- inbuf_putstr("\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
- "\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
- term_out();
- inbuf_putstr("\033[1m\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
- "\033[1m\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
- term_out();
- inbuf_putstr("\033[37;44mwhite on blue \033[32;41mgreen on red\015\012");
- term_out();
}
-
-/*
- * Set up the default palette, then call palette_reset to transfer
- * it to the working palette (should the emulator do this at
- * startup?
- */
static void mac_initpalette(struct mac_session *s) {
- int i;
- static const int ww[] = {
- 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21,
- 0, 1, 2, 3, 4, 4, 5, 5
- };
- for (i=0; i<24; i++) {
- int w = ww[i];
- s->defpal[i].red = cfg.colours[w][0] * 0x0101;
- s->defpal[i].green = cfg.colours[w][1] * 0x0101;
- s->defpal[i].blue = cfg.colours[w][2] * 0x0101;
- }
- palette_reset();
+ s->palette = NewPalette(0, NULL, 0, 0);
+ CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
}
-
/*
* Call from the terminal emulator to draw a bit of text
*
int style = 0;
int bgcolour, fgcolour;
RGBColor rgbfore, rgbback;
- RgnHandle textregion, intersection;
Rect textrect;
SetPort(s->window);
-#if 0
+
/* First check this text is relevant */
- textregion = NewRgn();
- SetRectRgn(textregion, x * font_width, (x + len) * font_width,
- y * font_height, (y + 1) * font_height);
- SectRgn(textregion, s->window->visRgn, textregion);
- if (EmptyRgn(textregion)) {
- DisposeRgn(textregion);
- return;
- }
-#else
- /* alternatively */
textrect.top = y * font_height;
textrect.bottom = (y + 1) * font_height;
textrect.left = x * font_width;
textrect.right = (x + len) * font_width;
if (!RectInRgn(&textrect, s->window->visRgn))
return;
-#endif
-
+
TextFont(s->fontnum);
if (cfg.fontisbold || (attr & ATTR_BOLD) && !cfg.bold_colour)
style |= bold;
}
if ((attr & ATTR_BOLD) && cfg.bold_colour)
fgcolour++;
- RGBForeColor(&s->palette[fgcolour]);
- RGBBackColor(&s->palette[bgcolour]);
+ /* RGBForeColor(&s->palette[fgcolour]); */ /* XXX Non-Color-QD version */
+ /* RGBBackColor(&s->palette[bgcolour]); */
+ PmForeColor(fgcolour);
+ PmBackColor(bgcolour);
SetFractEnable(FALSE); /* We want characters on pixel boundaries */
- MoveTo(x * font_width, y * font_height + s->font_ascent);
+ MoveTo(textrect.left, textrect.top + s->font_ascent);
DrawText(text, 0, len);
+
+ /* Tell the window manager about it in case this isn't an update */
+ ValidRect(&textrect);
}
/*
void beep(void) {
SysBeep(30);
+ /*
+ * XXX We should indicate the relevant window and/or use the
+ * Notification Manager
+ */
}
/*
- * Set icon string -- a no-op here (WIndowshade?)
+ * Set icon string -- a no-op here (Windowshade?)
*/
void set_icon(char *icon) {
*/
void set_title(char *title) {
Str255 mactitle;
+ struct mac_session *s = onlysession;
mactitle[0] = sprintf((char *)&mactitle[1], "%s", title);
- SetWTitle(onlysession->window, mactitle);
+ SetWTitle(s->window, mactitle);
}
/*
*/
void request_resize(int w, int h) {
- /* XXX: Do something */
+ cols = w;
+ rows = h;
+ mac_initfont(onlysession);
}
/*
* Set the logical palette
*/
void palette_set(int n, int r, int g, int b) {
-
- /* XXX: Do something */
+ RGBColor col;
+ struct mac_session *s = onlysession;
+ static const int first[21] = {
+ 0, 2, 4, 6, 8, 10, 12, 14,
+ 1, 3, 5, 7, 9, 11, 13, 15,
+ 16, 17, 18, 20, 22
+ };
+
+ col.red = r * 0x0101;
+ col.green = g * 0x0101;
+ col.blue = b * 0x0101;
+ SetEntryColor(s->palette, first[n], &col);
+ if (first[n] >= 18)
+ SetEntryColor(s->palette, first[n]+1, &col);
+ ActivatePalette(s->window);
}
/*
* Reset to the default palette
*/
void palette_reset(void) {
- int i;
struct mac_session *s = onlysession;
- for (i = 0; i < 24; i++) {
- s->palette[i].red = s->defpal[i].red;
- s->palette[i].green = s->defpal[i].green;
- s->palette[i].blue = s->defpal[i].blue;
- }
- term_invalidate();
+ if (mac_qdversion == gestaltOriginalQD)
+ return;
+ CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
+ ActivatePalette(s->window);
+ /* Palette Manager will generate update events as required. */
}