fen.c: for tty output show the indicator on the side to move, just like SVG - chess-puzzles - chess puzzle book generator
(HTM) git clone git://git.codemadness.org/chess-puzzles
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit a3b62d1145d314c0743fead2285f33326afeb263
(DIR) parent 340135cbaf1e942bafaa617b805aef4090601555
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 22 Jul 2025 15:58:43 +0200
fen.c: for tty output show the indicator on the side to move, just like SVG
Diffstat:
M fen.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/fen.c b/fen.c
@@ -549,7 +549,17 @@ output_tty(struct board *b)
t = b->theme;
SETBGCOLOR(t->border[0], t->border[1], t->border[2]);
- fputs(" ", stdout);
+ fputs(" ", stdout);
+ if (b->showside) {
+ if (b->side_to_move == 'w' && b->flipboard)
+ printf("\x1b[30;47m%c", b->side_to_move);
+ else if (b->side_to_move == 'b' && !b->flipboard)
+ printf("\x1b[37;40m%c", b->side_to_move);
+ else
+ putchar(' ');
+ } else {
+ putchar(' ');
+ }
printf("\x1b[0m"); /* reset */
putchar('\n');
@@ -589,7 +599,7 @@ output_tty(struct board *b)
putchar(ytorank(y));
putchar(' ');
} else {
- fputs(" ", stdout);
+ fputs(" ", stdout);
}
printf("\x1b[0m"); /* reset */
@@ -608,11 +618,14 @@ output_tty(struct board *b)
} else {
fputs(" ", stdout);
}
+
if (b->showside) {
- if (b->side_to_move == 'w')
+ if (b->side_to_move == 'w' && !b->flipboard)
printf("\x1b[30;47m%c", b->side_to_move);
- else
+ else if (b->side_to_move == 'b' && b->flipboard)
printf("\x1b[37;40m%c", b->side_to_move);
+ else
+ putchar(' ');
} else {
putchar(' ');
}