home · contact · privacy
Strongly simplified / standardized user action interfaces.
[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 #include <stdint.h> /* for uint8_t, int16_t */
11 #include "keybindings.h" /* for KeyBiData struct */
12 #include "yx_uint16.h" /* for yx_uint16 struct */
13 struct Win;
14 struct WinMeta;
15
16
17
18 /* Stores a window's configuration (like geometry, keybindings) and a pointer to
19  * the respective Win struct itself.
20  */
21 struct WinConf
22 {
23     char id; /* unique identifier of WinConf, abused as ID for ->win and  */
24              /* equivalent to the char following its "Win_" conffile name */
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     char draw; /* identifier of designated Win->draw; to be returned to */
30                /* after toggling window configuration view */
31     struct yx_uint16 center; /* designated center for Win->draw view; to be */
32                              /* returned to after toggling winconf view */
33     uint8_t view; /* 0: use ->draw as Win->draw; 1, 2: use draw_winconf()_* */
34     uint8_t height_type; /* both: 0: interpret ->height/->width as size in   */
35     uint8_t width_type;  /* positive cells; 1: as negative diff to max width */
36     struct KeyBiData kb; /* the window's specific keybindings */
37 };
38
39
40
41 /* Get WinConf fathering "win"; get Win of WinConf of "id". */
42 extern struct WinConf * get_winconf_by_win(struct Win * win);
43 extern struct Win * get_win_by_id(char id);
44
45
46
47 /* Create/initialize (from config files)/free Winconf structs. */
48 extern void init_winconfs();
49 extern void free_winconfs();
50 extern void init_wins();
51
52
53
54 /* Toggle windows in world.wins in the order desribed by the first line of
55  * config/windows/toggle_order_and_active, wherein each character should
56  * correspond to one window whose ID is found in world.winconf_ids. Unknown
57  * characters are silently ignored. The first character of the second line of
58  * the file is also read to determine which window to focus as active (but only
59  * if it fits the ID of a window thus toggled visible).
60  */
61 extern void sorted_wintoggle_and_activate();
62
63
64
65 /* Save all window's configurations to their configuration files. */
66 extern void save_win_configs();
67
68
69
70 /* Toggle "window configuration" view for active window. This also sets sensible
71  * values for Win->center for the various configuration views (y=0, x=0 for
72  * winconf_geometry and x= for winconf_keys).
73  */
74 extern void toggle_winconfig();
75
76
77
78 /* Toggle interpretation type for active Win's width/height in WinConf. Width
79  * only toggles to 1 if terminal window is at least as wide as WinConf->width.
80  */
81 extern void toggle_win_height_type();
82 extern void toggle_win_width_type();
83
84
85
86 /* Toggle display of a window identified by "id". */
87 extern void toggle_window(char id);
88
89
90
91 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
92  * subject to the limitations provided by the window manager via
93  * reset_pad_offset().
94  */
95 extern void scroll_pad(char dir);
96
97
98
99 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
100  * vertically ("change = "+"/"-") by one cell size, subject to the limitations
101  * provided by the window manager via resize_active_win().
102  *
103  * Forces WinConf->width_type = 0 if new width surpasses that of terminal win.
104  */
105 extern void growshrink_active_window(char change);
106
107
108
109 #endif