3 * Routines that build on top of the windows library to provide a simple window
4 * management API to the game. Also helps managing window-specific keybindings.
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 */
17 /* Stores a window's configuration (like geometry, keybindings) and a pointer to
18 * the respective Win struct itself.
22 char id; /* Unique identifier of WinConf, doubles aas identifier for .win */
23 /* and the char following "Win_" in the respective conffile name.*/
24 struct Win * win; /* Window / Win struct configured by this WinConf. */
25 struct KeyBiData kb; /* Window-specific keybindings. */
26 uint8_t view; /* 0: use .draw as Win.draw; 1/2: use draw_winconf()_(1/2). */
27 int16_t height; /* Designated height to pass to init_win(). */
28 int16_t width; /* Designated width to pass to init_win(). */
29 uint8_t height_type; /* 0: read .height/.width as size in positive cells; */
30 uint8_t width_type; /* 1: as negative diff in cells to the screen size. */
31 char * title; /* Designated title to pass to init_win(). */
32 char draw; /* Identifier of designated Win.draw; passed to init_win() */
33 /* and reset after toggling Win.draw via toggle_winconf(). */
34 struct yx_uint16 center; /* Designated Win.center; to be reset after */
35 }; /* toggling Win.center via toggle_winconf(). */
39 /* Get WinConf fathering "win" / get Win of WinConf of "id". */
40 extern struct WinConf * get_winconf_by_win(struct Win * win);
41 extern struct Win * get_win_by_id(char id);
43 /* Create, initialize (from config files)/free world.winconfs and their Wins. */
44 extern void init_winconfs();
45 extern void free_winconfs();
46 extern void init_wins();
48 /* Toggle windows in the order desribed by the 1st line of
49 * config/windows/toggle_order_and_active, where each char may fit a Winconf.id
50 * in world.winconfs. Silently ignore id chars not found there. The 1st char of
51 * the 2nd line of the same file determines which window (by its .id) to focus
52 * as active (but only if this window belongs to the ones just toggled).
54 extern void sorted_wintoggle_and_activate();
56 /* Save world.winconfs, visible window chain and active window selection to the
57 * respective configuration files in config/windows/.
59 extern void save_win_configs();
61 /* Toggle "window configuration" view for active window. Sets sensible
62 * Win.center values for the various configuration views (for winconf_geometry:
63 * y=0, x=0; for winconf_keys: x=0 (y is set by draw_winconf_keybindings()).
65 extern void toggle_winconfig();
67 /* Toggle WinConf.(height/width)_type ("axis" = "y": height; else: width). Avoid
68 * positive diff to screen width (value would be wrongly read as a non-diff),
69 * width_type toggles to 1 only if world.wmeta->screen's width >= WinConf.width.
71 extern void toggle_win_size_type(char axis);
73 /* Toggle display of a window identified by "id". */
74 extern void toggle_window(char id);
76 /* Try scrolling virtual screen left ("dir" = "-") or right ("dir" = "+") to the
77 * degree allowed by the window manager's reset_pad_offset().
79 extern void scroll_pad(char dir);
81 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
82 * vertically ("change = "+"/"-") by one cell size to the degree allowed by the
83 * window manager's resize_active_win(). If a new window width would surpass
84 * that of the terminal screen, set WinConf.width_type to 0.
86 extern void growshrink_active_window(char change);