1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-26 15:22:09 -05:00

macterm.c

[originally from svn r108]
This commit is contained in:
Ben Harris 1999-03-15 14:22:45 +00:00
parent 0e1e0363cd
commit f5741e4364

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.1.2.23 1999/03/14 20:43:51 ben Exp $ */ /* $Id: macterm.c,v 1.1.2.24 1999/03/15 14:22:45 ben Exp $ */
/* /*
* Copyright (c) 1999 Ben Harris * Copyright (c) 1999 Ben Harris
* All rights reserved. * All rights reserved.
@ -45,6 +45,7 @@
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "macresid.h" #include "macresid.h"
#include "putty.h" #include "putty.h"
@ -70,10 +71,12 @@ struct mac_session {
WindowPtr window; WindowPtr window;
PaletteHandle palette; PaletteHandle palette;
ControlHandle scrollbar; ControlHandle scrollbar;
WCTabHandle wctab;
}; };
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_adjustwinbg(struct mac_session *);
static void mac_adjustsize(struct mac_session *, int, int); static void mac_adjustsize(struct mac_session *, int, int);
static pascal void mac_scrolltracker(ControlHandle, short); static pascal void mac_scrolltracker(ControlHandle, short);
static pascal void do_text_for_device(short, short, GDHandle, long); static pascal void do_text_for_device(short, short, GDHandle, long);
@ -128,6 +131,7 @@ void mac_newsession(void) {
mac_loadconfig(&cfg); mac_loadconfig(&cfg);
/* back = &loop_backend; */ /* back = &loop_backend; */
s = smalloc(sizeof(*s)); s = smalloc(sizeof(*s));
memset(s, 0, sizeof(*s));
onlysession = s; onlysession = s;
/* XXX: Own storage management? */ /* XXX: Own storage management? */
@ -189,7 +193,6 @@ static void mac_adjustsize(struct mac_session *s, int newrows, int newcols) {
} }
static void mac_initpalette(struct mac_session *s) { static void mac_initpalette(struct mac_session *s) {
WinCTab ct;
if (mac_gestalts.qdvers == gestaltOriginalQD) if (mac_gestalts.qdvers == gestaltOriginalQD)
return; return;
@ -197,22 +200,24 @@ static void mac_initpalette(struct mac_session *s) {
if (s->palette == NULL) if (s->palette == NULL)
fatalbox("Unable to create palette"); fatalbox("Unable to create palette");
CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries); CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
mac_adjustwinbg(s);
} }
/* /*
* I don't think this is (a) safe or (b) a good way to do this. * I don't think this is (a) safe or (b) a good way to do this.
*/ */
static void mac_updatewinbg(struct mac_session *s) { static void mac_adjustwinbg(struct mac_session *s) {
WinCTab ct;
WCTabPtr ctp = &ct;
WCTabHandle cth = &ctp;
ct.wCSeed = 0; if (s->wctab == NULL)
ct.wCReserved = 0; s->wctab = (WCTabHandle)NewHandle(sizeof(**s->wctab));
ct.ctSize = 1; if (s->wctab == NULL)
ct.ctTable[0].value = wContentColor; return; /* do without */
ct.ctTable[0].rgb = (*s->palette)->pmInfo[16].ciRGB; (*s->wctab)->wCSeed = 0;
SetWinColor(s->window, cth); (*s->wctab)->wCReserved = 0;
(*s->wctab)->ctSize = 0;
(*s->wctab)->ctTable[0].value = wContentColor;
(*s->wctab)->ctTable[0].rgb = (*s->palette)->pmInfo[DEFAULT_BG].ciRGB;
SetWinColor(s->window, s->wctab);
} }
/* /*
@ -825,6 +830,8 @@ void palette_set(int n, int r, int g, int b) {
SetEntryColor(s->palette, first[n], &col); SetEntryColor(s->palette, first[n], &col);
if (first[n] >= 18) if (first[n] >= 18)
SetEntryColor(s->palette, first[n]+1, &col); SetEntryColor(s->palette, first[n]+1, &col);
if (first[n] == DEFAULT_BG)
mac_adjustwinbg(s);
ActivatePalette(s->window); ActivatePalette(s->window);
} }
@ -837,6 +844,7 @@ void palette_reset(void) {
if (mac_gestalts.qdvers == gestaltOriginalQD) if (mac_gestalts.qdvers == gestaltOriginalQD)
return; return;
CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries); CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
mac_adjustwinbg(s);
ActivatePalette(s->window); ActivatePalette(s->window);
/* Palette Manager will generate update events as required. */ /* Palette Manager will generate update events as required. */
} }