| 1 | /* |
| 2 | $Header: d:/cvsroot/tads/TADS2/TIO.H,v 1.2 1999/05/17 02:52:13 MJRoberts Exp $ |
| 3 | */ |
| 4 | |
| 5 | /* |
| 6 | * Copyright (c) 1992, 2002 Michael J. Roberts. All Rights Reserved. |
| 7 | * |
| 8 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 9 | * on using and copying this software. |
| 10 | */ |
| 11 | /* |
| 12 | Name |
| 13 | tio.h - text I/O interface |
| 14 | Function |
| 15 | Formatted text input and output interface definition |
| 16 | Notes |
| 17 | None |
| 18 | Modified |
| 19 | 04/11/99 CNebel - Move extern C. |
| 20 | 09/05/92 MJRoberts - add length parameter to getstring() |
| 21 | 02/16/92 MJRoberts - creation |
| 22 | */ |
| 23 | |
| 24 | #ifndef TIO_INCLUDED |
| 25 | #define TIO_INCLUDED |
| 26 | |
| 27 | #include <time.h> |
| 28 | |
| 29 | #ifndef ERR_INCLUDED |
| 30 | # include "err.h" |
| 31 | #endif |
| 32 | #ifndef OBJ_INCLUDED |
| 33 | # include "obj.h" |
| 34 | #endif |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif |
| 39 | |
| 40 | /* forward decls */ |
| 41 | struct runcxdef; |
| 42 | |
| 43 | /* text i/o context */ |
| 44 | struct tiocxdef |
| 45 | { |
| 46 | errcxdef *tiocxerr; /* error handling context */ |
| 47 | }; |
| 48 | typedef struct tiocxdef tiocxdef; |
| 49 | |
| 50 | /* |
| 51 | * Initialize the output formatter subsystem. This must be called once |
| 52 | * at startup. |
| 53 | */ |
| 54 | void out_init(void); |
| 55 | |
| 56 | |
| 57 | /* redirect all tioxxx routines to TADS v1.x outxxx equivalents */ |
| 58 | #define tioflushn(ctx, nl) outflushn(nl) |
| 59 | #define tioflush(ctx) outflush() |
| 60 | #define tioblank(ctx) outblank() |
| 61 | #define tioreset(ctx) outreset() |
| 62 | #define tiogets(ctx, prompt, str, siz) getstring(prompt, str, siz) |
| 63 | #define tioputs(ctx, str) outformat(str) |
| 64 | #define tioputslen(ctx, str, len) outformatlen(str, len) |
| 65 | #define tiocaps(ctx) outcaps() |
| 66 | #define tionocaps(ctx) outnocaps() |
| 67 | #define tioshow(ctx) outshow() |
| 68 | #define tiohide(ctx) outhide() |
| 69 | #define tioscore(ctx, s1, s2) os_score(s1, s2) |
| 70 | #define tiostrsc(ctx, s) os_strsc(s) |
| 71 | |
| 72 | /* set up format strings in output subsystem */ |
| 73 | void tiosetfmt(tiocxdef *ctx, struct runcxdef *rctx, uchar *fmtbase, |
| 74 | uint fmtlen); |
| 75 | |
| 76 | /* tell tio subsystem the current actor */ |
| 77 | void tiosetactor(struct tiocxdef *ctx, objnum actor); |
| 78 | |
| 79 | /* get the current tio subsystem actor */ |
| 80 | objnum tiogetactor(struct tiocxdef *ctx); |
| 81 | |
| 82 | /* turn output capture on/off */ |
| 83 | void tiocapture(struct tiocxdef *tioctx, struct mcmcxdef *memctx, |
| 84 | int flag); |
| 85 | |
| 86 | /* get the capture object handle */ |
| 87 | mcmon tiogetcapture(struct tiocxdef *ctx); |
| 88 | |
| 89 | /* get the amount of text captured */ |
| 90 | uint tiocapturesize(struct tiocxdef *ctx); |
| 91 | |
| 92 | /* format a length-prefixed (runtime-style) string to the display */ |
| 93 | void outfmt(tiocxdef *ctx, uchar *txt); |
| 94 | |
| 95 | /* format a null-terminated (C-style) string to the display */ |
| 96 | int outformat(char *s); |
| 97 | |
| 98 | /* format a counted-length string, which may not be null-terminated */ |
| 99 | int outformatlen(char *s, uint len); |
| 100 | |
| 101 | /* flush output, with specified newline mode */ |
| 102 | void outflushn(int nl); |
| 103 | |
| 104 | /* flush output */ |
| 105 | void outflush(void); |
| 106 | |
| 107 | /* reset output state */ |
| 108 | void outreset(void); |
| 109 | |
| 110 | /* |
| 111 | * Get a string from the keyboard. Returns non-zero if an error occurs |
| 112 | * (in particular, if no more input is available from the keyboard), |
| 113 | * zero on success. |
| 114 | */ |
| 115 | int getstring(char *prompt, char *buf, int bufl); |
| 116 | |
| 117 | /* set capitalize-next-character mode on/off */ |
| 118 | void outcaps(void); |
| 119 | void outnocaps(void); |
| 120 | |
| 121 | /* open/close output log file */ |
| 122 | int tiologopn(tiocxdef *ctx, char *fn); |
| 123 | int tiologcls(tiocxdef *ctx); |
| 124 | |
| 125 | /* |
| 126 | * Write text explicitly to the log file. This can be used to add |
| 127 | * special text (such as prompt text) that would normally be suppressed |
| 128 | * from the log file. When more mode is turned off, we don't |
| 129 | * automatically copy text to the log file; any text that the caller |
| 130 | * knows should be in the log file during times when more mode is turned |
| 131 | * off can be explicitly added with this function. |
| 132 | * |
| 133 | * If nl is true, we'll add a newline at the end of this text. The |
| 134 | * caller should not include any newlines in the text being displayed |
| 135 | * here. |
| 136 | */ |
| 137 | void out_logfile_print(char *txt, int nl); |
| 138 | |
| 139 | |
| 140 | /* |
| 141 | * Check output status. Indicate whether output is currently hidden, |
| 142 | * and whether any hidden output has occurred. |
| 143 | */ |
| 144 | void outstat(int *hidden, int *output_occurred); |
| 145 | |
| 146 | /* hide/show output */ |
| 147 | void outhide(void); |
| 148 | int outshow(void); |
| 149 | |
| 150 | /* set the flag to indicate that output has occurred */ |
| 151 | void outsethidden(void); |
| 152 | |
| 153 | /* write a blank line */ |
| 154 | void outblank(void); |
| 155 | |
| 156 | /* start/end watchpoint evaluation */ |
| 157 | void outwx(int flag); |
| 158 | |
| 159 | /* Begin/end capturing */ |
| 160 | void tiocapture(tiocxdef *tioctx, mcmcxdef *memctx, int flag); |
| 161 | |
| 162 | /* clear all captured output */ |
| 163 | void tioclrcapture(tiocxdef *tioctx); |
| 164 | |
| 165 | /* |
| 166 | * clear captured output back to a given point -- this can be used to |
| 167 | * remove captured output in an inner capture from an enclosing capture |
| 168 | */ |
| 169 | void tiopopcapture(tiocxdef *tioctx, uint orig_size); |
| 170 | |
| 171 | /* get the object handle of the captured output */ |
| 172 | mcmon tiogetcapture(tiocxdef *ctx); |
| 173 | |
| 174 | /* get the amount of text captured */ |
| 175 | uint tiocapturesize(tiocxdef *ctx); |
| 176 | |
| 177 | /* turn MORE mode on or off */ |
| 178 | int setmore(int state); |
| 179 | |
| 180 | /* explicitly activate the "MORE" prompt */ |
| 181 | void out_more_prompt(); |
| 182 | |
| 183 | /* |
| 184 | * QA controller functions |
| 185 | */ |
| 186 | int qasopn(char *scrnam, int quiet); |
| 187 | void qasclose(void); |
| 188 | char *qasgets(char *buf, int bufl); |
| 189 | |
| 190 | /* |
| 191 | * Set an HTML entity expansion. This is called during initialization |
| 192 | * when we read a character mapping table that includes HTML entity |
| 193 | * expansions. The HTML run-time uses its own expansion mechanism, so |
| 194 | * it will ignore this information. The standard character-mode TADS |
| 195 | * run-time, however, uses this information to map HTML entities to the |
| 196 | * local character set. |
| 197 | */ |
| 198 | void tio_set_html_expansion(unsigned int html_char_val, |
| 199 | const char *expansion, size_t expansion_len); |
| 200 | |
| 201 | /* check for HTML mode - returns true if an "\H+" sequence is active */ |
| 202 | int tio_is_html_mode(); |
| 203 | |
| 204 | /* set the user output filter function */ |
| 205 | void out_set_filter(objnum filter_fn); |
| 206 | |
| 207 | /* set the double-space mode */ |
| 208 | void out_set_doublespace(int dbl); |
| 209 | |
| 210 | /* |
| 211 | * Ask for a filename, using a system-defined dialog (via os_askfile) if |
| 212 | * possible. Uses the same interface as os_askfile(), which we will |
| 213 | * call directly for graphical implementations. We'll use formatted |
| 214 | * text for text-only implementations. |
| 215 | */ |
| 216 | int tio_askfile(const char *prompt, char *fname_buf, int fname_buf_len, |
| 217 | int prompt_type, os_filetype_t file_type); |
| 218 | |
| 219 | /* |
| 220 | * Display a dialog, using a system-defined dialog (via os_input_dialog) |
| 221 | * if possible. Uses the same interface as os_input_dialog(), which we |
| 222 | * will call directly for graphical implementations. We'll use |
| 223 | * formatted text for text-only implementations. |
| 224 | */ |
| 225 | int tio_input_dialog(int icon_id, const char *prompt, int standard_button_set, |
| 226 | const char **buttons, int button_count, |
| 227 | int default_index, int cancel_index); |
| 228 | |
| 229 | |
| 230 | #ifdef __cplusplus |
| 231 | } |
| 232 | #endif |
| 233 | |
| 234 | #endif /* TIO_INCLUDED */ |
| 235 |