4 #include <stdint.h> /* for uint8_t */
5 #include "windows.h" /* for cycle_active_win(), shift_active_win(), struct Win,
8 #include "keybindings.h" /* for get_action_key(), save_keybindings(),
9 * keyswin_move_selection(), keyswin_mod_key()
11 #include "map.h" /* for map_scroll(), map_center_player(), dir enum */
12 #include "main.h" /* for World struct */
13 #include "rexit.h" /* for exit_err() */
14 #include "misc.h" /* for scroll_pad(), toggle_window(),
15 * growshrink_active_window()
20 extern uint8_t meta_keys(int key, struct World * world)
22 struct WinMeta * win_meta = world->wins.meta;
23 struct Win * win_keys = world->wins.keys;
24 struct Win * win_map = world->wins.map;
25 struct Win * win_info = world->wins.info;
26 struct Win * win_log = world->wins.log;
27 char * err_toggle = "Trouble with toggle_window() in meta_keys().";
28 char * err_shift = "Trouble with shift_active_win() in meta_keys().";
29 char * err_resize = "Trouble with growshrink_active_window() in "
31 if (key == get_action_key(world->keybindings, "quit"))
35 else if (key == get_action_key(world->keybindings, "scroll pad right"))
37 scroll_pad(win_meta, '+');
39 else if (key == get_action_key(world->keybindings, "scroll pad left"))
41 scroll_pad(win_meta, '-');
43 else if (key == get_action_key(world->keybindings, "toggle keys window"))
45 exit_err(toggle_window(win_meta, win_keys), world, err_toggle);
47 else if (key == get_action_key(world->keybindings, "toggle map window"))
49 exit_err(toggle_window(win_meta, win_map), world, err_toggle);
51 else if (key == get_action_key(world->keybindings, "toggle info window"))
53 exit_err(toggle_window(win_meta, win_info), world, err_toggle);
55 else if (key == get_action_key(world->keybindings, "toggle log window"))
57 exit_err(toggle_window(win_meta, win_log), world, err_toggle);
59 else if (key == get_action_key(world->keybindings, "cycle forwards"))
61 cycle_active_win(win_meta, 'f');
63 else if (key == get_action_key(world->keybindings, "cycle backwards"))
65 cycle_active_win(win_meta, 'b');
67 else if (key == get_action_key(world->keybindings, "shift forwards"))
69 exit_err(shift_active_win(win_meta, 'f'), world, err_shift);
71 else if (key == get_action_key(world->keybindings, "shift backwards"))
73 exit_err(shift_active_win(win_meta, 'b'), world, err_shift);
75 else if (key == get_action_key(world->keybindings, "grow horizontally"))
77 exit_err(growshrink_active_window(win_meta, '*'), world, err_resize);
79 else if (key == get_action_key(world->keybindings, "shrink horizontally"))
81 exit_err(growshrink_active_window(win_meta, '_'), world, err_resize);
83 else if (key == get_action_key(world->keybindings, "grow vertically"))
85 exit_err(growshrink_active_window(win_meta, '+'), world, err_resize);
87 else if (key == get_action_key(world->keybindings, "shrink vertically"))
89 exit_err(growshrink_active_window(win_meta, '-'), world, err_resize);
91 else if (key == get_action_key(world->keybindings, "save keys"))
93 save_keybindings(world);
95 else if (key == get_action_key(world->keybindings, "keys nav up"))
97 keyswin_move_selection (world, 'u');
99 else if (key == get_action_key(world->keybindings, "keys nav down"))
101 keyswin_move_selection (world, 'd');
103 else if (key == get_action_key(world->keybindings, "keys mod"))
105 keyswin_mod_key (world, win_meta);
107 else if (key == get_action_key(world->keybindings, "map up"))
109 map_scroll(world->map, NORTH, win_map->frame.size);
111 else if (key == get_action_key(world->keybindings, "map down"))
113 map_scroll(world->map, SOUTH, win_map->frame.size);
115 else if (key == get_action_key(world->keybindings, "map right"))
117 map_scroll(world->map, EAST, win_map->frame.size);
119 else if (key == get_action_key(world->keybindings, "map left"))
121 map_scroll(world->map, WEST, win_map->frame.size);
123 else if (key == get_action_key(world->keybindings, "map center player"))
125 map_center_player (world->map, world->player, win_map->frame.size);