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

Fixes so it runs (with bugs) without Color QuickDraw.

[originally from svn r186]
This commit is contained in:
Ben Harris 1999-07-24 15:51:12 +00:00
parent 346137d280
commit 3b6d5dcf1a
3 changed files with 57 additions and 34 deletions

5
mac.h
View File

@ -7,6 +7,7 @@
#include <MacTypes.h> #include <MacTypes.h>
#include <Events.h> #include <Events.h>
#include <Gestalt.h>
#include <MacWindows.h> #include <MacWindows.h>
struct mac_gestalts { struct mac_gestalts {
@ -18,6 +19,8 @@ struct mac_gestalts {
extern struct mac_gestalts mac_gestalts; extern struct mac_gestalts mac_gestalts;
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
/* from macterm.c */ /* from macterm.c */
extern void mac_newsession(void); extern void mac_newsession(void);
extern void mac_activateterm(WindowPtr, Boolean); extern void mac_activateterm(WindowPtr, Boolean);
@ -32,6 +35,8 @@ extern void mac_menuterm(WindowPtr, short, short);
extern void mac_loadconfig(Config *); extern void mac_loadconfig(Config *);
/* from macnet.c */ /* from macnet.c */
extern void macnet_eventcheck(void); extern void macnet_eventcheck(void);
/* from opentpt.c */
extern void opentpt_shutdown(void);
#endif #endif

View File

@ -1,9 +1,10 @@
/* $Id: maccfg.c,v 1.1.2.5 1999/03/28 02:06:10 ben Exp $ */ /* $Id: maccfg.c,v 1.1.2.6 1999/07/24 15:51:12 ben Exp $ */
/* /*
* maccfg.c -- Mac port configuration * maccfg.c -- Mac port configuration
*/ */
#include <MacMemory.h> #include <MacMemory.h>
#include <Palettes.h>
#include <Resources.h> #include <Resources.h>
#include <TextUtils.h> #include <TextUtils.h>
@ -129,9 +130,11 @@ void mac_loadconfig(Config *cfg) {
/* Colour */ /* Colour */
cfg->try_palette = FALSE; /* XXX */ cfg->try_palette = FALSE; /* XXX */
cfg->bold_colour = (s->colour_flags & BOLD_COLOUR) != 0; cfg->bold_colour = (s->colour_flags & BOLD_COLOUR) != 0;
cfg->colours = GetNewPalette(s->colours_id); if (HAVE_COLOR_QD()) {
if (cfg->colours == NULL) cfg->colours = GetNewPalette(s->colours_id);
fatalbox("Failed to get default palette"); if (cfg->colours == NULL)
fatalbox("Failed to get default palette");
}
/* Selection */ /* Selection */
cfg->implicit_copy = (s->selection_flags & IMPLICIT_COPY) != 0; cfg->implicit_copy = (s->selection_flags & IMPLICIT_COPY) != 0;
get_wordness(s->wordness_id, cfg->wordness); get_wordness(s->wordness_id, cfg->wordness);

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.1.2.34 1999/04/04 18:23:34 ben Exp $ */ /* $Id: macterm.c,v 1.1.2.35 1999/07/24 15:51:12 ben Exp $ */
/* /*
* Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999 Ben Harris * Copyright (c) 1999 Ben Harris
@ -96,11 +96,6 @@ static RoutineDescriptor mac_set_attr_mask_upp =
#define mac_set_attr_mask_upp mac_set_attr_mask #define mac_set_attr_mask_upp mac_set_attr_mask
#endif /* not TARGET_RT_MAC_CFM */ #endif /* not TARGET_RT_MAC_CFM */
/*
* Temporary hack till I get the terminal emulator supporting multiple
* sessions
*/
static void inbuf_putc(Session *s, int c) { static void inbuf_putc(Session *s, int c) {
s->inbuf[s->inbuf_head] = c; s->inbuf[s->inbuf_head] = c;
s->inbuf_head = (s->inbuf_head+1) & INBUF_MASK; s->inbuf_head = (s->inbuf_head+1) & INBUF_MASK;
@ -140,13 +135,13 @@ void mac_newsession(void) {
s = smalloc(sizeof(*s)); s = smalloc(sizeof(*s));
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
mac_loadconfig(&s->cfg); mac_loadconfig(&s->cfg);
s->back = &telnet_backend; s->back = &null_backend;
/* XXX: Own storage management? */ /* XXX: Own storage management? */
if (mac_gestalts.qdvers == gestaltOriginalQD) if (HAVE_COLOR_QD())
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
else
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1); s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
else
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
SetWRefCon(s->window, (long)s); SetWRefCon(s->window, (long)s);
s->scrollbar = GetNewControl(cVScroll, s->window); s->scrollbar = GetNewControl(cVScroll, s->window);
term_init(s); term_init(s);
@ -154,16 +149,18 @@ void mac_newsession(void) {
mac_initfont(s); mac_initfont(s);
mac_initpalette(s); mac_initpalette(s);
s->attr_mask = ATTR_MASK; s->attr_mask = ATTR_MASK;
/* Set to FALSE to not get palette updates in the background. */ if (HAVE_COLOR_QD()) {
SetPalette(s->window, s->palette, TRUE); /* Set to FALSE to not get palette updates in the background. */
ActivatePalette(s->window); SetPalette(s->window, s->palette, TRUE);
ActivatePalette(s->window);
}
ShowWindow(s->window); ShowWindow(s->window);
s->back->init(s); s->back->init(s);
/* starttime = TickCount(); */ starttime = TickCount();
/* display_resource(s, 'pTST', 128); */ display_resource(s, 'pTST', 128);
/* sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime); */ sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime);
/* inbuf_putstr(s, msg); */ inbuf_putstr(s, msg);
/* term_out(s); */ term_out(s);
} }
static void mac_initfont(Session *s) { static void mac_initfont(Session *s) {
@ -209,7 +206,7 @@ static void mac_adjustsize(Session *s, int newrows, int newcols) {
static void mac_initpalette(Session *s) { static void mac_initpalette(Session *s) {
if (mac_gestalts.qdvers == gestaltOriginalQD) if (!HAVE_COLOR_QD())
return; return;
s->palette = NewPalette((*s->cfg.colours)->pmEntries, s->palette = NewPalette((*s->cfg.colours)->pmEntries,
NULL, pmCourteous, 0); NULL, pmCourteous, 0);
@ -226,6 +223,8 @@ static void mac_initpalette(Session *s) {
*/ */
static void mac_adjustwinbg(Session *s) { static void mac_adjustwinbg(Session *s) {
if (!HAVE_COLOR_QD())
return;
#if TARGET_RT_CFM /* XXX doesn't link (at least for 68k) */ #if TARGET_RT_CFM /* XXX doesn't link (at least for 68k) */
if (mac_gestalts.windattr & gestaltWindowMgrPresent) if (mac_gestalts.windattr & gestaltWindowMgrPresent)
SetWindowContentColor(s->window, SetWindowContentColor(s->window,
@ -680,7 +679,10 @@ void mac_activateterm(WindowPtr window, Boolean active) {
if (active) if (active)
ShowControl(s->scrollbar); ShowControl(s->scrollbar);
else { else {
PmBackColor(DEFAULT_BG); /* HideControl clears behind the control */ if (HAVE_COLOR_QD())
PmBackColor(DEFAULT_BG);/* HideControl clears behind the control */
else
BackColor(blackColor);
HideControl(s->scrollbar); HideControl(s->scrollbar);
} }
mac_drawgrowicon(s); mac_drawgrowicon(s);
@ -699,8 +701,13 @@ void mac_updateterm(WindowPtr window) {
(*window->visRgn)->rgnBBox.right, (*window->visRgn)->rgnBBox.right,
(*window->visRgn)->rgnBBox.bottom); (*window->visRgn)->rgnBBox.bottom);
/* Restore default colours in case the Window Manager uses them */ /* Restore default colours in case the Window Manager uses them */
PmForeColor(DEFAULT_FG); if (HAVE_COLOR_QD()) {
PmBackColor(DEFAULT_BG); PmForeColor(DEFAULT_FG);
PmBackColor(DEFAULT_BG);
} else {
ForeColor(whiteColor);
BackColor(blackColor);
}
if (FrontWindow() != window) if (FrontWindow() != window)
EraseRect(&(*s->scrollbar)->contrlRect); EraseRect(&(*s->scrollbar)->contrlRect);
UpdateControls(window, window->visRgn); UpdateControls(window, window->visRgn);
@ -771,7 +778,7 @@ void do_text(Session *s, int x, int y, char *text, int len,
TextFace(style); TextFace(style);
TextSize(s->cfg.fontheight); TextSize(s->cfg.fontheight);
SetFractEnable(FALSE); /* We want characters on pixel boundaries */ SetFractEnable(FALSE); /* We want characters on pixel boundaries */
if (mac_gestalts.qdvers > gestaltOriginalQD) if (HAVE_COLOR_QD())
if (style & bold) { if (style & bold) {
SpaceExtra(s->font_boldadjust << 16); SpaceExtra(s->font_boldadjust << 16);
CharExtra(s->font_boldadjust << 16); CharExtra(s->font_boldadjust << 16);
@ -781,10 +788,10 @@ void do_text(Session *s, int x, int y, char *text, int len,
} }
textrgn = NewRgn(); textrgn = NewRgn();
RectRgn(textrgn, &a.textrect); RectRgn(textrgn, &a.textrect);
if (mac_gestalts.qdvers == gestaltOriginalQD) if (HAVE_COLOR_QD())
do_text_for_device(1, 0, NULL, (long)&a);
else
DeviceLoop(textrgn, &do_text_for_device_upp, (long)&a, 0); DeviceLoop(textrgn, &do_text_for_device_upp, (long)&a, 0);
else
do_text_for_device(1, 0, NULL, (long)&a);
DisposeRgn(textrgn); DisposeRgn(textrgn);
/* Tell the window manager about it in case this isn't an update */ /* Tell the window manager about it in case this isn't an update */
ValidRect(&a.textrect); ValidRect(&a.textrect);
@ -843,6 +850,7 @@ static pascal void do_text_for_device(short depth, short devflags,
else else
EraseRect(&a->leadrect); EraseRect(&a->leadrect);
MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent); MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent);
/* FIXME: Sort out bold width adjustments on Original QuickDraw. */
DrawText(a->text, 0, a->len); DrawText(a->text, 0, a->len);
if (a->attr & ATTR_PASCURS) { if (a->attr & ATTR_PASCURS) {
@ -866,7 +874,10 @@ static pascal void do_text_for_device(short depth, short devflags,
void pre_paint(Session *s) { void pre_paint(Session *s) {
s->attr_mask = ATTR_INVALID; s->attr_mask = ATTR_INVALID;
DeviceLoop(s->window->visRgn, &mac_set_attr_mask_upp, (long)s, 0); if (HAVE_COLOR_QD())
DeviceLoop(s->window->visRgn, &mac_set_attr_mask_upp, (long)s, 0);
else
mac_set_attr_mask(1, 0, NULL, (long)s);
} }
static pascal void mac_set_attr_mask(short depth, short devflags, static pascal void mac_set_attr_mask(short depth, short devflags,
@ -966,7 +977,7 @@ void palette_set(Session *s, int n, int r, int g, int b) {
16, 17, 18, 20, 22 16, 17, 18, 20, 22
}; };
if (mac_gestalts.qdvers == gestaltOriginalQD) if (!HAVE_COLOR_QD())
return; return;
col.red = r * 0x0101; col.red = r * 0x0101;
col.green = g * 0x0101; col.green = g * 0x0101;
@ -984,7 +995,7 @@ void palette_set(Session *s, int n, int r, int g, int b) {
*/ */
void palette_reset(Session *s) { void palette_reset(Session *s) {
if (mac_gestalts.qdvers == gestaltOriginalQD) if (!HAVE_COLOR_QD())
return; return;
CopyPalette(s->cfg.colours, s->palette, 0, 0, CopyPalette(s->cfg.colours, s->palette, 0, 0,
(*s->cfg.colours)->pmEntries); (*s->cfg.colours)->pmEntries);
@ -1001,8 +1012,12 @@ void do_scroll(Session *s, int topline, int botline, int lines) {
Rect r; Rect r;
RgnHandle update; RgnHandle update;
/* FIXME: This is seriously broken on Original QuickDraw. No idea why. */
SetPort(s->window); SetPort(s->window);
PmBackColor(DEFAULT_BG); if (HAVE_COLOR_QD())
PmBackColor(DEFAULT_BG);
else
BackColor(blackColor);
update = NewRgn(); update = NewRgn();
SetRect(&r, 0, topline * s->font_height, SetRect(&r, 0, topline * s->font_height,
s->cols * s->font_width, (botline + 1) * s->font_height); s->cols * s->font_width, (botline + 1) * s->font_height);