Hengband  2.1.4
 全て データ構造 ファイル 関数 変数 型定義 マクロ定義 ページ
z-term.h
説明を見る。
1 /* File: z-term.h */
2 
3 /*
4  * Copyright (c) 1997 Ben Harrison
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.
9  */
10 
11 #ifndef INCLUDED_Z_TERM_H
12 #define INCLUDED_Z_TERM_H
13 
14 #include "h-basic.h"
15 
16 
17 /*
18  * A term_win is a "window" for a Term
19  *
20  * - Cursor Useless/Visible codes
21  * - Cursor Location (see "Useless")
22  *
23  * - Array[h] -- Access to the attribute array
24  * - Array[h] -- Access to the character array
25  *
26  * - Array[h*w] -- Attribute array
27  * - Array[h*w] -- Character array
28  *
29  * Note that the attr/char pair at (x,y) is a[y][x]/c[y][x]
30  * and that the row of attr/chars at (0,y) is a[y]/c[y]
31  */
32 
33 typedef struct term_win term_win;
34 
35 struct term_win
36 {
37  bool cu, cv;
39 
40  byte **a;
41  char **c;
42 
43  byte *va;
44  char *vc;
45 
46  byte **ta;
47  char **tc;
48 
50  char *vtc;
51 };
52 
53 
54 
55 /*
56  * An actual "term" structure
57  *
58  * - Extra "user" info (used by application)
59  *
60  * - Extra "data" info (used by implementation)
61  *
62  *
63  * - Flag "user_flag"
64  * An extra "user" flag (used by application)
65  *
66  *
67  * - Flag "data_flag"
68  * An extra "data" flag (used by implementation)
69  *
70  *
71  * - Flag "active_flag"
72  * This "term" is "active"
73  *
74  * - Flag "mapped_flag"
75  * This "term" is "mapped"
76  *
77  * - Flag "total_erase"
78  * This "term" should be fully erased
79  *
80  * - Flag "fixed_shape"
81  * This "term" is not allowed to resize
82  *
83  * - Flag "icky_corner"
84  * This "term" has an "icky" corner grid
85  *
86  * - Flag "soft_cursor"
87  * This "term" uses a "software" cursor
88  *
89  * - Flag "always_pict"
90  * Use the "Term_pict()" routine for all text
91  *
92  * - Flag "higher_pict"
93  * Use the "Term_pict()" routine for special text
94  *
95  * - Flag "always_text"
96  * Use the "Term_text()" routine for invisible text
97  *
98  * - Flag "unused_flag"
99  * Reserved for future use
100  *
101  * - Flag "never_bored"
102  * Never call the "TERM_XTRA_BORED" action
103  *
104  * - Flag "never_frosh"
105  * Never call the "TERM_XTRA_FROSH" action
106  *
107  *
108  * - Value "attr_blank"
109  * Use this "attr" value for "blank" grids
110  *
111  * - Value "char_blank"
112  * Use this "char" value for "blank" grids
113  *
114  *
115  * - Ignore this pointer
116  *
117  * - Keypress Queue -- various data
118  *
119  * - Keypress Queue -- pending keys
120  *
121  *
122  * - Window Width (max 255)
123  * - Window Height (max 255)
124  *
125  * - Minimum modified row
126  * - Maximum modified row
127  *
128  * - Minimum modified column (per row)
129  * - Maximum modified column (per row)
130  *
131  *
132  * - Displayed screen image
133  * - Requested screen image
134  *
135  * - Temporary screen image
136  * - Memorized screen image
137  *
138  *
139  * - Hook for init-ing the term
140  * - Hook for nuke-ing the term
141  *
142  * - Hook for user actions
143  *
144  * - Hook for extra actions
145  *
146  * - Hook for placing the cursor
147  *
148  * - Hook for drawing some blank spaces
149  *
150  * - Hook for drawing a string of chars using an attr
151  *
152  * - Hook for drawing a sequence of special attr/char pairs
153  */
154 
155 typedef struct term term;
156 
157 struct term
158 {
160 
162 
163  bool user_flag;
164 
165  bool data_flag;
166 
179 
182 
183  char *key_queue;
184 
189 
192 
195 
198 
201 
204 
205  void (*init_hook)(term *t);
206  void (*nuke_hook)(term *t);
207 
208  errr (*user_hook)(int n);
209 
210  errr (*xtra_hook)(int n, int v);
211 
212  errr (*curs_hook)(int x, int y);
213 
214  errr (*bigcurs_hook)(int x, int y);
215 
216  errr (*wipe_hook)(int x, int y, int n);
217 
218  errr (*text_hook)(int x, int y, int n, byte a, cptr s);
219 
220  void (*resize_hook)(void);
221 
222  errr (*pict_hook)(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp);
223 };
224 
225 
226 
227 
228 
229 
230 
231 /**** Available Constants ****/
232 
233 
234 /*
235  * Definitions for the "actions" of "Term_xtra()"
236  *
237  * These values may be used as the first parameter of "Term_xtra()",
238  * with the second parameter depending on the "action" itself. Many
239  * of the actions shown below are optional on at least one platform.
240  *
241  * The "TERM_XTRA_EVENT" action uses "v" to "wait" for an event
242  * The "TERM_XTRA_SHAPE" action uses "v" to "show" the cursor
243  * The "TERM_XTRA_FROSH" action uses "v" for the index of the row
244  * The "TERM_XTRA_SOUND" action uses "v" for the index of a sound
245  * The "TERM_XTRA_ALIVE" action uses "v" to "activate" (or "close")
246  * The "TERM_XTRA_LEVEL" action uses "v" to "resume" (or "suspend")
247  * The "TERM_XTRA_DELAY" action uses "v" as a "millisecond" value
248  *
249  * The other actions do not need a "v" code, so "zero" is used.
250  */
251 #define TERM_XTRA_EVENT 1 /* Process some pending events */
252 #define TERM_XTRA_FLUSH 2 /* Flush all pending events */
253 #define TERM_XTRA_CLEAR 3 /* Clear the entire window */
254 #define TERM_XTRA_SHAPE 4 /* Set cursor shape (optional) */
255 #define TERM_XTRA_FROSH 5 /* Flush one row (optional) */
256 #define TERM_XTRA_FRESH 6 /* Flush all rows (optional) */
257 #define TERM_XTRA_NOISE 7 /* Make a noise (optional) */
258 #define TERM_XTRA_SOUND 8 /* Make a sound (optional) */
259 #define TERM_XTRA_BORED 9 /* Handle stuff when bored (optional) */
260 #define TERM_XTRA_REACT 10 /* React to global changes (optional) */
261 #define TERM_XTRA_ALIVE 11 /* Change the "hard" level (optional) */
262 #define TERM_XTRA_LEVEL 12 /* Change the "soft" level (optional) */
263 #define TERM_XTRA_DELAY 13 /* Delay some milliseconds (optional) */
264 #define TERM_XTRA_MUSIC_BASIC 14 /* Play a music(basic) (optional) */
265 #define TERM_XTRA_MUSIC_DUNGEON 15 /* Play a music(dungeon) (optional) */
266 #define TERM_XTRA_MUSIC_QUEST 16 /* Play a music(quest) (optional) */
267 #define TERM_XTRA_MUSIC_TOWN 17 /* Play a music(floor) (optional) */
268 
269 
270 /**** Available Variables ****/
271 
272 extern term *Term;
273 
274 
275 /**** Available Functions ****/
276 
277 extern errr Term_user(int n);
278 extern errr Term_xtra(int n, int v);
279 
280 extern void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc);
281 extern void Term_queue_bigchar(int x, int y, byte a, char c, byte ta, char tc);
282 
283 extern void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc);
284 
285 extern void Term_queue_chars(int x, int y, int n, byte a, cptr s);
286 
287 extern errr Term_fresh(void);
288 extern errr Term_set_cursor(int v);
289 extern errr Term_gotoxy(int x, int y);
290 extern errr Term_draw(int x, int y, byte a, char c);
291 extern errr Term_addch(byte a, char c);
292 extern errr Term_add_bigch(byte a, char c);
293 extern errr Term_addstr(int n, byte a, cptr s);
294 extern errr Term_putch(int x, int y, byte a, char c);
295 extern errr Term_putstr(int x, int y, int n, byte a, cptr s);
296 #ifdef JP
297 extern errr Term_putstr_v(int x, int y, int n, byte a, cptr s);
298 #endif
299 extern errr Term_erase(int x, int y, int n);
300 extern errr Term_clear(void);
301 extern errr Term_redraw(void);
302 extern errr Term_redraw_section(int x1, int y1, int x2, int y2);
303 
304 extern errr Term_get_cursor(int *v);
305 extern errr Term_get_size(int *w, int *h);
306 extern errr Term_locate(int *x, int *y);
307 extern errr Term_what(int x, int y, byte *a, char *c);
308 
309 extern errr Term_flush(void);
310 extern errr Term_keypress(int k);
311 extern errr Term_key_push(int k);
312 extern errr Term_inkey(char *ch, bool wait, bool take);
313 
314 extern errr Term_save(void);
315 extern errr Term_load(void);
316 
317 extern errr Term_exchange(void);
318 
319 extern errr Term_resize(int w, int h);
320 
321 extern errr Term_activate(term *t);
322 
323 extern errr term_nuke(term *t);
324 extern errr term_init(term *t, int w, int h, int k);
325 
326 
327 #endif
328 
329 
u16b key_head
Definition: z-term.h:185
bool never_bored
Definition: z-term.h:177
errr Term_draw(int x, int y, byte a, char c)
Definition: z-term.c:1837
byte ** ta
Definition: z-term.h:46
byte ** a
Definition: z-term.h:40
errr Term_exchange(void)
Definition: z-term.c:2591
bool soft_cursor
Definition: z-term.h:172
errr Term_what(int x, int y, byte *a, char *c)
Definition: z-term.c:2356
const char * cptr
文字列定数用ポインタ定義 / A simple pointer (to unmodifiable strings)
Definition: h-type.h:46
bool always_pict
Definition: z-term.h:173
char ** tc
Definition: z-term.h:47
errr Term_get_size(int *w, int *h)
Definition: z-term.c:2323
bool never_frosh
Definition: z-term.h:178
errr term_init(term *t, int w, int h, int k)
Definition: z-term.c:2930
bool icky_corner
Definition: z-term.h:171
errr(* wipe_hook)(int x, int y, int n)
Definition: z-term.h:216
void * vptr
void型ポインタ定義 / A standard pointer (to "void" because ANSI C says so)
Definition: h-type.h:45
bool active_flag
Definition: z-term.h:167
vptr data
Definition: z-term.h:161
errr Term_putch(int x, int y, byte a, char c)
Definition: z-term.c:1991
char * key_queue
Definition: z-term.h:183
byte cx
Definition: z-term.h:38
errr Term_flush(void)
Definition: z-term.c:2381
errr Term_gotoxy(int x, int y)
Definition: z-term.c:1811
term_win * scr
Definition: z-term.h:200
errr Term_addch(byte a, char c)
Definition: z-term.c:1873
bool unused_flag
Definition: z-term.h:176
term_win * old
Definition: z-term.h:199
bool always_text
Definition: z-term.h:175
byte * va
Definition: z-term.h:43
byte * vta
Definition: z-term.h:49
errr Term_clear(void)
Definition: z-term.c:2162
errr Term_redraw(void)
Definition: z-term.c:2220
char ** c
Definition: z-term.h:41
u16b key_xtra
Definition: z-term.h:187
byte * x1
Definition: z-term.h:196
byte attr_blank
Definition: z-term.h:180
byte hgt
Definition: z-term.h:191
byte y1
Definition: z-term.h:193
変愚時追加された基本事項のヘッダーファイル / The most basic "include" file.
u16b key_size
Definition: z-term.h:188
errr Term_redraw_section(int x1, int y1, int x2, int y2)
Definition: z-term.c:2236
bool fixed_shape
Definition: z-term.h:170
errr Term_set_cursor(int v)
Definition: z-term.c:1793
bool mapped_flag
Definition: z-term.h:168
int errr
エラーコードの定義 / Error codes for function return values
Definition: h-type.h:56
char * vc
Definition: z-term.h:44
unsigned short u16b
Definition: h-type.h:93
bool cv
Definition: z-term.h:37
errr(* curs_hook)(int x, int y)
Definition: z-term.h:212
errr Term_locate(int *x, int *y)
Definition: z-term.c:2337
errr Term_user(int n)
Definition: z-term.c:411
char char_blank
Definition: z-term.h:181
void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc)
Definition: z-term.c:516
void(* init_hook)(term *t)
Definition: z-term.h:205
void Term_queue_chars(int x, int y, int n, byte a, cptr s)
Definition: z-term.c:717
errr Term_erase(int x, int y, int n)
Definition: z-term.c:2059
errr term_nuke(term *t)
Definition: z-term.c:2860
errr Term_inkey(char *ch, bool wait, bool take)
Definition: z-term.c:2462
errr(* xtra_hook)(int n, int v)
Definition: z-term.h:210
byte wid
Definition: z-term.h:190
errr(* bigcurs_hook)(int x, int y)
Definition: z-term.h:214
void Term_queue_bigchar(int x, int y, byte a, char c, byte ta, char tc)
Definition: z-term.c:564
void(* resize_hook)(void)
Definition: z-term.h:220
errr Term_load(void)
Definition: z-term.c:2551
errr Term_key_push(int k)
Definition: z-term.c:2425
term_win * mem
Definition: z-term.h:203
errr Term_fresh(void)
Definition: z-term.c:1494
errr Term_get_cursor(int *v)
Definition: z-term.c:2310
vptr user
Definition: z-term.h:159
errr(* pict_hook)(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
Definition: z-term.h:222
bool data_flag
Definition: z-term.h:165
void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc)
Definition: z-term.c:646
bool user_flag
Definition: z-term.h:163
Definition: z-term.h:157
term * Term
Definition: z-term.c:288
char * vtc
Definition: z-term.h:50
u16b key_tail
Definition: z-term.h:186
void(* nuke_hook)(term *t)
Definition: z-term.h:206
bool cu
Definition: z-term.h:37
errr Term_activate(term *t)
Definition: z-term.c:2824
errr(* user_hook)(int n)
Definition: z-term.h:208
errr Term_addstr(int n, byte a, cptr s)
Definition: z-term.c:1954
byte y2
Definition: z-term.h:194
Definition: z-term.h:35
term_win * tmp
Definition: z-term.h:202
errr Term_save(void)
Definition: z-term.c:2523
byte cy
Definition: z-term.h:38
errr Term_resize(int w, int h)
Definition: z-term.c:2637
errr Term_xtra(int n, int v)
Definition: z-term.c:423
errr(* text_hook)(int x, int y, int n, byte a, cptr s)
Definition: z-term.h:218
bool higher_pict
Definition: z-term.h:174
errr Term_keypress(int k)
Definition: z-term.c:2398
errr Term_add_bigch(byte a, char c)
Definition: z-term.c:1908
bool total_erase
Definition: z-term.h:169
unsigned char byte
byte型をunsighned charとして定義 / Note that unsigned values can cause math problems / An unsigned byte of m...
Definition: h-type.h:76
errr Term_putstr(int x, int y, int n, byte a, cptr s)
Definition: z-term.c:2009
byte * x2
Definition: z-term.h:197