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