tadsio.hfile | source file |
Classes Summary | Functions Summary Details | Macros Summary Details | Enums Summary Details | Templates Summary Details |
This header defines the tads-io intrinsic function set.
The TADS input/output function set provides access to the user interface. This lets you read input from the keyboard and display output on the monitor or terminal. It also provides access to windowing features (via the "banner" functions) on systems that support multiple display windows (which doesn't necessarily mean GUI-type systems: many character-mode systems support the banner operations as well, simply by dividing up the character-mode screen into rectangular regions).
bannerClear
bannerCreate
bannerDelete
bannerFlush
bannerGetInfo
bannerGoTo
bannerSay
bannerSetScreenColor
bannerSetSize
bannerSetTextColor
bannerSizeToContents
clearScreen
flushOutput
getLocalCharSet
inputDialog
inputEvent
inputFile
inputKey
inputLine
inputLineCancel
inputLineTimeout
logConsoleClose
logConsoleCreate
logConsoleSay
logInputEvent
morePrompt
resExists
setLogFile
setScriptFile
statusMode
statusRight
systemInfo
tadsSay
timeDelay
BannerAfter
BannerAlignBottom
BannerAlignLeft
BannerAlignRight
BannerAlignTop
BannerBefore
BannerFirst
BannerLast
BannerSizeAbsolute
BannerSizePercent
BannerStyleAutoHScroll
BannerStyleAutoVScroll
BannerStyleBorder
BannerStyleHScroll
BannerStyleHStrut
BannerStyleMoreMode
BannerStyleTabAlign
BannerStyleVScroll
BannerStyleVStrut
BannerTypeText
BannerTypeTextGrid
CharsetDisplay
CharsetFileCont
CharsetFileName
CloseCommand
ColorAqua
ColorBlack
ColorBlue
ColorCyan
ColorFuchsia
ColorGray
ColorGreen
ColorInput
ColorLime
ColorMagenta
ColorMaroon
ColorNavy
ColorOlive
ColorPurple
ColorRed
ColorRGB
ColorSilver
ColorStatusBg
ColorStatusText
ColorTeal
ColorText
ColorTextBg
ColorTransparent
ColorWhite
ColorYellow
FileTypeBin
FileTypeCmd
FileTypeData
FileTypeLog
FileTypeT3Image
FileTypeT3Save
FileTypeText
FileTypeUnknown
HelpCommand
InDlgIconError
InDlgIconInfo
InDlgIconNone
InDlgIconQuestion
InDlgIconWarning
InDlgLblCancel
InDlgLblNo
InDlgLblOk
InDlgLblYes
InDlgOk
InDlgOkCancel
InDlgYesNo
InDlgYesNoCancel
InEvtEndQuietScript
InEvtEndScript
InEvtEof
InEvtHref
InEvtKey
InEvtLine
InEvtNoTimeout
InEvtNotimeout
InEvtSysCommand
InEvtTimeout
InFileCancel
InFileFailure
InFileOpen
InFileSave
InFileSuccess
LogTypeCommand
LogTypeScript
LogTypeTranscript
MainWindowLogHandle
QuitCommand
RestoreCommand
SaveCommand
ScriptFileEvent
ScriptFileNonstop
ScriptFileQuiet
ScriptReqGetStatus
StatModeNormal
StatModeStatus
SysInfoAudioCrossfade
SysInfoAudioFade
SysInfoBanners
SysInfoFadeMIDI
SysInfoFadeMPEG
SysInfoFadeOGG
SysInfoFadeWAV
SysInfoIClassHTML
SysInfoIClassText
SysInfoIClassTextGUI
SysInfoInterpClass
SysInfoJpeg
SysInfoLinksFtp
SysInfoLinksHttp
SysInfoLinksMailto
SysInfoLinksNews
SysInfoLinksTelnet
SysInfoMidi
SysInfoMng
SysInfoMngAlpha
SysInfoMngTrans
SysInfoMpeg
SysInfoMpeg1
SysInfoMpeg2
SysInfoMpeg3
SysInfoOgg
SysInfoOsName
SysInfoPng
SysInfoPngAlpha
SysInfoPngTrans
SysInfoPrefImages
SysInfoPrefLinks
SysInfoPrefMusic
SysInfoPrefSounds
SysInfoTextColors
SysInfoTextHilite
SysInfoTxcAnsiFg
SysInfoTxcAnsiFgBg
SysInfoTxcNone
SysInfoTxcParam
SysInfoTxcRGB
SysInfoVersion
SysInfoWav
SysInfoWavMidiOvl
SysInfoWavOvl
UndoCommand
bannerClear (handle) | tadsio.h[350] |
bannerCreate (parent, where, other, windowType, align, size, sizeUnits, styleFlags) | tadsio.h[336] |
'parent' is the handle of the parent window; if this is nil, the banner is split off from the main display window. 'where' is a BannerXxx value giving the list position; if this is BannerBefore or BannerAfter, 'other' is the handle of an existing banner window child of the same parent. 'windowType' is a BannerTypeXxx value giving the type of window to create. 'align' is a BannerAlignXxx value giving the alignment - that is, the edge of the parent window to which the new banner window attaches. 'size' is the size of the window, in the units given by 'sizeUnits', which is a BannerSizeXxx value. 'styleFlags' is a combination of BannerStyleXxx bit flags that specifies the desired combination of visual styles and UI behavior for the new window.
bannerDelete (handle) | tadsio.h[343] |
bannerFlush (handle) | tadsio.h[368] |
bannerGetInfo (handle) | tadsio.h[418] |
bannerGoTo (handle, row, col) | tadsio.h[393] |
bannerSay (handle, ...) | tadsio.h[361] |
The value list is handled the same way as the arguments to tadsSay() in terms of type conversions.
bannerSetScreenColor (handle, color) | tadsio.h[412] |
bannerSetSize (handle, size, sizeUnits, isAdvisory) | tadsio.h[432] |
bannerSetTextColor (handle, fg, bg) | tadsio.h[402] |
bannerSizeToContents (handle) | tadsio.h[385] |
Note that not all systems support this function. On systems where the function is not supported, this call has no effect. Because of this, you should always use this function in conjunction with an "advisory" call to bannerSetSize().
clearScreen ( ) | tadsio.h[48] |
flushOutput ( ) | tadsio.h[265] |
getLocalCharSet (which) | tadsio.h[258] |
inputDialog (icon, prompt, buttons, defaultButton, cancelButton) | tadsio.h[123] |
'buttons' can be given as an InDlgXxx constant (InDlgOk, InDlgOkCancel, etc.) to select one of the standard sets of buttons. Or, it can be a list giving a custom set of buttons, in which case each element of the list is either a string giving a custom label for the button, or one of the InDlgLblXxx values to select a standard label. The standard labels should be used when possible, as these will be automatically localized; labels given explicitly as strings will be used exactly as given. If a list of custom button labels is given, the buttons are displayed in the dialog in the order of the list (usually left to right, but this could vary according to system conventions and localization).
Each custom button label string can incorporate an ampersand ("&"). The letter immediately following the ampersand, if provided, is used as the keyboard shortcut for the button. This is particularly important on character-mode systems, where the "dialog" is typically shown merely as a text prompt, and the user responds by selecting the letter of the desired option. Typically, you should use the first character of a button label as its keyboard shortcut, but this obviously won't work when two button labels have the same first letter; in these cases, you should choose another letter from the button label, preferably something like the first letter of the second word of the button label, or the first letter of the stressed syllable of the most important word of the label.
The return value is the index among the buttons of the button that the user selects to dismiss the dialog. The function doesn't return until the user selects one of the buttons.
inputEvent (timeout?) | tadsio.h[79] |
inputFile (prompt, dialogType, fileType, flags) | tadsio.h[183] |
'prompt' is the message string to display in the dialog to let the user know what type of file is being requested. 'dialogType' is one of the InFileXxx constants specifying whether the request is to select an existing file or to specify the name for a new file. 'fileType' is a FileTypeXxx constant giving the format of the file being requested; this is used on some systems to filter the displayed list of existing files so that only files of the same format are included, to reduce clutter. 'flags' is reserved for future use and should simply be set to zero.
The return value is a list. The first element is an integer giving the status: InFileSuccess indicates that the user successfully selected a file, whose name is given as a string in the second element of the result list; InFileFailure indicates a system error of some kind showing the dialog; and InFileCancel indicates that the user explicitly canceled the dialog.
On success (return list[1] == InFileSuccess), the list contains the following additional elements:
[2] = the selected filename
[3] = nil (reserved for future use)
[4] = script warning message, or nil if no warning
The warning message is a string to be displayed to the user to warn about a possible error condition in the script input. The script reader checks the file specified in the script to see if it's valid; if the dialog type is Open, the script reader verifies that the file exists, and for a Save dialog the reader warns if the file *does* already exist or is not writable. In the conventional UI, the script reader displays these warnings directly to the user through the console UI, but this isn't possible in the Web UI since the user might be running on a remote browser. Instead, the script reader still checks for the possible errors, but rather than displaying any warnings, it returns them here. The caller is responsible for displaying the warning and asking the user for confirmation.
For localization purposes, the warning message starts with a two-letter code indicating the specific error, followed by a space, followed by the English text of the warning. The codes are:
OV - the script might overwrite an existing file (Save dialog)
WR - the file can't be created/written (Save dialog)
RD - the file doesn't exist/can't be read (Open dialog)
Note that the warning message will always be nil if the script reader displayed the warning message itself. This means that your program can unconditionally display this message if it's non-nil - there's no danger that the script reader will have redundantly displayed the message.
inputKey ( ) | tadsio.h[68] |
inputLine ( ) | tadsio.h[62] |
inputLineCancel (reset) | tadsio.h[315] |
This function updates the UI to reflect that command line editing is no longer in progress. If 'reset' is true, it also resets the internal memory of the command editing session, so that a subsequent call to inputLineTimeout() will start from scratch with an empty command line. If 'reset' is nil, this function merely adjusts the UI, but does not clear the internal memory; the next call to inputLineTimeout() will automatically restore the editing status, re-displaying what the user had typed so far on the interrupted command line and restoring the cursor position to its position when the timeout occurred.
Note that it's not necessary (or desirable) to call this function after a timed-out input line if the next input/output function that affects the main window is simply another call to inputLineTimeout(). In this case, inputLineTimeout() simply picks up where it left off, without any indication to the user that the input editing was ever interrupted.
inputLineTimeout (timeout?) | tadsio.h[288] |
The return value is a list. The first element is an InEvtXxx code giving the status. If the status is InEvtLine, the second element is a string giving the command line the user entered. If the status is InEvtTimeout, the second element is a string giving the text of the command line so far - that is, the text that the user had typed up to the point when the timeout expired. Other status codes have no additional list elements.
When an InEvtTimeout status is returned, the caller must either cancel the interrupted input line with inputLineCancel(), or must make another call to inputLineTimeout() without any intervening call to any output function that displays anything in the main window, or any input function other than inputLineTimeout().
logConsoleClose (handle) | tadsio.h[449] |
logConsoleCreate (filename, charset, width) | tadsio.h[442] |
logConsoleSay (handle, ...) | tadsio.h[456] |
logInputEvent (evt) | tadsio.h[479] |
It's only necessary to call this function when obtaining user input from custom code that bypasses the system input APIs. The system input functions all log events automatically, so you must not call this for input obtained from them (doing so would write each input twice, since it's already being written once by the input functions). For example, this is useful for the Web UI, since it obtains input via network transactions with the javascript client.
'evt' is a list describing the event, using the same format that inputEvent() returns. Note one special extension: if the first element of the list is a string, the string is used as the tag name if we're writing an event script. This can be used to write custom events or events with no InEvtXxx type code, such as <dialog> input events.
morePrompt ( ) | tadsio.h[56] |
resExists (fname) | tadsio.h[220] |
setLogFile (fname, logType?) | tadsio.h[43] |
setScriptFile (filename, flags?) | tadsio.h[251] |
Note that the ScriptFileEvent flag is ignored if included in the 'flags' parameter. The script reader automatically determines the script type by examining the file's contents, so you can't set the type using flags. This flag is used only in "get status" requests (ScriptReqGetStatus) - it's included in the returned flags if applicable. The purpose of this flag is to let you determine what the script reader decided about the script, rather than telling the script reader how to interpret the script.
If 'filename' is nil, this cancels the current script. If the script was invoked from an enclosing script, this resumes the enclosing script, otherwise it resumes reading input from the keyboard. The 'flags' argument is ignored in this case.
New in 3.0.17: if 'filename' is one of the ScriptReqXxx constants, this performs a special script request. See the ScriptReqXxx constants for details. Note that calling this function with a ScriptReqXxx constant on an VM prior to 3.0.17 will result in a run-time error, so you can use try-catch to detect whether the request is supported.
statusMode (mode) | tadsio.h[203] |
statusRight (txt) | tadsio.h[212] |
systemInfo (infoType, ...) | tadsio.h[195] |
tadsSay (val, ...) | tadsio.h[35] |
timeDelay (delayMilliseconds) | tadsio.h[188] |
BannerAfter | tadsio.h[659] |
4
BannerAlignBottom | tadsio.h[671] |
1
BannerAlignLeft | tadsio.h[672] |
2
BannerAlignRight | tadsio.h[673] |
3
BannerAlignTop | tadsio.h[670] |
0
BannerBefore | tadsio.h[658] |
3
BannerFirst | tadsio.h[656] |
1
BannerLast | tadsio.h[657] |
2
BannerSizeAbsolute | tadsio.h[679] |
2 /* size is in natural units of window type */
BannerSizePercent | tadsio.h[678] |
1 /* size is a percentage of available space */
BannerStyleAutoHScroll | tadsio.h[688] |
0x0010 /* automatic horizontal scrolling */
BannerStyleAutoVScroll | tadsio.h[687] |
0x0008 /* automatic vertical scrolling */
BannerStyleBorder | tadsio.h[684] |
0x0001 /* banner has a visible border */
BannerStyleHScroll | tadsio.h[686] |
0x0004 /* horizontal scrollbar */
BannerStyleHStrut | tadsio.h[691] |
0x0080 /* include in parent's auto width */
BannerStyleMoreMode | tadsio.h[690] |
0x0040 /* use MORE mode */
BannerStyleTabAlign | tadsio.h[689] |
0x0020 /* alignment support */
BannerStyleVScroll | tadsio.h[685] |
0x0002 /* vertical scrollbar */
BannerStyleVStrut | tadsio.h[692] |
0x0100 /* include in parent's auto height */
BannerTypeText | tadsio.h[664] |
1 /* ordinary text stream window */
BannerTypeTextGrid | tadsio.h[665] |
2 /* text grid window */
CharsetDisplay | tadsio.h[649] |
1 /* the display/keyboard character set */
CharsetFileCont | tadsio.h[651] |
3 /* default file contents character set */
CharsetFileName | tadsio.h[650] |
2 /* the file system character set */
CloseCommand | tadsio.h[517] |
0x0005 /* close the game window */
ColorAqua | tadsio.h[736] |
ColorRGB(0x00, 0xFF, 0xFF)
ColorBlack | tadsio.h[729] |
ColorRGB(0x00, 0x00, 0x00)
ColorBlue | tadsio.h[732] |
ColorRGB(0x00, 0x00, 0xFF)
ColorCyan | tadsio.h[735] |
ColorRGB(0x00, 0xFF, 0xFF)
ColorFuchsia | tadsio.h[742] |
ColorRGB(0xFF, 0x00, 0xFF)
ColorGray | tadsio.h[739] |
ColorRGB(0x80, 0x80, 0x80)
ColorGreen | tadsio.h[733] |
ColorRGB(0x00, 0x80, 0x00)
ColorInput | tadsio.h[726] |
0x06000000
ColorLime | tadsio.h[743] |
ColorRGB(0x00, 0xFF, 0x00)
ColorMagenta | tadsio.h[737] |
ColorRGB(0xFF, 0x00, 0xFF)
ColorMaroon | tadsio.h[740] |
ColorRGB(0x80, 0x00, 0x00)
ColorNavy | tadsio.h[745] |
ColorRGB(0x00, 0x00, 0x80)
ColorOlive | tadsio.h[744] |
ColorRGB(0x80, 0x80, 0x00)
ColorPurple | tadsio.h[741] |
ColorRGB(0x80, 0x00, 0x80)
ColorRed | tadsio.h[731] |
ColorRGB(0xff, 0x00, 0x00)
ColorRGB (r, g, b) | tadsio.h[719] |
((((r) & 0xff) << 16) + (((g) & 0xff) << 8) + ((b) & 0xff))
RGB colors are specified with each component given in the range 0 to 255; the color (0,0,0) is pure black, and (255,255,255) is pure white.
The special value "transparent" is not a color at all, but rather specifies that the current screen color should be used.
The "Text" and "TextBg" colors are the current default text and text background colors. The actual colors displayed for these values depend on the system, and on some systems these colors might be configurable by the user through a preferences selection. These are the same colors selected by the HTML parameterized color names 'text' and 'bgcolor'.
The "StatusText" and "StatusBg" colors are the current default statusline text and background colors, which depend on the system and may be user-configurable on some systems. These are the same colors selected by the HTML parameterized color names 'statustext' and 'statusbg'.
The "input" color is the current default input text color.
ColorSilver | tadsio.h[738] |
ColorRGB(0xC0, 0xC0, 0xC0)
ColorStatusBg | tadsio.h[725] |
0x05000000
ColorStatusText | tadsio.h[724] |
0x04000000
ColorTeal | tadsio.h[746] |
ColorRGB(0x00, 0x80, 0x80)
ColorText | tadsio.h[722] |
0x02000000
ColorTextBg | tadsio.h[723] |
0x03000000
ColorTransparent | tadsio.h[721] |
0x01000000
ColorWhite | tadsio.h[730] |
ColorRGB(0xff, 0xff, 0xff)
ColorYellow | tadsio.h[734] |
ColorRGB(0xFF, 0xFF, 0x00)
FileTypeBin | tadsio.h[561] |
8 /* binary data file */
FileTypeCmd | tadsio.h[559] |
5 /* command input file */
FileTypeData | tadsio.h[558] |
4 /* arbitrary data file */
FileTypeLog | tadsio.h[557] |
2 /* a transcript (log) file */
FileTypeT3Image | tadsio.h[563] |
12 /* T3 executable image (game) file */
FileTypeT3Save | tadsio.h[564] |
15 /* T3 saved state file */
FileTypeText | tadsio.h[560] |
7 /* text file */
FileTypeUnknown | tadsio.h[562] |
11 /* unknown file type */
HelpCommand | tadsio.h[518] |
0x0006 /* show game HELP */
InDlgIconError | tadsio.h[533] |
4
InDlgIconInfo | tadsio.h[531] |
2
InDlgIconNone | tadsio.h[529] |
0
InDlgIconQuestion | tadsio.h[532] |
3
InDlgIconWarning | tadsio.h[530] |
1
InDlgLblCancel | tadsio.h[536] |
2
InDlgLblNo | tadsio.h[538] |
4
InDlgLblOk | tadsio.h[535] |
1
InDlgLblYes | tadsio.h[537] |
3
InDlgOk | tadsio.h[524] |
1
InDlgOkCancel | tadsio.h[525] |
2
InDlgYesNo | tadsio.h[526] |
3
InDlgYesNoCancel | tadsio.h[527] |
4
InEvtEndQuietScript | tadsio.h[507] |
10000
InEvtEndScript | tadsio.h[508] |
10003
InEvtEof | tadsio.h[504] |
5
InEvtHref | tadsio.h[501] |
3
InEvtKey | tadsio.h[499] |
1
InEvtLine | tadsio.h[505] |
6
InEvtNoTimeout | tadsio.h[502] |
4
InEvtNotimeout | tadsio.h[503] |
4 /* (note minor capitalization variation) */
InEvtSysCommand | tadsio.h[506] |
0x100
InEvtTimeout | tadsio.h[500] |
2
InFileCancel | tadsio.h[552] |
2 /* player canceled the file selector */
InFileFailure | tadsio.h[551] |
1 /* an error occurred asking for a file */
InFileOpen | tadsio.h[543] |
1 /* open an existing file for reading */
InFileSave | tadsio.h[544] |
2 /* save to the file */
InFileSuccess | tadsio.h[550] |
0 /* success - 2nd list element is filename */
LogTypeCommand | tadsio.h[484] |
2 /* log only command-line input */
LogTypeScript | tadsio.h[485] |
3 /* log all input events */
LogTypeTranscript | tadsio.h[483] |
1 /* log all input and output to a transcript */
MainWindowLogHandle | tadsio.h[493] |
(-1)
QuitCommand | tadsio.h[516] |
0x0004 /* QUIT the game */
RestoreCommand | tadsio.h[514] |
0x0002 /* RESTORE a saved position */
SaveCommand | tadsio.h[513] |
0x0001 /* SAVE the current position */
ScriptFileEvent | tadsio.h[632] |
4 /* this is an event script (query only) */
ScriptFileNonstop | tadsio.h[631] |
2 /* turn off MORE prompt while reading script */
ScriptFileQuiet | tadsio.h[630] |
1 /* do not display output while reading script */
ScriptReqGetStatus | tadsio.h[644] |
0x7000
StatModeNormal | tadsio.h[624] |
0 /* displaying normal text */
StatModeStatus | tadsio.h[625] |
1 /* display status line text */
SysInfoAudioCrossfade | tadsio.h[601] |
36
SysInfoAudioFade | tadsio.h[600] |
35
SysInfoBanners | tadsio.h[598] |
33
SysInfoFadeMIDI | tadsio.h[619] |
0x0008
SysInfoFadeMPEG | tadsio.h[616] |
0x0001
SysInfoFadeOGG | tadsio.h[617] |
0x0002
SysInfoFadeWAV | tadsio.h[618] |
0x0004
SysInfoIClassHTML | tadsio.h[613] |
3
SysInfoIClassText | tadsio.h[611] |
1
SysInfoIClassTextGUI | tadsio.h[612] |
2
SysInfoInterpClass | tadsio.h[599] |
34
SysInfoJpeg | tadsio.h[571] |
5
SysInfoLinksFtp | tadsio.h[586] |
21
SysInfoLinksHttp | tadsio.h[585] |
20
SysInfoLinksMailto | tadsio.h[588] |
23
SysInfoLinksNews | tadsio.h[587] |
22
SysInfoLinksTelnet | tadsio.h[589] |
24
SysInfoMidi | tadsio.h[574] |
8
SysInfoMng | tadsio.h[593] |
28
SysInfoMngAlpha | tadsio.h[595] |
30
SysInfoMngTrans | tadsio.h[594] |
29
SysInfoMpeg | tadsio.h[581] |
15
SysInfoMpeg1 | tadsio.h[582] |
16
SysInfoMpeg2 | tadsio.h[583] |
17
SysInfoMpeg3 | tadsio.h[584] |
18
SysInfoOgg | tadsio.h[592] |
27
SysInfoOsName | tadsio.h[570] |
3
SysInfoPng | tadsio.h[572] |
6
SysInfoPngAlpha | tadsio.h[591] |
26
SysInfoPngTrans | tadsio.h[590] |
25
SysInfoPrefImages | tadsio.h[577] |
11
SysInfoPrefLinks | tadsio.h[580] |
14
SysInfoPrefMusic | tadsio.h[579] |
13
SysInfoPrefSounds | tadsio.h[578] |
12
SysInfoTextColors | tadsio.h[597] |
32
SysInfoTextHilite | tadsio.h[596] |
31
SysInfoTxcAnsiFg | tadsio.h[606] |
2
SysInfoTxcAnsiFgBg | tadsio.h[607] |
3
SysInfoTxcNone | tadsio.h[604] |
0
SysInfoTxcParam | tadsio.h[605] |
1
SysInfoTxcRGB | tadsio.h[608] |
4
SysInfoVersion | tadsio.h[569] |
2
SysInfoWav | tadsio.h[573] |
7
SysInfoWavMidiOvl | tadsio.h[575] |
9
SysInfoWavOvl | tadsio.h[576] |
10
UndoCommand | tadsio.h[515] |
0x0003 /* UNDO one turn */
(none)