-/* $Id: mac.c,v 1.44 2003/02/04 00:33:11 ben Exp $ */
+/* $Id: mac.c,v 1.45 2003/02/04 23:39:26 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
/*
* Work out what kind of window we're dealing with.
- * Concept shamelessly nicked from SurfWriter.
*/
-static int mac_windowtype(WindowPtr window) {
- int kind;
- long refcon;
-
- if (window == NULL)
- return wNone;
- kind = GetWindowKind(window);
- if (kind < 0)
+static int mac_windowtype(WindowPtr window)
+{
+
+#if !TARGET_API_MAC_CARBON
+ if (GetWindowKind(window) < 0)
return wDA;
- if (GetWVariant(window) == zoomDocProc)
- return wTerminal;
- refcon = GetWRefCon(window);
- if (refcon < 1024)
- return refcon;
- else
- return wSettings;
+#endif
+ return ((WinInfo *)GetWRefCon(window))->wtype;
}
/*
VersRecHndl vers;
Rect box;
StringPtr longvers;
+ WinInfo *wi;
if (windows.about)
SelectWindow(windows.about);
else {
windows.about =
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
+ wi = smalloc(sizeof(*wi));
+ wi->s = NULL;
+ wi->wtype = wAbout;
+ SetWRefCon(windows.about, (long)wi);
vers = (VersRecHndl)Get1Resource('vers', 1);
if (vers != NULL && *vers != NULL) {
longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
}
static void mac_openlicence(void) {
+ WinInfo *wi;
if (windows.licence)
SelectWindow(windows.licence);
else {
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
+ wi = smalloc(sizeof(*wi));
+ wi->s = NULL;
+ wi->wtype = wLicence;
+ SetWRefCon(windows.licence, (long)wi);
ShowWindow(windows.licence);
}
}
switch (mac_windowtype(window)) {
#if !TARGET_API_MAC_CARBON
case wDA:
- CloseDeskAcc(((WindowPeek)window)->windowKind);
+ CloseDeskAcc(GetWindowKind(window));
break;
#endif
case wTerminal:
-/* $Id: macdlg.c,v 1.10 2003/02/02 15:59:00 ben Exp $ */
+/* $Id: macdlg.c,v 1.11 2003/02/04 23:39:26 ben Exp $ */
/*
* Copyright (c) 2002 Ben Harris
* All rights reserved.
void mac_dupsession(void)
{
- Session *s1 = (Session *)GetWRefCon(FrontWindow());
+ Session *s1 = mac_windowsession(FrontWindow());
Session *s2;
s2 = smalloc(sizeof(*s2));
void mac_savesession(void)
{
- Session *s = (Session *)GetWRefCon(FrontWindow());
+ Session *s = mac_windowsession(FrontWindow());
void *sesshandle;
assert(s->hasfile);
void mac_savesessionas(void)
{
#if !TARGET_API_MAC_CARBON /* XXX Navigation Services */
- Session *s = (Session *)GetWRefCon(FrontWindow());
+ Session *s = mac_windowsession(FrontWindow());
StandardFileReply sfr;
void *sesshandle;
void mac_clickdlg(WindowPtr window, EventRecord *event)
{
short item;
- Session *s = (Session *)GetWRefCon(window);
+ Session *s = mac_windowsession(window);
DialogRef dialog = GetDialogFromWindow(window);
if (DialogSelect(event, &dialog, &item))
-/* $Id: macterm.c,v 1.67 2003/02/04 02:08:03 ben Exp $ */
+/* $Id: macterm.c,v 1.68 2003/02/04 23:39:26 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
{
char *errmsg;
int i;
+ WinInfo *wi;
init_ucs(s);
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
else
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
- SetWRefCon(s->window, (long)s);
+ wi = smalloc(sizeof(*wi));
+ wi->s = s;
+ wi->wtype = wTerminal;
+ SetWRefCon(s->window, (long)wi);
s->scrollbar = GetNewControl(cVScroll, s->window);
s->term = term_init(&s->cfg, &s->ucsdata, s);
#endif
SetPort((GrafPtr)GetWindowPort(window));
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
GlobalToLocal(&mouse);
part = FindControl(mouse, window, &control);
if (control == s->scrollbar) {
long offset;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
menu = GetMenuHandle(mFile);
DisableItem(menu, iSave); /* XXX enable if modified */
EnableItem(menu, iSaveAs);
void mac_menuterm(WindowPtr window, short menu, short item) {
Session *s;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
switch (menu) {
case mEdit:
switch (item) {
int part;
static ControlActionUPP mac_scrolltracker_upp = NULL;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
SetPort((GrafPtr)GetWindowPort(window));
mouse = event->where;
GlobalToLocal(&mouse);
Session *s;
#if TARGET_API_MAC_CARBON
- s = (Session *)GetWRefCon(GetControlOwner(control));
+ s = mac_windowsession(GetControlOwner(control));
#else
- s = (Session *)GetWRefCon((*control)->contrlOwner);
+ s = mac_windowsession((*control)->contrlOwner);
#endif
switch (part) {
case kControlUpButtonPart:
}
void mac_keyterm(WindowPtr window, EventRecord *event) {
- Session *s = (Session *)GetWRefCon(window);
+ Session *s = mac_windowsession(window);
Key_Sym keysym = PK_NULL;
unsigned int mods = 0, flags = PKF_NUMLOCK;
UniChar utxt[1];
FontInfo fi;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
#if !TARGET_API_MAC_CARBON
draghooksave = LMGetDragHook();
void mac_closeterm(WindowPtr window)
{
- Session *s = (Session *)GetWRefCon(window);
+ Session *s = mac_windowsession(window);
/* XXX warn on close */
HideWindow(s->window);
if (s->uni_to_font != NULL)
DisposeUnicodeToTextInfo(&s->uni_to_font);
term_free(s->term);
+ sfree((WinInfo *)GetWRefCon(s->window));
DisposeWindow(s->window);
DisposePalette(s->palette);
sfree(s);
void mac_activateterm(WindowPtr window, Boolean active) {
Session *s;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
s->term->has_focus = active;
term_update(s->term);
if (active)
RgnHandle visrgn;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
SetPort((GrafPtr)GetWindowPort(window));
BeginUpdate(window);
pre_paint(s);