Angband
ui-term.h
Go to the documentation of this file.
1 
11 #ifndef INCLUDED_Z_TERM_H
12 #define INCLUDED_Z_TERM_H
13 
14 #include "h-basic.h"
15 #include "ui-event.h"
16 
17 
37 typedef struct term_win term_win;
38 
39 struct term_win
40 {
41  bool cu, cv;
42  int cx, cy;
43 
44  int **a;
45  wchar_t **c;
46 
47  int *va;
48  wchar_t *vc;
49 
50  int **ta;
51  wchar_t **tc;
52 
53  int *vta;
54  wchar_t *vtc;
55 
57 };
58 
59 
160 typedef struct term term;
161 
162 struct term
163 {
164  void *user;
165 
166  void *data;
167 
168  bool user_flag;
169 
170  bool data_flag;
171 
184 
186  wchar_t char_blank;
187 
189 
191 
196 
197  int wid;
198  int hgt;
199 
200  int y1;
201  int y2;
202 
203  int *x1;
204  int *x2;
205 
206  /* Offsets used by the map subwindows */
207  int offset_x;
208  int offset_y;
209 
212 
215 
216  /* Number of times saved */
218 
221 
222  errr (*xtra_hook)(int n, int v);
223 
224  errr (*curs_hook)(int x, int y);
225 
226  errr (*bigcurs_hook)(int x, int y);
227 
228  errr (*wipe_hook)(int x, int y, int n);
229 
230  errr (*text_hook)(int x, int y, int n, int a, const wchar_t *s);
231 
232  errr (*pict_hook)(int x, int y, int n, const int *ap, const wchar_t *cp, const int *tap, const wchar_t *tcp);
233 
235 
236 };
237 
238 
239 
240 
241 
251 #define ANGBAND_TERM_MAX 8
252 
256 #define SCREEN_ROWS (Term->hgt - ROW_MAP - 1)
257 
261 #define SCREEN_HGT ((int) (SCREEN_ROWS / tile_height))
262 
266 #define SCREEN_WID ((int)((Term->wid - COL_MAP - 1) / tile_width))
267 
268 #define ROW_MAP 1
269 #define COL_MAP 13
270 
271 
288 #define TERM_XTRA_EVENT 1 /* Process some pending events */
289 #define TERM_XTRA_FLUSH 2 /* Flush all pending events */
290 #define TERM_XTRA_CLEAR 3 /* Clear the entire window */
291 #define TERM_XTRA_SHAPE 4 /* Set cursor shape (optional) */
292 #define TERM_XTRA_FROSH 5 /* Flush one row (optional) */
293 #define TERM_XTRA_FRESH 6 /* Flush all rows (optional) */
294 #define TERM_XTRA_NOISE 7 /* Make a noise (optional) */
295 #define TERM_XTRA_BORED 9 /* Handle stuff when bored (optional) */
296 #define TERM_XTRA_REACT 10 /* React to global changes (optional) */
297 #define TERM_XTRA_ALIVE 11 /* Change the "hard" level (optional) */
298 #define TERM_XTRA_LEVEL 12 /* Change the "soft" level (optional) */
299 #define TERM_XTRA_DELAY 13 /* Delay some milliseconds (optional) */
300 
304 #define PW_INVEN 0x00000001L /* Display inven/equip */
305 #define PW_EQUIP 0x00000002L /* Display equip/inven */
306 #define PW_PLAYER_0 0x00000004L /* Display player (basic) */
307 #define PW_PLAYER_1 0x00000008L /* Display player (extra) */
308 #define PW_PLAYER_2 0x00000010L /* Display player (compact) */
309 #define PW_MAP 0x00000020L /* Display dungeon map */
310 #define PW_MESSAGE 0x00000040L /* Display messages */
311 #define PW_OVERHEAD 0x00000080L /* Display overhead view */
312 #define PW_MONSTER 0x00000100L /* Display monster recall */
313 #define PW_OBJECT 0x00000200L /* Display object recall */
314 #define PW_MONLIST 0x00000400L /* Display monster list */
315 #define PW_STATUS 0x00000800L /* Display status */
316 #define PW_ITEMLIST 0x00001000L /* Display item list */
317 
318 #define PW_MAPS (PW_MAP | PW_OVERHEAD)
319 
320 #define PW_MAX_FLAGS 16
321 
322 
326 #define KEYLOG_SIZE 8
327 extern int log_i;
328 extern int log_size;
329 extern struct keypress keylog[KEYLOG_SIZE];
330 
331 
337 extern term *Term;
338 extern byte tile_width;
339 extern byte tile_height;
340 extern bool bigcurs;
341 extern bool smlcurs;
343 extern char angband_term_name[ANGBAND_TERM_MAX][16];
345 
349 #define term_screen (angband_term[0])
350 
351 
352 
358 extern errr Term_xtra(int n, int v);
359 
360 extern void Term_queue_char(term *t, int x, int y, int a, wchar_t c, int ta, wchar_t tc);
361 extern void Term_big_queue_char(term *t, int x, int y, int a, wchar_t c, int a1, wchar_t c1);
362 extern void Term_queue_chars(int x, int y, int n, int a, const wchar_t *s);
363 
364 extern errr Term_fresh(void);
365 extern errr Term_set_cursor(bool v);
366 extern errr Term_gotoxy(int x, int y);
367 extern errr Term_draw(int x, int y, int a, wchar_t c);
368 extern errr Term_addch(int a, wchar_t c);
369 extern errr Term_addstr(int n, int a, const char *s);
370 extern errr Term_putch(int x, int y, int a, wchar_t c);
371 extern void Term_big_putch(int x, int y, int a, wchar_t c);
372 extern errr Term_putstr(int x, int y, int n, int a, const char *s);
373 extern errr Term_erase(int x, int y, int n);
374 extern errr Term_clear(void);
375 extern errr Term_redraw(void);
376 extern errr Term_redraw_section(int x1, int y1, int x2, int y2);
377 extern errr Term_mark(int x, int y);
378 
379 extern errr Term_get_cursor(bool *v);
380 extern errr Term_get_size(int *w, int *h);
381 extern errr Term_locate(int *x, int *y);
382 extern errr Term_what(int x, int y, int *a, wchar_t *c);
383 
384 extern errr Term_flush(void);
385 extern errr Term_mousepress(int x, int y, char button);
387 extern errr Term_key_push(int k);
388 extern errr Term_event_push(const ui_event *ke);
389 extern errr Term_inkey(ui_event *ch, bool wait, bool take);
390 
391 extern errr Term_save(void);
392 extern errr Term_load(void);
393 
394 extern errr Term_resize(int w, int h);
395 
396 extern errr Term_activate(term *t);
397 
398 extern errr term_nuke(term *t);
399 extern errr term_init(term *t, int w, int h, int k);
400 
401 extern int big_pad(int col, int row, byte a, wchar_t c);
402 
403 #endif /* INCLUDED_Z_TERM_H */
uint16_t u16b
Definition: h-basic.h:169
u16b key_head
Definition: ui-term.h:192
png_bytepp row
Definition: libpng12/png.h:1784
errr Term_set_cursor(bool v)
Output routines
Definition: ui-term.c:1344
term * angband_term[ANGBAND_TERM_MAX]
This file provides a generic, efficient, terminal window package, which can be used not only on stand...
Definition: ui-term.c:271
bool never_bored
Definition: ui-term.h:182
bool bigcurs
Helper variables for large cursor.
Definition: ui-term.c:1016
int * x2
Definition: ui-term.h:204
void Term_queue_chars(int x, int y, int n, int a, const wchar_t *s)
Mentally draw some attr/chars at a given location.
Definition: ui-term.c:603
bool soft_cursor
Definition: ui-term.h:177
bool always_pict
Definition: ui-term.h:178
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
errr Term_save(void)
Extra routines
Definition: ui-term.c:2070
void Term_queue_char(term *t, int x, int y, int a, wchar_t c, int ta, wchar_t tc)
Efficient routines
Definition: ui-term.c:505
errr Term_event_push(const ui_event *ke)
Definition: ui-term.c:1987
bool never_frosh
Definition: ui-term.h:183
uint32_t u32b
Definition: h-basic.h:172
bool icky_corner
Definition: ui-term.h:176
errr(* wipe_hook)(int x, int y, int n)
Definition: ui-term.h:228
int * va
Definition: ui-term.h:47
int big_pad(int col, int row, byte a, wchar_t c)
Emit a 'graphical' symbol and a padding character if appropriate.
Definition: ui-term.c:2495
byte tile_width
Definition: ui-term.c:1010
bool active_flag
Definition: ui-term.h:172
byte mods
Definition: ui-event.h:165
int wid
Definition: ui-term.h:197
errr(* pict_hook)(int x, int y, int n, const int *ap, const wchar_t *cp, const int *tap, const wchar_t *tcp)
Definition: ui-term.h:232
int errr
ANSI C headers.
Definition: h-basic.h:164
uint8_t byte
Definition: h-basic.h:167
#define h
errr Term_redraw_section(int x1, int y1, int x2, int y2)
Redraw part of a window.
Definition: ui-term.c:1742
#define ANGBAND_TERM_MAX
Available Constants
Definition: ui-term.h:251
int attr_blank
Definition: ui-term.h:185
int * x1
Definition: ui-term.h:203
term_win * scr
Definition: ui-term.h:211
#define c1(a, i)
Definition: main-nds.c:87
int log_size
Definition: ui-term.c:303
bool unused_flag
Definition: ui-term.h:181
term_win * old
Definition: ui-term.h:210
bool always_text
Definition: ui-term.h:180
int * vta
Definition: ui-term.h:53
void Term_big_putch(int x, int y, int a, wchar_t c)
Move to a location and, using an attr, add a big tile.
Definition: ui-term.c:1530
#define KEYLOG_SIZE
sketchy key logging pt.
Definition: ui-term.h:326
errr Term_flush(void)
Input routines
Definition: ui-term.c:1867
Struct holding all relevant info for keypresses.
Definition: ui-event.h:162
ui_event * key_queue
Definition: ui-term.h:190
u16b key_xtra
Definition: ui-term.h:194
errr Term_clear(void)
Clear the entire window, and move to the top left corner.
Definition: ui-term.c:1671
errr Term_locate(int *x, int *y)
Extract the current cursor location.
Definition: ui-term.c:1820
int ** a
Definition: ui-term.h:44
byte tile_height
Definition: ui-term.c:1011
The lowest level header.
u16b key_size
Definition: ui-term.h:195
bool fixed_shape
Definition: ui-term.h:175
bool mapped_flag
Definition: ui-term.h:173
errr Term_activate(term *t)
Activate a new Term (and deactivate the current Term)
Definition: ui-term.c:2331
bool cv
Definition: ui-term.h:41
errr Term_what(int x, int y, int *a, wchar_t *c)
At a given location, determine the "current" attr and char Note that this refers to what will be on t...
Definition: ui-term.c:1839
int cy
Definition: ui-term.h:42
errr(* curs_hook)(int x, int y)
Definition: ui-term.h:224
void * user
Definition: ui-term.h:164
errr Term_inkey(ui_event *ch, bool wait, bool take)
Check for a pending keypress on the key queue.
Definition: ui-term.c:2020
void(* init_hook)(term *t)
Definition: ui-term.h:219
term_win * next
Definition: ui-term.h:56
errr Term_fresh(void)
Actually perform all requested changes to the window.
Definition: ui-term.c:1132
wchar_t * vtc
Definition: ui-term.h:54
errr Term_draw(int x, int y, int a, wchar_t c)
At a given location, place an attr/char Do not change the cursor position No visual changes until "Te...
Definition: ui-term.c:1388
bool smlcurs
Definition: ui-term.c:1017
errr(* xtra_hook)(int n, int v)
Definition: ui-term.h:222
#define w
void(* view_map_hook)(term *t)
Definition: ui-term.h:234
errr(* bigcurs_hook)(int x, int y)
Definition: ui-term.h:226
errr Term_mousepress(int x, int y, char button)
Add a mouse event to the "queue".
Definition: ui-term.c:1943
void Term_big_queue_char(term *t, int x, int y, int a, wchar_t c, int a1, wchar_t c1)
Queue a large-sized tile.
Definition: ui-term.c:546
errr term_init(term *t, int w, int h, int k)
Initialize a term, using a window of the given size.
Definition: ui-term.c:2429
term_win * mem
Definition: ui-term.h:214
errr Term_addch(int a, wchar_t c)
Using the given attr, add the given char at the cursor.
Definition: ui-term.c:1424
void * data
Definition: ui-term.h:166
errr Term_redraw(void)
Redraw (and refresh) the whole window.
Definition: ui-term.c:1726
errr Term_load(void)
Restore the "requested" contents (see above).
Definition: ui-term.c:2103
errr term_nuke(term *t)
Nuke a term.
Definition: ui-term.c:2366
wchar_t ** c
Definition: ui-term.h:45
wchar_t char_blank
Definition: ui-term.h:186
bool data_flag
Definition: ui-term.h:170
bool user_flag
Definition: ui-term.h:168
Definition: ui-term.h:162
int log_i
Definition: ui-term.c:302
errr Term_addstr(int n, int a, const char *s)
At the current location, using an attr, add a string.
Definition: ui-term.c:1470
u16b key_tail
Definition: ui-term.h:193
void(* nuke_hook)(term *t)
Definition: ui-term.h:220
bool cu
Definition: ui-term.h:41
char angband_term_name[ANGBAND_TERM_MAX][16]
The array[ANGBAND_TERM_MAX] of window names (modifiable?)
Definition: ui-term.c:279
struct keypress keylog[KEYLOG_SIZE]
Definition: ui-term.c:304
errr Term_get_cursor(bool *v)
Access routines
Definition: ui-term.c:1796
term * Term
Available Variables
Definition: ui-term.c:299
errr Term_xtra(int n, int v)
Available Functions
Definition: ui-term.c:427
wchar_t * vc
Definition: ui-term.h:48
Definition: ui-term.h:39
errr Term_gotoxy(int x, int y)
Place the cursor at a given location.
Definition: ui-term.c:1362
Utility functions relating to UI events.
int offset_y
Definition: ui-term.h:208
wchar_t ** tc
Definition: ui-term.h:51
term_win * tmp
Definition: ui-term.h:213
int hgt
Definition: ui-term.h:198
errr Term_erase(int x, int y, int n)
Place cursor at (x,y), and clear the next "n" chars.
Definition: ui-term.c:1596
errr Term_putstr(int x, int y, int n, int a, const char *s)
Move to a location and, using an attr, add a string.
Definition: ui-term.c:1574
u32b keycode_t
Type capable of holding any input key we might want to use.
Definition: ui-event.h:156
Union type to hold information about any given event.
Definition: ui-event.h:191
int y2
Definition: ui-term.h:201
u32b window_flag[ANGBAND_TERM_MAX]
Definition: ui-term.c:291
int ** ta
Definition: ui-term.h:50
errr Term_mark(int x, int y)
Mark a spot as needing refresh (see "Term_fresh")
Definition: ui-term.c:989
bool higher_pict
Definition: ui-term.h:179
byte saved
Definition: ui-term.h:217
int cx
Definition: ui-term.h:42
int offset_x
Definition: ui-term.h:207
errr Term_resize(int w, int h)
React to a new physical window size.
Definition: ui-term.c:2153
errr Term_keypress(keycode_t k, byte mods)
Add a keypress to the "queue".
Definition: ui-term.c:1900
errr Term_key_push(int k)
Add a keypress to the FRONT of the "queue".
Definition: ui-term.c:1974
bool complex_input
Definition: ui-term.h:188
bool total_erase
Definition: ui-term.h:174
errr(* text_hook)(int x, int y, int n, int a, const wchar_t *s)
Definition: ui-term.h:230
errr Term_putch(int x, int y, int a, wchar_t c)
Move to a location and, using an attr, add a char.
Definition: ui-term.c:1512
errr Term_get_size(int *w, int *h)
Extract the current window size.
Definition: ui-term.c:1809
int y1
Definition: ui-term.h:200