Mac port update
* Update Mac port to new options system. * Update Mac-specific documentation. * Remove hardcoded version strings. * Remove obsolete popup_dialog.
This commit is contained in:
@@ -12,11 +12,4 @@ extern char queued_resp(char *resp);
|
||||
extern char topl_yn_function(const char *query, const char *resp, char def);
|
||||
extern int get_line_from_key_queue(char *bufp);
|
||||
|
||||
#define ENABLE_MAC_POPUP 0
|
||||
#if ENABLE_MAC_POPUP
|
||||
|
||||
extern char popup_yn_function(const char *query, const char *resp, char def);
|
||||
extern void popup_getlin (const char *query, char *bufp);
|
||||
|
||||
#endif /* ENABLE_MAC_POPUP */
|
||||
#endif /* MACPOPUP_H */
|
||||
|
||||
@@ -68,7 +68,7 @@ static struct Bool_Opt
|
||||
{"color", &iflags.wc_color, FALSE, SET_IN_GAME}, /*WC*/
|
||||
# endif
|
||||
{"confirm",&flags.confirm, TRUE, SET_IN_GAME},
|
||||
#ifdef TERMLIB
|
||||
#if defined(TERMLIB) && !defined(MAC_GRAPHICS_ENV)
|
||||
{"DECgraphics", &iflags.DECgraphics, FALSE, SET_IN_GAME},
|
||||
#else
|
||||
{"DECgraphics", (boolean *)0, FALSE, SET_IN_FILE},
|
||||
@@ -98,8 +98,12 @@ static struct Bool_Opt
|
||||
#else
|
||||
{"IBMgraphics", (boolean *)0, FALSE, SET_IN_FILE},
|
||||
#endif
|
||||
#ifndef MAC
|
||||
{"ignintr", &flags.ignintr, FALSE, SET_IN_GAME},
|
||||
{"large_font", &iflags.wc_large_font, FALSE, SET_IN_GAME}, /*WC*/
|
||||
#else
|
||||
{"ignintr", (boolean *)0, FALSE, SET_IN_FILE},
|
||||
#endif
|
||||
{"large_font", &iflags.wc_large_font, FALSE, SET_IN_FILE}, /*WC*/
|
||||
{"legacy", &flags.legacy, TRUE, DISP_IN_GAME},
|
||||
{"lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME},
|
||||
#ifdef MAC_GRAPHICS_ENV
|
||||
@@ -3014,7 +3018,7 @@ struct wc_Opt wc_options[] = {
|
||||
{"color", WC_COLOR},
|
||||
{"eight_bit_tty", WC_EIGHT_BIT_IN},
|
||||
{"hilite_pet", WC_HILITE_PET},
|
||||
{"large_font", WC_LARGE_FONT},
|
||||
{"large_font", WC_LARGE_FONT}, /* now obsolete */
|
||||
{"popup_dialog", WC_POPUP_DIALOG},
|
||||
{"preload_tiles", WC_PRELOAD_TILES},
|
||||
{"tiled_map", WC_TILED_MAP},
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
#include <MacTypes.r>
|
||||
#include "date.h"
|
||||
#include "patchlevel.h"
|
||||
|
||||
resource 'vers' (1, purgeable) {
|
||||
VERSION_MAJOR, (VERSION_MINOR<<4) | PATCHLEVEL, final, EDITLEVEL, verUS,
|
||||
VERSION_STRING,
|
||||
VERSION_STRING
|
||||
};
|
||||
|
||||
resource 'vers' (2, purgeable) {
|
||||
VERSION_MAJOR, (VERSION_MINOR<<4) | PATCHLEVEL, final, EDITLEVEL, verUS,
|
||||
VERSION_STRING,
|
||||
"devteam@nethack.org"
|
||||
};
|
||||
|
||||
read 'File' (1000,"cmdhelp") ":dat:cmdhelp";
|
||||
read 'File' (1001,"help") ":dat:help";
|
||||
read 'File' (1002,"hh") ":dat:hh";
|
||||
@@ -30,31 +46,38 @@ read 'File' (1028,"medusa-2.lev") ":lib:medusa-2.lev";
|
||||
read 'File' (1029,"minefill.lev") ":lib:minefill.lev";
|
||||
read 'File' (1030,"minend-1.lev") ":lib:minend-1.lev";
|
||||
read 'File' (1031,"minend-2.lev") ":lib:minend-2.lev";
|
||||
read 'File' (1032,"minetn-1.lev") ":lib:minetn-1.lev";
|
||||
read 'File' (1033,"minetn-2.lev") ":lib:minetn-2.lev";
|
||||
read 'File' (1034,"options") ":lib:options";
|
||||
read 'File' (1035,"oracle.lev") ":lib:oracle.lev";
|
||||
read 'File' (1036,"oracles") ":lib:oracles";
|
||||
read 'File' (1037,"orcus.lev") ":lib:orcus.lev";
|
||||
read 'File' (1038,"quest.dat") ":lib:quest.dat";
|
||||
read 'File' (1039,"rumors") ":lib:rumors";
|
||||
read 'File' (1040,"sanctum.lev") ":lib:sanctum.lev";
|
||||
read 'File' (1041,"soko1-1.lev") ":lib:soko1-1.lev";
|
||||
read 'File' (1042,"soko1-2.lev") ":lib:soko1-2.lev";
|
||||
read 'File' (1043,"soko2-1.lev") ":lib:soko2-1.lev";
|
||||
read 'File' (1044,"soko2-2.lev") ":lib:soko2-2.lev";
|
||||
read 'File' (1045,"soko3-1.lev") ":lib:soko3-1.lev";
|
||||
read 'File' (1046,"soko3-2.lev") ":lib:soko3-2.lev";
|
||||
read 'File' (1047,"soko4-1.lev") ":lib:soko4-1.lev";
|
||||
read 'File' (1048,"soko4-2.lev") ":lib:soko4-2.lev";
|
||||
read 'File' (1049,"tower1.lev") ":lib:tower1.lev";
|
||||
read 'File' (1050,"tower2.lev") ":lib:tower2.lev";
|
||||
read 'File' (1051,"tower3.lev") ":lib:tower3.lev";
|
||||
read 'File' (1052,"valley.lev") ":lib:valley.lev";
|
||||
read 'File' (1053,"water.lev") ":lib:water.lev";
|
||||
read 'File' (1054,"wizard1.lev") ":lib:wizard1.lev";
|
||||
read 'File' (1055,"wizard2.lev") ":lib:wizard2.lev";
|
||||
read 'File' (1056,"wizard3.lev") ":lib:wizard3.lev";
|
||||
read 'File' (1032,"minend-3.lev") ":lib:minend-3.lev";
|
||||
read 'File' (1033,"minend-4.lev") ":lib:minend-4.lev";
|
||||
read 'File' (1034,"minetn-1.lev") ":lib:minetn-1.lev";
|
||||
read 'File' (1035,"minetn-2.lev") ":lib:minetn-2.lev";
|
||||
read 'File' (1036,"minetn-3.lev") ":lib:minetn-3.lev";
|
||||
read 'File' (1037,"minetn-4.lev") ":lib:minetn-4.lev";
|
||||
read 'File' (1038,"minetn-5.lev") ":lib:minetn-5.lev";
|
||||
read 'File' (1039,"minetn-6.lev") ":lib:minetn-6.lev";
|
||||
read 'File' (1040,"minetn-7.lev") ":lib:minetn-7.lev";
|
||||
read 'File' (1041,"options") ":lib:options";
|
||||
read 'File' (1042,"oracle.lev") ":lib:oracle.lev";
|
||||
read 'File' (1043,"oracles") ":lib:oracles";
|
||||
read 'File' (1044,"orcus.lev") ":lib:orcus.lev";
|
||||
read 'File' (1045,"quest.dat") ":lib:quest.dat";
|
||||
read 'File' (1046,"rumors") ":lib:rumors";
|
||||
read 'File' (1047,"sanctum.lev") ":lib:sanctum.lev";
|
||||
read 'File' (1048,"soko1-1.lev") ":lib:soko1-1.lev";
|
||||
read 'File' (1049,"soko1-2.lev") ":lib:soko1-2.lev";
|
||||
read 'File' (1050,"soko2-1.lev") ":lib:soko2-1.lev";
|
||||
read 'File' (1051,"soko2-2.lev") ":lib:soko2-2.lev";
|
||||
read 'File' (1052,"soko3-1.lev") ":lib:soko3-1.lev";
|
||||
read 'File' (1053,"soko3-2.lev") ":lib:soko3-2.lev";
|
||||
read 'File' (1054,"soko4-1.lev") ":lib:soko4-1.lev";
|
||||
read 'File' (1055,"soko4-2.lev") ":lib:soko4-2.lev";
|
||||
read 'File' (1056,"tower1.lev") ":lib:tower1.lev";
|
||||
read 'File' (1057,"tower2.lev") ":lib:tower2.lev";
|
||||
read 'File' (1058,"tower3.lev") ":lib:tower3.lev";
|
||||
read 'File' (1059,"valley.lev") ":lib:valley.lev";
|
||||
read 'File' (1060,"water.lev") ":lib:water.lev";
|
||||
read 'File' (1061,"wizard1.lev") ":lib:wizard1.lev";
|
||||
read 'File' (1062,"wizard2.lev") ":lib:wizard2.lev";
|
||||
read 'File' (1063,"wizard3.lev") ":lib:wizard3.lev";
|
||||
read 'File' (1100,"Arc-fila.lev") ":lib:Arc-fila.lev";
|
||||
read 'File' (1101,"Arc-filb.lev") ":lib:Arc-filb.lev";
|
||||
read 'File' (1102,"Arc-goal.lev") ":lib:Arc-goal.lev";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Macintosh-specific help file for NetHack 3.3
|
||||
Macintosh-specific help file for NetHack 3.4
|
||||
|
||||
The following are options, features, or concerns specific to the
|
||||
Macintosh port of NetHack 3.3. Bug reports, suggestions, comments,
|
||||
MacOS Classic port of NetHack. Bug reports, suggestions, comments,
|
||||
and so on, should be addressed to:
|
||||
|
||||
To: nethack-bugs@nethack.org
|
||||
Subject: Mac NetHack 3.3
|
||||
Subject: Mac NetHack 3.4
|
||||
|
||||
or you can use our on-line bug reporting form at
|
||||
|
||||
@@ -17,10 +17,10 @@ and so on).
|
||||
|
||||
|
||||
=== Configuration of a playground
|
||||
NetHack 3.3 is packaged in a Dungeon Folder which includes:
|
||||
NetHack is packaged in a Dungeon Folder which includes:
|
||||
NetHack - the application file itself.
|
||||
NetHack Defaults - text file for default option settings.
|
||||
license - licensing terms for nethack.
|
||||
License - licensing terms for nethack.
|
||||
Guidebook - description of the game in long format.
|
||||
Recover - the application to restore save files from crashed games.
|
||||
Previous versions had a large number of data files in the Dungeon
|
||||
@@ -50,6 +50,7 @@ and so on).
|
||||
and answer the "Who are you?" dialog with the player name of
|
||||
the saved game in the Dungeon Folder.
|
||||
|
||||
|
||||
=== Windows
|
||||
The Dungeon Map and Message windows are the essential windows used
|
||||
during window-mode play. During tty-mode play there is only one
|
||||
@@ -68,23 +69,13 @@ and so on).
|
||||
window positions are saved in a file labelled "NetHack Windows"
|
||||
in the appropriate preferences folder.
|
||||
|
||||
|
||||
=== Default options
|
||||
The following options are specific to the Macintosh port:
|
||||
background: - black or white
|
||||
MACgraphics - use enhanced dungeon map symbols [TRUE]
|
||||
large_font - use 12 point font instead of 9 point font [FALSE]
|
||||
popup_dialog - use real dialogs for question prompts [FALSE]
|
||||
page_wait - display --MORE-- after messages [TRUE]
|
||||
use_stone:# - use a background pattern for the dungeon.
|
||||
|
||||
large_font is currently a pre-game option and has no effect
|
||||
after the Dungeon Map window is created.
|
||||
|
||||
use_stone is also a pre-game option. The number parameter
|
||||
specifies which pattern to use. If the number is 0 or
|
||||
greater than the number of available patterns, it has no
|
||||
effect.
|
||||
|
||||
Default options may be set by editing the NetHack Defaults text
|
||||
file (using SimpleText or your favorite editor). The following
|
||||
notation is used:
|
||||
|
||||
110
sys/mac/NHDeflts
110
sys/mac/NHDeflts
@@ -1,23 +1,35 @@
|
||||
# SCCS Id: @(#)NetHack Defaults 3.3 99/11/20
|
||||
# Copyright (c) 1999 by Dean Luick, Mark Modrall, and Kevin Hugo
|
||||
# SCCS Id: @(#)NetHack Defaults 3.4 2002/03/15
|
||||
# Copyright (c) 2002 by Dean Luick, Mark Modrall, and Kevin Hugo
|
||||
# NetHack may be freely redistributed. See license for details.
|
||||
#
|
||||
# Default settings for the Macintosh port of NetHack.
|
||||
# Comment lines begin with a `#' character.
|
||||
# Lines beginning with a `#' character are "comments" and are
|
||||
# ignored all the way to the end of the line. Using this
|
||||
# method, some of the lines below have been disabled so you
|
||||
# can see an example without having those options actually
|
||||
# set. Remove the `#' character to "uncomment" the line and
|
||||
# allow those options to take effect.
|
||||
|
||||
|
||||
### Display ###
|
||||
# Uncomment for the traditional single-window tty interface
|
||||
#OPTIONS=win:tty
|
||||
|
||||
# Font size and style (use HackFont or NewHackFont)
|
||||
OPTIONS=!large,fontmap:NewHackFont
|
||||
# Boulder symbol
|
||||
#OPTIONS=boulder:0
|
||||
|
||||
# Color and background
|
||||
OPTIONS=color,background:white,use_stone:1
|
||||
# Color
|
||||
OPTIONS=color
|
||||
|
||||
# Obsolete way to obtain reverse video; use background:black instead
|
||||
#OPTIONS=palette:000/c22/2c2/ca0/22c/a2a/2aa/ccc/999/f00/0f0/dd0/00f/d0d/0dd/fff/999/444/622/62c/-222
|
||||
# Fonts
|
||||
#OPTIONS=font_map:NewHackFont,font_size_map:9
|
||||
#OPTIONS=font_menu:geneva,font_size_menu:9
|
||||
#OPTIONS=font_message:PSHackFont,font_size_message:9
|
||||
#OPTIONS=font_status:monaco,font_size_status:9
|
||||
#OPTIONS=font_text:geneva,font_size_text:9
|
||||
|
||||
# Don't make dark corridors look like lit corridors
|
||||
OPTIONS=!lit_corridor
|
||||
|
||||
# Enable sound and beeps
|
||||
OPTIONS=sound,!silent
|
||||
@@ -30,33 +42,48 @@ OPTIONS=sound,!silent
|
||||
# Save game state periodically in case of crashes (recommended)
|
||||
OPTIONS=checkpoint
|
||||
|
||||
# How to prompt for things after death
|
||||
#OPTIONS=disclose:+i na -v yg nc
|
||||
|
||||
# Show tombstone and top scores at death
|
||||
OPTIONS=tombstone,scores:10t/3a/o
|
||||
|
||||
# Show top ten list in its own window
|
||||
#OPTIONS=toptenwin
|
||||
|
||||
|
||||
### User input and feedback ###
|
||||
# Choose between menus or text prompts
|
||||
# (traditional, combination, partial, or full)
|
||||
OPTIONS=menustyle:full
|
||||
|
||||
# Display a little more information with some commands
|
||||
OPTIONS=verbose
|
||||
# Extended (`#') commands by menu
|
||||
#OPTIONS=extmenu
|
||||
|
||||
# Pause for --more-- and make it boldface
|
||||
OPTIONS=page_wait,standout
|
||||
|
||||
# Allow spacebar as rest command
|
||||
#OPTIONS=rest_on_space
|
||||
# Increase the number of message lines remembered
|
||||
#OPTIONS=msghistory:60
|
||||
|
||||
# Enable the number pad keys
|
||||
OPTIONS=number_pad
|
||||
|
||||
# Pause for --more-- and make it boldface
|
||||
OPTIONS=page_wait,standout
|
||||
|
||||
# Ask for confirmation with the #pray command
|
||||
OPTIONS=prayconfirm
|
||||
|
||||
# Allow spacebar as rest command
|
||||
#OPTIONS=rest_on_space
|
||||
|
||||
# Display experience, score, and time on status line
|
||||
OPTIONS=showexp,showscore,time
|
||||
|
||||
# Use popup windows for yes/no questions
|
||||
# This is likely to go away in future releases
|
||||
#OPTIONS=popup_dialog
|
||||
# Turn off animations
|
||||
#OPTIONS=!sparkle
|
||||
|
||||
# Display a little more information with some commands
|
||||
#OPTIONS=suppress_alert:3.3.0
|
||||
OPTIONS=verbose
|
||||
|
||||
|
||||
### Character ###
|
||||
@@ -76,18 +103,59 @@ OPTIONS=showexp,showscore,time
|
||||
|
||||
|
||||
### Inventory ###
|
||||
# Automatically dig if wielding a pick
|
||||
#OPTIONS=autodig
|
||||
|
||||
# Disable autopickup (toggle it with the `@' command)
|
||||
#OPTIONS=!autopickup
|
||||
#OPTIONS=!autopickup,pickup_types:$*
|
||||
|
||||
# Automatically fill the quiver
|
||||
#OPTIONS=autoquiver
|
||||
|
||||
# Don't use fixed inventory letters
|
||||
OPTIONS=!fixinv,perm_invent,sortpack
|
||||
|
||||
# What you want to call slime molds
|
||||
#OPTIONS=fruit:grape
|
||||
|
||||
# Desired inventory display order
|
||||
#OPTIONS=packorder:)[(
|
||||
|
||||
# How much you're willing to carry without confirmation
|
||||
#OPTIONS=pickup_burden:B
|
||||
|
||||
# Put weapon in secondary slot when wielding another
|
||||
#OPTIONS=pushweapon
|
||||
|
||||
|
||||
### Pets ###
|
||||
# What to call your starting pet, and its type
|
||||
OPTIONS=dogname:Quinn,catname:Vladimir,horsename:Silver,pettype:dog
|
||||
#OPTIONS=dogname:Quinn,catname:Vladimir,horsename:Silver,pettype:dog
|
||||
|
||||
# Don't intentionally attack your pets
|
||||
OPTIONS=confirm,!hilite_pet,safe_pet
|
||||
|
||||
|
||||
### Unused options ###
|
||||
|
||||
# Now obsolete
|
||||
#
|
||||
# background, large_font, popup_dialog, use_stone
|
||||
|
||||
# Obsolete way to obtain reverse video; use at your own risk
|
||||
#OPTIONS=palette:000/c22/2c2/ca0/22c/a2a/2aa/ccc/999/f00/0f0/dd0/00f/d0d/0dd/fff/999/444/622/62c/-222
|
||||
|
||||
# Options used in tty window mode, but not mac window mode
|
||||
#
|
||||
# menu_..., msg_window, timed_delay, use_inverse, vary_msgcount
|
||||
|
||||
# Options used by other ports but not Macintosh:
|
||||
#
|
||||
# align_message, align_status, ascii_map, BIOS, checkspace,
|
||||
# decgraphics, eight_bit_tty, ibmgraphics, ignintr, mail,
|
||||
# map_mode, null, player_selection, preload_tiles, rawio,
|
||||
# splash_screen, tiled_map, tile_..., videocolors, videoshades,
|
||||
# windowcolors
|
||||
|
||||
|
||||
# End-of-file
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Welcome to NetHack 3.3 for the Macintosh
|
||||
Welcome to NetHack 3.4 for MacOS 7.0 - 9.x
|
||||
|
||||
Unfortunately, the 68k version is no longer supported.
|
||||
|
||||
This game is brought to you by Dean Luick, Kevin Hugo, and Mark Modrall.
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ Jan 2002
|
||||
|
||||
The MPW compilers are now supported again.
|
||||
|
||||
Note that the graphical MacOSX variant uses the Qt windowport and the UNIX
|
||||
Support for 68k has been discontinued due to a lack of a debugging
|
||||
system for 68k binaries.
|
||||
|
||||
Note that the graphical MacOS X variant uses the Qt windowport and the UNIX
|
||||
build system.
|
||||
|
||||
|
||||
|
||||
@@ -59,12 +59,7 @@ char def;
|
||||
* If resp is NULL, any single character is accepted and returned.
|
||||
*/
|
||||
{
|
||||
#if ENABLE_MAC_POPUP
|
||||
if (iflags.popup_dialog)
|
||||
return popup_yn_function(query, resp, def);
|
||||
else
|
||||
#endif
|
||||
return topl_yn_function(query, resp, def);
|
||||
}
|
||||
|
||||
/*topl.c*/
|
||||
/* mactopl.c */
|
||||
|
||||
@@ -626,9 +626,12 @@ got1 :
|
||||
|
||||
if (kind == NHW_MESSAGE) {
|
||||
aWin->font_number = win_fonts [NHW_MESSAGE];
|
||||
aWin->font_size = iflags.large_font ? 12 : 9;
|
||||
aWin->font_size = iflags.wc_fontsiz_message? iflags.wc_fontsiz_message :
|
||||
iflags.large_font ? 12 : 9;
|
||||
if (!top_line) {
|
||||
const Rect out_of_scr = {10000, 10000, 10100, 10100};
|
||||
TextFont(aWin->font_number);
|
||||
TextSize(aWin->font_size);
|
||||
TextFace(bold);
|
||||
top_line = TENew(&out_of_scr, &out_of_scr);
|
||||
TEActivate(top_line);
|
||||
@@ -636,7 +639,7 @@ got1 :
|
||||
}
|
||||
} else {
|
||||
aWin->font_number = win_fonts [NHW_TEXT];
|
||||
aWin->font_size = 9;
|
||||
aWin->font_size = iflags.wc_fontsiz_text ? iflags.wc_fontsiz_text : 9;
|
||||
}
|
||||
|
||||
TextFont (aWin->font_number);
|
||||
@@ -2488,7 +2491,10 @@ try_key_queue (char *bufp) {
|
||||
/* Interface definition, for windows.c */
|
||||
struct window_procs mac_procs = {
|
||||
"mac",
|
||||
WC_ASCII_MAP|WC_COLOR|WC_LARGE_FONT,
|
||||
WC_COLOR | WC_HILITE_PET |
|
||||
WC_LARGE_FONT | /* obsolete */
|
||||
WC_FONT_MAP | WC_FONT_MENU | WC_FONT_MESSAGE | WC_FONT_STATUS | WC_FONT_TEXT |
|
||||
WC_FONTSIZ_MAP | WC_FONTSIZ_MENU | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_TEXT,
|
||||
mac_init_nhwindows,
|
||||
mac_unimplemented, /* see macmenu.c:mac_askname() for player selection */
|
||||
mac_askname,
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "macpopup.h"
|
||||
#include "func_tab.h"
|
||||
|
||||
extern int NDECL(extcmd_via_menu); /* cmd.c */
|
||||
|
||||
typedef Boolean FDECL ((* key_func), (unsigned char));
|
||||
|
||||
int
|
||||
@@ -48,13 +50,7 @@ topl_getlin(const char *query, char *bufp, Boolean ext) {
|
||||
*/
|
||||
void
|
||||
mac_getlin(const char *query, char *bufp) {
|
||||
|
||||
#if ENABLE_MAC_POPUP
|
||||
if (iflags.popup_dialog)
|
||||
popup_getlin (query, bufp);
|
||||
else
|
||||
#endif
|
||||
topl_getlin (query, bufp, false);
|
||||
topl_getlin (query, bufp, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +63,7 @@ mac_get_ext_cmd() {
|
||||
char bufp[BUFSZ];
|
||||
int i;
|
||||
|
||||
if (iflags.extmenu) return extcmd_via_menu();
|
||||
topl_getlin("# ", bufp, true);
|
||||
for (i = 0; extcmdlist[i].ef_txt != (char *)0; i++)
|
||||
if (!strcmp(bufp, extcmdlist[i].ef_txt)) break;
|
||||
|
||||
638
sys/mac/mmodal.c
638
sys/mac/mmodal.c
@@ -3,10 +3,6 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <Dialogs.h>
|
||||
#if ENABLE_MAC_POPUP
|
||||
#include "hack.h"
|
||||
#include "mactty.h"
|
||||
#endif
|
||||
#include "macpopup.h"
|
||||
#include <ControlDefinitions.h>
|
||||
|
||||
@@ -27,637 +23,3 @@ FlashButton (WindowPtr wind, short item) {
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_MAC_POPUP
|
||||
static void mv_handle_click (EventRecord *theEvent);
|
||||
|
||||
#define MAX_MV_DIALOGS 20
|
||||
static int old_dialog_count = 0;
|
||||
static struct {
|
||||
short id;
|
||||
Boolean init_visible;
|
||||
DialogPtr dialog;
|
||||
} old_dialog[MAX_MV_DIALOGS];
|
||||
|
||||
|
||||
static short frame_corner;
|
||||
static pascal void FrameItem(DialogPtr dlog, short item);
|
||||
static UserItemUPP FrameItemUPP = NULL;
|
||||
|
||||
static pascal void
|
||||
FrameItem (DialogPtr dlog, short item) {
|
||||
short k;
|
||||
Handle h;
|
||||
Rect r;
|
||||
|
||||
GetDialogItem (dlog, item, &k, &h, &r);
|
||||
PenSize (3, 3);
|
||||
FrameRoundRect (&r, frame_corner, frame_corner);
|
||||
PenNormal ();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SetFrameItem (DialogPtr dlog, short frame, short item) {
|
||||
Rect r, r2;
|
||||
short kind;
|
||||
Handle h;
|
||||
|
||||
if (!FrameItemUPP) /* initialize handler routine */
|
||||
FrameItemUPP = NewUserItemProc(FrameItem);
|
||||
|
||||
GetDialogItem (dlog, item, &kind, &h, &r);
|
||||
InsetRect (&r, -4, -4);
|
||||
r2 = r;
|
||||
GetDialogItem (dlog, frame, &kind, &h, &r);
|
||||
SetDialogItem (dlog, frame, kind, (Handle) FrameItemUPP, &r2);
|
||||
frame_corner = 16;
|
||||
}
|
||||
|
||||
|
||||
/* Instead of calling GetNewDialog everytime, just call
|
||||
SelectWindow/ShowWindow for the old dialog to remember its location.
|
||||
*/
|
||||
/*
|
||||
* Unfortunately, this does not work, as it doesn't handle old text
|
||||
* in edit text boxes, and not ParamText parameters either.
|
||||
*
|
||||
*/
|
||||
static DialogPtr
|
||||
mv_get_new_dialog(short dialogID) {
|
||||
DialogPtr dialog;
|
||||
int d_idx = old_dialog_count;
|
||||
Rect oldRect;
|
||||
Boolean hadOld = 0;
|
||||
|
||||
old_dialog[0].id = dialogID;
|
||||
while (old_dialog[d_idx].id != dialogID)
|
||||
--d_idx;
|
||||
|
||||
/*
|
||||
* This routine modified so that the old dialog is
|
||||
* disposed, and the new one read in after we remember
|
||||
* the old dialog's position.
|
||||
*
|
||||
* This takes care of strange default strings and ParamTexts
|
||||
*
|
||||
*/
|
||||
|
||||
if (d_idx) {
|
||||
dialog = old_dialog [d_idx] . dialog;
|
||||
oldRect = dialog->portBits . bounds;
|
||||
DisposeDialog (dialog);
|
||||
old_dialog [d_idx] . dialog = (DialogPtr) 0;
|
||||
hadOld = 1;
|
||||
|
||||
} else {
|
||||
d_idx = ++ old_dialog_count;
|
||||
}
|
||||
|
||||
dialog = GetNewDialog(dialogID, nil, (WindowPtr)-1);
|
||||
if (dialog) {
|
||||
if (hadOld) {
|
||||
MoveWindow (dialog, - oldRect . left, - oldRect . top, FALSE);
|
||||
}
|
||||
old_dialog[d_idx].id = dialogID;
|
||||
old_dialog[d_idx].init_visible
|
||||
= ((WindowPeek)dialog)->visible;
|
||||
old_dialog[d_idx].dialog = dialog;
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/* Instead of actually closing the dialog, just hide it so its location
|
||||
is remembered. */
|
||||
static void mv_close_dialog(DialogPtr dialog) {
|
||||
HideWindow(dialog);
|
||||
}
|
||||
|
||||
/* This routine is stolen/borrowed from HandleClick (macwin.c). See the
|
||||
comments in mv_modal_dialog for more information. */
|
||||
static void
|
||||
mv_handle_click (EventRecord *theEvent) {
|
||||
int code;
|
||||
WindowPtr theWindow;
|
||||
Rect r = (*GetGrayRgn ())->rgnBBox;
|
||||
|
||||
InsetRect (&r, 4, 4);
|
||||
InitCursor ();
|
||||
|
||||
code = FindWindow (theEvent->where, &theWindow);
|
||||
|
||||
switch (code) {
|
||||
case inContent :
|
||||
if (theWindow != FrontWindow ()) {
|
||||
nhbell ();
|
||||
}
|
||||
break;
|
||||
case inDrag :
|
||||
SetCursor(&qd.arrow);
|
||||
DragWindow (theWindow, theEvent->where, &r);
|
||||
SaveWindowPos (theWindow);
|
||||
break;
|
||||
default :
|
||||
HandleEvent (theEvent);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mv_modal_dialog(ModalFilterProcPtr filterProc, short *itemHit) {
|
||||
GrafPtr org_port;
|
||||
GetPort(&org_port);
|
||||
|
||||
for (;;) {
|
||||
DialogPtr dialog = FrontWindow();
|
||||
EventRecord evt;
|
||||
|
||||
WaitNextEvent(everyEvent, &evt, GetCaretTime(), (RgnHandle) nil);
|
||||
|
||||
if (evt.what == keyDown)
|
||||
if (evt.modifiers &cmdKey) {
|
||||
if ((evt.message & charCodeMask) == '.') {
|
||||
/* 0x351b is the key code and character code of the esc key. */
|
||||
evt.message = 0x351b;
|
||||
evt.modifiers &= ~cmdKey;
|
||||
}
|
||||
} else
|
||||
trans_num_keys(&evt);
|
||||
|
||||
if (filterProc) {
|
||||
if ((*filterProc)(dialog, &evt, itemHit))
|
||||
break;
|
||||
} else if (evt.what == keyDown) {
|
||||
char ch = evt.message & charCodeMask;
|
||||
if (ch == CHAR_CR || ch == CHAR_ENTER) {
|
||||
*itemHit = ok;
|
||||
FlashButton(dialog, ok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDialogEvent(&evt)) {
|
||||
DialogPtr dont_care;
|
||||
if (DialogSelect(&evt, &dont_care, itemHit))
|
||||
break;
|
||||
|
||||
/* The following part is problemmatic: (1) Calling HandleEvent
|
||||
here may cause some re-entrance problem (seems ok, but I am
|
||||
not sure). (2) It is ugly to treat mouseDown events as a
|
||||
special case. If we can just say "else HandleEvent(&evt);"
|
||||
here it will be better. */
|
||||
} else if (evt.what == mouseDown)
|
||||
mv_handle_click(&evt);
|
||||
else
|
||||
HandleEvent(&evt);
|
||||
|
||||
SetPort(org_port);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************
|
||||
* mactopl routines using dialogs
|
||||
*********************************************************************************/
|
||||
|
||||
#define YN_DLOG 133
|
||||
#define YNQ_DLOG 134
|
||||
#define YNAQ_DLOG 135
|
||||
#define YNNAQ_DLOG 136
|
||||
|
||||
static int yn_user_item [] = {5, 6, 7, 8};
|
||||
static short gEnterItem, gEscItem;
|
||||
static const char *gRespStr = (const char *)0;
|
||||
static char gDef = 0;
|
||||
static short dlogID;
|
||||
|
||||
|
||||
static void
|
||||
SetEnterItem (DialogPtr dp, const short newEnterItem) {
|
||||
short kind;
|
||||
Handle item;
|
||||
Rect r, r2;
|
||||
|
||||
if (gEnterItem != newEnterItem) {
|
||||
GetDialogItem (dp, gEnterItem, &kind, &item, &r2);
|
||||
InsetRect (&r2, - 4, - 4);
|
||||
EraseRect (&r2);
|
||||
InvalRect (&r2);
|
||||
|
||||
gEnterItem = newEnterItem;
|
||||
|
||||
GetDialogItem (dp, newEnterItem, &kind, &item, &r2);
|
||||
frame_corner = kind == ctrlItem + btnCtrl ? 16 : 0;
|
||||
InsetRect (&r2, - 4, - 4);
|
||||
InvalRect (&r2);
|
||||
r = r2;
|
||||
GetDialogItem (dp, yn_user_item [dlogID - YN_DLOG], &kind, &item, &r2);
|
||||
SetDialogItem (dp, yn_user_item [dlogID - YN_DLOG], kind, item, &r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_tabbing (DialogPtr dp) {
|
||||
SetEnterItem(dp, gEnterItem == 1 ? strlen(gRespStr) : gEnterItem - 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_yn_number(DialogPtr dp) {
|
||||
if (gRespStr && gRespStr[gEnterItem-1] == '#') {
|
||||
short k;
|
||||
Handle h;
|
||||
Rect r;
|
||||
Str255 s;
|
||||
GetDialogItem(dp, gEnterItem, &k, &h, &r);
|
||||
GetDialogItemText(h, s);
|
||||
if (s[0])
|
||||
StringToNum(s, &yn_number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static pascal Boolean
|
||||
YNAQFilter (DialogPtr dp, EventRecord *ev, short *itemHit) {
|
||||
unsigned char code;
|
||||
char ch;
|
||||
char *re = (char *) gRespStr;
|
||||
|
||||
if (ev->what != keyDown) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
code = (ev->message & 0xff00) >> 8;
|
||||
ch = ev->message & 0xff;
|
||||
|
||||
switch (code) {
|
||||
case 0x24 :
|
||||
case 0x4c :
|
||||
set_yn_number (dp);
|
||||
*itemHit = gEnterItem;
|
||||
FlashButton (dp, *itemHit);
|
||||
return 1;
|
||||
case 0x35 :
|
||||
case 0x47 :
|
||||
*itemHit = gEscItem;
|
||||
FlashButton (dp, *itemHit);
|
||||
return 1;
|
||||
case 0x30 :
|
||||
do_tabbing (dp);
|
||||
return 0;
|
||||
}
|
||||
switch (ch) {
|
||||
case '\r' :
|
||||
case '\n' :
|
||||
case ' ' :
|
||||
case 3 :
|
||||
set_yn_number (dp);
|
||||
*itemHit = gEnterItem;
|
||||
FlashButton (dp, *itemHit);
|
||||
return 1;
|
||||
|
||||
case 9 :
|
||||
do_tabbing (dp);
|
||||
return 0;
|
||||
|
||||
case 27 :
|
||||
*itemHit = gEscItem;
|
||||
FlashButton (dp, *itemHit);
|
||||
return 1;
|
||||
|
||||
case CHAR_BS :
|
||||
case 28 : case 29 : case 30 : case 31 : /* the four arrow keys */
|
||||
case '0' : case '1' : case '2' : case '3' : case '4' :
|
||||
case '5' : case '6' : case '7' : case '8' : case '9' : {
|
||||
char *loc = strchr (gRespStr, '#');
|
||||
if (loc) {
|
||||
SetEnterItem(dp, loc - gRespStr + 1);
|
||||
return 0; /* Dialog Manager will then put this key into the text field. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (*re) {
|
||||
if (*re == ch) {
|
||||
*itemHit = (re - gRespStr) + 1;
|
||||
FlashButton (dp, *itemHit);
|
||||
return 1;
|
||||
}
|
||||
re ++;
|
||||
}
|
||||
|
||||
nhbell ();
|
||||
ev->what = nullEvent;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static char
|
||||
do_question_dialog (char *query, int dlog, int defbut, char *resp) {
|
||||
Str255 p;
|
||||
DialogPtr dp;
|
||||
short item;
|
||||
|
||||
char c = queued_resp ((char *) resp);
|
||||
if (c)
|
||||
return c;
|
||||
|
||||
dlogID = dlog;
|
||||
C2P (query, p);
|
||||
ParamText ((char *)p, (uchar *) 0, (uchar *) 0, (uchar *) 0);
|
||||
dp = mv_get_new_dialog (dlog);
|
||||
if (! dp) {
|
||||
return 0;
|
||||
}
|
||||
SetPort (dp);
|
||||
ShowWindow (dp);
|
||||
|
||||
gEscItem = strlen (resp);
|
||||
gEnterItem = defbut;
|
||||
gRespStr = resp;
|
||||
|
||||
SetFrameItem (dp, yn_user_item [dlogID - YN_DLOG], gEnterItem);
|
||||
|
||||
InitCursor ();
|
||||
mv_modal_dialog (YNAQFilter, &item);
|
||||
mv_close_dialog (dp);
|
||||
return resp [item - 1];
|
||||
}
|
||||
|
||||
|
||||
static pascal Boolean
|
||||
OneCharDLOGFilter (DialogPtr dp, EventRecord *ev, short *item) {
|
||||
char ch;
|
||||
short k;
|
||||
Handle h;
|
||||
Rect r;
|
||||
unsigned char com [2];
|
||||
|
||||
if (ev->what != keyDown) {
|
||||
return 0;
|
||||
}
|
||||
ch = ev->message & 0xff;
|
||||
|
||||
com [0] = 1;
|
||||
com [1] = ch;
|
||||
|
||||
if (ch == 27) {
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 2;
|
||||
FlashButton (dp, 2);
|
||||
return 1;
|
||||
}
|
||||
if (! gRespStr || strchr (gRespStr, ch)) {
|
||||
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;
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
}
|
||||
if (ch > 32 && ch < 127) {
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
}
|
||||
nhbell ();
|
||||
ev->what = nullEvent;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static char
|
||||
generic_yn_function (query, resp, def)
|
||||
const char *query, *resp;
|
||||
char def;
|
||||
{
|
||||
DialogPtr dp;
|
||||
short k, item;
|
||||
Handle h;
|
||||
Rect r;
|
||||
unsigned char com [32] = {1, 27}; // margin for GetDialogItemText
|
||||
Str255 pQuery;
|
||||
|
||||
char c = queued_resp ((char *) resp);
|
||||
if (c)
|
||||
return c;
|
||||
|
||||
dp = mv_get_new_dialog (137);
|
||||
if (! dp) {
|
||||
return 0;
|
||||
}
|
||||
SetPort (dp);
|
||||
ShowWindow (dp);
|
||||
InitCursor ();
|
||||
SetFrameItem (dp, 6, 1);
|
||||
if (def) {
|
||||
com [1] = def;
|
||||
}
|
||||
strcpy ((char *) &pQuery[1], query);
|
||||
if (resp && *resp) {
|
||||
strcat ((char *) &pQuery[1], " (");
|
||||
strcat ((char *) &pQuery[1], resp);
|
||||
strcat ((char *) &pQuery[1], ")");
|
||||
}
|
||||
pQuery[0] = strlen (&pQuery[1]);
|
||||
ParamText ((char *) pQuery, (uchar *) 0, (uchar *) 0, (uchar *) 0);
|
||||
GetDialogItem (dp, 4, &k, &h, &r);
|
||||
SetDialogItemText (h, com);
|
||||
SelectDialogItemText (dp, 4, 0, 0x7fff);
|
||||
InitCursor ();
|
||||
SetFrameItem (dp, 6, 1);
|
||||
gRespStr = resp;
|
||||
gDef = def;
|
||||
do {
|
||||
mv_modal_dialog (OneCharDLOGFilter, &item);
|
||||
|
||||
} while (item != 1 && item != 2);
|
||||
GetDialogItemText (h, com);
|
||||
|
||||
mv_close_dialog (dp);
|
||||
if (item == 2 || ! com [0]) {
|
||||
return 27; // escape
|
||||
}
|
||||
return com [1];
|
||||
}
|
||||
|
||||
|
||||
static char
|
||||
ynaq_dialog (query, resp, def)
|
||||
const char *query, *resp;
|
||||
char def;
|
||||
{
|
||||
int dia = 0;
|
||||
|
||||
if (resp) {
|
||||
if (! strcmp (resp, ynchars)) {
|
||||
dia = YN_DLOG;
|
||||
}
|
||||
if (! strcmp (resp, ynqchars)) {
|
||||
dia = YNQ_DLOG;
|
||||
}
|
||||
if (! strcmp (resp, ynaqchars)) {
|
||||
dia = YNAQ_DLOG;
|
||||
}
|
||||
if (! strcmp (resp, ynNaqchars)) {
|
||||
dia = YNNAQ_DLOG;
|
||||
}
|
||||
}
|
||||
if (! dia) {
|
||||
return generic_yn_function (query, resp, def);
|
||||
}
|
||||
|
||||
return do_question_dialog ((char *) query, dia ,
|
||||
(strchr (resp, def) - resp) + 1, (char *) resp);
|
||||
}
|
||||
|
||||
|
||||
char
|
||||
popup_yn_function(const char *query, const char *resp, char def) {
|
||||
char ch;
|
||||
|
||||
if (ch = ynaq_dialog (query, resp, def))
|
||||
return ch;
|
||||
|
||||
return topl_yn_function(query, resp, def);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************
|
||||
* mgetline routines using dialogs
|
||||
*********************************************************************************/
|
||||
|
||||
static pascal Boolean
|
||||
getlinFilter (DialogPtr dp, EventRecord *ev, short *itemHit) {
|
||||
if (ev->what == keyDown) {
|
||||
int key = ev->message & keyCodeMask,
|
||||
ch = ev->message & charCodeMask;
|
||||
|
||||
if (ch == 0x1b || key == 0x3500 || key == 0x4700) {
|
||||
*itemHit = 2;
|
||||
FlashButton(dp, 2);
|
||||
return true;
|
||||
} else if (ch == CHAR_CR || ch == CHAR_ENTER) {
|
||||
*itemHit = 1;
|
||||
FlashButton(dp, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Boolean
|
||||
ExtendedCommandDialogFilter (DialogPtr dp, EventRecord *ev, short *item) {
|
||||
int ix;
|
||||
Handle h;
|
||||
Rect r;
|
||||
short k;
|
||||
Str255 s;
|
||||
unsigned char com [2];
|
||||
|
||||
if (ev->what != keyDown) {
|
||||
return 0;
|
||||
}
|
||||
com [0] = 1;
|
||||
com [1] = ev->message & 0xff;
|
||||
|
||||
if (com [1] == 10 || com [1] == 13 || com [1] == 32 ||
|
||||
com [1] == 3) { // various "OK"
|
||||
*item = 1;
|
||||
FlashButton (dp, 1);
|
||||
return 1;
|
||||
}
|
||||
if (com [1] == 27 || (ev->message & 0xff00 == 0x3500)) { // escape
|
||||
*item = 2;
|
||||
FlashButton (dp, 2);
|
||||
return 1;
|
||||
}
|
||||
for (ix = 3; ix; ix ++) {
|
||||
h = (Handle) 0;
|
||||
k = 0;
|
||||
GetDialogItem (dp, ix, &k, &h, &r);
|
||||
if (! k || ! h) {
|
||||
return 0;
|
||||
}
|
||||
if (k == 6) { // Radio Button Item
|
||||
GetCTitle ((ControlHandle) h, s);
|
||||
s [0] = 1;
|
||||
if (! IUEqualString (com, s)) {
|
||||
*item = ix;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
popup_getlin (const char *query, char *bufp) {
|
||||
ControlHandle ctrl;
|
||||
DialogPtr promptDialog;
|
||||
short itemHit, type;
|
||||
Rect box;
|
||||
Str255 pasStr;
|
||||
|
||||
if (get_line_from_key_queue (bufp))
|
||||
return;
|
||||
|
||||
/*
|
||||
** Make a copy of the prompt string and convert the copy to a Pascal string.
|
||||
*/
|
||||
|
||||
C2P(query, pasStr);
|
||||
|
||||
/*
|
||||
** Set the query line as parameter text.
|
||||
*/
|
||||
|
||||
ParamText(pasStr, "\p", "\p", "\p");
|
||||
|
||||
promptDialog = mv_get_new_dialog(130);
|
||||
ShowWindow(promptDialog);
|
||||
|
||||
InitCursor ();
|
||||
SetFrameItem (promptDialog, 6, 1);
|
||||
do {
|
||||
mv_modal_dialog(&getlinFilter, &itemHit);
|
||||
} while ((itemHit != 1) && (itemHit != 2));
|
||||
|
||||
if (itemHit != 2) {
|
||||
/*
|
||||
** Get the text from the text edit item.
|
||||
*/
|
||||
|
||||
GetDialogItem(promptDialog, 4, &type, (Handle *) &ctrl, &box);
|
||||
GetDialogItemText((Handle) ctrl, pasStr);
|
||||
|
||||
/*
|
||||
** Convert it to a 'C' string and copy it into the return value.
|
||||
*/
|
||||
|
||||
P2C (pasStr, bufp);
|
||||
} else {
|
||||
/*
|
||||
** Return a null-terminated string consisting of a single <ESC>.
|
||||
*/
|
||||
|
||||
bufp[0] = '\033';
|
||||
bufp[1] = '\0';
|
||||
}
|
||||
|
||||
mv_close_dialog(promptDialog);
|
||||
}
|
||||
|
||||
#endif /* ENABLE_MAC_POPUP */
|
||||
|
||||
@@ -232,7 +232,8 @@ short hor, vert;
|
||||
SetPort (_mt_window);
|
||||
SetOrigin (-1, -1);
|
||||
|
||||
font_size = (iflags.large_font && !small_screen) ? 12 : 9;
|
||||
font_size = iflags.wc_fontsiz_map ? iflags.wc_fontsiz_map :
|
||||
(iflags.large_font && !small_screen) ? 12 : 9;
|
||||
if (init_tty_number (_mt_window, win_fonts [NHW_MAP], font_size, CO, LI) != noErr)
|
||||
error("_mt_init_stuff: Couldn't init tty.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user