4 * Copyright (c) 1997 Ben Harrison
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.
11 #ifndef INCLUDED_Z_TERM_H
12 #define INCLUDED_Z_TERM_H
14 #include "system/angband.h"
15 #include "system/h-basic.h"
18 * @brief A term_win is a "window" for a Term
20 typedef struct term_win {
21 bool cu, cv; //!< Cursor Useless / Visible codes
22 TERM_LEN cx, cy; //!< Cursor Location (see "Useless")
24 TERM_COLOR **a; //!< Array[h*w] -- Attribute array
25 char **c; //!< Array[h*w] -- Character array
27 TERM_COLOR *va; //!< Array[h] -- Access to the attribute array
28 char *vc; //!< Array[h] -- Access to the character array
30 TERM_COLOR **ta; //!< Note that the attr pair at(x, y) is a[y][x]
31 char **tc; //!< Note that the char pair at(x, y) is c[y][x]
33 TERM_COLOR *vta; //!< Note that the row of attr at(0, y) is a[y]
34 char *vtc; //!< Note that the row of chars at(0, y) is c[y]
38 * @brief term実装構造体 / An actual "term" structure
40 typedef struct term_type term_type;
41 typedef struct term_type {
42 vptr user; //!< Extra "user" info (used by application)
43 vptr data; //!< Extra "data" info (used by implementation)
45 bool user_flag; //!< Flag "user_flag" An extra "user" flag (used by application)
46 bool data_flag; //!< Flag "data_flag" An extra "data" flag (used by implementation)
48 bool active_flag; //!< Flag "active_flag" This "term" is "active"
49 bool mapped_flag; //!< Flag "mapped_flag" This "term" is "mapped"
50 bool total_erase; //!< Flag "total_erase" This "term" should be fully erased
51 bool fixed_shape; //!< Flag "fixed_shape" This "term" is not allowed to resize
52 bool icky_corner; //!< Flag "icky_corner" This "term" has an "icky" corner grid
53 bool soft_cursor; //!< Flag "soft_cursor" This "term" uses a "software" cursor
54 bool always_pict; //!< Flag "always_pict" Use the "Term_pict()" routine for all text
55 bool higher_pict; //!< Flag "higher_pict" Use the "Term_pict()" routine for special text
56 bool always_text; //!< Flag "always_text" Use the "Term_text()" routine for invisible text
57 bool unused_flag; //!< Flag "unused_flag" Reserved for future use
58 bool never_bored; //!< Flag "never_bored" Never call the "TERM_XTRA_BORED" action
59 bool never_frosh; //!< Flag "never_frosh" Never call the "TERM_XTRA_FROSH" action
60 bool never_fresh; //!< Flag "never_fresh" Never redraw the Term
62 byte attr_blank; //!< Value "attr_blank" Use this "attr" value for "blank" grids
63 char char_blank; //!< Value "char_blank" Use this "char" value for "blank" grids
65 char *key_queue; //!< Keypress Queue -- various data / Keypress Queue -- pending keys
71 TERM_LEN wid; //!< Window Width(max 255)
72 TERM_LEN hgt; //!< Window Height(max 255)
74 TERM_LEN y1; //!< Minimum modified row
75 TERM_LEN y2; //!< Maximum modified row
77 TERM_LEN *x1; //!< Minimum modified column(per row)
78 TERM_LEN *x2; //!< Maximum modified column(per row)
80 term_win *old; //!< Displayed screen image
81 term_win *scr; //!< Requested screen image
83 term_win *tmp; //!< Temporary screen image
84 term_win *mem; //!< Memorized screen image
86 void (*init_hook)(term_type *t); //!< Hook for init - ing the term
87 void (*nuke_hook)(term_type *t); //!< Hook for nuke - ing the term
89 errr (*user_hook)(int n); //!< ユーザ設定項目実装部 / Hook for user actions
90 errr (*xtra_hook)(int n, int v); //!< 拡張機能実装部 / Hook for extra actions
91 errr (*curs_hook)(TERM_LEN x, TERM_LEN y); //!< カーソル描画実装部 / Hook for placing the cursor
92 errr (*bigcurs_hook)(TERM_LEN x, TERM_LEN y); //!< 大型タイル時カーソル描画実装部 / Hook for placing the cursor on bigtile mode
93 errr (*wipe_hook)(TERM_LEN x, TERM_LEN y, int n); //!< 指定座標テキスト消去実装部 / Hook for drawing some blank spaces
94 errr (*text_hook)(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s); //!< テキスト描画実装部 / Hook for drawing a string of chars using an attr
95 void (*resize_hook)(void); //!< 画面リサイズ実装部
96 errr (*pict_hook)(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap,
97 concptr tcp); //!< タイル描画実装部 / Hook for drawing a sequence of special attr / char pairs
100 /**** Available Constants ****/
103 * Definitions for the "actions" of "term_xtra()"
105 * These values may be used as the first parameter of "term_xtra()",
106 * with the second parameter depending on the "action" itself. Many
107 * of the actions shown below are optional on at least one platform.
109 * The "TERM_XTRA_EVENT" action uses "v" to "wait" for an event
110 * The "TERM_XTRA_SHAPE" action uses "v" to "show" the cursor
111 * The "TERM_XTRA_FROSH" action uses "v" for the index of the row
112 * The "TERM_XTRA_SOUND" action uses "v" for the index of a sound
113 * The "TERM_XTRA_ALIVE" action uses "v" to "activate" (or "close")
114 * The "TERM_XTRA_LEVEL" action uses "v" to "resume" (or "suspend")
115 * The "TERM_XTRA_DELAY" action uses "v" as a "millisecond" value
117 * The other actions do not need a "v" code, so "zero" is used.
119 #define TERM_XTRA_EVENT 1 /* Process some pending events */
120 #define TERM_XTRA_FLUSH 2 /* Flush all pending events */
121 #define TERM_XTRA_CLEAR 3 /* Clear the entire window */
122 #define TERM_XTRA_SHAPE 4 /* Set cursor shape (optional) */
123 #define TERM_XTRA_FROSH 5 /* Flush one row (optional) */
124 #define TERM_XTRA_FRESH 6 /* Flush all rows (optional) */
125 #define TERM_XTRA_NOISE 7 /* Make a noise (optional) */
126 #define TERM_XTRA_SOUND 8 /* Make a sound (optional) */
127 #define TERM_XTRA_BORED 9 /* Handle stuff when bored (optional) */
128 #define TERM_XTRA_REACT 10 /* React to global changes (optional) */
129 #define TERM_XTRA_ALIVE 11 /* Change the "hard" level (optional) */
130 #define TERM_XTRA_LEVEL 12 /* Change the "soft" level (optional) */
131 #define TERM_XTRA_DELAY 13 /* Delay some milliseconds (optional) */
132 #define TERM_XTRA_MUSIC_BASIC 14 /* Play a music(basic) (optional) */
133 #define TERM_XTRA_MUSIC_DUNGEON 15 /* Play a music(dungeon) (optional) */
134 #define TERM_XTRA_MUSIC_QUEST 16 /* Play a music(quest) (optional) */
135 #define TERM_XTRA_MUSIC_TOWN 17 /* Play a music(floor) (optional) */
136 #define TERM_XTRA_MUSIC_MUTE 18
138 /**** Available Variables ****/
139 extern term_type *Term;
141 errr term_win_nuke(term_win *s, TERM_LEN w, TERM_LEN h);
142 errr term_user(int n);
143 errr term_xtra(int n, int v);
145 void term_queue_char(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc);
146 void term_queue_bigchar(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c, TERM_COLOR ta, char tc);
147 void term_queue_line(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR *a, char *c, TERM_COLOR *ta, char *tc);
148 bool macro_running(void);
150 errr term_fresh(void);
151 errr term_set_cursor(int v);
152 errr term_gotoxy(TERM_LEN x, TERM_LEN y);
153 errr term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
154 errr term_addch(TERM_COLOR a, char c);
155 errr term_add_bigch(TERM_COLOR a, char c);
156 errr term_addstr(int n, TERM_COLOR a, concptr s);
157 errr term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
158 errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, concptr s);
159 errr term_erase(TERM_LEN x, TERM_LEN y, int n);
160 errr term_clear(void);
161 errr term_redraw(void);
162 errr term_redraw_section(TERM_LEN x1, TERM_LEN y1, TERM_LEN x2, TERM_LEN y2);
164 errr term_get_cursor(int *v);
165 errr term_get_size(TERM_LEN *w, TERM_LEN *h);
166 errr term_locate(TERM_LEN *x, TERM_LEN *y);
167 errr term_what(TERM_LEN x, TERM_LEN y, TERM_COLOR *a, char *c);
169 errr term_flush(void);
170 errr term_key_push(int k);
171 errr term_inkey(char *ch, bool wait, bool take);
173 errr term_save(void);
174 errr term_load(void);
176 errr term_exchange(void);
178 errr term_resize(TERM_LEN w, TERM_LEN h);
180 errr term_activate(term_type *t);
182 errr term_init(term_type *t, TERM_LEN w, TERM_LEN h, int k);
185 errr term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s);
189 errr term_nuke(term_type *t);