| 1 | #charset "us-ascii" |
| 2 | #pragma once |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1999, 2006 Michael J. Roberts |
| 6 | * |
| 7 | * This file is part of TADS 3 |
| 8 | * |
| 9 | * This header defines the tads-io intrinsic function set. |
| 10 | * |
| 11 | * The TADS input/output function set provides access to the user |
| 12 | * interface. This lets you read input from the keyboard and display |
| 13 | * output on the monitor or terminal. It also provides access to windowing |
| 14 | * features (via the "banner" functions) on systems that support multiple |
| 15 | * display windows (which doesn't necessarily mean GUI-type systems: many |
| 16 | * character-mode systems support the banner operations as well, simply by |
| 17 | * dividing up the character-mode screen into rectangular regions). |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | * tads-io - the TADS Input/Output intrinsic function set |
| 23 | */ |
| 24 | intrinsic 'tads-io/030007' |
| 25 | { |
| 26 | /* |
| 27 | * Display values on the console. One or more values can be displayed. |
| 28 | * Each value can be a string, in which case the string is displayed as |
| 29 | * given (with HTML interpretation); an integer, in which case it's |
| 30 | * converted to a string, using a decimal (base 10) radix and |
| 31 | * displayed; a BigNumber, in which case it's converted to a string |
| 32 | * using the default formatting; or nil, in which case nothing is |
| 33 | * displayed. |
| 34 | */ |
| 35 | tadsSay(val, ...); |
| 36 | |
| 37 | /* |
| 38 | * Set the output log file (which records the output transcript) or the |
| 39 | * command log file (which records command lines the user enters). |
| 40 | * 'fname' is the name of the file to open, and 'logType' gives the |
| 41 | * type of log to open, as a LogTypeXxx value. |
| 42 | */ |
| 43 | setLogFile(fname, logType?); |
| 44 | |
| 45 | /* |
| 46 | * Clear the display. This clears the main window. |
| 47 | */ |
| 48 | clearScreen(); |
| 49 | |
| 50 | /* |
| 51 | * Show the "more" prompt, if supported on the platform. This causes a |
| 52 | * "more" prompt to be displayed, according to local system |
| 53 | * conventions, as though consecutive text output had exceeded the |
| 54 | * screen/window height. |
| 55 | */ |
| 56 | morePrompt(); |
| 57 | |
| 58 | /* |
| 59 | * Read a line of text from the keyboard. Pauses to let the user edit |
| 60 | * and enter a command line, then returns the entered text as a string. |
| 61 | */ |
| 62 | inputLine(); |
| 63 | |
| 64 | /* |
| 65 | * Read a single keystroke from the keyboard. Waits until the user |
| 66 | * presses a key, then returns the keystroke as a string. |
| 67 | */ |
| 68 | inputKey(); |
| 69 | |
| 70 | /* |
| 71 | * Read a single input event. Waits until an input event is available, |
| 72 | * then returns the event as a list. The first element of the list is |
| 73 | * an InEvtXxx value indicating the type of the event; the remainder of |
| 74 | * the list varies according to the event type. If 'timeout' is |
| 75 | * provided, it gives the maximum waiting interval in milliseconds; if |
| 76 | * no input event occurs within this interval, the function returns an |
| 77 | * InEvtTimeout event. |
| 78 | */ |
| 79 | inputEvent(timeout?); |
| 80 | |
| 81 | /* |
| 82 | * Display a simple "message box" dialog (known on some systems as an |
| 83 | * "alert" dialog). This displays a dialog that includes a short |
| 84 | * message for the user to read, an icon indicating the general nature |
| 85 | * of the condition that gave rise to the dialog (an error, a warning, |
| 86 | * a choice for the user to make, etc.), and a set of push-buttons that |
| 87 | * dismiss the dialog and (in some cases) let the user choose among |
| 88 | * options. 'icon' is an InDlgIconXxx value giving the type of icon to |
| 89 | * show, if any; 'prompt' is the message string to display; 'buttons' |
| 90 | * gives the set of buttons to display; 'defaultButton' is the index |
| 91 | * (starting at 1) among the buttons of the default button; and |
| 92 | * 'cancelButton' is the index of the cancellation button. |
| 93 | * |
| 94 | * 'buttons' can be given as an InDlgXxx constant (InDlgOk, |
| 95 | * InDlgOkCancel, etc.) to select one of the standard sets of buttons. |
| 96 | * Or, it can be a list giving a custom set of buttons, in which case |
| 97 | * each element of the list is either a string giving a custom label |
| 98 | * for the button, or one of the InDlgLblXxx values to select a |
| 99 | * standard label. The standard labels should be used when possible, |
| 100 | * as these will be automatically localized; labels given explicitly as |
| 101 | * strings will be used exactly as given. If a list of custom button |
| 102 | * labels is given, the buttons are displayed in the dialog in the |
| 103 | * order of the list (usually left to right, but this could vary |
| 104 | * according to system conventions and localization). |
| 105 | * |
| 106 | * Each custom button label string can incorporate an ampersand ("&"). |
| 107 | * The letter immediately following the ampersand, if provided, is used |
| 108 | * as the keyboard shortcut for the button. This is particularly |
| 109 | * important on character-mode systems, where the "dialog" is typically |
| 110 | * shown merely as a text prompt, and the user responds by selecting |
| 111 | * the letter of the desired option. Typically, you should use the |
| 112 | * first character of a button label as its keyboard shortcut, but this |
| 113 | * obviously won't work when two button labels have the same first |
| 114 | * letter; in these cases, you should choose another letter from the |
| 115 | * button label, preferably something like the first letter of the |
| 116 | * second word of the button label, or the first letter of the stressed |
| 117 | * syllable of the most important word of the label. |
| 118 | * |
| 119 | * The return value is the index among the buttons of the button that |
| 120 | * the user selects to dismiss the dialog. The function doesn't return |
| 121 | * until the user selects one of the buttons. |
| 122 | */ |
| 123 | inputDialog(icon, prompt, buttons, defaultButton, cancelButton); |
| 124 | |
| 125 | /* |
| 126 | * Display a file selector dialog. This prompts the user to select a |
| 127 | * file. On GUI systems, this will typically display the standard |
| 128 | * system file selection dialog; on character-mode systems, it might |
| 129 | * simply display the prompt string and let the user type the name of a |
| 130 | * file directly. |
| 131 | * |
| 132 | * 'prompt' is the message string to display in the dialog to let the |
| 133 | * user know what type of file is being requested. 'dialogType' is one |
| 134 | * of the InFileXxx constants specifying whether the request is to |
| 135 | * select an existing file or to specify the name for a new file. |
| 136 | * 'fileType' is a FileTypeXxx constant giving the format of the file |
| 137 | * being requested; this is used on some systems to filter the |
| 138 | * displayed list of existing files so that only files of the same |
| 139 | * format are included, to reduce clutter. 'flags' is reserved for |
| 140 | * future use and should simply be set to zero. |
| 141 | * |
| 142 | * The return value is a list. The first element is an integer giving |
| 143 | * the status: InFileSuccess indicates that the user successfully |
| 144 | * selected a file, whose name is given as a string in the second |
| 145 | * element of the result list; InFileFailure indicates a system error |
| 146 | * of some kind showing the dialog; and InFileCancel indicates that the |
| 147 | * user explicitly canceled the dialog. |
| 148 | * |
| 149 | * On success (return list[1] == InFileSuccess), the list contains the |
| 150 | * following additional elements: |
| 151 | * |
| 152 | *. [2] = the selected filename |
| 153 | *. [3] = nil (reserved for future use) |
| 154 | *. [4] = script warning message, or nil if no warning |
| 155 | * |
| 156 | * The warning message is a string to be displayed to the user to warn |
| 157 | * about a possible error condition in the script input. The script |
| 158 | * reader checks the file specified in the script to see if it's valid; |
| 159 | * if the dialog type is Open, the script reader verifies that the file |
| 160 | * exists, and for a Save dialog the reader warns if the file *does* |
| 161 | * already exist or is not writable. In the conventional UI, the |
| 162 | * script reader displays these warnings directly to the user through |
| 163 | * the console UI, but this isn't possible in the Web UI since the user |
| 164 | * might be running on a remote browser. Instead, the script reader |
| 165 | * still checks for the possible errors, but rather than displaying any |
| 166 | * warnings, it returns them here. The caller is responsible for |
| 167 | * displaying the warning and asking the user for confirmation. |
| 168 | * |
| 169 | * For localization purposes, the warning message starts with a |
| 170 | * two-letter code indicating the specific error, followed by a space, |
| 171 | * followed by the English text of the warning. The codes are: |
| 172 | * |
| 173 | *. OV - the script might overwrite an existing file (Save dialog) |
| 174 | *. WR - the file can't be created/written (Save dialog) |
| 175 | *. RD - the file doesn't exist/can't be read (Open dialog) |
| 176 | * |
| 177 | * Note that the warning message will always be nil if the script |
| 178 | * reader displayed the warning message itself. This means that your |
| 179 | * program can unconditionally display this message if it's non-nil - |
| 180 | * there's no danger that the script reader will have redundantly |
| 181 | * displayed the message. |
| 182 | */ |
| 183 | inputFile(prompt, dialogType, fileType, flags); |
| 184 | |
| 185 | /* |
| 186 | * Pause for the given number of milliseconds. |
| 187 | */ |
| 188 | timeDelay(delayMilliseconds); |
| 189 | |
| 190 | /* |
| 191 | * Retrieve local system information. 'infoType' is a SysInfoXxx |
| 192 | * constant giving the type of information to retrieve. Additional |
| 193 | * arguments and the return value vary according to the infoType value. |
| 194 | */ |
| 195 | systemInfo(infoType, ...); |
| 196 | |
| 197 | /* |
| 198 | * Set the status-line display mode. This is meaningful only with |
| 199 | * text-only interpreters that don't support banner windows; other |
| 200 | * interpreters ignore this. 'mode' is a StatModeXxx constant giving |
| 201 | * the new mode. |
| 202 | */ |
| 203 | statusMode(mode); |
| 204 | |
| 205 | /* |
| 206 | * Write text on the right half of the status line. This is meaningful |
| 207 | * only for text-only interpreters that don't support banner windows; |
| 208 | * other interpreters ignore this. On non-banner interpreters, this |
| 209 | * sets the right half of the status line to display the given text, |
| 210 | * right-justified. |
| 211 | */ |
| 212 | statusRight(txt); |
| 213 | |
| 214 | /* |
| 215 | * Determine if a multimedia resource exists. 'fname' is the name of a |
| 216 | * resource (a JPEG image file, PNG image file, etc), given in |
| 217 | * URL-style path notation. Returns true if the resource is available, |
| 218 | * nil if not. |
| 219 | */ |
| 220 | resExists(fname); |
| 221 | |
| 222 | /* |
| 223 | * Set the script input file. This opens the given file as the script |
| 224 | * input file. 'filename' is a string giving the name of the file to |
| 225 | * open, and 'flags' is a combination of ScriptFileXxx bit flags giving |
| 226 | * the mode to use to read the file. When a script file is active, the |
| 227 | * system reads command-line input from the file rather than from the |
| 228 | * keyboard. This lets the program replay an input script. |
| 229 | * |
| 230 | * Note that the ScriptFileEvent flag is ignored if included in the |
| 231 | * 'flags' parameter. The script reader automatically determines the |
| 232 | * script type by examining the file's contents, so you can't set the |
| 233 | * type using flags. This flag is used only in "get status" requests |
| 234 | * (ScriptReqGetStatus) - it's included in the returned flags if |
| 235 | * applicable. The purpose of this flag is to let you determine what |
| 236 | * the script reader decided about the script, rather than telling the |
| 237 | * script reader how to interpret the script. |
| 238 | * |
| 239 | * If 'filename' is nil, this cancels the current script. If the |
| 240 | * script was invoked from an enclosing script, this resumes the |
| 241 | * enclosing script, otherwise it resumes reading input from the |
| 242 | * keyboard. The 'flags' argument is ignored in this case. |
| 243 | * |
| 244 | * New in 3.0.17: if 'filename' is one of the ScriptReqXxx constants, |
| 245 | * this performs a special script request. See the ScriptReqXxx |
| 246 | * constants for details. Note that calling this function with a |
| 247 | * ScriptReqXxx constant on an VM prior to 3.0.17 will result in a |
| 248 | * run-time error, so you can use try-catch to detect whether the |
| 249 | * request is supported. |
| 250 | */ |
| 251 | setScriptFile(filename, flags?); |
| 252 | |
| 253 | /* |
| 254 | * Get the local default character set. 'which' is a CharsetXxx value |
| 255 | * giving which local character set to retrieve. Returns a string |
| 256 | * giving the name of the given local character set. |
| 257 | */ |
| 258 | getLocalCharSet(which); |
| 259 | |
| 260 | /* |
| 261 | * Flush text output and update the main display window. This ensures |
| 262 | * that any text displayed with tadsSay() is actually displayed, for |
| 263 | * the user to see (rather than being held in internal buffers). |
| 264 | */ |
| 265 | flushOutput(); |
| 266 | |
| 267 | /* |
| 268 | * Read a line of text from the keyboard. Waits for the user to edit |
| 269 | * and enter a command line. If a 'timeout' value is specified, it |
| 270 | * gives the maximum interval to wait for the user to finish entering |
| 271 | * the input, in milliseconds. If the timeout expires before the user |
| 272 | * finishes entering the line, the function stops waiting and returns. |
| 273 | * |
| 274 | * The return value is a list. The first element is an InEvtXxx code |
| 275 | * giving the status. If the status is InEvtLine, the second element |
| 276 | * is a string giving the command line the user entered. If the status |
| 277 | * is InEvtTimeout, the second element is a string giving the text of |
| 278 | * the command line so far - that is, the text that the user had typed |
| 279 | * up to the point when the timeout expired. Other status codes have |
| 280 | * no additional list elements. |
| 281 | * |
| 282 | * When an InEvtTimeout status is returned, the caller must either |
| 283 | * cancel the interrupted input line with inputLineCancel(), or must |
| 284 | * make another call to inputLineTimeout() without any intervening call |
| 285 | * to any output function that displays anything in the main window, or |
| 286 | * any input function other than inputLineTimeout(). |
| 287 | */ |
| 288 | inputLineTimeout(timeout?); |
| 289 | |
| 290 | /* |
| 291 | * Cancel an input line that was interrupted by timeout. This function |
| 292 | * must be called after an inputLineTimeout() returns with an |
| 293 | * InEvtTimeout status indication and before any subsequent output |
| 294 | * function that displays anything in the main window, or any input |
| 295 | * fucntion other than inputLineTimeout(). |
| 296 | * |
| 297 | * This function updates the UI to reflect that command line editing is |
| 298 | * no longer in progress. If 'reset' is true, it also resets the |
| 299 | * internal memory of the command editing session, so that a subsequent |
| 300 | * call to inputLineTimeout() will start from scratch with an empty |
| 301 | * command line. If 'reset' is nil, this function merely adjusts the |
| 302 | * UI, but does not clear the internal memory; the next call to |
| 303 | * inputLineTimeout() will automatically restore the editing status, |
| 304 | * re-displaying what the user had typed so far on the interrupted |
| 305 | * command line and restoring the cursor position to its position when |
| 306 | * the timeout occurred. |
| 307 | * |
| 308 | * Note that it's not necessary (or desirable) to call this function |
| 309 | * after a timed-out input line if the next input/output function that |
| 310 | * affects the main window is simply another call to |
| 311 | * inputLineTimeout(). In this case, inputLineTimeout() simply picks |
| 312 | * up where it left off, without any indication to the user that the |
| 313 | * input editing was ever interrupted. |
| 314 | */ |
| 315 | inputLineCancel(reset); |
| 316 | |
| 317 | /* |
| 318 | * Create a banner window. Returns the "handle" of the new window, |
| 319 | * which is used to identify the window in subsequent bannerXxx() |
| 320 | * functions. Not all interpreters support banner windows; if the |
| 321 | * interpreter does not support this feature, the return value is nil. |
| 322 | * |
| 323 | * 'parent' is the handle of the parent window; if this is nil, the |
| 324 | * banner is split off from the main display window. 'where' is a |
| 325 | * BannerXxx value giving the list position; if this is BannerBefore or |
| 326 | * BannerAfter, 'other' is the handle of an existing banner window |
| 327 | * child of the same parent. 'windowType' is a BannerTypeXxx value |
| 328 | * giving the type of window to create. 'align' is a BannerAlignXxx |
| 329 | * value giving the alignment - that is, the edge of the parent window |
| 330 | * to which the new banner window attaches. 'size' is the size of the |
| 331 | * window, in the units given by 'sizeUnits', which is a BannerSizeXxx |
| 332 | * value. 'styleFlags' is a combination of BannerStyleXxx bit flags |
| 333 | * that specifies the desired combination of visual styles and UI |
| 334 | * behavior for the new window. |
| 335 | */ |
| 336 | bannerCreate(parent, where, other, windowType, align, |
| 337 | size, sizeUnits, styleFlags); |
| 338 | |
| 339 | /* |
| 340 | * Delete a banner window. 'handle' is the handle to the window to be |
| 341 | * removed. |
| 342 | */ |
| 343 | bannerDelete(handle); |
| 344 | |
| 345 | /* |
| 346 | * Clear the contents of a banner window. 'color' is the color to use |
| 347 | * for the screen color after clearing the window, given as a ColorXxx |
| 348 | * value (see below). |
| 349 | */ |
| 350 | bannerClear(handle); |
| 351 | |
| 352 | /* |
| 353 | * Write text to a banner window. The text is displayed in the given |
| 354 | * banner. For a BannerTypeText window, HTML tags in the text are |
| 355 | * interpreted; for a BannerTypeTextGrid window, the text is written |
| 356 | * exactly as given, without any HTML interpretation. |
| 357 | * |
| 358 | * The value list is handled the same way as the arguments to tadsSay() |
| 359 | * in terms of type conversions. |
| 360 | */ |
| 361 | bannerSay(handle, ...); |
| 362 | |
| 363 | /* |
| 364 | * Flush all buffers for a banner window. This ensures that any text |
| 365 | * written with bannerSay() is actually displayed for the user to see |
| 366 | * (rather than being held in internal buffers). |
| 367 | */ |
| 368 | bannerFlush(handle); |
| 369 | |
| 370 | /* |
| 371 | * Size a banner to fit its contents. This resizes the banner such |
| 372 | * that the contents just fit. In the case of a top- or bottom-aligned |
| 373 | * banner, the height is set just high enough to hold all of the text |
| 374 | * currently displayed. In the case of a left- or right-aligned |
| 375 | * banner, the width is set just wide enough to hold the widest single |
| 376 | * word that can't be broken across lines. In all cases, the size |
| 377 | * includes any fixed margin space, to ensure that all of the text in |
| 378 | * the window is actually visible without scrolling. |
| 379 | * |
| 380 | * Note that not all systems support this function. On systems where |
| 381 | * the function is not supported, this call has no effect. Because of |
| 382 | * this, you should always use this function in conjunction with an |
| 383 | * "advisory" call to bannerSetSize(). |
| 384 | */ |
| 385 | bannerSizeToContents(handle); |
| 386 | |
| 387 | /* |
| 388 | * Go to to an output position. This is meaningful only for |
| 389 | * BannerTypeTextGrid windows. This sets the next text output position |
| 390 | * to the given row and column in the text grid; the next call to |
| 391 | * bannerSay() will display its output starting at this position. |
| 392 | */ |
| 393 | bannerGoTo(handle, row, col); |
| 394 | |
| 395 | /* |
| 396 | * Set text foreground and background colors. This affects the color |
| 397 | * of subsequently displayed text; text displayed previously is not |
| 398 | * affected. The colors are given as ColorXxx values (see below). If |
| 399 | * 'bg' is ColorTransparent, then text is shown with the current screen |
| 400 | * color in the window. |
| 401 | */ |
| 402 | bannerSetTextColor(handle, fg, bg); |
| 403 | |
| 404 | /* |
| 405 | * Set the "screen color" in the banner window. This is the color used |
| 406 | * to fill parts of the window that aren't displaying any text, and as |
| 407 | * the background color for all text displayed when the text background |
| 408 | * color is ColorTransparent. Setting the screen color immediately |
| 409 | * sets the color for the entire window - even text previously |
| 410 | * displayed in the window is affected by this change. |
| 411 | */ |
| 412 | bannerSetScreenColor(handle, color); |
| 413 | |
| 414 | /* |
| 415 | * Get information on the banner. This returns a list giving a |
| 416 | * detailed set of information describing the banner. |
| 417 | */ |
| 418 | bannerGetInfo(handle); |
| 419 | |
| 420 | /* |
| 421 | * Set the size of a banner. This explicitly sets the banner's height |
| 422 | * (for a top or bottom banner) or width (for a left or right) banner |
| 423 | * to the 'size', which is specified in units given by 'sizeUnits', |
| 424 | * which is a BannerSizeXxx constant. If 'isAdvisory' is true, the |
| 425 | * caller is indicating that this call will be followed soon by a call |
| 426 | * to bannerSizeToContents(). On systems that support sizing to |
| 427 | * contents, an "advisory" call to bannerSetSize() will simply be |
| 428 | * ignored in anticipation of the upcoming call to |
| 429 | * bannerSizeToContents(). On systems that don't support sizing to |
| 430 | * contents, an advisory call will actually resize the window. |
| 431 | */ |
| 432 | bannerSetSize(handle, size, sizeUnits, isAdvisory); |
| 433 | |
| 434 | /* |
| 435 | * Create a log file console. This creates a console that has no |
| 436 | * display, but simply captures its output to the given log file. |
| 437 | * Writing to a log console is different from writing to a regular text |
| 438 | * file in that we apply all of the normal formatting (including |
| 439 | * text-only-mode HTML interpretation) to the output sent to this |
| 440 | * console. |
| 441 | */ |
| 442 | logConsoleCreate(filename, charset, width); |
| 443 | |
| 444 | /* |
| 445 | * Close a log console. This closes the file associated with the log |
| 446 | * console and deletes the console object. The given console handle is |
| 447 | * no longer valid after this function is called. |
| 448 | */ |
| 449 | logConsoleClose(handle); |
| 450 | |
| 451 | /* |
| 452 | * Write text to a log console. This works the same as tadsSay(), but |
| 453 | * writes the output to the given log console rather than to the main |
| 454 | * output window. |
| 455 | */ |
| 456 | logConsoleSay(handle, ...); |
| 457 | |
| 458 | /* |
| 459 | * Log an input event that's obtained externally - i.e., from a source |
| 460 | * other than the system input APIs (inputLine, inputKey, inputEvent, |
| 461 | * etc). This adds the event to any command or event log that the |
| 462 | * system is currently writing, as set with setLogFile(). |
| 463 | * |
| 464 | * It's only necessary to call this function when obtaining user input |
| 465 | * from custom code that bypasses the system input APIs. The system |
| 466 | * input functions all log events automatically, so you must not call |
| 467 | * this for input obtained from them (doing so would write each input |
| 468 | * twice, since it's already being written once by the input |
| 469 | * functions). For example, this is useful for the Web UI, since it |
| 470 | * obtains input via network transactions with the javascript client. |
| 471 | * |
| 472 | * 'evt' is a list describing the event, using the same format that |
| 473 | * inputEvent() returns. Note one special extension: if the first |
| 474 | * element of the list is a string, the string is used as the tag name |
| 475 | * if we're writing an event script. This can be used to write custom |
| 476 | * events or events with no InEvtXxx type code, such as <dialog> input |
| 477 | * events. |
| 478 | */ |
| 479 | logInputEvent(evt); |
| 480 | } |
| 481 | |
| 482 | /* log file types */ |
| 483 | #define LogTypeTranscript 1 /* log all input and output to a transcript */ |
| 484 | #define LogTypeCommand 2 /* log only command-line input */ |
| 485 | #define LogTypeScript 3 /* log all input events */ |
| 486 | |
| 487 | /* |
| 488 | * The special log console handle for the main console window's transcript. |
| 489 | * This can be used as the handle in logConsoleSay(), to write text |
| 490 | * directly to the main console's log file, if any. Note that this console |
| 491 | * cannot be closed via logConsoleClose(); use setLogFile(nil) instead. |
| 492 | */ |
| 493 | #define MainWindowLogHandle (-1) |
| 494 | |
| 495 | /* |
| 496 | * constants for the event codes returned by the inputEvent() and |
| 497 | * inputLineTimeout() intrinsic functions |
| 498 | */ |
| 499 | #define InEvtKey 1 |
| 500 | #define InEvtTimeout 2 |
| 501 | #define InEvtHref 3 |
| 502 | #define InEvtNoTimeout 4 |
| 503 | #define InEvtNotimeout 4 /* (note minor capitalization variation) */ |
| 504 | #define InEvtEof 5 |
| 505 | #define InEvtLine 6 |
| 506 | #define InEvtSysCommand 0x100 |
| 507 | #define InEvtEndQuietScript 10000 |
| 508 | #define InEvtEndScript 10003 |
| 509 | |
| 510 | /* |
| 511 | * Command codes for InEvtSysCommand |
| 512 | */ |
| 513 | #define SaveCommand 0x0001 /* SAVE the current position */ |
| 514 | #define RestoreCommand 0x0002 /* RESTORE a saved position */ |
| 515 | #define UndoCommand 0x0003 /* UNDO one turn */ |
| 516 | #define QuitCommand 0x0004 /* QUIT the game */ |
| 517 | #define CloseCommand 0x0005 /* close the game window */ |
| 518 | #define HelpCommand 0x0006 /* show game HELP */ |
| 519 | |
| 520 | |
| 521 | /* |
| 522 | * constants for inputDialog() |
| 523 | */ |
| 524 | #define InDlgOk 1 |
| 525 | #define InDlgOkCancel 2 |
| 526 | #define InDlgYesNo 3 |
| 527 | #define InDlgYesNoCancel 4 |
| 528 | |
| 529 | #define InDlgIconNone 0 |
| 530 | #define InDlgIconWarning 1 |
| 531 | #define InDlgIconInfo 2 |
| 532 | #define InDlgIconQuestion 3 |
| 533 | #define InDlgIconError 4 |
| 534 | |
| 535 | #define InDlgLblOk 1 |
| 536 | #define InDlgLblCancel 2 |
| 537 | #define InDlgLblYes 3 |
| 538 | #define InDlgLblNo 4 |
| 539 | |
| 540 | /* |
| 541 | * inputFile() dialog types |
| 542 | */ |
| 543 | #define InFileOpen 1 /* open an existing file for reading */ |
| 544 | #define InFileSave 2 /* save to the file */ |
| 545 | |
| 546 | /* |
| 547 | * inputFile() return codes - these are returned in the first element of |
| 548 | * the list returned from inputFile() |
| 549 | */ |
| 550 | #define InFileSuccess 0 /* success - 2nd list element is filename */ |
| 551 | #define InFileFailure 1 /* an error occurred asking for a file */ |
| 552 | #define InFileCancel 2 /* player canceled the file selector */ |
| 553 | |
| 554 | /* |
| 555 | * constants for inputFile() file type codes |
| 556 | */ |
| 557 | #define FileTypeLog 2 /* a transcript (log) file */ |
| 558 | #define FileTypeData 4 /* arbitrary data file */ |
| 559 | #define FileTypeCmd 5 /* command input file */ |
| 560 | #define FileTypeText 7 /* text file */ |
| 561 | #define FileTypeBin 8 /* binary data file */ |
| 562 | #define FileTypeUnknown 11 /* unknown file type */ |
| 563 | #define FileTypeT3Image 12 /* T3 executable image (game) file */ |
| 564 | #define FileTypeT3Save 15 /* T3 saved state file */ |
| 565 | |
| 566 | /* |
| 567 | * constants for systemInfo information type codes |
| 568 | */ |
| 569 | #define SysInfoVersion 2 |
| 570 | #define SysInfoOsName 3 |
| 571 | #define SysInfoJpeg 5 |
| 572 | #define SysInfoPng 6 |
| 573 | #define SysInfoWav 7 |
| 574 | #define SysInfoMidi 8 |
| 575 | #define SysInfoWavMidiOvl 9 |
| 576 | #define SysInfoWavOvl 10 |
| 577 | #define SysInfoPrefImages 11 |
| 578 | #define SysInfoPrefSounds 12 |
| 579 | #define SysInfoPrefMusic 13 |
| 580 | #define SysInfoPrefLinks 14 |
| 581 | #define SysInfoMpeg 15 |
| 582 | #define SysInfoMpeg1 16 |
| 583 | #define SysInfoMpeg2 17 |
| 584 | #define SysInfoMpeg3 18 |
| 585 | #define SysInfoLinksHttp 20 |
| 586 | #define SysInfoLinksFtp 21 |
| 587 | #define SysInfoLinksNews 22 |
| 588 | #define SysInfoLinksMailto 23 |
| 589 | #define SysInfoLinksTelnet 24 |
| 590 | #define SysInfoPngTrans 25 |
| 591 | #define SysInfoPngAlpha 26 |
| 592 | #define SysInfoOgg 27 |
| 593 | #define SysInfoMng 28 |
| 594 | #define SysInfoMngTrans 29 |
| 595 | #define SysInfoMngAlpha 30 |
| 596 | #define SysInfoTextHilite 31 |
| 597 | #define SysInfoTextColors 32 |
| 598 | #define SysInfoBanners 33 |
| 599 | #define SysInfoInterpClass 34 |
| 600 | #define SysInfoAudioFade 35 |
| 601 | #define SysInfoAudioCrossfade 36 |
| 602 | |
| 603 | /* SysInfoTextColors support level codes */ |
| 604 | #define SysInfoTxcNone 0 |
| 605 | #define SysInfoTxcParam 1 |
| 606 | #define SysInfoTxcAnsiFg 2 |
| 607 | #define SysInfoTxcAnsiFgBg 3 |
| 608 | #define SysInfoTxcRGB 4 |
| 609 | |
| 610 | /* SysInfoInterpClass codes */ |
| 611 | #define SysInfoIClassText 1 |
| 612 | #define SysInfoIClassTextGUI 2 |
| 613 | #define SysInfoIClassHTML 3 |
| 614 | |
| 615 | /* SysInfoAudioFade and SysInfoAudioCrossfade result codes */ |
| 616 | #define SysInfoFadeMPEG 0x0001 |
| 617 | #define SysInfoFadeOGG 0x0002 |
| 618 | #define SysInfoFadeWAV 0x0004 |
| 619 | #define SysInfoFadeMIDI 0x0008 |
| 620 | |
| 621 | /* |
| 622 | * constants for statusMode |
| 623 | */ |
| 624 | #define StatModeNormal 0 /* displaying normal text */ |
| 625 | #define StatModeStatus 1 /* display status line text */ |
| 626 | |
| 627 | /* |
| 628 | * flags for setScriptFile |
| 629 | */ |
| 630 | #define ScriptFileQuiet 1 /* do not display output while reading script */ |
| 631 | #define ScriptFileNonstop 2 /* turn off MORE prompt while reading script */ |
| 632 | #define ScriptFileEvent 4 /* this is an event script (query only) */ |
| 633 | |
| 634 | /* |
| 635 | * Script Request - get current script status. In 3.0.17+, passing this |
| 636 | * constant as the 'filename' argument to getScriptFile() will perform a |
| 637 | * "get script status" request. If there's no script file in progress, the |
| 638 | * function returns nil. If a script file is being read, the function |
| 639 | * returns an integer value giving a combination of ScriptFileXxx flag |
| 640 | * values indicating the current script status. Note that a return value |
| 641 | * of 0 (zero) means that a script is running but none of the ScriptFileXxx |
| 642 | * flags are applicable. |
| 643 | */ |
| 644 | #define ScriptReqGetStatus 0x7000 |
| 645 | |
| 646 | /* |
| 647 | * selectors for getLocalCharSet |
| 648 | */ |
| 649 | #define CharsetDisplay 1 /* the display/keyboard character set */ |
| 650 | #define CharsetFileName 2 /* the file system character set */ |
| 651 | #define CharsetFileCont 3 /* default file contents character set */ |
| 652 | |
| 653 | /* |
| 654 | * banner insertion point specifies (for 'where' in bannerCreate) |
| 655 | */ |
| 656 | #define BannerFirst 1 |
| 657 | #define BannerLast 2 |
| 658 | #define BannerBefore 3 |
| 659 | #define BannerAfter 4 |
| 660 | |
| 661 | /* |
| 662 | * banner types |
| 663 | */ |
| 664 | #define BannerTypeText 1 /* ordinary text stream window */ |
| 665 | #define BannerTypeTextGrid 2 /* text grid window */ |
| 666 | |
| 667 | /* |
| 668 | * banner alignment types |
| 669 | */ |
| 670 | #define BannerAlignTop 0 |
| 671 | #define BannerAlignBottom 1 |
| 672 | #define BannerAlignLeft 2 |
| 673 | #define BannerAlignRight 3 |
| 674 | |
| 675 | /* |
| 676 | * banner size unit types |
| 677 | */ |
| 678 | #define BannerSizePercent 1 /* size is a percentage of available space */ |
| 679 | #define BannerSizeAbsolute 2 /* size is in natural units of window type */ |
| 680 | |
| 681 | /* |
| 682 | * banner style flags |
| 683 | */ |
| 684 | #define BannerStyleBorder 0x0001 /* banner has a visible border */ |
| 685 | #define BannerStyleVScroll 0x0002 /* vertical scrollbar */ |
| 686 | #define BannerStyleHScroll 0x0004 /* horizontal scrollbar */ |
| 687 | #define BannerStyleAutoVScroll 0x0008 /* automatic vertical scrolling */ |
| 688 | #define BannerStyleAutoHScroll 0x0010 /* automatic horizontal scrolling */ |
| 689 | #define BannerStyleTabAlign 0x0020 /* <TAB> alignment support */ |
| 690 | #define BannerStyleMoreMode 0x0040 /* use MORE mode */ |
| 691 | #define BannerStyleHStrut 0x0080 /* include in parent's auto width */ |
| 692 | #define BannerStyleVStrut 0x0100 /* include in parent's auto height */ |
| 693 | |
| 694 | /* |
| 695 | * Color codes. A color can be specified with explicit RGB |
| 696 | * (red-green-blue) component values, or can be "parameterized," which |
| 697 | * means that the color uses a pre-defined color for a particular purpose. |
| 698 | * |
| 699 | * RGB colors are specified with each component given in the range 0 to |
| 700 | * 255; the color (0,0,0) is pure black, and (255,255,255) is pure white. |
| 701 | * |
| 702 | * The special value "transparent" is not a color at all, but rather |
| 703 | * specifies that the current screen color should be used. |
| 704 | * |
| 705 | * The "Text" and "TextBg" colors are the current default text and text |
| 706 | * background colors. The actual colors displayed for these values depend |
| 707 | * on the system, and on some systems these colors might be configurable by |
| 708 | * the user through a preferences selection. These are the same colors |
| 709 | * selected by the HTML parameterized color names 'text' and 'bgcolor'. |
| 710 | * |
| 711 | * The "StatusText" and "StatusBg" colors are the current default |
| 712 | * statusline text and background colors, which depend on the system and |
| 713 | * may be user-configurable on some systems. These are the same colors |
| 714 | * selected by the HTML parameterized color names 'statustext' and |
| 715 | * 'statusbg'. |
| 716 | * |
| 717 | * The "input" color is the current default input text color. |
| 718 | */ |
| 719 | #define ColorRGB(r, g, b) \ |
| 720 | ((((r) & 0xff) << 16) + (((g) & 0xff) << 8) + ((b) & 0xff)) |
| 721 | #define ColorTransparent 0x01000000 |
| 722 | #define ColorText 0x02000000 |
| 723 | #define ColorTextBg 0x03000000 |
| 724 | #define ColorStatusText 0x04000000 |
| 725 | #define ColorStatusBg 0x05000000 |
| 726 | #define ColorInput 0x06000000 |
| 727 | |
| 728 | /* some specific colors by name, for convenience */ |
| 729 | #define ColorBlack ColorRGB(0x00, 0x00, 0x00) |
| 730 | #define ColorWhite ColorRGB(0xff, 0xff, 0xff) |
| 731 | #define ColorRed ColorRGB(0xff, 0x00, 0x00) |
| 732 | #define ColorBlue ColorRGB(0x00, 0x00, 0xFF) |
| 733 | #define ColorGreen ColorRGB(0x00, 0x80, 0x00) |
| 734 | #define ColorYellow ColorRGB(0xFF, 0xFF, 0x00) |
| 735 | #define ColorCyan ColorRGB(0x00, 0xFF, 0xFF) |
| 736 | #define ColorAqua ColorRGB(0x00, 0xFF, 0xFF) |
| 737 | #define ColorMagenta ColorRGB(0xFF, 0x00, 0xFF) |
| 738 | #define ColorSilver ColorRGB(0xC0, 0xC0, 0xC0) |
| 739 | #define ColorGray ColorRGB(0x80, 0x80, 0x80) |
| 740 | #define ColorMaroon ColorRGB(0x80, 0x00, 0x00) |
| 741 | #define ColorPurple ColorRGB(0x80, 0x00, 0x80) |
| 742 | #define ColorFuchsia ColorRGB(0xFF, 0x00, 0xFF) |
| 743 | #define ColorLime ColorRGB(0x00, 0xFF, 0x00) |
| 744 | #define ColorOlive ColorRGB(0x80, 0x80, 0x00) |
| 745 | #define ColorNavy ColorRGB(0x00, 0x00, 0x80) |
| 746 | #define ColorTeal ColorRGB(0x00, 0x80, 0x80) |
| 747 |