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 */
20 WINDOW * screen; /* ncurses' pointer to the terminal screen */
21 WINDOW * pad; /* ncurses pad of virtual screen */
22 struct WinConf * winconfs;
23 struct Win * chain_start; /* first Win in chain; its .prev == 0 */
24 struct Win * chain_end; /* last Win in chain; its .next == 0 */
25 struct Win * win_active; /* Win highlighted / selected for manipulation */
26 struct yx_uint16 padsize; /* virtual screen size */
27 char * ids; /* all windows' ids */
28 char * order; /* order of visible windows (identified by IDs) */
29 uint16_t pad_offset; /* number of cells view is moved to the right */
30 char id_active; /* id of window selected as active */
33 /* Window's configuration (like geometry, keybindings) and the Win itself. */
36 struct Win * win; /* Window / Win struct configured by this WinConf. */
37 struct KeyBindingDB kb; /* Window-specific keybindings. */
38 struct yx_uint16 center; /* Designated Win.center. */
39 int16_t height; /* Designated height to pass to init_win(). */
40 int16_t width; /* Designated width to pass to init_win(). */
41 uint8_t height_type; /* 0: read .height/.width as size in positive cells; */
42 uint8_t width_type; /* 1: as negative diff in cells to the screen size. */
43 uint8_t view; /* 0: use .draw as Win.draw; 1/2: use draw_winconf()_(1/2). */
44 char id; /* Identifier of WinConf, also identifies Win.draw function. */
45 char * title; /* Designated title to pass to init_win(). */
50 /* Get WinConf fathering "win" / get Win of WinConf of "id". */
51 extern struct WinConf * get_winconf_by_win(struct Win * win);
52 extern struct Win * get_win_by_id(char id);
54 /* Free all WinConf DB data. */
55 extern void free_winconfs();
57 /* Initialize Win structs for WinConfs in WinConf database. */
58 extern void init_wins();
60 /* Toggle windows in order set by world.win_order. Point active window selection
61 * to window identified by world.wins.win_active.
63 extern void sorted_win_toggle_and_activate();
65 /* Read/write world.win_order and world.wins.win_active from/to "file". */
66 extern void read_order_wins_visible_active(char * line, uint32_t linemax,
68 extern void write_order_wins_visible_active(FILE * file, char * delim);
70 /* Iterate over chars of world.wins.winconf_ids array. Restart after \0.*/
71 extern char get_next_winconf_id();
73 /* Read/write individual WinConf (identified by "c") from/to file. */
74 extern uint8_t read_winconf_from_file(char * line, uint32_t linemax,
76 extern void write_winconf_of_id_to_file(FILE * file, char c, char * delim);
78 /* Toggle "window configuration" view for active window. Sets sensible
79 * Win.center values for the various configuration views (for winconf_geometry:
80 * y=0, x=0; for winconf_keys: x=0 (y is set by draw_winconf_keybindings()).
82 extern void toggle_winconfig();
84 /* Toggle WinConf.(height/width)_type ("axis" = "y": height; else: width). Avoid
85 * positive diff to screen width (value would be wrongly read as a non-diff),
86 * width_type toggles to 1 only if world.wins.screen's width >= WinConf.width.
88 extern void toggle_win_size_type(char axis);
90 /* Toggle display of a window identified by "id". */
91 extern void toggle_window(char id);
93 /* Try scrolling virtual screen left ("dir" = "-") or right ("dir" = "+") to the
94 * degree allowed by the window manager's reset_pad_offset().
96 extern void scroll_pad(char dir);
98 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
99 * vertically ("change = "+"/"-") by one cell size to the degree allowed by the
100 * window manager's resize_active_win(). If a new window width would surpass
101 * that of the terminal screen, set WinConf.width_type to 0.
103 extern void growshrink_active_window(char change);