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 * order; /* order of visible windows (identified by IDs) */
22 char active; /* id of window selected as active */
25 /* Window's configuration (like geometry, keybindings) and the Win itself. */
28 struct Win * win; /* Window / Win struct configured by this WinConf. */
29 struct KeyBindingDB kb; /* Window-specific keybindings. */
30 struct yx_uint16 center; /* Designated Win.center. */
31 int16_t height; /* Designated height to pass to init_win(). */
32 int16_t width; /* Designated width to pass to init_win(). */
33 uint8_t height_type; /* 0: read .height/.width as size in positive cells; */
34 uint8_t width_type; /* 1: as negative diff in cells to the screen size. */
35 uint8_t view; /* 0: use .draw as Win.draw; 1/2: use draw_winconf()_(1/2). */
36 char id; /* Identifier of WinConf, also identifies Win.draw function. */
37 char * title; /* Designated title to pass to init_win(). */
42 /* Get WinConf fathering "win" / get Win of WinConf of "id". */
43 extern struct WinConf * get_winconf_by_win(struct Win * win);
44 extern struct Win * get_win_by_id(char id);
46 /* Free all WinConf DB data. */
47 extern void free_winconfs();
49 /* Initialize Win structs for WinConfs in WinConf database. */
50 extern void init_wins();
52 /* Toggle windows in order set by world.win_order. Point active window selection
53 * to window identified by world.winconf_db.active.
55 extern void sorted_win_toggle_and_activate();
57 /* Read/write world.win_order and world.winconf_db.active from/to "file". */
58 extern void read_order_wins_visible_active(char * line, uint32_t linemax, FILE * file);
59 extern void write_order_wins_visible_active(FILE * file, char * delim);
61 /* Iterate over chars of world.winconf_db.winconf_ids array. Restart after \0.*/
62 extern char get_next_winconf_id();
64 /* Read/write individual WinConf (identified by "c") from/to file. */
65 extern uint8_t read_winconf_from_file(char * line, uint32_t linemax, FILE * file);
66 extern void write_winconf_of_id_to_file(FILE * file, char c, char * delim);
68 /* Toggle "window configuration" view for active window. Sets sensible
69 * Win.center values for the various configuration views (for winconf_geometry:
70 * y=0, x=0; for winconf_keys: x=0 (y is set by draw_winconf_keybindings()).
72 extern void toggle_winconfig();
74 /* Toggle WinConf.(height/width)_type ("axis" = "y": height; else: width). Avoid
75 * positive diff to screen width (value would be wrongly read as a non-diff),
76 * width_type toggles to 1 only if world.wmeta->screen's width >= WinConf.width.
78 extern void toggle_win_size_type(char axis);
80 /* Toggle display of a window identified by "id". */
81 extern void toggle_window(char id);
83 /* Try scrolling virtual screen left ("dir" = "-") or right ("dir" = "+") to the
84 * degree allowed by the window manager's reset_pad_offset().
86 extern void scroll_pad(char dir);
88 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
89 * vertically ("change = "+"/"-") by one cell size to the degree allowed by the
90 * window manager's resize_active_win(). If a new window width would surpass
91 * that of the terminal screen, set WinConf.width_type to 0.
93 extern void growshrink_active_window(char change);