#include "map.h" /* for map_scroll(), map_center_player(), dir enum */
#include "main.h" /* for World struct */
#include "rexit.h" /* for exit_err() */
-#include "misc.h" /* for scroll_pad(), toggle_window(),
- * growshrink_active_window()
- */
+#include "wincontrol.h" /* for scroll_pad(), toggle_window(),
+ * growshrink_active_window()
+ */
#include "map_object_actions.h" /* for player_wait(), move_player() */
#include "command_db.h" /* for is_command_id_shortdsc() */
* build_map_objects()
*/
#include "map.h" /* for struct Map, init_map() */
-#include "misc.h" /* for update_log(), toggle_window(), find_passable_pos(),
- * save_game()
- */
+#include "misc.h" /* for update_log(), find_passable_pos(), save_game() */
+#include "wincontrol.h" /* for toggle_window() */
#include "rrand.h" /* for rrand(), rrand_seed() */
#include "rexit.h" /* for exit_game() */
#include "control.h" /* for meta_control() */
#include <unistd.h> /* for unlink(), acess() */
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for strlen(), strcmp(), memcpy() */
-#include <stdint.h> /* for uint8_t */
-#include "windows.h" /* for suspend_win(), append_win(), reset_pad_offset(),
- * resize_active_win(), struct Win, struct WinMeta
- */
+#include <stdint.h> /* for uint16_t */
#include "readwrite.h" /* for [read/write]_uint[8/16/32][_bigendian]() */
#include "map_objects.h" /* for struct Monster, write_map_objects(), */
#include "map_object_actions.h" /* for is_passable(), move_monster() */
#include "map.h" /* for Map struct */
#include "main.h" /* for World struct */
-#include "yx_uint16.h" /* for yx_uint16 */
+#include "yx_uint16.h" /* for yx_uint16 struct */
#include "rrand.h" /* for rrand(), rrand_seed() */
#include "rexit.h" /* for exit_err() */
+
extern void textfile_sizes(FILE * file, uint16_t * linemax_p,
uint16_t * n_lines_p)
{
-extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win)
-{
- if (0 != win->frame.curses_win)
- {
- return suspend_win(win_meta, win);
- }
- else
- {
- return append_win(win_meta, win);
- }
-}
-
-
-
-extern void scroll_pad(struct WinMeta * win_meta, char dir)
-{
- if ('+' == dir)
- {
- reset_pad_offset(win_meta, win_meta->pad_offset + 1);
- }
- else if ('-' == dir)
- {
- reset_pad_offset(win_meta, win_meta->pad_offset - 1);
- }
-}
-
-
-
-extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change)
-{
- if (0 != win_meta->active)
- {
- struct yx_uint16 size = win_meta->active->frame.size;
- if (change == '-')
- {
- size.y--;
- }
- else if (change == '+')
- {
- size.y++;
- }
- else if (change == '_')
- {
- size.x--;
- }
- else if (change == '*')
- {
- size.x++;
- }
- return resize_active_win (win_meta, size);
- }
- return 0;
-}
-
-
-
extern struct yx_uint16 find_passable_pos(struct Map * map)
{
struct yx_uint16 pos;
-#include <stdint.h> /* for uint8_t, uint16_t, uint32_t */
+#include <stdint.h> /* for uint16_t */
#include <stdio.h> /* for FILE typedef */
#include "yx_uint16.h" /* for yx_uint16 coordinates */
struct World;
-struct WinMeta;
-struct Win;
struct Map;
-/* Toggle display of a window "win".
- *
- * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
- */
-extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win);
-
-
-
-/* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
- * subject to the limitations provided by the window manager via
- * reset_pad_offset().
- */
-extern void scroll_pad(struct WinMeta * win_meta, char dir);
-
-
-
-/* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
- * vertically ("change = "+"/"-") by one cell size, subject to the limitations
- * provided by the window manager via resize_active_win().
- *
- * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
- */
-extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change);
-
-
-
/* Return a random position on the map "map" that is passable (as determined by
* is_passable().
*/
--- /dev/null
+/* wincontrol.c */
+
+#include "wincontrol.h"
+#include <stdint.h> /* for uint8_t */
+#include "windows.h" /* for suspend_win(), append_win(), reset_pad_offset(),
+ * resize_active_win(), struct Win, struct WinMeta
+ */
+#include "yx_uint16.h" /* for yx_uint16 struct */
+
+
+extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win)
+{
+ if (0 != win->frame.curses_win)
+ {
+ return suspend_win(win_meta, win);
+ }
+ else
+ {
+ return append_win(win_meta, win);
+ }
+}
+
+
+
+extern void scroll_pad(struct WinMeta * win_meta, char dir)
+{
+ if ('+' == dir)
+ {
+ reset_pad_offset(win_meta, win_meta->pad_offset + 1);
+ }
+ else if ('-' == dir)
+ {
+ reset_pad_offset(win_meta, win_meta->pad_offset - 1);
+ }
+}
+
+
+
+extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change)
+{
+ if (0 != win_meta->active)
+ {
+ struct yx_uint16 size = win_meta->active->frame.size;
+ if (change == '-')
+ {
+ size.y--;
+ }
+ else if (change == '+')
+ {
+ size.y++;
+ }
+ else if (change == '_')
+ {
+ size.x--;
+ }
+ else if (change == '*')
+ {
+ size.x++;
+ }
+ return resize_active_win (win_meta, size);
+ }
+ return 0;
+}
+
--- /dev/null
+/* wincontrol.h
+ *
+ * Routines that build on top of the windows library to provide a simple window
+ * management API to the game.
+ */
+
+#ifndef WINCONTROL_H
+#define WINCONTROL_H
+
+
+
+#include <stdint.h> /* for uint8_t */
+struct Win;
+struct WinMeta;
+
+
+
+/* Toggle display of a window "win".
+ *
+ * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
+ */
+extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win);
+
+
+
+/* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
+ * subject to the limitations provided by the window manager via
+ * reset_pad_offset().
+ */
+extern void scroll_pad(struct WinMeta * win_meta, char dir);
+
+
+
+/* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
+ * vertically ("change = "+"/"-") by one cell size, subject to the limitations
+ * provided by the window manager via resize_active_win().
+ *
+ * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
+ */
+extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change);
+
+
+
+#endif