don't write past the end of the array
[tetrinet.git] / io.h
blobdd2039d6f7dd0ee4703d2c7277fe93305011c063
1 /* Tetrinet for Linux, by Andrew Church <achurch@achurch.org>
2 * This program is public domain.
4 * Input/output interface declaration and constant definitions.
5 */
7 #ifndef IO_H
8 #define IO_H
10 /* Text buffers: */
11 #define BUFFER_PLINE 0
12 #define BUFFER_GMSG 1
13 #define BUFFER_ATTDEF 2
15 typedef struct {
17 /**** Input routine. ****/
19 /* Wait for input and return either an ASCII code, a K_* value, -1 if
20 * server input is waiting, or -2 if we time out. */
21 int (*wait_for_input)(int msec);
23 /**** Output routines. ****/
25 /* Initialize for output. */
26 void (*screen_setup)(void);
27 /* Redraw the screen. */
28 void (*screen_refresh)(void);
29 /* Redraw the screen after clearing it. */
30 void (*screen_redraw)(void);
32 /* Draw text into the given buffer (@s can contain enum tattr fields;
33 * these are the ones with < TATTR_MAX). */
34 void (*draw_text)(int bufnum, const char *s);
35 /* Clear the given text buffer. */
36 void (*clear_text)(int bufnum);
38 /* Set up the fields display. */
39 void (*setup_fields)(void);
40 /* Draw our own field. */
41 void (*draw_own_field)(void);
42 /* Draw someone else's field. */
43 void (*draw_other_field)(int player);
44 /* Draw the game status information. */
45 void (*draw_status)(void);
46 /* Draw specials stuff */
47 void (*draw_specials)(void);
48 /* Write a text string for usage of a special. */
49 void (*draw_attdef)(const char *type, int from, int to);
50 /* Draw the game message input window. */
51 void (*draw_gmsg_input)(const char *s, int pos);
52 /* Clear the game message input window. */
53 void (*clear_gmsg_input)(void);
55 /* Set up the partyline display. */
56 void (*setup_partyline)(void);
57 /* Draw the partyline input string with the cursor at the given position. */
58 void (*draw_partyline_input)(const char *s, int pos);
60 /* Set up the winlist display. */
61 void (*setup_winlist)(void);
63 } Interface;
65 extern Interface tty_interface, xwin_interface;
68 /* Text attributes; note that in strings, they are always encoded with +1 to
69 * avoid black terminating the string. */
71 enum tattr {
72 /* Note that TATTR_CBLACK text should be visible on a black background, too. */
73 TATTR_CBLACK,
74 TATTR_CRED,
75 TATTR_CGREEN,
76 TATTR_CBROWN,
77 TATTR_CBLUE,
78 TATTR_CMAGENTA,
79 TATTR_CCYAN,
80 TATTR_CGREY,
81 TATTR_CXBRIGHT, /* | this with the colors above to get the bright variant. */
82 TATTR_CMAX = 16,
84 TATTR_BOLD,
85 TATTR_ITALIC,
86 TATTR_UNDERLINE,
88 TATTR_RESET,
90 TATTR_MAX
94 #endif /* IO_H */