# HG changeset patch # User Mike Becker # Date 1777476483 -7200 # Node ID ee539a9691f067bdb0b4596d1738b3bf0ac98713 # Parent 4bf18d42e7ee0a13335f6430752b598af032438c add prompt whether PGN should be exported with comments resolves #825 diff -r 4bf18d42e7ee -r ee539a9691f0 src/chess/pgn.c --- a/src/chess/pgn.c Tue Apr 28 12:33:22 2026 +0200 +++ b/src/chess/pgn.c Wed Apr 29 17:28:03 2026 +0200 @@ -196,7 +196,8 @@ } } -void write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo) { +void write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo, + bool export_comments) { // TODO: tag pairs /* Result */ @@ -250,6 +251,11 @@ } moveblkptr += snpr; + if (!export_comments) { + *(moveblkptr++) = ' '; + continue; + } + /* add clock times when the game was under time control */ if (gameinfo->timecontrol) { memcpy(moveblkptr, " {[%clk ", 8); diff -r 4bf18d42e7ee -r ee539a9691f0 src/chess/pgn.h --- a/src/chess/pgn.h Tue Apr 28 12:33:22 2026 +0200 +++ b/src/chess/pgn.h Wed Apr 29 17:28:03 2026 +0200 @@ -39,7 +39,8 @@ #endif int read_pgn(FILE *stream, GameState *gamestate, GameInfo *gameinfo); -void write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo); +void write_pgn(FILE* stream, GameState *gamestate, GameInfo *gameinfo, + bool export_comments); void compute_fen(char *str, GameState *gamestate); const char* pgn_error_str(int code); diff -r 4bf18d42e7ee -r ee539a9691f0 src/game.c --- a/src/game.c Tue Apr 28 12:33:22 2026 +0200 +++ b/src/game.c Wed Apr 29 17:28:03 2026 +0200 @@ -181,7 +181,9 @@ } static void save_pgn(GameState *gamestate, GameInfo *gameinfo) { - printw("Filename: "); + bool export_comments = prompt_yesno("Export with comments"); + + printw("\rFilename: "); clrtoeol(); refresh(); @@ -191,7 +193,7 @@ move(y, 0); FILE *file = fopen(filename, "w"); if (file) { - write_pgn(file, gamestate, gameinfo); + write_pgn(file, gamestate, gameinfo, export_comments); fclose(file); printw("File saved."); } else { diff -r 4bf18d42e7ee -r ee539a9691f0 src/input.c --- a/src/input.c Tue Apr 28 12:33:22 2026 +0200 +++ b/src/input.c Wed Apr 29 17:28:03 2026 +0200 @@ -32,6 +32,7 @@ int prompt_yesno(char *msg) { printw("%s (y/n)? ", msg); + clrtoeol(); refresh(); noecho(); int ch;