From 641e49de3a9c317c028215dfb1764235a313bf54 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Thu, 20 Apr 2006 20:47:12 -0400 Subject: [PATCH] Added configuration parameter 'board_details' to enable/disable it by default. Added board details indicator at the lower-right of the board window. --- doc/cboard.man | 4 ++++ doc/config.example | 4 ++++ src/cboard.c | 22 ++++++++++++---------- src/cboard.h | 1 - src/conf.h | 1 + src/rcfile.c | 2 ++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/doc/cboard.man b/doc/cboard.man index 1071ae4..652a59f 100644 --- a/doc/cboard.man +++ b/doc/cboard.man @@ -152,6 +152,10 @@ default tag values. It can also be used more than once. Enable or disable board line graphics. The default is .Ar off . .Pp +.It Cm board_details Ar BOOL +When enabled castling availability and the en passasnt square will be shown on +the board. This can be toggled with the `d' key. +.Pp .It Cm save_directory Pa path If set, the default directory where games will be saved and restored from. Tildes `~' and environment variables are supported. diff --git a/doc/config.example b/doc/config.example index 9bdad8f..fffbd0a 100644 --- a/doc/config.example +++ b/doc/config.example @@ -53,6 +53,10 @@ line_graphics on # If on, show valid moves for the selected piece. BOOL valid_moves on +# When enabled castling availability and the en passasnt square will be shown +# on the board. This can be toggled with the `d' key. BOOL +board_details off + # If enabled and there is a parsing error when loading a file, stop processing # immediately. Normally a game or round will be flagged as having an error and # other games will be loaded. BOOL diff --git a/src/cboard.c b/src/cboard.c index 789e2f5..c5e1515 100644 --- a/src/cboard.c +++ b/src/cboard.c @@ -1433,7 +1433,7 @@ static int castling_state(GAME *g, BOARD b, int row, int col, int piece, int mod return 0; } -static void draw_board(GAME *g, int details) +static void draw_board(GAME *g) { int row, col; int bcol = 0, brow = 0; @@ -1549,13 +1549,13 @@ static void draw_board(GAME *g, int details) if (row == maxy - 1) waddch(boardw, x_grid_chars[bcol] | CP_BOARD_COORDS); else { - if (details && d->b[row / 2][bcol].enpassant) + if (config.details && d->b[row / 2][bcol].enpassant) piece = 'x'; else piece = d->b[row / 2][bcol].icon; - if (details && castling_state(g, d->b, brow, bcol, - piece, 0)) + if (config.details && castling_state(g, d->b, brow, + bcol, piece, 0)) attrs |= A_REVERSE; if (g->side == WHITE && isupper(piece)) @@ -1583,6 +1583,8 @@ static void draw_board(GAME *g, int details) brow = row / 2; } + + mvwaddch(boardw, maxy - 1, maxx - 2, (config.details) ? '!' : ' '); } void invalid_move(int n, const char *m) @@ -2534,7 +2536,7 @@ static int playmode_keys(chtype c) historymode_keys(c); break; case 'd': - board_details = (board_details) ? 0 : 1; + config.details = (config.details) ? 0 : 1; break; case 'p': paused = (paused) ? 0 : 1; @@ -2644,7 +2646,7 @@ static void historymode_keys(chtype c) switch (c) { case 'd': - board_details = (board_details) ? 0 : 1; + config.details = (config.details) ? 0 : 1; break; case ' ': movestep = (movestep == 1) ? 2 : 1; @@ -3335,13 +3337,13 @@ static int globalkeys(chtype c) if (game[gindex].mode != MODE_EDIT) { pgn_board_init_fen(&game[gindex], d->b, NULL); - board_details++; + config.details++; game[gindex].mode = MODE_EDIT; update_all(game[gindex]); return 1; } - board_details--; + config.details--; pgn_tag_add(&game[gindex].tag, "FEN", pgn_game_to_fen(game[gindex], d->b)); pgn_tag_add(&game[gindex].tag, "SetUp", "1"); @@ -3470,7 +3472,7 @@ void game_loop() d = game[gindex].data; error_recover = 0; - draw_board(&game[gindex], board_details); + draw_board(&game[gindex]); update_all(game[gindex]); wmove(boardw, ROWTOMATRIX(d->c_row), COLTOMATRIX(d->c_col)); @@ -3616,8 +3618,8 @@ void catch_signal(int which) static void set_defaults() { - filetype = NO_FILE; set_config_defaults(); + filetype = NO_FILE; } int main(int argc, char *argv[]) diff --git a/src/cboard.h b/src/cboard.h index 2761068..3037004 100644 --- a/src/cboard.h +++ b/src/cboard.h @@ -52,7 +52,6 @@ PANEL *enginep; int delete_count = 0; int markstart = -1, markend = -1; -int board_details; int pushkey; int keycount; char loadfile[FILENAME_MAX]; diff --git a/src/conf.h b/src/conf.h index 4df9bb5..e651319 100644 --- a/src/conf.h +++ b/src/conf.h @@ -80,6 +80,7 @@ struct { * or new game. */ struct key_s **keys; // Custom commands to send to the engine. + int details; // Board details. } config; #endif diff --git a/src/rcfile.c b/src/rcfile.c index 75ad165..b41e541 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -311,6 +311,8 @@ void parse_rcfile(const char *filename) config.deleteprompt = on_or_off(filename, lines, val); else if (strcmp(var, "valid_moves") == 0) config.validmoves = on_or_off(filename, lines, val); + else if (strcmp(var, "board_details") == 0) + config.details = on_or_off(filename, lines, val); else if (strcmp(var, "engine_cmd") == 0) altengine = strdup(val); else if (strcmp(var, "color_board_window") == 0) -- 2.11.4.GIT