1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
3 Copyright (C) 2002-2018 Ben Kibbey <bjk@luxsci.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define WINDOW_TIMEOUT 70
23 #define CTRL_KEY(x) ((x) & 0x1f)
24 #define KEY_ESCAPE CTRL_KEY('[')
25 #define CALCPOSY(y) ((y > LINES - 1) ? 0 : LINES / 2 - y / 2)
26 #define CALCPOSX(x) (COLS / 2 - x / 2)
27 #define CENTERX(x, str) abs((x / 2 - (int)wcslen (str) / 2))
28 #define CENTER_INT(x, n) (x / 2 - n / 2)
30 typedef struct window_s WIN
;
31 typedef int (window_func
) (WIN
*);
32 typedef void (window_exit_func
) (WIN
*);
33 typedef void (window_resize_func
) (WIN
*);
45 * Function that is called when a key is pressed from game_loop(). This is
46 * the only place where a key is gotten from. This is for the top window
47 * (LIFO). When the function returns -1, the window is destroyed and the
48 * top becomes top - 1.
51 window_exit_func
*efunc
;
52 window_resize_func
*rfunc
;
56 int freedata
; // Whether or not to free() .data when destroying
62 WIN
*window_create (const char *title
, int h
, int w
, int y
, int x
,
63 window_func
, void *data
, window_exit_func
,
65 void window_destroy (WIN
*);
66 void window_draw_title (WINDOW
*, const char *, int, chtype
, chtype
);
67 void window_draw_prompt (WINDOW
*, int, int, const char *, chtype
);
68 void window_resize_all ();