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> /* uint8_t, int16_t */
11 #include "keybindings.h" /* struct KeyBindingDB */
12 #include "../common/yx_uint16.h" /* yx_uint16 struct */
19 struct WinConf * winconfs;
21 char active; /* id of window selected as active */
22 char * order; /* order of visible windows (identified by IDs) */
25 /* Stores a window's configuration (like geometry, keybindings) and a pointer to
26 * the respective Win struct itself.
30 char id; /* Unique identifier of WinConf, doubles aas identifier for .win */
31 /* and the char following "Win_" in the respective conffile name.*/
32 struct Win * win; /* Window / Win struct configured by this WinConf. */
33 struct KeyBindingDB kb; /* Window-specific keybindings. */
34 uint8_t view; /* 0: use .draw as Win.draw; 1/2: use draw_winconf()_(1/2). */
35 int16_t height; /* Designated height to pass to init_win(). */
36 int16_t width; /* Designated width to pass to init_win(). */
37 uint8_t height_type; /* 0: read .height/.width as size in positive cells; */
38 uint8_t width_type; /* 1: as negative diff in cells to the screen size. */
39 char * title; /* Designated title to pass to init_win(). */
40 char draw; /* Identifier of designated Win.draw; passed to init_win() */
41 /* and reset after toggling Win.draw via toggle_winconf(). */
42 struct yx_uint16 center; /* Designated Win.center; to be reset after */
43 }; /* toggling Win.center via toggle_winconf(). */
47 /* Get WinConf fathering "win" / get Win of WinConf of "id". */
48 extern struct WinConf * get_winconf_by_win(struct Win * win);
49 extern struct Win * get_win_by_id(char id);
51 /* Free all WinConf DB data. */
52 extern void free_winconfs();
54 /* Initialize Win structs for WinConfs in WinConf database. */
55 extern void init_wins();
57 /* Toggle windows in order set by world.win_order. Point active window selection
58 * to window identified by world.winconf_db.active.
60 extern void sorted_win_toggle_and_activate();
62 /* Read/write world.win_order and world.winconf_db.active from/to "file". */
63 extern void read_order_wins_visible_active(char * line, uint32_t linemax, FILE * file);
64 extern void write_order_wins_visible_active(FILE * file, char * delim);
66 /* Iterate over chars of world.winconf_db.winconf_ids array. Restart after \0.*/
67 extern char get_next_winconf_id();
69 /* Read/write individual WinConf (identified by "c") from/to file. */
70 extern uint8_t read_winconf_from_file(char * line, uint32_t linemax, FILE * file);
71 extern void write_winconf_of_id_to_file(FILE * file, char c, char * delim);
73 /* Toggle "window configuration" view for active window. Sets sensible
74 * Win.center values for the various configuration views (for winconf_geometry:
75 * y=0, x=0; for winconf_keys: x=0 (y is set by draw_winconf_keybindings()).
77 extern void toggle_winconfig();
79 /* Toggle WinConf.(height/width)_type ("axis" = "y": height; else: width). Avoid
80 * positive diff to screen width (value would be wrongly read as a non-diff),
81 * width_type toggles to 1 only if world.wmeta->screen's width >= WinConf.width.
83 extern void toggle_win_size_type(char axis);
85 /* Toggle display of a window identified by "id". */
86 extern void toggle_window(char id);
88 /* Try scrolling virtual screen left ("dir" = "-") or right ("dir" = "+") to the
89 * degree allowed by the window manager's reset_pad_offset().
91 extern void scroll_pad(char dir);
93 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
94 * vertically ("change = "+"/"-") by one cell size to the degree allowed by the
95 * window manager's resize_active_win(). If a new window width would surpass
96 * that of the terminal screen, set WinConf.width_type to 0.
98 extern void growshrink_active_window(char change);