home · contact · privacy
Read interface config from one file (which can be set as command line argument)
[plomrogue] / src / client / wincontrol.h
1 /* src/client/wincontrol.h
2  *
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.
5  */
6
7 #ifndef WINCONTROL_H
8 #define WINCONTROL_H
9
10 #include <stdint.h> /* uint8_t, int16_t */
11 #include "keybindings.h" /* struct KeyBindingDB */
12 #include "../common/yx_uint16.h" /* yx_uint16 struct */
13 struct Win;
14
15
16
17 struct WinConfDB
18 {
19     struct WinConf * winconfs;
20     char * ids;
21     char active; /* id of window selected as active */
22     char * order; /* order of visible windows (identified by IDs) */
23 };
24
25 /* Stores a window's configuration (like geometry, keybindings) and a pointer to
26  * the respective Win struct itself.
27  */
28 struct WinConf
29 {
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(). */
44
45
46
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);
50
51 /* Free all WinConf DB data. */
52 extern void free_winconfs();
53
54 /* Initialize  Win structs for WinConfs in WinConf database. */
55 extern void init_wins();
56
57 /* Toggle windows in order set by world.win_order. Point active window selection
58  * to window identified by world.winconf_db.active.
59  */
60 extern void sorted_win_toggle_and_activate();
61
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);
65
66 /* Iterate over chars of world.winconf_db.winconf_ids array. Restart after \0.*/
67 extern char get_next_winconf_id();
68
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);
72
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()).
76  */
77 extern void toggle_winconfig();
78
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.
82  */
83 extern void toggle_win_size_type(char axis);
84
85 /* Toggle display of a window identified by "id". */
86  extern void toggle_window(char id);
87
88 /* Try scrolling virtual screen left ("dir" = "-") or right ("dir" = "+") to the
89  * degree allowed by the window manager's reset_pad_offset().
90  */
91 extern void scroll_pad(char dir);
92
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.
97  */
98 extern void growshrink_active_window(char change);
99
100
101
102 #endif