3 * Routines that build on top of the windows library to provide a simple window
4 * management API to the game.
12 #include <stdint.h> /* for uint8_t, int16_t */
13 #include "keybindings.h" /* for KeyBiData struct */
14 #include "yx_uint16.h" /* for yx_uint16 struct */
21 /* Stores a window's configuration (like geometry, keybindings) and a pointer to
22 * the respective Win struct itself.
26 char id; /* unique identifier of WinConf, abused as ID for ->win and */
27 /* equivalent to the char following its "Win_" conffile name */
28 struct Win * win; /* window configured by this WinConf */
29 char * title; /* designated title as passed to init_win() */
30 int16_t height; /* designated height as interpreted by init_win()*/
31 int16_t width; /* designated width as interpreted by init_win() */
32 char draw; /* identifier of designated Win->draw; to be returned to */
33 /* after toggling window configuration view */
34 struct yx_uint16 center; /* designated center for Win->draw view; to be */
35 /* returned to after toggling winconf view */
36 uint8_t view; /* 0: use ->draw as Win->_draw; 1, 2: use draw_winconf()_* */
37 uint8_t height_type; /* both: 0: interpret ->height/->width as size in */
38 uint8_t width_type; /* positive cells; 1: as negative diff to max width */
39 struct KeyBiData kb; /* the window's specific keybindings */
44 /* Get WinConf fathering "win"; get Win of WinConf of "id". */
45 extern struct WinConf * get_winconf_by_win(struct World * world,
47 extern struct Win * get_win_by_id(struct World * world, char id);
51 /* Create/initialize (from config files)/free Winconf structs. */
52 extern void init_winconfs(struct World * world);
53 extern void free_winconfs(struct World * world);
54 extern void init_wins(struct World * world);
58 /* Toggle windows in world->wins in the order desribed by the first line of
59 * config/windows/toggle_order_and_active, wherein each character should
60 * correspond to one window whose ID is found in world->winconf_ids. Unknown
61 * characters are silently ignored. The first character of the second line of
62 * the file is also read to determine which window to focus as active (but only
63 * if it fits the ID of a window thus toggled visible).
65 extern void sorted_wintoggle_and_activate(struct World * world);
69 /* Save all window's configurations to their configuration files. */
70 extern void save_win_configs(struct World * world);
74 /* Toggle "window configuration" view for "win". This also sets sensible values
75 * for win->center for the various configuration views (y=0, x=0 for
76 * winconf_geometry and x= for winconf_keys).
78 extern void toggle_winconfig(struct World * world, struct Win * win);
82 /* Toggle interpretation type for Win's width/height of Win in WinConf. Width
83 * only toggles to 1 if terminal window is at least as wide as WinConf->width.
85 extern void toggle_win_height_type(struct World * world, struct Win * win);
86 extern void toggle_win_width_type(struct World * world, struct Win * win);
90 /* Toggle display of a window "win".
92 * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
94 extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win);
98 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
99 * subject to the limitations provided by the window manager via
100 * reset_pad_offset().
102 extern void scroll_pad(struct WinMeta * win_meta, char dir);
106 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
107 * vertically ("change = "+"/"-") by one cell size, subject to the limitations
108 * provided by the window manager via resize_active_win().
110 * Forces WinConf->width_type = 0 if new width surpasses that of terminal win.
112 * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
114 extern uint8_t growshrink_active_window(struct World * world, char change);