Macintosh port update
Several long-awaited updates for the Macintosh port, by Dean Luick and myself. This set affects Mac-only files. * Update the support for MPW compilers. * Use new system call names provided for in the latest Apple Universal Headers. * Tune up some of the includes for CodeWarrior. * Define YY_NEVER_INTERACTIVE for the dungeon and level compilers. * Remove pointless debugging code. * Clean up some unterminated comments.
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
/* Copyright (c) Michael Hamel, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifdef applec /* This needs to be resident always */
|
||||
#if defined(macintosh) && defined(__SC__) && !defined(__FAR_CODE__)
|
||||
/* this needs to be resident always */
|
||||
#pragma segment Main
|
||||
#endif
|
||||
|
||||
@@ -12,6 +13,25 @@
|
||||
#include <TextUtils.h>
|
||||
#include <Resources.h>
|
||||
|
||||
|
||||
void error(const char *format,...)
|
||||
{
|
||||
Str255 buf;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vsprintf((char *)buf, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
C2P((char *)buf, buf);
|
||||
ParamText(buf, (StringPtr)"", (StringPtr)"", (StringPtr)"");
|
||||
Alert(128, (ModalFilterUPP) NULL);
|
||||
ExitToShell();
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* Remainder of file is obsolete and will be removed */
|
||||
|
||||
#define stackDepth 1
|
||||
#define errAlertID 129
|
||||
#define stdIOErrID 1999
|
||||
@@ -33,7 +53,6 @@ void showerror(char * errdesc, const char * errcomment)
|
||||
itemHit = Alert(errAlertID, (ModalFilterUPP)nil);
|
||||
}
|
||||
|
||||
|
||||
Boolean itworked(short errcode)
|
||||
/* Return TRUE if it worked, do an error message and return false if it didn't. Error
|
||||
strings for native C errors are in STR#1999, Mac errs in STR 2000-errcode, e.g
|
||||
@@ -111,13 +130,13 @@ error VA_DECL(const char *, line)
|
||||
showerror("of an internal error",line);
|
||||
}
|
||||
|
||||
|
||||
void attemptingto(char * activity)
|
||||
/* Say what we are trying to do for subsequent error-handling: will appear as x in an
|
||||
alert in the form "Could not x because y" */
|
||||
{ C2P(activity,gActivities[gTopactivity]);
|
||||
}
|
||||
|
||||
#if 0 /* Apparently unused */
|
||||
void comment(char *s, long n)
|
||||
{
|
||||
Str255 paserr;
|
||||
@@ -145,4 +164,5 @@ void popattempt(void)
|
||||
if (gTopactivity > 1) --gTopactivity;
|
||||
else error("activity stack underflow");
|
||||
}
|
||||
#endif /* Apparently unused */
|
||||
|
||||
#endif /* Obsolete */
|
||||
|
||||
@@ -66,7 +66,6 @@ static int
|
||||
OpenHandleFile (const unsigned char *name, long fileType)
|
||||
{
|
||||
int i;
|
||||
OSErr err;
|
||||
Handle h;
|
||||
Str255 s;
|
||||
|
||||
@@ -74,15 +73,11 @@ OpenHandleFile (const unsigned char *name, long fileType)
|
||||
if (theHandleFiles[i].data == 0L) break;
|
||||
}
|
||||
|
||||
if (i >= MAX_HF) {
|
||||
error("Ran out of HandleFiles");
|
||||
if (i >= MAX_HF)
|
||||
return -1;
|
||||
}
|
||||
|
||||
h = GetNamedResource (fileType, name);
|
||||
err = ResError();
|
||||
if (err == resNotFound) return -1; /* Don't complain, this might be normal */
|
||||
if (!itworked(err)) return -1;
|
||||
if (!h) return (-1);
|
||||
|
||||
theHandleFiles[i].data = h;
|
||||
theHandleFiles[i].size = GetHandleSize (h);
|
||||
@@ -97,7 +92,6 @@ static int
|
||||
CloseHandleFile (int fd)
|
||||
{
|
||||
if (!IsHandleFile (fd)) {
|
||||
error("CloseHandleFile: isn't a handle");
|
||||
return -1;
|
||||
}
|
||||
fd -= FIRST_HF;
|
||||
@@ -298,26 +292,15 @@ macread (int fd, void *ptr, unsigned len)
|
||||
long amt = len;
|
||||
|
||||
if (IsHandleFile (fd)) {
|
||||
|
||||
return ReadHandleFile (fd, ptr, amt);
|
||||
} else {
|
||||
|
||||
short err = FSRead (fd, &amt, ptr);
|
||||
if (err == eofErr && len) {
|
||||
|
||||
return amt;
|
||||
}
|
||||
if (itworked (err)) {
|
||||
|
||||
return (amt);
|
||||
|
||||
} else {
|
||||
|
||||
return -1;
|
||||
}
|
||||
return ((err == noErr) || (err == eofErr && len)) ? amt : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* this function isn't used, if you use it, uncomment prototype in macwin.h */
|
||||
char *
|
||||
macgets (int fd, char *ptr, unsigned len)
|
||||
@@ -344,9 +327,10 @@ macwrite (int fd, void *ptr, unsigned len)
|
||||
long amt = len;
|
||||
|
||||
if (IsHandleFile (fd)) return -1;
|
||||
|
||||
if (itworked(FSWrite (fd, &amt, ptr))) return(amt);
|
||||
else return(-1);
|
||||
if (FSWrite(fd, &amt, ptr) == noErr)
|
||||
return (amt);
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -372,12 +356,13 @@ macseek (int fd, long where, short whence)
|
||||
break;
|
||||
}
|
||||
|
||||
if (itworked(SetFPos (fd, posMode, where)) && itworked(GetFPos (fd, &curPos)))
|
||||
return(curPos);
|
||||
|
||||
return(-1);
|
||||
if (SetFPos(fd, posMode, where) == noErr && GetFPos(fd, &curPos) == noErr)
|
||||
return (curPos);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
boolean rsrc_dlb_init(void) {
|
||||
|
||||
@@ -12,27 +12,23 @@
|
||||
#include <OSUtils.h>
|
||||
#include <files.h>
|
||||
#include <Types.h>
|
||||
#ifdef MAC_MPW32
|
||||
#include <String.h>
|
||||
#include <Strings.h>
|
||||
#endif
|
||||
#include <Dialogs.h>
|
||||
#include <Packages.h>
|
||||
#include <ToolUtils.h>
|
||||
#include <Resources.h>
|
||||
#ifdef applec
|
||||
#include <SysEqu.h>
|
||||
#endif
|
||||
#include <Errors.h>
|
||||
|
||||
#ifndef O_RDONLY
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
finder_file_request(void);
|
||||
static void finder_file_request(void);
|
||||
int main(void);
|
||||
|
||||
#if __SC__ || __MRC__
|
||||
QDGlobals qd;
|
||||
#endif
|
||||
|
||||
int NDECL(main);
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
||||
@@ -288,11 +288,11 @@ ask_enable (WindowPtr wind, short item, int enable)
|
||||
|
||||
|
||||
/* Enable or disable the appropriate item */
|
||||
GetDItem(wind, item, &type, &handle, &rect);
|
||||
GetDialogItem(wind, item, &type, &handle, &rect);
|
||||
if (enable) type &= ~itemDisable;
|
||||
else type |= itemDisable;
|
||||
HiliteControl((ControlHandle)handle, enable ? 0 : 255);
|
||||
SetDItem(wind, item, type, handle, &rect);
|
||||
SetDialogItem(wind, item, type, handle, &rect);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ ask_redraw (WindowPtr wind, DialogItemIndex item)
|
||||
|
||||
|
||||
/* Which item shall we redraw? */
|
||||
GetDItem(wind, item, &type, &handle, &rect);
|
||||
GetDialogItem(wind, item, &type, &handle, &rect);
|
||||
switch (item) {
|
||||
case RSRC_ASK_DEFAULT:
|
||||
PenSize(3, 3);
|
||||
@@ -510,8 +510,8 @@ void mac_askname ()
|
||||
/* Initialize the name text item */
|
||||
ask_restring(plname, str);
|
||||
if (plname[0]) {
|
||||
GetDItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetIText(handle, str);
|
||||
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetDialogItemText(handle, str);
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
@@ -534,8 +534,8 @@ void mac_askname ()
|
||||
}
|
||||
}
|
||||
if (pName [0]) {
|
||||
GetDItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetIText(handle, pName);
|
||||
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetDialogItemText(handle, pName);
|
||||
if (pName [0] > 2 && pName [pName [0] - 1] == '-') {
|
||||
short role = (*pANR).anMenu[anRole];
|
||||
char suffix = (char) pName[pName[0]],
|
||||
@@ -550,7 +550,7 @@ void mac_askname ()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SelIText(askdialog, RSRC_ASK_NAME, 0, 32767);
|
||||
SelectDialogItemText(askdialog, RSRC_ASK_NAME, 0, 32767);
|
||||
|
||||
/* Initialize the role popup menu */
|
||||
if (!(askmenu[RSRC_ASK_ROLE] = NewMenu(RSRC_ASK_ROLE, "\p")))
|
||||
@@ -620,8 +620,8 @@ void mac_askname ()
|
||||
|
||||
/* Set the redraw procedures */
|
||||
for (item = RSRC_ASK_DEFAULT; item <= RSRC_ASK_MODE; item++) {
|
||||
GetDItem(askdialog, item, &type, &handle, &rect);
|
||||
SetDItem(askdialog, item, type, (Handle)redraw, &rect);
|
||||
GetDialogItem(askdialog, item, &type, &handle, &rect);
|
||||
SetDialogItem(askdialog, item, type, (Handle)redraw, &rect);
|
||||
}
|
||||
|
||||
/* Handle dialog events */
|
||||
@@ -646,7 +646,7 @@ void mac_askname ()
|
||||
if (!races[++j].noun) j = 0;
|
||||
} while (i != j);
|
||||
if (currrace != i) {
|
||||
GetDItem(askdialog, RSRC_ASK_RACE, &type, &handle, &rect);
|
||||
GetDialogItem(askdialog, RSRC_ASK_RACE, &type, &handle, &rect);
|
||||
InvalRect(&rect);
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ void mac_askname ()
|
||||
if (++j >= ROLE_GENDERS) j = 0;
|
||||
} while (i != j);
|
||||
if (currgend != i) {
|
||||
GetDItem(askdialog, RSRC_ASK_GEND, &type, &handle, &rect);
|
||||
GetDialogItem(askdialog, RSRC_ASK_GEND, &type, &handle, &rect);
|
||||
InvalRect(&rect);
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ void mac_askname ()
|
||||
if (++j >= ROLE_ALIGNS) j = 0;
|
||||
} while (i != j);
|
||||
if (curralign != i) {
|
||||
GetDItem(askdialog, RSRC_ASK_ALIGN, &type, &handle, &rect);
|
||||
GetDialogItem(askdialog, RSRC_ASK_ALIGN, &type, &handle, &rect);
|
||||
InvalRect(&rect);
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ void mac_askname ()
|
||||
for (i = 0; roles[i].name.m; i++) {
|
||||
ask_restring((currgend && roles[i].name.f) ?
|
||||
roles[i].name.f : roles[i].name.m, str);
|
||||
SetItem(askmenu[RSRC_ASK_ROLE], i+1, str);
|
||||
SetMenuItemText(askmenu[RSRC_ASK_ROLE], i+1, str);
|
||||
CheckItem(askmenu[RSRC_ASK_ROLE], i+1, currrole == i);
|
||||
}
|
||||
|
||||
@@ -718,7 +718,7 @@ void mac_askname ()
|
||||
case RSRC_ASK_ALIGN:
|
||||
case RSRC_ASK_GEND:
|
||||
case RSRC_ASK_MODE:
|
||||
GetDItem(askdialog, item, &type, &handle, &rect);
|
||||
GetDialogItem(askdialog, item, &type, &handle, &rect);
|
||||
pt = *(Point *)▭
|
||||
LocalToGlobal(&pt);
|
||||
if (!!(i = PopUpMenuSelect(askmenu[item], pt.v, pt.h,
|
||||
@@ -749,8 +749,8 @@ void mac_askname ()
|
||||
} while ((item != RSRC_ASK_PLAY) && (item != RSRC_ASK_QUIT));
|
||||
|
||||
/* Process the name */
|
||||
GetDItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
GetIText(handle, str);
|
||||
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
GetDialogItemText(handle, str);
|
||||
if (str[0] > PL_NSIZ-1) str[0] = PL_NSIZ-1;
|
||||
BlockMove(&str[1], plname, str[0]);
|
||||
plname[str[0]] = '\0';
|
||||
@@ -1151,7 +1151,7 @@ askQuit()
|
||||
|
||||
ParamText("\pReally Quit?", "\p", "\p", "\p");
|
||||
itemHit = Alert(alrtMenu_NY, (ModalFilterUPP) 0L);
|
||||
ResetAlrtStage();
|
||||
ResetAlertStage();
|
||||
|
||||
if (itemHit != bttnMenuAlertYes) {
|
||||
doQuit = 0;
|
||||
|
||||
@@ -55,9 +55,8 @@ mac_speaker (struct obj *instr, char *melody) {
|
||||
/*
|
||||
* Set up the synth
|
||||
*/
|
||||
if (itworked (SndNewChannel (&theChannel, sampledSynth, initMono +
|
||||
initNoInterp, (void *) 0))) {
|
||||
|
||||
if (SndNewChannel(&theChannel, sampledSynth, initMono +
|
||||
initNoInterp, (void *) 0) == noErr) {
|
||||
char midi_note [] = {57, 59, 60, 62, 64, 65, 67};
|
||||
|
||||
short err;
|
||||
@@ -89,8 +88,6 @@ mac_speaker (struct obj *instr, char *melody) {
|
||||
}
|
||||
SndDisposeChannel (theChannel, false); /* Sync wait for completion */
|
||||
ReleaseResource (theSound);
|
||||
|
||||
mustwork (err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mactopl.c 3.1 91/07/23
|
||||
/* SCCS Id: @(#)mactopl.c 3.1 91/07/23 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
#ifndef __MWERKS__
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
int
|
||||
|
||||
@@ -8,32 +8,15 @@
|
||||
#include "mactty.h"
|
||||
#include "wintty.h"
|
||||
|
||||
#if defined(applec)
|
||||
#include <sysequ.h>
|
||||
#else
|
||||
#include <LowMem.h>
|
||||
#endif
|
||||
#include <AppleEvents.h>
|
||||
#include <Gestalt.h>
|
||||
#include <TextUtils.h>
|
||||
#include <DiskInit.h>
|
||||
#include <ControlDefinitions.h>
|
||||
|
||||
NhWindow *theWindows = (NhWindow *) 0;
|
||||
|
||||
#ifndef USESROUTINEDESCRIPTORS /* not using universal headers */
|
||||
/* Cast everything in terms of the new Low Memory function calls. */
|
||||
# if defined(applec)
|
||||
# define LMGetCurStackBase() (*(long *) CurStackBase)
|
||||
# define LMGetDefltStack() (*(long *) DefltStack)
|
||||
# elif defined(THINK_C)
|
||||
# define LMGetCurStackBase() CurStackBase
|
||||
# define LMGetDefltStack() (*(long *) DefltStack)
|
||||
# elif defined(__MWERKS__)
|
||||
# else
|
||||
# error /* need to define LM functions for this compiler */
|
||||
# endif
|
||||
#endif /* !USEROUTINEDESCRIPTORS (universal headers) */
|
||||
|
||||
/* Borrowed from the Mac tty port */
|
||||
extern WindowPtr _mt_window;
|
||||
|
||||
@@ -355,13 +338,13 @@ InitMac(void) {
|
||||
/* set up base fonts for all window types */
|
||||
GetFNum ("\pHackFont", &i);
|
||||
if (i == 0)
|
||||
i = monaco;
|
||||
i = kFontIDMonaco;
|
||||
win_fonts [NHW_BASE] = win_fonts [NHW_MAP] = win_fonts [NHW_STATUS] = i;
|
||||
GetFNum ("\pPSHackFont", &i);
|
||||
if (i == 0)
|
||||
i = geneva;
|
||||
i = kFontIDGeneva;
|
||||
win_fonts [NHW_MESSAGE] = i;
|
||||
win_fonts [NHW_TEXT] = geneva;
|
||||
win_fonts [NHW_TEXT] = kFontIDGeneva;
|
||||
|
||||
macFlags.hasAE = 0;
|
||||
if(!Gestalt(gestaltAppleEventsAttr, &l) && (l & (1L << gestaltAppleEventsPresent))){
|
||||
@@ -685,7 +668,8 @@ mac_init_nhwindows (int *argcp, char **argv) {
|
||||
InitMenuRes ();
|
||||
|
||||
theWindows = (NhWindow *) NewPtrClear (NUM_MACWINDOWS * sizeof (NhWindow));
|
||||
mustwork(MemError());
|
||||
if (MemError())
|
||||
error("mac_init_nhwindows: Couldn't allocate memory for windows.");
|
||||
|
||||
DimMenuBar ();
|
||||
|
||||
@@ -808,7 +792,7 @@ topl_resp_rect(int resp_idx, Rect *r) {
|
||||
void
|
||||
enter_topl_mode(char *query) {
|
||||
if (in_topl_mode())
|
||||
Debugger();
|
||||
return;
|
||||
|
||||
putstr(WIN_MESSAGE, ATR_BOLD, query);
|
||||
|
||||
@@ -832,7 +816,7 @@ leave_topl_mode(char *answer) {
|
||||
NhWindow *aWin = theWindows + WIN_MESSAGE;
|
||||
|
||||
if (!in_topl_mode())
|
||||
Debugger();
|
||||
return;
|
||||
|
||||
/* remove unprintables from the answer */
|
||||
for (ap = *(*top_line)->hText + topl_query_len, bp = answer; ans_len > 0; ans_len--, ap++) {
|
||||
@@ -1147,7 +1131,7 @@ mac_destroy_nhwindow (winid win) {
|
||||
if (iflags.window_inited) {
|
||||
if (flags.tombstone && killer) {
|
||||
/* Prepare for the coming of the tombstone window. */
|
||||
win_fonts [NHW_TEXT] = monaco;
|
||||
win_fonts [NHW_TEXT] = kFontIDMonaco;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1160,7 +1144,7 @@ mac_destroy_nhwindow (winid win) {
|
||||
if ((!((WindowPeek) theWindow)->visible || (kind != NHW_MENU && kind != NHW_TEXT))) {
|
||||
DisposeWindow (theWindow);
|
||||
if (aWin->windowText) {
|
||||
DisposHandle (aWin->windowText);
|
||||
DisposeHandle (aWin->windowText);
|
||||
}
|
||||
aWin->its_window = (WindowPtr) 0;
|
||||
aWin->windowText = (Handle) 0;
|
||||
@@ -1477,7 +1461,7 @@ macClickTerm (EventRecord *theEvent, WindowPtr theWindow) {
|
||||
where.v = where.v / nhw->row_height;
|
||||
clicked_mod = (theEvent->modifiers & shiftKey) ? CLICK_2 : CLICK_1;
|
||||
|
||||
if (strchr(topl_resp, click_to_cmd(where.h, where.v, clicked_mod)))
|
||||
if (strchr(topl_resp, *click_to_cmd(where.h, where.v, clicked_mod)))
|
||||
nhbell();
|
||||
else {
|
||||
if (cursor_locked)
|
||||
@@ -1595,8 +1579,6 @@ mac_doprev_message(void) {
|
||||
|
||||
static short
|
||||
macDoNull (EventRecord *theEvent, WindowPtr theWindow) {
|
||||
if (!theEvent || !theWindow)
|
||||
Debugger ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1626,9 +1608,8 @@ macUpdateMessage (EventRecord *theEvent, WindowPtr theWindow) {
|
||||
NhWindow *aWin = GetNhWin (theWindow);
|
||||
int l;
|
||||
|
||||
if (!theEvent) {
|
||||
Debugger ();
|
||||
}
|
||||
if (!theEvent)
|
||||
return 0;
|
||||
|
||||
GetClip(org_clip);
|
||||
|
||||
@@ -1666,7 +1647,7 @@ macUpdateMessage (EventRecord *theEvent, WindowPtr theWindow) {
|
||||
name = tmp;
|
||||
break;
|
||||
}
|
||||
TextFont(geneva);
|
||||
TextFont(kFontIDGeneva);
|
||||
TextSize(9);
|
||||
GetFontInfo(&font);
|
||||
MoveTo ((frame.left + frame.right - StringWidth(name)) / 2,
|
||||
@@ -1770,9 +1751,8 @@ GeneralUpdate (EventRecord *theEvent, WindowPtr theWindow) {
|
||||
RgnHandle h;
|
||||
Boolean vis;
|
||||
|
||||
if (!theEvent) {
|
||||
Debugger ();
|
||||
}
|
||||
if (!theEvent)
|
||||
return 0;
|
||||
|
||||
r2.left = r2.right - SBARWIDTH;
|
||||
r2.right += 1;
|
||||
@@ -1829,7 +1809,7 @@ macCursorTerm (EventRecord *theEvent, WindowPtr theWindow, RgnHandle mouseRgn) {
|
||||
|
||||
GlobalToLocal (&where);
|
||||
dir_bas = iflags.num_pad ? (char *) ndir : (char *) sdir;
|
||||
dir = strchr (dir_bas, click_to_cmd (where.h / nhw->char_width + 1 ,
|
||||
dir = strchr (dir_bas, *click_to_cmd (where.h / nhw->char_width + 1 ,
|
||||
where.v / nhw->row_height, CLICK_1));
|
||||
}
|
||||
ch = GetCursor (dir ? dir - dir_bas + 513 : 512);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)getline.c 3.1 90/22/02
|
||||
/* SCCS Id: @(#)getline.c 3.1 90/22/02 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "mactty.h"
|
||||
#endif
|
||||
#include "macpopup.h"
|
||||
#include <ControlDefinitions.h>
|
||||
|
||||
/* Flash a dialog button when its accelerator key is pressed */
|
||||
void
|
||||
@@ -18,7 +19,7 @@ FlashButton (WindowPtr wind, short item) {
|
||||
unsigned long ticks;
|
||||
|
||||
/* Apple recommends 8 ticks */
|
||||
GetDItem(wind, item, &type, &handle, &rect);
|
||||
GetDialogItem(wind, item, &type, &handle, &rect);
|
||||
HiliteControl((ControlHandle)handle, kControlButtonPart);
|
||||
Delay(8, &ticks);
|
||||
HiliteControl((ControlHandle)handle, 0);
|
||||
@@ -48,7 +49,7 @@ FrameItem (DialogPtr dlog, short item) {
|
||||
Handle h;
|
||||
Rect r;
|
||||
|
||||
GetDItem (dlog, item, &k, &h, &r);
|
||||
GetDialogItem (dlog, item, &k, &h, &r);
|
||||
PenSize (3, 3);
|
||||
FrameRoundRect (&r, frame_corner, frame_corner);
|
||||
PenNormal ();
|
||||
@@ -64,11 +65,11 @@ SetFrameItem (DialogPtr dlog, short frame, short item) {
|
||||
if (!FrameItemUPP) /* initialize handler routine */
|
||||
FrameItemUPP = NewUserItemProc(FrameItem);
|
||||
|
||||
GetDItem (dlog, item, &kind, &h, &r);
|
||||
GetDialogItem (dlog, item, &kind, &h, &r);
|
||||
InsetRect (&r, -4, -4);
|
||||
r2 = r;
|
||||
GetDItem (dlog, frame, &kind, &h, &r);
|
||||
SetDItem (dlog, frame, kind, (Handle) FrameItemUPP, &r2);
|
||||
GetDialogItem (dlog, frame, &kind, &h, &r);
|
||||
SetDialogItem (dlog, frame, kind, (Handle) FrameItemUPP, &r2);
|
||||
frame_corner = 16;
|
||||
}
|
||||
|
||||
@@ -235,20 +236,20 @@ SetEnterItem (DialogPtr dp, const short newEnterItem) {
|
||||
Rect r, r2;
|
||||
|
||||
if (gEnterItem != newEnterItem) {
|
||||
GetDItem (dp, gEnterItem, &kind, &item, &r2);
|
||||
GetDialogItem (dp, gEnterItem, &kind, &item, &r2);
|
||||
InsetRect (&r2, - 4, - 4);
|
||||
EraseRect (&r2);
|
||||
InvalRect (&r2);
|
||||
|
||||
gEnterItem = newEnterItem;
|
||||
|
||||
GetDItem (dp, newEnterItem, &kind, &item, &r2);
|
||||
GetDialogItem (dp, newEnterItem, &kind, &item, &r2);
|
||||
frame_corner = kind == ctrlItem + btnCtrl ? 16 : 0;
|
||||
InsetRect (&r2, - 4, - 4);
|
||||
InvalRect (&r2);
|
||||
r = r2;
|
||||
GetDItem (dp, yn_user_item [dlogID - YN_DLOG], &kind, &item, &r2);
|
||||
SetDItem (dp, yn_user_item [dlogID - YN_DLOG], kind, item, &r);
|
||||
GetDialogItem (dp, yn_user_item [dlogID - YN_DLOG], &kind, &item, &r2);
|
||||
SetDialogItem (dp, yn_user_item [dlogID - YN_DLOG], kind, item, &r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,8 +267,8 @@ set_yn_number(DialogPtr dp) {
|
||||
Handle h;
|
||||
Rect r;
|
||||
Str255 s;
|
||||
GetDItem(dp, gEnterItem, &k, &h, &r);
|
||||
GetIText(h, s);
|
||||
GetDialogItem(dp, gEnterItem, &k, &h, &r);
|
||||
GetDialogItemText(h, s);
|
||||
if (s[0])
|
||||
StringToNum(s, &yn_number);
|
||||
}
|
||||
@@ -399,30 +400,30 @@ OneCharDLOGFilter (DialogPtr dp, EventRecord *ev, short *item) {
|
||||
com [1] = ch;
|
||||
|
||||
if (ch == 27) {
|
||||
GetDItem (dp, 4, &k, &h, &r);
|
||||
SetIText (h, com);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 2;
|
||||
FlashButton (dp, 2);
|
||||
return 1;
|
||||
}
|
||||
if (! gRespStr || strchr (gRespStr, ch)) {
|
||||
GetDItem (dp, 4, &k, &h, &r);
|
||||
SetIText (h, com);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
}
|
||||
if (ch == 10 || ch == 13 || ch == 3 || ch == 32) {
|
||||
com [1] = gDef;
|
||||
GetDItem (dp, 4, &k, &h, &r);
|
||||
SetIText (h, com);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
}
|
||||
if (ch > 32 && ch < 127) {
|
||||
GetDItem (dp, 4, &k, &h, &r);
|
||||
SetIText (h, com);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
@@ -442,7 +443,7 @@ char def;
|
||||
short k, item;
|
||||
Handle h;
|
||||
Rect r;
|
||||
unsigned char com [32] = {1, 27}; // margin for getitext
|
||||
unsigned char com [32] = {1, 27}; // margin for GetDialogItemText
|
||||
Str255 pQuery;
|
||||
|
||||
char c = queued_resp ((char *) resp);
|
||||
@@ -468,9 +469,9 @@ char def;
|
||||
}
|
||||
pQuery[0] = strlen (&pQuery[1]);
|
||||
ParamText ((char *) pQuery, (uchar *) 0, (uchar *) 0, (uchar *) 0);
|
||||
GetDItem (dp, 4, &k, &h, &r);
|
||||
SetIText (h, com);
|
||||
SelIText (dp, 4, 0, 0x7fff);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
SelectDialogItemText (dp, 4, 0, 0x7fff);
|
||||
InitCursor ();
|
||||
SetFrameItem (dp, 6, 1);
|
||||
gRespStr = resp;
|
||||
@@ -479,7 +480,7 @@ char def;
|
||||
mv_modal_dialog (OneCharDLOGFilter, &item);
|
||||
|
||||
} while (item != 1 && item != 2);
|
||||
GetIText (h, com);
|
||||
GetDialogItemText (h, com);
|
||||
|
||||
mv_close_dialog (dp);
|
||||
if (item == 2 || ! com [0]) {
|
||||
@@ -584,7 +585,7 @@ ExtendedCommandDialogFilter (DialogPtr dp, EventRecord *ev, short *item) {
|
||||
for (ix = 3; ix; ix ++) {
|
||||
h = (Handle) 0;
|
||||
k = 0;
|
||||
GetDItem (dp, ix, &k, &h, &r);
|
||||
GetDialogItem (dp, ix, &k, &h, &r);
|
||||
if (! k || ! h) {
|
||||
return 0;
|
||||
}
|
||||
@@ -639,8 +640,8 @@ popup_getlin (const char *query, char *bufp) {
|
||||
** Get the text from the text edit item.
|
||||
*/
|
||||
|
||||
GetDItem(promptDialog, 4, &type, (Handle *) &ctrl, &box);
|
||||
GetIText((Handle) ctrl, pasStr);
|
||||
GetDialogItem(promptDialog, 4, &type, (Handle *) &ctrl, &box);
|
||||
GetDialogItemText((Handle) ctrl, pasStr);
|
||||
|
||||
/*
|
||||
** Convert it to a 'C' string and copy it into the return value.
|
||||
|
||||
@@ -225,17 +225,20 @@ short hor, vert;
|
||||
}
|
||||
}
|
||||
|
||||
mustwork (create_tty (&_mt_window, WIN_BASE_KIND + NHW_MAP, _mt_in_color));
|
||||
if (create_tty (&_mt_window, WIN_BASE_KIND + NHW_MAP, _mt_in_color) != noErr)
|
||||
error("_mt_init_stuff: Couldn't create tty.");
|
||||
((WindowPeek) _mt_window)->windowKind = (WIN_BASE_KIND + NHW_MAP);
|
||||
SelectWindow (_mt_window);
|
||||
SetPort (_mt_window);
|
||||
SetOrigin (-1, -1);
|
||||
|
||||
font_size = (iflags.large_font && !small_screen) ? 12 : 9;
|
||||
mustwork (init_tty_number (_mt_window, win_fonts [NHW_MAP], font_size, CO, LI));
|
||||
if (init_tty_number (_mt_window, win_fonts [NHW_MAP], font_size, CO, LI) != noErr)
|
||||
error("_mt_init_stuff: Couldn't init tty.");
|
||||
|
||||
mustwork (get_tty_metrics (_mt_window, &num_cols, &num_rows, &win_width ,
|
||||
&win_height, &font_num, &font_size, &char_width, &row_height));
|
||||
if (get_tty_metrics (_mt_window, &num_cols, &num_rows, &win_width ,
|
||||
&win_height, &font_num, &font_size, &char_width, &row_height))
|
||||
error("_mt_init_stuff: Couldn't get tty metrics.");
|
||||
|
||||
SizeWindow (_mt_window, win_width + 2, win_height + 2, 1);
|
||||
if (RetrievePosition (kMapWindow, &vert, &hor)) {
|
||||
@@ -245,17 +248,17 @@ short hor, vert;
|
||||
ShowWindow (_mt_window);
|
||||
|
||||
/* Start in raw, always flushing mode */
|
||||
mustwork (get_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, &flag));
|
||||
get_tty_attrib(_mt_window, TTY_ATTRIB_FLAGS, &flag);
|
||||
flag |= TA_ALWAYS_REFRESH | TA_WRAP_AROUND;
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, flag));
|
||||
set_tty_attrib(_mt_window, TTY_ATTRIB_FLAGS, flag);
|
||||
|
||||
mustwork (get_tty_attrib (_mt_window, TTY_ATTRIB_CURSOR, &flag));
|
||||
get_tty_attrib(_mt_window, TTY_ATTRIB_CURSOR, &flag);
|
||||
flag |= (TA_BLINKING_CURSOR | TA_NL_ADD_CR);
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_CURSOR, flag));
|
||||
set_tty_attrib(_mt_window, TTY_ATTRIB_CURSOR, flag);
|
||||
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_FOREGROUND, _mt_colors [NO_COLOR] [0]));
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_BACKGROUND, _mt_colors [NO_COLOR] [1]));
|
||||
clear_tty (_mt_window);//
|
||||
set_tty_attrib(_mt_window, TTY_ATTRIB_FOREGROUND, _mt_colors[NO_COLOR][0]);
|
||||
set_tty_attrib(_mt_window, TTY_ATTRIB_BACKGROUND, _mt_colors[NO_COLOR][1]);
|
||||
clear_tty (_mt_window);
|
||||
|
||||
InitMenuRes ();
|
||||
}
|
||||
@@ -481,15 +484,15 @@ term_start_color (int color) {
|
||||
|
||||
|
||||
void
|
||||
setftty (void) {
|
||||
long flag;
|
||||
setftty (void)
|
||||
{
|
||||
long flag;
|
||||
|
||||
mustwork (get_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, &flag));
|
||||
/* Buffered output in the game */
|
||||
/* Buffered output for the game */
|
||||
get_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, &flag);
|
||||
flag &= ~ TA_ALWAYS_REFRESH;
|
||||
flag |= TA_INHIBIT_VERT_SCROLL; /* don't scroll */
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, flag));
|
||||
|
||||
set_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, flag);
|
||||
iflags.cbreak = 1;
|
||||
}
|
||||
|
||||
@@ -508,16 +511,17 @@ gettty (void) {
|
||||
|
||||
|
||||
void
|
||||
settty (const char *str) {
|
||||
long flag;
|
||||
settty (const char *str)
|
||||
{
|
||||
long flag;
|
||||
|
||||
update_tty (_mt_window);
|
||||
|
||||
mustwork (get_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, &flag));
|
||||
/* Buffered output in the game, raw in "raw" mode */
|
||||
/* Buffered output for the game, raw in "raw" mode */
|
||||
get_tty_attrib(_mt_window, TTY_ATTRIB_FLAGS, &flag);
|
||||
flag &= ~ TA_INHIBIT_VERT_SCROLL; /* scroll */
|
||||
flag |= TA_ALWAYS_REFRESH;
|
||||
mustwork (set_tty_attrib (_mt_window, TTY_ATTRIB_FLAGS, flag));
|
||||
set_tty_attrib(_mt_window, TTY_ATTRIB_FLAGS, flag);
|
||||
|
||||
tty_raw_print ("\n");
|
||||
if (str) {
|
||||
|
||||
Reference in New Issue
Block a user