Removed RCS headers.
[cboard.git] / src / cboard.h
blob8ca73ed109a02fbd0006cd9abca18517e4bdd833
1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
2 /*
3 Copyright (C) 2002-2006 Ben Kibbey <bjk@arbornet.org>
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 6
33 #define HISTORY_WIDTH (COLS - STATUS_WIDTH)
35 enum {
36 UP, DOWN, LEFT, RIGHT
39 /* The order must match the BOOK_... enumeration on common.h. */
40 const char *book_methods[] = {
41 BOOK_OFF_STR, BOOK_PREFER_STR, BOOK_BEST_STR, BOOK_WORST_STR,
42 BOOK_RANDOM_STR
45 WINDOW *boardw;
46 PANEL *boardp;
47 WINDOW *tagw;
48 PANEL *tagp;
49 WINDOW *statusw;
50 PANEL *statusp;
51 WINDOW *historyw;
52 PANEL *historyp;
54 BOARD board;
55 int quit;
56 char **agony;
57 int paused;
59 const char *cmdlinehelp[] = {
60 "Usage: cboard [-hv] [-pf <file>] [-i hostname[:port]] "
61 "[-u username[:passwd]]\n",
62 " -p Load PGN file.\n",
63 " -f Load FEN file.\n",
64 " -i ICS hostname and optional port.\n",
65 " -u ICS username and optional password.\n",
66 " -v Version information.\n",
67 " -h This help text.\n",
68 NULL
71 const char *historyhelp[] = {
72 " UP/DOWN - next or previous history with jump count *",
73 "RIGHT/LEFT - next or previous history *",
74 " SPACE - toggle half move stepping",
75 " j - jump to move number *",
76 " / - specify a new move text search expression *",
77 " ] - find the next move text expression *",
78 " [ - find the previous move text expression *",
79 " a - edit comments for the previous move",
80 " v - view comments for the next move",
81 " V - view comments for the previous move",
82 " h - toggle history mode",
83 NULL
86 const char *mainhelp[] = {
87 "p - play mode keys",
88 "h - history mode keys",
89 "e - board edit mode keys",
90 "g - other game keys",
91 NULL
94 const char *edithelp[] = {
95 " 0...9 - cursor repeat count",
96 "UP/DOWN/LEFT/RIGHT - position cursor *",
97 " !-*A-H - position cursor at rank or file",
98 " SPACE - select piece under cursor for movement",
99 " ENTER - commit selected piece",
100 " ESCAPE - cancel selected piece",
101 " x - delete the piece under the cursor",
102 " I - insert a new piece",
103 " e - toggle board edit mode",
104 NULL,
107 const char *gamehelp[] = {
108 " 0...9 - command repeat count",
109 " t - edit the current games roster tags",
110 " i - view the current games roster tags",
111 " ? - specify a new roster tag expression *",
112 " } - find the next roster tag expression *",
113 " { - find the previous roster tag expression *",
114 " n - start new game or round",
115 " N - start new game from scratch resetting all other games",
116 " > - next game or round *",
117 " < - previous game or round *",
118 " J - jump to game or round *",
119 " x - toggle game delete flag *",
120 " X - delete the current or all flagged games",
121 " r - resume a saved game",
122 " s - save game",
123 " S - save game and prompt",
124 " q - quit",
125 NULL
128 const char *playhelp[] = {
129 " 0...9 - cursor repeat count",
130 "UP/DOWN/LEFT/RIGHT - position cursor *",
131 " !-*A-H - position cursor at rank or file",
132 " SPACE - select piece under cursor for movement",
133 " ENTER - commit selected piece",
134 " ESCAPE - cancel selected piece",
135 " + - increase engine depth level *",
136 " _ - decrease engine depth level *",
137 " b - cycle through book modes",
138 " w - switch playing side",
139 " u - undo previous move *",
140 " g - force engine to make the next move",
141 " c - send a command to the chess engine",
142 NULL
145 pid_t init_chess_engine(void);
146 int parse_pgn_file(BOARD, const char *);
147 void update_history(void);
148 void reset_history(void);
149 TAG *edit_tags(BOARD, TAG *, int, int);
150 void parse_engine_output(BOARD, char *);
151 char *real_filename(char *);
152 void send_to_engine(const char *, ...);
153 int get_history_by_index(int, HISTORY *);
154 void history_next(BOARD, int, int *, int *);
155 void history_previous(BOARD, int, int *, int *);
156 void init_history(BOARD);
157 void parse_rcfile(const char *);
158 char *history_edit_nag(void *);
159 void view_annotation(int);
160 int save_pgn(const char *, int, int);
161 void set_engine_defaults(void);
162 int start_chess_engine(void);
163 void stop_engine(void);
164 int help(const char *, const char *, const char **);
165 void draw_window_title(WINDOW *, const char *, int, chtype, chtype);
166 void init_color_pairs(void);
167 char *browse_directory(void *);
168 char *a2a4tosan(BOARD, char *);
169 int add_tag(TAG **, int *, const char *, const char *);
170 void new_game(BOARD);
171 void *Malloc(size_t);
172 int isinteger(const char *);
173 int parse_ics_output(char *);
174 char *compression_cmd(const char *, int);
175 int piece_to_int(int);
176 int int_to_piece(int);
177 void free_tag_data(TAG *, int);
178 void free_historydata(HISTORY **, int, int);
179 void get_valid_moves(BOARD, int, int, int, int *, int *, int *, int *);
180 void reset_valid_moves(BOARD);
181 int parse_move_text(BOARD, char *);
182 void parse_history_move(BOARD, int);
183 void switch_turn(void);
184 char *str_etc(const char *, int, int);
185 char *tilde_expand(char *);
186 int parse_fen_file(BOARD, const char *);
187 char *board_to_fen(BOARD, GAME);
188 void set_defaults(void);
190 #endif