home · contact · privacy
Removed unneeded function; also some minor comment improvmenets.
[plomrogue] / src / wincontrol.h
1 /* wincontrol.h
2  *
3  * Routines that build on top of the windows library to provide a simple window
4  * management API to the game.
5  */
6
7 #ifndef WINCONTROL_H
8 #define WINCONTROL_H
9
10
11
12 #include <stdint.h> /* for uint8_t, int16_t */
13 struct Win;
14 struct WinMeta;
15 struct World;
16
17
18
19 /* Stores designated configuration of a window pointed to in it, and data used
20  * to manipulate said window in the "window configuration" view of it.
21  */
22 struct WinConf
23 {
24     char id; /* unique identifier of WinConf, abused as ID for ->win, too */
25     struct Win * win; /* window configured by this WinConf */
26     char * title; /* designated title as passed to init_win() */
27     int16_t height; /* designated height as interpreted by init_win()*/
28     int16_t width; /* designated width as interpreted by init_win() */
29     void (* draw) (struct Win *); /* designated Win->_draw; to be returned to */
30                                   /* after toggling window configuration view */
31     uint8_t view; /* 0: use ->draw as Win->_draw; 1: use draw_winconf()*/
32     uint8_t height_type; /* both: 0: interpret ->height/->width as size in   */
33     uint8_t width_type;  /* positive cells; 1: as negative diff to max width */
34 };
35
36
37
38 /* Get WinConf fathering "win"; get Win of WinConf of "id". */
39 extern struct WinConf * get_winconf_by_win(struct World * world,
40                                            struct Win * win);
41 extern struct Win * get_win_by_id(struct World * world, char id);
42
43
44
45 /* Create/initialize (from config files)/free Winconf / Win structs. */
46 extern void init_winconfs(struct World * world);
47 extern void free_winconfs(struct World * world);
48 extern void init_wins(struct World * world);
49 extern void free_wins(struct World * world);
50
51
52
53 /* Toggle windows in world->wins in the order desribed by the first line of
54  * config/windows/toggled_win_order, wherein each character may correspond to
55  * one hardcoded window.
56  */
57 extern void sorted_wintoggle(struct World * world);
58
59 /* Reload windows in order and sizes defined in win config. */
60 extern void reload_win_config(struct World * world);
61
62 /* Save all window's configurations to their configuration files. */
63 extern void save_win_configs(struct World * world);
64
65
66
67 /* Toggle "window configuration" view for "win". */
68 extern void toggle_winconfig(struct World * world, struct Win * win);
69
70 /* Toggle interpretation type for Win's width/height of Win in WinConf. Width
71  * only toggles to 1 if terminal window is at least as wide as WinConf->width.
72  */
73 extern void toggle_win_height_type(struct World * world, struct Win * win);
74 extern void toggle_win_width_type(struct World * world, struct Win * win);
75
76
77
78 /* Toggle display of a window "win".
79  *
80  * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
81  */
82 extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win);
83
84
85
86 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
87  * subject to the limitations provided by the window manager via
88  * reset_pad_offset().
89  */
90 extern void scroll_pad(struct WinMeta * win_meta, char dir);
91
92
93
94 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
95  * vertically ("change = "+"/"-") by one cell size, subject to the limitations
96  * provided by the window manager via resize_active_win().
97  *
98  * Forces WinConf->width_type = 0 if new width surpasses that of terminal win.
99  *
100  * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
101  */
102 extern uint8_t growshrink_active_window(struct World * world, char change);
103
104
105
106 #endif