Fix engine status.
[cboard.git] / src / cboard.h
blobfdc9ecc90efdc7c14cae552770f7780f576d8744
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;
49 int delete_count = 0;
50 int markstart = -1, markend = -1;
51 int board_details;
52 int c_row, c_col;
53 int pushkey;
54 int keycount;
55 char loadfile[FILENAME_MAX];
56 int quit;
57 char **agony;
58 int paused;
60 // The selected piece.
61 struct {
62 unsigned char icon; // The piece.
63 char row; // The source rank.
64 char col; // The source file.
65 char destrow; // Destination rank.
66 char destcol; // Destination file.
67 } sp;
69 // Loaded filename from the command line or from the file input dialog.
70 int filetype;
71 enum {
72 NO_FILE, PGN_FILE, FEN_FILE, EPD_FILE
75 struct country_codes {
76 char code[4];
77 char country[64];
78 } *ccodes;
80 const char *historyhelp[] = {
81 " UP/DOWN - jump to next or previous history *",
82 "RIGHT/LEFT - next or previous history *",
83 " SPACE - toggle half move (ply) stepping",
84 " j - jump to move number (prompt) *",
85 " / - specify a new move text search expression *",
86 " ] - find the next move text expression *",
87 " [ - find the previous move text expression *",
88 " a - annotate the previous move",
89 " v - view annotation for the next move",
90 " V - view annotation for the previous move",
91 " + - next variation for the previous move",
92 " - - previous variation for the previous move",
93 " h - exit history mode",
94 NULL
97 const char *mainhelp[] = {
98 "p - play mode keys",
99 "h - history mode keys",
100 "e - board edit mode keys",
101 "g - other game keys",
102 NULL
105 const char *edithelp[] = {
106 " 0..9 - cursor repeat count",
107 "UP/DOWN/LEFT/RIGHT - position cursor *",
108 " !-*A-H - position cursor at rank or file",
109 " SPACE - select piece under cursor for movement",
110 " ENTER - commit selected piece",
111 " ESCAPE - cancel selected piece",
112 " d - delete the piece under the cursor",
113 " i - insert a new piece",
114 " c - toggle castling availability",
115 " p - this square is the en passant one",
116 " w - switch turn",
117 " e - exit edit mode",
118 NULL,
121 const char *gamehelp[] = {
122 " 0...9 - command repeat count",
123 " T - edit the current games roster tags",
124 " t - view the current games roster tags",
125 " ? - specify a new roster tag expression *",
126 " } - find the next roster tag expression *",
127 " { - find the previous roster tag expression *",
128 " n - start new game or round",
129 " N - start new game from scratch resetting all other games",
130 " > - next game or round *",
131 " < - previous game or round *",
132 " J - jump to game or round *",
133 " x - toggle game delete flag *",
134 " X - delete the current or all flagged games",
135 " r - resume a saved game",
136 " s - save game",
137 " S - save game and prompt",
138 " Q - quit",
139 NULL
142 const char *playhelp[] = {
143 " 0...9 - cursor repeat count",
144 "UP/DOWN/LEFT/RIGHT - position cursor *",
145 " !-*A-H - position cursor at rank or file",
146 " SPACE - select piece under cursor for movement",
147 " ENTER - commit selected piece",
148 " ESCAPE - cancel selected piece",
149 " d - show game board details",
150 " w - switch playing side",
151 " u - undo previous move *",
152 " g - force engine to make the next move",
153 " | - send a command to the chess engine",
154 " o - toggle engine looping",
155 NULL
158 const char *cc_help[] = {
159 " UP/DOWN - previous/next menu entry",
160 " HOME - first entry",
161 " END - last entry",
162 "CTRL-n/PGDN - next page",
163 "CTRL-p/PGUP - previous page",
164 " a-zA-Z0-9 - jump to entry",
165 " ENTER - selected entry",
166 " ESCAPE - cancel",
167 NULL
170 const char *pgn_info_help[] = {
171 " UP/DOWN - select menu entry",
172 " HOME - first entry",
173 " END - last entry",
174 "CTRL-n/PGDN - next page",
175 "CTRL-p/PGUP - previous page",
176 " a-zA-Z0-9 - jump to entry",
177 " ENTER - view selected entry",
178 " ESCAPE - quit",
179 NULL
182 const char *pgn_edit_help[] = {
183 " UP/DOWN - select menu entry",
184 " HOME - first entry",
185 " END - last entry",
186 "CTRL-n/PGDN - next page",
187 "CTRL-p/PGUP - previous page",
188 " a-zA-Z0-9 - jump to entry",
189 " ENTER - edit selected entry",
190 " CTRL-a - add an entry",
191 " CTRL-f - add FEN tag from current position",
192 " CTRL-r - remove selected entry",
193 " CTRL-t - add custom tags",
194 " ESCAPE - quit",
195 NULL
198 struct d_entries {
199 char *name;
200 char *fancy;
201 char desc[25];
204 const char *file_browser_help[] = {
205 " UP/DOWN - select menu entry",
206 " HOME - first entry",
207 " END - last entry",
208 "CTRL-n/PGDN - next page",
209 "CTRL-p/PGUP - previous page",
210 " a-zA-Z0-9 - jump to entry",
211 " CTRL-x - change directory",
212 " ~ - change to home directory",
213 " ENTER - commit selected entry",
214 " ESCAPE - quit",
215 NULL
218 const char *naghelp[] = {
219 " UP/DOWN - previous/next item",
220 " LEFT/RIGHT - previous/next selected item",
221 " HOME - first item",
222 " END - last item",
223 "CTRL-p/PGUP - previous page",
224 "CTRL-n/PGDN - next page",
225 " a-zA-Z0-9 - jump to item",
226 " SPACE - toggle current item",
227 " ENTER - quit with changes",
228 " ESCAPE - quit without changes",
229 NULL
232 struct nag_s {
233 char *line;
234 } *nags;
236 // Status window.
237 struct {
238 char *notify; // The status window notification line buffer.
239 } status;
241 enum {
242 MODE_HISTORY, MODE_PLAY, MODE_EDIT
245 int curses_initialized;
246 // Two human players. FIXME
247 int noengine;
249 // When in history mode a full step is to the next move of the same playing
250 // side. Half stepping is alternating sides.
251 int movestep;
253 void update_all(GAME g);
254 void parse_engine_output(GAME *g, char *str);
256 #ifdef DEBUG
257 void dump_board(int, BOARD);
258 void dump_flags(int);
259 char *debug_board(BOARD);
260 #endif
262 #endif