edit: fix piece insert prompt.
[cboard.git] / src / common.h
blob2eb6bf1c7a4030c470dea9445f3d2c2c04d27408
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
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
19 #ifndef COMMON_H
20 #define COMMON_H
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include <wchar.h>
28 #if defined(HAVE_NCURSESW_CURSES_H)
29 #include <ncursesw/curses.h>
30 #elif defined(HAVE_NCURSESW_H)
31 #include <ncursesw.h>
32 #elif defined(HAVE_NCURSES_CURSES_H)
33 #include <ncurses/curses.h>
34 #elif defined(HAVE_NCURSES_H)
35 #include <ncurses.h>
36 #elif defined(HAVE_CURSES_H)
37 #include <curses.h>
38 #else
39 #error "SysV or X/Open-compatible Curses header file required"
40 #endif
42 #if defined(HAVE_NCURSESW_PANEL_H)
43 #include <ncursesw/panel.h>
44 #elif defined(HAVE_NCURSES_PANEL_H)
45 #include <ncurses/panel.h>
46 #elif defined(HAVE_PANEL_H)
47 #include <panel.h>
48 #else
49 #error "SysV-compatible Curses Panel header file required"
50 #endif
52 #if defined(HAVE_NCURSESW_MENU_H)
53 #include <ncursesw/menu.h>
54 #elif defined(HAVE_NCURSES_MENU_H)
55 #include <ncurses/menu.h>
56 #elif defined(HAVE_MENU_H)
57 #include <menu.h>
58 #else
59 #error "SysV-compatible Curses Menu header file required"
60 #endif
62 #if defined(HAVE_NCURSESW_FORM_H)
63 #include <ncursesw/form.h>
64 #elif defined(HAVE_NCURSES_FORM_H)
65 #include <ncurses/form.h>
66 #elif defined(HAVE_FORM_H)
67 #include <form.h>
68 #else
69 #error "SysV-compatible Curses Form header file required"
70 #endif
72 #ifndef _
73 #include "gettext.h"
74 #define _(msgid) gettext(msgid)
75 #endif
77 #include "chess.h"
79 #define CF_ENGINE_LOOP 0x01
80 #define CF_HUMAN 0x02
81 #define CF_NEW 0x04
82 #define CF_CLOCK 0x08
83 #define CF_MODIFIED 0x10
84 #define CF_DELETE 0x20
85 #ifdef WITH_LIBPERL
86 #define CF_PERL 0x40
87 #endif
89 #include <sys/time.h>
90 #define MAX_TC 8 /* Time controls. */
92 #define ANY_KEY_STR _("[ press any key to continue ]")
93 #define ANY_KEY_SCROLL_STR _("[ press any key to continue (UP/DN to scroll) ]")
94 #define ERROR_STR _("[ ERROR ]")
96 struct clock_s
98 struct timeval elapsed;
99 unsigned short move; /* move count */
100 int tc[MAX_TC][2]; /* 0 = move count, 1 = time (in seconds) */
101 int tcn;
102 int incr;
106 * Attached to game[n].data.
108 struct userdata_s
110 BOARD b;
111 int global_help;
112 struct engine_s *engine;
113 unsigned short flags;
114 char c_row;
115 char c_col;
116 char pm_frfr[6]; // Previous move
117 char pm_row;
118 char pm_col;
119 char ospm_row;
120 char ospm_col;
121 char pm_undo;
122 char paused;
123 unsigned n;
124 unsigned char mode;
125 char rotate; // Rotation control board
126 int go_move; // Movement function result 'do_play_go'
127 int play_mode;
128 struct clock_s wclock;
129 struct clock_s bclock;
130 struct timeval elapsed;
132 // The selected piece.
133 struct
135 unsigned char icon;
136 char scol;
137 char srow;
138 char col;
139 char row;
140 } sp;
142 void *data; // For the history menu
144 #ifdef WITH_LIBPERL
145 char *perlfen;
146 char *oldfen;
147 unsigned short perlflags;
148 #endif
151 /* A pointer to the game in focus. */
152 GAME gp;
154 void gameover (GAME);
155 void update_cursor (GAME, int);
156 void invalid_move (int n, int e, const char *m);
157 void update_status_window (GAME g);
158 void update_all (GAME g);
159 void update_status_notify (GAME g, const char *fmt, ...);
160 void update_tag_window (TAG ** tags);
161 void update_all (GAME g);
162 void edit_tags (GAME g, BOARD b, int edit);
163 void add_custom_tags (TAG *** t);
164 wchar_t *translate_tag_name (const char *);
166 #endif