- enable toggling of window borders
- make log scrollable
-
-- re-organize code: empty misc.h into proper modules, split up windows.h
--- /dev/null
+/* src/client/array_append.c */
+
+#include "array_append.h"
+#include <stddef.h> /* size_t */
+#include <stdint.h> /* uint32_t */
+#include <stdlib.h> /* free() */
+#include <string.h> /* memcpy() */
+#include "../common/try_malloc.h" /* try_malloc() */
+
+
+
+extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
+ void ** ptr_old_array)
+{
+ char * f_name = "array_append()";
+ uint32_t old_size = old_n * region_size;
+ uint32_t new_size = old_size + region_size;
+ char * new_array = try_malloc(new_size, f_name);
+ memcpy(new_array, * ptr_old_array, old_size);
+ memcpy(new_array + (old_n * region_size), new_region, region_size);
+ free(* ptr_old_array);
+ * ptr_old_array = new_array;
+}
+
--- /dev/null
+/* src/client/array_append.h
+ *
+ * Small memory management helper.
+ */
+
+#ifndef ARRAY_APPEND_H
+#define ARRAY_APPEND_H
+
+#include <stddef.h> /* size_t */
+#include <stdint.h> /* uint32_t */
+
+
+
+/* Append to array pointed to by "ptr_old_array" of "old_n" elements of
+ * "region_size" "new region".
+ */
+extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
+ void ** ptr_old_array);
+
+
+
+#endif
+
#include "../common/readwrite.h" /* try_fopen(),try_fclose(),textfile_width() */
#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
-#include "misc.h" /* array_append() */
+#include "array_append.h" /* array_append() */
#include "world.h" /* global world */
#include "cleanup.h" /* set_cleanup_flag() */
* mod_selected_keyb(), move_keyb_selection()
*/
#include "map.h" /* for map_scroll(), map_center() */
-#include "misc.h" /* nav_inventory() */
#include "wincontrol.h" /* shift_active_win(), resize_active_win(),
* toggle_win_size_type(), toggle_window(),
* cycle_active_win(), scroll_v_screen(),
+/* Move world.inventory_sel up ("dir"="u") or down (else) as far as possible. */
+static void nav_inventory(char dir);
+
/* If "command"'s .dsc_short fits "match", apply "f" with provided char
* arguments and return 1; else, return 0.
*/
+static void nav_inventory(char dir)
+{
+ if ('u' == dir)
+ {
+ world.player_inventory_select = world.player_inventory_select
+ - (world.player_inventory_select > 0);
+ return;
+ }
+ uint8_t n_elems = 0;
+ uint8_t i;
+ for (i = 0; '\0' != world.player_inventory[i]; i++)
+ {
+ n_elems = n_elems + ('\n' == world.player_inventory[i]);
+ }
+ world.player_inventory_select = world.player_inventory_select
+ + (world.player_inventory_select < n_elems);
+}
+
+
+
static uint8_t try_0args(struct Command * command, char * match, void (* f) ())
{
if (!strcmp(command->dsc_short, match))
/* src/client/interface_conf.c */
-#include "misc.h"
+#include "interface_conf.h"
#include <ncurses.h> /* delwin() */
#include <stdint.h> /* uint8_t, uint32_t */
#include <stdio.h> /* FILE, sprintf() */
*/
#include "control.h" /* try_key() */
#include "map.h" /* map_center() */
-#include "misc.h" /* reset_windows() */
#include "windows.h" /* reset_windows_on_winch(), draw_all_wins() */
#include "world.h" /* world global */
#include "../common/readwrite.h" /* try_fwrite()*/
#include "../common/try_malloc.h" /* try_malloc() */
#include "command_db.h" /* get_command() */
-#include "misc.h" /* array_append() */
+#include "array_append.h" /* array_append() */
#include "windows.h" /* draw_all_wins() */
#include "world.h" /* global world */
#include "map.h"
#include <stdint.h> /* uint8_t */
-#include "misc.h" /* center_offset() */
-#include "windows.h" /* struct Win, get_win_by_id() */
+#include "windows.h" /* struct Win, center_offset(), get_win_by_id() */
#include "world.h" /* for global world */
+++ /dev/null
-/* src/client/misc.c */
-
-#include "misc.h"
-#include <stddef.h> /* size_t */
-#include <stdint.h> /* uint8_t, uint32_t */
-#include <stdlib.h> /* free() */
-#include <string.h> /* memcpy() */
-#include "../common/try_malloc.h" /* try_malloc() */
-#include "world.h" /* global world */
-
-
-
-extern void nav_inventory(char dir)
-{
- if ('u' == dir)
- {
- world.player_inventory_select = world.player_inventory_select
- - (world.player_inventory_select > 0);
- return;
- }
- uint8_t n_elems = 0;
- uint8_t i;
- for (i = 0; '\0' != world.player_inventory[i]; i++)
- {
- n_elems = n_elems + ('\n' == world.player_inventory[i]);
- }
- world.player_inventory_select = world.player_inventory_select
- + (world.player_inventory_select < n_elems);
-}
-
-
-
-extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
- void ** ptr_old_array)
-{
- char * f_name = "array_append()";
- uint32_t old_size = old_n * region_size;
- uint32_t new_size = old_size + region_size;
- char * new_array = try_malloc(new_size, f_name);
- memcpy(new_array, * ptr_old_array, old_size);
- memcpy(new_array + (old_n * region_size), new_region, region_size);
- free(* ptr_old_array);
- * ptr_old_array = new_array;
-}
+++ /dev/null
-/* src/client/misc.h
- *
- * Miscellaneous routines that have not yet found a proper parent module. Having
- * LOTS of stuff in here is a sure sign that better modularization is in order.
- */
-
-#ifndef MISC_H
-#define MISC_H
-
-#include <stddef.h> /* size_t */
-#include <stdint.h> /* uint32_t */
-
-
-
-/* Move world.inventory_sel up ("dir"="u") or down (else) as far as possible. */
-extern void nav_inventory(char dir);
-
-/* Append to array pointed to by "ptr_old_array" of "old_n" elements of
- * "region_size" "new region".
- */
-extern void array_append(uint32_t old_n, size_t region_size, void * new_region,
- void ** ptr_old_array);
-
-
-
-#endif
#include "../common/rexit.h" /* exit_trouble(), exit_err() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/yx_uint16.h" /* struct yx_uint16 */
+#include "array_append.h" /* array_append() */
#include "draw_wins.h" /* draw_winconf_geometry(), draw_winconf_keybindings(),
* draw_win_inventory(), draw_win_info(), draw_win_log(),
* draw_win_available_keybindings(), draw_win_map(),
#include "keybindings.h" /* write_keybidings_to_file(),
* read_keybindings_from_file()
*/
-#include "misc.h" /* array_append() */
#include "wincontrol.h" /* toggle_window() */
#include "world.h" /* global world */