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
27 #include <sys/types.h>
45 attributes (const char *filename
, int line
, char *str
)
50 while ((tmp
= strsep (&str
, ",")) != NULL
)
52 if (strcasecmp (tmp
, "BOLD") == 0)
54 else if (strcasecmp (tmp
, "REVERSE") == 0)
56 else if (strcasecmp (tmp
, "NONE") == 0)
58 else if (strcasecmp (tmp
, "DIM") == 0)
60 else if (strcasecmp (tmp
, "STANDOUT") == 0)
62 else if (strcasecmp (tmp
, "UNDERLINE") == 0)
64 else if (strcasecmp (tmp
, "BLINK") == 0)
66 else if (strcasecmp (tmp
, "INVISIBLE") == 0)
69 errx (EXIT_FAILURE
, _("%s(%i): invalid attribute \"%s\""), filename
,
77 color_name (const char *filename
, int line
, const char *color
)
79 if (strcasecmp (color
, "BLACK") == 0)
81 else if (strcasecmp (color
, "WHITE") == 0)
83 else if (strcasecmp (color
, "GREEN") == 0)
85 else if (strcasecmp (color
, "YELLOW") == 0)
87 else if (strcasecmp (color
, "MAGENTA") == 0)
89 else if (strcasecmp (color
, "BLUE") == 0)
91 else if (strcasecmp (color
, "RED") == 0)
93 else if (strcasecmp (color
, "CYAN") == 0)
95 else if (strcasecmp (color
, "-") == 0)
98 errx (EXIT_FAILURE
, _("%s(%i): invalid color \"%s\""), filename
, line
,
105 parse_color (const char *filename
, int line
, const char *str
,
108 char fg
[16], bg
[16], attr
[64], nattr
[64];
112 sscanf (str
, "%[a-zA-Z-] %[a-zA-Z-] %[a-zA-Z,-] %[a-zA-Z,-]", fg
, bg
,
114 errx (EXIT_FAILURE
, _("%s(%i): parse error"), filename
, line
);
116 if ((n
= color_name (filename
, line
, fg
)) >= 0)
119 if ((n
= color_name (filename
, line
, bg
)) >= 0)
122 c
->attrs
= c
->nattrs
= 0;
125 c
->attrs
= attributes (filename
, line
, attr
);
128 c
->nattrs
= attributes (filename
, line
, nattr
);
132 on_or_off (const char *filename
, int lines
, const char *str
)
134 if (strcasecmp (str
, "on") == 0 || strcasecmp (str
, "1") == 0 ||
135 strcasecmp (str
, "yes") == 0 || strcasecmp (str
, "true") == 0)
138 if (strcasecmp (str
, "off") == 0 || strcasecmp (str
, "0") == 0 ||
139 strcasecmp (str
, "no") == 0 || strcasecmp (str
, "false") == 0)
142 errx (EXIT_FAILURE
, _("%s(%i): invalid value \"%s\""), filename
, lines
,
147 copydatafile (const char *dst
, const char *src
)
150 char buf
[LINE_MAX
], *s
;
152 snprintf (buf
, sizeof (buf
), "%s/%s", DATA_PATH
, src
);
154 if ((fp
= fopen (buf
, "r")) == NULL
)
161 if ((ofp
= fopen (dst
, "w+")) == NULL
)
168 while ((s
= fgets (buf
, sizeof (buf
), fp
)) != NULL
)
169 fprintf (ofp
, "%s", s
);
176 fancy_key_name (wint_t c
)
178 static char buf
[64] = { 0 };
181 strncpy (buf
, keyname (c
) ? keyname (c
) : key_name (c
), sizeof (buf
) - 1);
184 if (*p
== '^' && *(p
+ 1) == '[')
187 if (*p
== '^' && *(p
+ 1) == 'J')
190 if (strncasecmp (p
, "KEY_", 4) == 0)
192 for (p
= buf
; *p
; p
++)
210 else if (strcmp (p
, "ppage") == 0)
212 else if (strcmp (p
, "npage") == 0)
226 add_key_binding (struct key_s
***dst
, key_func
* func
, wint_t c
,
227 char *desc
, int repeat
)
230 struct key_s
**k
= *dst
;
233 for (i
= 0; k
[i
]; i
++);
235 k
= Realloc (k
, (i
+ 2) * sizeof (struct key_s
*));
236 k
[i
] = Calloc (1, sizeof (struct key_s
));
240 k
[i
]->key
= str_to_wchar (fancy_key_name (c
));
243 k
[i
]->d
= str_to_wchar (desc
);
253 add_key_binding (&history_keys
, do_history_jump_next
, KEY_UP
,
254 _("history jump next"), 1);
255 add_key_binding (&history_keys
, do_history_jump_prev
, KEY_DOWN
,
256 _("history jump previous"), 1);
257 add_key_binding (&history_keys
, do_history_next
, KEY_RIGHT
, _("next move"),
259 add_key_binding (&history_keys
, do_history_prev
, KEY_LEFT
,
260 _("previous move"), 1);
261 add_key_binding (&history_keys
, do_history_half_move_toggle
, ' ',
262 _("toggle half move (ply) stepping"), 0);
263 add_key_binding (&history_keys
, do_history_rotate_board
, 'r',
264 _("rotate board"), 0);
265 add_key_binding (&history_keys
, do_history_jump
, 'j',
266 _("jump to move number"), 1);
267 add_key_binding (&history_keys
, do_history_find_new
, '/',
268 _("new move text expression"), 0);
269 add_key_binding (&history_keys
, do_history_find_next
, ']',
270 _("find next move text expression"), 1);
271 add_key_binding (&history_keys
, do_history_find_prev
, '[',
272 _("find previous move text expression"), 1);
273 add_key_binding (&history_keys
, do_history_annotate
, CTRL_KEY ('a'),
274 _("annotate the previous move"), 0);
275 add_key_binding (&history_keys
, do_history_rav_next
, '+',
276 _("next variation of the previous move"), 0);
277 add_key_binding (&history_keys
, do_history_rav_prev
, '-',
278 _("previous variation of the previous move"), 0);
279 add_key_binding (&history_keys
, do_history_menu
, 'M',
280 _("move history tree"), 0);
281 add_key_binding (&history_keys
, do_history_help
, KEY_F (1), _("more help"),
283 add_key_binding (&history_keys
, do_history_help
, CTRL_KEY ('g'), NULL
, 0);
284 add_key_binding (&history_keys
, do_history_toggle
, 'h',
285 _("exit history mode"), 0);
287 add_key_binding (&edit_keys
, do_edit_select
, ' ',
288 _("select piece for movement"), 0);
289 add_key_binding (&edit_keys
, do_edit_commit
, '\n',
290 _("commit selected piece"), 0);
291 add_key_binding (&edit_keys
, do_edit_cancel_selected
, KEY_ESCAPE
,
292 _("cancel selected piece"), 0);
293 add_key_binding (&edit_keys
, do_edit_delete
, 'd',
294 _("remove the piece under the cursor"), 0);
295 add_key_binding (&edit_keys
, do_edit_insert
, 'i', _("insert piece"), 0);
296 add_key_binding (&edit_keys
, do_edit_toggle_castle
, 'c',
297 _("toggle castling availability"), 0);
298 add_key_binding (&edit_keys
, do_edit_enpassant
, 'p',
299 _("toggle enpassant square"), 0);
300 add_key_binding (&edit_keys
, do_edit_switch_turn
, 'w', _("toggle turn"), 0);
301 add_key_binding (&edit_keys
, do_edit_help
, KEY_F (1), _("more help"), 0);
302 add_key_binding (&edit_keys
, do_edit_help
, CTRL_KEY ('g'), NULL
, 0);
303 add_key_binding (&edit_keys
, do_edit_exit
, 'e', _("exit edit mode"), 0);
305 add_key_binding (&play_keys
, do_play_select
, ' ',
306 _("select piece for movement"), 0);
307 add_key_binding (&play_keys
, do_play_commit
, '\n',
308 _("commit selected piece"), 0);
309 add_key_binding (&play_keys
, do_play_cancel_selected
, KEY_ESCAPE
,
310 _("cancel selected piece"), 0);
311 add_key_binding (&play_keys
, do_play_set_clock
, 'C', _("set clock"), 0);
312 // add_key_binding(&play_keys, do_play_switch_turn, 'w', _("switch turn"), 0);
313 add_key_binding (&play_keys
, do_play_undo
, 'u', _("undo previous move"), 1);
314 add_key_binding (&play_keys
, do_play_go
, 'g',
315 _("force the chess engine to make the next move"), 0);
316 add_key_binding (&play_keys
, do_play_send_command
, '|',
317 _("send a command to the chess engine"), 0);
318 add_key_binding (&play_keys
, do_play_toggle_eh_mode
, 'w',
319 _("toggle engine/human play"), 0);
320 add_key_binding (&play_keys
, do_play_toggle_engine
, 'E',
321 _("toggle engine/engine play"), 0);
322 add_key_binding (&play_keys
, do_play_toggle_human
, 'H',
323 _("toggle human/human play"), 0);
324 add_key_binding (&play_keys
, do_play_toggle_pause
, 'p',
325 _("toggle pausing of this game"), 0);
326 add_key_binding (&play_keys
, do_play_history_mode
, 'h',
327 _("enter history mode"), 0);
328 add_key_binding (&play_keys
, do_play_edit_mode
, 'e', _("enter edit mode"),
330 add_key_binding (&play_keys
, do_play_help
, KEY_F (1), _("more help"), 0);
331 add_key_binding (&play_keys
, do_play_help
, CTRL_KEY ('g'), NULL
, 0);
333 add_key_binding (&global_keys
, do_global_tag_edit
, CTRL_KEY ('t'),
334 _("edit roster tags"), 0);
335 add_key_binding (&global_keys
, do_global_tag_view
, 't',
336 _("view roster tags"), 0);
337 add_key_binding (&global_keys
, do_global_find_new
, '?',
338 _("new find game expression"), 0);
339 add_key_binding (&global_keys
, do_global_find_next
, '}',
340 _("find next game"), 1);
341 add_key_binding (&global_keys
, do_global_find_prev
, '{',
342 _("find previous game"), 1);
343 add_key_binding (&global_keys
, do_global_new_game
, CTRL_KEY ('n'),
344 _("new game or round"), 0);
345 add_key_binding (&global_keys
, do_global_new_all
, CTRL_KEY ('k'),
346 _("new game from scratch"), 0);
347 add_key_binding (&global_keys
, do_global_copy_game
, CTRL_KEY ('i'),
348 _("copy current game"), 0);
349 add_key_binding (&global_keys
, do_global_next_game
, '>', _("next game"), 1);
350 add_key_binding (&global_keys
, do_global_prev_game
, '<', _("previous game"),
352 add_key_binding (&global_keys
, do_global_game_jump
, 'J', _("jump to game"),
354 add_key_binding (&global_keys
, do_global_toggle_delete
, 'X',
355 _("toggle delete flag"), 1);
356 add_key_binding (&global_keys
, do_global_delete_game
, CTRL_KEY ('X'),
357 _("delete the current or flagged games"), 0);
358 add_key_binding (&global_keys
, do_global_resume_game
, CTRL_KEY ('r'),
359 _("load a PGN file"), 0);
360 add_key_binding (&global_keys
, do_global_save_game
, 's', _("save game"), 0);
361 add_key_binding (&global_keys
, do_global_toggle_board_details
,
362 CTRL_KEY ('d'), _("toggle board details"), 0);
363 add_key_binding (&global_keys
, do_global_toggle_strict_castling
,
364 CTRL_KEY ('p'), _("toggle strict castling"), 0);
365 add_key_binding (&global_keys
, do_global_toggle_engine_window
, 'W',
366 _("toggle chess engine IO window"), 0);
368 add_key_binding (&global_keys
, do_global_perl
, CTRL_KEY ('O'),
369 _("Call PERL subroutine"), 0);
371 add_key_binding (&global_keys
, do_global_about
, KEY_F (10),
372 _("version information"), 0);
373 add_key_binding (&global_keys
, do_global_redraw
, CTRL_KEY ('L'),
374 _("redraw the screen"), 0);
375 add_key_binding (&global_keys
, NULL
, KEY_F (1), _("more help"), 0);
376 add_key_binding (&global_keys
, NULL
, CTRL_KEY ('g'), NULL
, 0);
377 add_key_binding (&global_keys
, do_global_quit
, 'Q', _("quit"), 0);
381 set_config_defaults ()
385 config
.pattern
= strdup ("*.[Pp][Gg][Nn]*");
386 config
.engine_cmd
= strdup ("gnuchess --xboard");
387 config
.engine_protocol
= 1;
388 config
.jumpcount
= 5;
389 config
.linegraphics
= 1;
390 config
.saveprompt
= 1;
391 config
.deleteprompt
= 1;
392 config
.validmoves
= 1;
394 config
.showattacks
= 1;
395 config
.coordsyleft
= TRUE
;
396 config
.fmpolyglot
= FALSE
;
397 config
.boardleft
= TRUE
;
398 config
.exitdialogbox
= TRUE
;
399 config
.enginecmdblacktag
= TRUE
;
400 config
.bprevmove
= TRUE
;
401 config
.utf8_pieces
= 1;
403 set_default_colors ();
405 if (stat (config
.nagfile
, &st
) == -1)
408 copydatafile (config
.nagfile
, "nag.data");
410 warn ("%s", config
.nagfile
);
413 if (stat (config
.ccfile
, &st
) == -1)
416 copydatafile (config
.ccfile
, "cc.data");
418 warn ("%s", config
.ccfile
);
423 update_key (struct key_s
**dst
, struct custom_key_s config_key
,
424 wint_t c
, char *desc
)
428 for (i
= 0; dst
[i
]; i
++)
430 if (dst
[i
]->f
== config_key
.func
)
437 dst
[i
]->key
= str_to_wchar (fancy_key_name (c
));
441 dst
[i
]->d
= str_to_wchar (desc
);
448 add_key_binding (&dst
, config_key
.func
, c
,
449 (desc
) ? desc
: _("no description"), config_key
.r
);
455 static struct known_key_s
484 KEY_ESCAPE
, "escape"},
492 parse_key (const char *filename
, int lines
, wchar_t ** key
)
494 wchar_t *p
= key
? *key
: NULL
;
495 wchar_t *orig
= key
? *key
: NULL
;
498 if (!key
|| !wcslen (*key
))
503 if (orig
[wcslen (orig
) - 1] != '\"')
504 errx (EXIT_FAILURE
, _("%s(%i): unbalanced quotes"), filename
, lines
);
507 orig
[wcslen (orig
) - 1] = 0;
516 for (i
= 0; known_keys
[i
].name
; i
++)
518 wchar_t *wc
= str_to_wchar (known_keys
[i
].name
);
520 if (!wcsncasecmp (p
, wc
, wcslen (wc
)))
523 p
+= strlen (known_keys
[i
].name
);
538 else if (*p
== 'F' || *p
== 'f')
540 char *str
= wchar_to_str (++p
);
542 c
= KEY_F (atoi (str
));
543 p
+= integer_len (atoi (str
));
552 errx (EXIT_FAILURE
, _("%s(%i): parse error \"%ls\""), filename
,
563 orig
+= wcslen (orig
) - wcslen (p
);
569 parse_key_binding (const char *filename
, int lines
, char *val
)
571 char mode
[64], func
[64];
572 wchar_t desc
[64] = { 0 };
582 n
= sscanf (val
, "%s %ls %s %63lc", mode
, key
, func
, desc
);
585 errx (EXIT_FAILURE
, _("%s(%i): too few arguments"), filename
, lines
);
587 if (strcasecmp (mode
, "history") == 0)
589 else if (strcasecmp (mode
, "play") == 0)
591 else if (strcasecmp (mode
, "edit") == 0)
594 errx (EXIT_FAILURE
, _("%s(%i): invalid game mode \"%s\""), filename
,
598 c
= parse_key (filename
, lines
, &p
);
602 for (i
= 0; global_keys
[i
]; i
++)
604 if (global_keys
[i
]->c
== c
)
606 _("%s(%i): key \"%ls\" conflicts with a global key"),
607 filename
, lines
, key
);
611 for (f
= -2, i
= 0; config_keys
[i
].name
; i
++)
613 if (strcmp (config_keys
[i
].name
, func
) == 0 && config_keys
[i
].mode
== m
)
621 errx (EXIT_FAILURE
, _("%s(%i): invalid command \"%s\""), filename
,
624 str
= wchar_to_str (desc
);
629 update_key (play_keys
, config_keys
[f
], c
, (n
> 3) ? str
: NULL
);
632 update_key (history_keys
, config_keys
[f
], c
, (n
> 3) ? str
: NULL
);
635 update_key (edit_keys
, config_keys
[f
], c
, (n
> 3) ? str
: NULL
);
638 update_key (global_keys
, config_keys
[f
], c
, (n
> 3) ? str
: NULL
);
646 parse_macro (const char *filename
, int lines
, char *val
)
649 wchar_t keys
[2048] = { 0 }, key
[8];
656 n
= sscanf (val
, "%s %ls %2047lc", mode
, key
, keys
);
659 errx (EXIT_FAILURE
, _("%s(%i): too few arguments"), filename
, lines
);
661 if (strcasecmp (mode
, "history") == 0)
663 else if (strcasecmp (mode
, "play") == 0)
665 else if (strcasecmp (mode
, "edit") == 0)
667 else if (strcasecmp (mode
, "any") == 0)
670 errx (EXIT_FAILURE
, _("%s(%i): invalid game mode \"%s\""), filename
,
674 c
= parse_key (filename
, lines
, &p
);
677 for (i
= 0; macros
[i
]; i
++);
679 macros
= Realloc (macros
, (i
+ 2) * sizeof (struct macro_s
*));
680 macros
[i
] = Calloc (1, sizeof (struct macro_s
));
685 while ((c
= parse_key (filename
, lines
, &p
)) != 0)
687 macros
[i
]->keys
= Realloc (macros
[i
]->keys
, (macros
[i
]->total
+ 2) *
689 macros
[i
]->keys
[macros
[i
]->total
++] = c
;
696 parse_rcfile (const char *filename
)
699 char *line
, buf
[LINE_MAX
];
701 char *altengine
= NULL
;
706 if ((fp
= fopen (filename
, "r")) == NULL
)
707 err (EXIT_FAILURE
, "%s", filename
);
709 while ((line
= fgets (buf
, sizeof (buf
), fp
)) != NULL
)
712 char var
[30] = { 0 }, val
[LINE_MAX
- sizeof (var
) - 1] =
715 char token
[MAX_PGN_LINE_LEN
+ 1] = { 0 };
716 char value
[MAX_PGN_LINE_LEN
+ 1] = { 0 };
722 if (!line
[0] || line
[0] == '#')
725 if ((n
= sscanf (line
, "%s %[^\n]", var
, val
)) != 2)
726 errx (EXIT_FAILURE
, _("%s(%i): parse error %i"), filename
, lines
, n
);
728 p
= strdup (trim (val
));
729 strncpy (val
, p
, sizeof (val
) - 1);
731 p
= strdup (trim (var
));
732 strncpy (var
, p
, sizeof (var
) - 1);
735 if (strcmp (var
, "jump_count") == 0)
737 if (!isinteger (val
))
738 errx (EXIT_FAILURE
, _("%s(%i): value is not an integer"),
741 config
.jumpcount
= atoi (val
);
743 else if (strcmp (var
, "engine_init") == 0)
746 Realloc (config
.einit
, (init
+ 2) * sizeof (wchar_t *));
747 config
.einit
[init
++] = str_to_wchar (val
);
748 config
.einit
[init
] = NULL
;
750 else if (strcmp (var
, "pattern") == 0)
752 free (config
.pattern
);
753 config
.pattern
= strdup (val
);
755 else if (strcmp (var
, "mpl") == 0)
757 if (!isinteger (val
))
758 errx (EXIT_FAILURE
, _("%s(%i): value is not an integer"),
760 pgn_config_set (PGN_MPL
, atoi (val
));
762 else if (strcmp (var
, "stop_on_error") == 0)
763 pgn_config_set (PGN_STOP_ON_ERROR
, on_or_off (filename
, lines
, val
));
764 else if (strcmp (var
, "tag") == 0)
766 if ((n
= sscanf (val
, "%s %s ", token
, value
)) < 1 || n
> 2)
767 errx (EXIT_FAILURE
, _("%s(%i): invalid value \"%s\""), filename
,
774 p
= val
+ strlen (token
);
775 strncpy (value
, p
, sizeof (value
) - 1);
778 for (n
= 0; n
< strlen (token
); n
++)
780 if (!isalnum (token
[n
]) && token
[n
] != '_')
782 _("%s(%i): token names must match 0-9A-Za-z_."),
786 token
[0] = toupper (token
[0]);
787 pgn_tag_add (&config
.tag
, token
, value
);
789 else if (strcmp (var
, "save_directory") == 0)
790 config
.savedirectory
= strdup (val
);
791 else if (strcmp (var
, "line_graphics") == 0)
792 config
.linegraphics
= on_or_off (filename
, lines
, val
);
793 else if (strcmp (var
, "save_prompt") == 0)
794 config
.saveprompt
= on_or_off (filename
, lines
, val
);
795 else if (strcmp (var
, "delete_prompt") == 0)
796 config
.deleteprompt
= on_or_off (filename
, lines
, val
);
797 else if (strcmp (var
, "valid_moves") == 0)
798 config
.validmoves
= on_or_off (filename
, lines
, val
);
799 else if (strcmp (var
, "board_details") == 0)
800 config
.details
= on_or_off (filename
, lines
, val
);
801 else if (strcmp (var
, "show_attacks") == 0)
802 config
.showattacks
= on_or_off (filename
, lines
, val
);
803 else if (strcmp (var
, "coords_y_left") == 0)
804 config
.coordsyleft
= on_or_off (filename
, lines
, val
);
805 else if (strcmp (var
, "fm_polyglot") == 0)
806 config
.fmpolyglot
= on_or_off (filename
, lines
, val
);
807 else if (strcmp (var
, "board_left") == 0)
808 config
.boardleft
= on_or_off (filename
, lines
, val
);
809 else if (strcmp (var
, "exit_dialog_box") == 0)
810 config
.exitdialogbox
= on_or_off (filename
, lines
, val
);
811 else if (strcmp (var
, "engine_cmd_blacktag") == 0)
812 config
.enginecmdblacktag
= on_or_off (filename
, lines
, val
);
813 else if (strcmp (var
, "board_prev_move") == 0)
814 config
.bprevmove
= on_or_off (filename
, lines
, val
);
815 else if (strcmp (var
, "strict_castling") == 0)
816 pgn_config_set (PGN_STRICT_CASTLING
,
817 on_or_off (filename
, lines
, val
));
818 else if (strcmp (var
, "engine_cmd") == 0)
819 altengine
= strdup (val
);
820 else if (strcmp (var
, "engine_protocol") == 0)
822 if (!isinteger (val
))
823 errx (EXIT_FAILURE
, _("%s(%i): value is not an integer"),
826 config
.engine_protocol
= atoi (val
);
828 if (config
.engine_protocol
!= 1 && config
.engine_protocol
!= 2)
829 errx (EXIT_FAILURE
, _("%s(%i): invalid value"), filename
, lines
);
831 else if (strcmp (var
, "utf8_pieces") == 0)
832 config
.utf8_pieces
= on_or_off (filename
, lines
, val
);
833 else if (strcmp (var
, "turn_cmd") == 0)
834 config
.turn_cmd
= strdup (val
);
835 else if (strcmp (var
, "color_board_window") == 0)
836 parse_color (filename
, lines
, val
, &config
.color
[CONF_BDWINDOW
]);
837 else if (strcmp (var
, "color_board_selected") == 0)
838 parse_color (filename
, lines
, val
, &config
.color
[CONF_BSELECTED
]);
839 else if (strcmp (var
, "color_board_white_moves") == 0)
840 parse_color (filename
, lines
, val
, &config
.color
[CONF_BMOVESW
]);
841 else if (strcmp (var
, "color_board_black_moves") == 0)
842 parse_color (filename
, lines
, val
, &config
.color
[CONF_BMOVESB
]);
843 else if (strcmp (var
, "color_board_count") == 0)
844 parse_color (filename
, lines
, val
, &config
.color
[CONF_BCOUNT
]);
845 else if (strcmp (var
, "color_board_cursor") == 0)
846 parse_color (filename
, lines
, val
, &config
.color
[CONF_BCURSOR
]);
847 else if (strcmp (var
, "color_board_black") == 0)
848 parse_color (filename
, lines
, val
, &config
.color
[CONF_BBLACK
]);
849 else if (strcmp (var
, "color_board_white") == 0)
850 parse_color (filename
, lines
, val
, &config
.color
[CONF_BWHITE
]);
851 else if (strcmp (var
, "color_board_graphics") == 0)
852 parse_color (filename
, lines
, val
, &config
.color
[CONF_BGRAPHICS
]);
853 else if (strcmp (var
, "color_board_coords") == 0)
854 parse_color (filename
, lines
, val
, &config
.color
[CONF_BCOORDS
]);
855 else if (strcmp (var
, "color_board_castling") == 0)
856 parse_color (filename
, lines
, val
, &config
.color
[CONF_BCASTLING
]);
857 else if (strcmp (var
, "color_board_enpassant") == 0)
858 parse_color (filename
, lines
, val
, &config
.color
[CONF_BENPASSANT
]);
859 else if (strcmp (var
, "color_board_attack") == 0)
860 parse_color (filename
, lines
, val
, &config
.color
[CONF_BATTACK
]);
861 else if (strcmp (var
, "color_board_prev_move") == 0)
862 parse_color (filename
, lines
, val
, &config
.color
[CONF_BPREVMOVE
]);
863 else if (strcmp (var
, "color_status_window") == 0)
864 parse_color (filename
, lines
, val
, &config
.color
[CONF_SWINDOW
]);
865 else if (strcmp (var
, "color_status_title") == 0)
866 parse_color (filename
, lines
, val
, &config
.color
[CONF_STITLE
]);
867 else if (strcmp (var
, "color_status_border") == 0)
868 parse_color (filename
, lines
, val
, &config
.color
[CONF_SBORDER
]);
869 else if (strcmp (var
, "color_status_notify") == 0)
870 parse_color (filename
, lines
, val
, &config
.color
[CONF_SNOTIFY
]);
871 else if (strcmp (var
, "color_status_engine") == 0)
872 parse_color (filename
, lines
, val
, &config
.color
[CONF_SENGINE
]);
873 else if (strcmp (var
, "color_tag_window") == 0)
874 parse_color (filename
, lines
, val
, &config
.color
[CONF_TWINDOW
]);
875 else if (strcmp (var
, "color_tag_title") == 0)
876 parse_color (filename
, lines
, val
, &config
.color
[CONF_TTITLE
]);
877 else if (strcmp (var
, "color_tag_border") == 0)
878 parse_color (filename
, lines
, val
, &config
.color
[CONF_TBORDER
]);
879 else if (strcmp (var
, "color_history_window") == 0)
880 parse_color (filename
, lines
, val
, &config
.color
[CONF_HWINDOW
]);
881 else if (strcmp (var
, "color_history_title") == 0)
882 parse_color (filename
, lines
, val
, &config
.color
[CONF_HTITLE
]);
883 else if (strcmp (var
, "color_history_border") == 0)
884 parse_color (filename
, lines
, val
, &config
.color
[CONF_HBORDER
]);
885 else if (strcmp (var
, "color_message_window") == 0)
886 parse_color (filename
, lines
, val
, &config
.color
[CONF_MWINDOW
]);
887 else if (strcmp (var
, "color_message_title") == 0)
888 parse_color (filename
, lines
, val
, &config
.color
[CONF_MTITLE
]);
889 else if (strcmp (var
, "color_message_border") == 0)
890 parse_color (filename
, lines
, val
, &config
.color
[CONF_MBORDER
]);
891 else if (strcmp (var
, "color_message_prompt") == 0)
892 parse_color (filename
, lines
, val
, &config
.color
[CONF_MPROMPT
]);
893 else if (strcmp (var
, "color_input_window") == 0)
894 parse_color (filename
, lines
, val
, &config
.color
[CONF_IWINDOW
]);
895 else if (strcmp (var
, "color_input_title") == 0)
896 parse_color (filename
, lines
, val
, &config
.color
[CONF_ITITLE
]);
897 else if (strcmp (var
, "color_input_border") == 0)
898 parse_color (filename
, lines
, val
, &config
.color
[CONF_IBORDER
]);
899 else if (strcmp (var
, "color_input_prompt") == 0)
900 parse_color (filename
, lines
, val
, &config
.color
[CONF_IPROMPT
]);
901 else if (strcmp (var
, "color_menu") == 0)
902 parse_color (filename
, lines
, val
, &config
.color
[CONF_MENU
]);
903 else if (strcmp (var
, "color_menu_selected") == 0)
904 parse_color (filename
, lines
, val
, &config
.color
[CONF_MENUS
]);
905 else if (strcmp (var
, "color_menu_highlight") == 0)
906 parse_color (filename
, lines
, val
, &config
.color
[CONF_MENUH
]);
907 else if (strcmp (var
, "color_menu_graphics") == 0)
908 parse_color (filename
, lines
, val
,
909 &config
.color
[CONF_HISTORY_MENU_LG
]);
910 else if (strcmp (var
, "bind") == 0)
911 parse_key_binding (filename
, lines
, val
);
912 else if (strcmp (var
, "macro") == 0)
913 parse_macro (filename
, lines
, val
);
914 else if (strcmp (var
, "cbind") == 0)
916 config
.keys
= Realloc (config
.keys
, (k
+ 2) *
917 sizeof (struct config_key_s
*));
918 config
.keys
[k
] = Calloc (1, sizeof (struct config_key_s
));
922 while (*p
&& !isspace (*p
))
929 if (strcasecmp (p
, "none") == 0)
930 config
.keys
[k
]->type
= KEY_DEFAULT
;
931 else if (strcasecmp (p
, "repeat") == 0)
932 config
.keys
[k
]->type
= KEY_REPEAT
;
933 else if (strcasecmp (p
, "set") == 0)
934 config
.keys
[k
]->type
= KEY_SET
;
936 errx (EXIT_FAILURE
, _("%s(%i): invalid value \"%s\""), filename
,
942 while (*p
&& isspace (*p
))
945 config
.keys
[k
]->c
= *p
++;
950 config
.keys
[k
++]->str
= str_to_wchar (p
);
951 config
.keys
[k
] = NULL
;
954 errx (EXIT_FAILURE
, _("%s(%i): invalid parameter \"%s\""), filename
,
962 free (config
.engine_cmd
);
963 config
.engine_cmd
= NULL
;
964 config
.engine_cmd
= altengine
;
967 if (config
.enginecmdblacktag
)
968 pgn_tag_add (&config
.tag
, (char *) "Black", config
.engine_cmd
);