Temporary fix of NAG parsing bug.
[cboard.git] / src / cboard.h
blob19894f5690a5922291bb26198bdb6699a04a3710
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
3 Copyright (C) 2002-2006 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 CBOARD_H
20 #define CBOARD_H
22 #define COPYRIGHT "Copyright (C) 2002-2006 " PACKAGE_BUGREPORT
23 #define LINE_GRAPHIC(c) ((!config.linegraphics) ? ' ' : c)
24 #define ROWTOMATRIX(r) ((8 - r) * 2 + 2 - 1)
25 #define COLTOMATRIX(c) ((c == 1) ? 1 : c * 4 - 3)
26 #define BOARD_HEIGHT 18
27 #define BOARD_WIDTH 34
28 #define STATUS_HEIGHT (BOARD_HEIGHT + HISTORY_HEIGHT - TAG_HEIGHT)
29 #define STATUS_WIDTH (COLS - BOARD_WIDTH)
30 #define TAG_HEIGHT 10
31 #define TAG_WIDTH (COLS - BOARD_WIDTH)
32 #define HISTORY_HEIGHT (LINES - BOARD_HEIGHT)
33 #define HISTORY_WIDTH (COLS - STATUS_WIDTH)
34 #define MAX_VALUE_WIDTH (COLS - 8)
36 enum {
37 UP, DOWN, LEFT, RIGHT
40 WINDOW *boardw;
41 PANEL *boardp;
42 WINDOW *tagw;
43 PANEL *tagp;
44 WINDOW *statusw;
45 PANEL *statusp;
46 WINDOW *historyw;
47 PANEL *historyp;
48 WINDOW *loadingw;
49 PANEL *loadingp;
50 WINDOW *enginew;
51 PANEL *enginep;
53 int delete_count = 0;
54 int markstart = -1, markend = -1;
55 int board_details;
56 int c_row, c_col;
57 int pushkey;
58 int keycount;
59 char loadfile[FILENAME_MAX];
60 int quit;
61 char **agony;
62 int paused;
64 // The selected piece.
65 struct {
66 unsigned char icon; // The piece.
67 char row; // The source rank.
68 char col; // The source file.
69 char destrow; // Destination rank.
70 char destcol; // Destination file.
71 } sp;
73 // Loaded filename from the command line or from the file input dialog.
74 int filetype;
75 enum {
76 NO_FILE, PGN_FILE, FEN_FILE, EPD_FILE
79 struct country_codes {
80 char code[4];
81 char country[64];
82 } *ccodes;
84 const char *historyhelp[] = {
85 " UP/DOWN - jump to next or previous history *",
86 "RIGHT/LEFT - next or previous history *",
87 " SPACE - toggle half move (ply) stepping",
88 " j - jump to move number (prompt) *",
89 " / - specify a new move text search expression *",
90 " ] - find the next move text expression *",
91 " [ - find the previous move text expression *",
92 " a - annotate the previous move",
93 " v - view annotation for the next move",
94 " V - view annotation for the previous move",
95 " + - next variation for the previous move",
96 " - - previous variation for the previous move",
97 " h - exit history mode",
98 " F1 - global and other key help",
99 NULL
102 const char *mainhelp[] = {
103 "p - play mode keys",
104 "h - history mode keys",
105 "e - board edit mode keys",
106 "g - global game keys",
107 NULL
110 const char *edithelp[] = {
111 " 0..9 - cursor repeat count",
112 "UP/DOWN/LEFT/RIGHT - position cursor *",
113 " SPACE - select piece under cursor for movement",
114 " ENTER - commit selected piece",
115 " ESCAPE - cancel selected piece",
116 " d - delete the piece under the cursor",
117 " i - insert a new piece",
118 " c - toggle castling availability",
119 " p - this square is the en passant one",
120 " w - switch turn",
121 " e - exit edit mode",
122 " F1 - global and other key help",
123 NULL,
126 const char *gamehelp[] = {
127 " 0..9 - command repeat count",
128 " T - edit the current games roster tags",
129 " t - view the current games roster tags",
130 " ? - specify a new roster tag expression *",
131 " } - find the next roster tag expression *",
132 " { - find the previous roster tag expression *",
133 " n - start new game or round",
134 " N - start new game from scratch resetting all other games",
135 " > - next game or round *",
136 " < - previous game or round *",
137 " J - jump to game or round *",
138 " x - toggle game delete flag *",
139 " X - delete the current or all flagged games",
140 " r - resume a saved game",
141 " s - save game",
142 " S - save game and prompt",
143 " Q - quit",
144 " F10 - About",
145 " F1 - global and other key help",
146 NULL
149 const char *playhelp[] = {
150 " 0..9 - cursor repeat count",
151 "UP/DOWN/LEFT/RIGHT - position cursor *",
152 " SPACE - select piece under cursor for movement",
153 " ENTER - commit selected piece",
154 " ESCAPE - cancel selected piece",
155 " d - show game board details",
156 " w - switch playing side",
157 " u - undo previous move *",
158 " g - force engine to make the next move",
159 " | - send a command to the chess engine",
160 " E - toggle engine/engine play",
161 " W - toggle engine input/output window",
162 " H - toggle human/human play",
163 " F1 - global and other key help",
164 NULL
167 const char *cc_help[] = {
168 " UP/DOWN - previous/next menu entry",
169 " HOME - first entry",
170 " END - last entry",
171 "CTRL-n/PGDN - next page",
172 "CTRL-p/PGUP - previous page",
173 " a-zA-Z0-9 - jump to entry",
174 " ENTER - selected entry",
175 " ESCAPE - cancel",
176 NULL
179 const char *pgn_info_help[] = {
180 " UP/DOWN - select menu entry",
181 " HOME - first entry",
182 " END - last entry",
183 "CTRL-n/PGDN - next page",
184 "CTRL-p/PGUP - previous page",
185 " a-zA-Z0-9 - jump to entry",
186 " ENTER - view selected entry",
187 " ESCAPE - quit",
188 NULL
191 const char *pgn_edit_help[] = {
192 " UP/DOWN - select menu entry",
193 " HOME - first entry",
194 " END - last entry",
195 "CTRL-n/PGDN - next page",
196 "CTRL-p/PGUP - previous page",
197 " a-zA-Z0-9 - jump to entry",
198 " ENTER - edit selected entry",
199 " CTRL-a - add an entry",
200 " CTRL-f - add FEN tag from current position",
201 " CTRL-r - remove selected entry",
202 " CTRL-t - add custom tags",
203 " ESCAPE - quit",
204 NULL
207 struct file_s {
208 char *path;
209 char *name;
210 char *st;
213 const char *file_browser_help[] = {
214 " UP/DOWN - select menu entry",
215 " HOME - first entry",
216 " END - last entry",
217 "CTRL-n/PGDN - next page",
218 "CTRL-p/PGUP - previous page",
219 " a-zA-Z0-9 - jump to entry",
220 " CTRL-x - change directory",
221 " ~ - change to home directory",
222 " ENTER - commit selected entry",
223 " ESCAPE - quit",
224 NULL
227 const char *naghelp[] = {
228 " UP/DOWN - previous/next item",
229 " LEFT/RIGHT - previous/next selected item",
230 " HOME - first item",
231 " END - last item",
232 "CTRL-p/PGUP - previous page",
233 "CTRL-n/PGDN - next page",
234 " a-zA-Z0-9 - jump to item",
235 " SPACE - toggle current item",
236 " ENTER - quit with changes",
237 " ESCAPE - quit without changes",
238 NULL
241 char **nags;
243 // Status window.
244 struct {
245 char *notify; // The status window notification line buffer.
246 } status;
248 enum {
249 MODE_HISTORY, MODE_PLAY, MODE_EDIT
252 int curses_initialized;
254 // When in history mode a full step is to the next move of the same playing
255 // side. Half stepping is alternating sides.
256 int movestep;
258 void update_all(GAME g);
259 void parse_engine_output(GAME *g, char *str);
261 #ifdef DEBUG
262 void dump_board(int, BOARD);
263 void dump_flags(int);
264 char *debug_board(BOARD);
265 #endif
267 #endif