2026-10-18 01:54:06 +03:00
|
|
|
//! PGN import (scan + lazy parse) and export.
|
|
|
|
|
|
|
|
|
|
mod lexer;
|
|
|
|
|
pub mod parse;
|
|
|
|
|
pub mod scan;
|
Own databases: create PGN bases, add, save, delete games; library logging
Desktop: «✚ New database» on the shelf (Ctrl+Shift+N), «Add to database…»
(Ctrl+Shift+S, 💾, ☰) for any game — new, pasted, from a ChessBase, online or
legacy-encoded database — into a PGN of the user's choice; Ctrl+S saves the
changes back into the game's own PGN (its record is replaced) or adds the game
when the source is read-only; the game data editor (F2, the title, ☰) asked once
when a new game is first added; duplicate check (same players, date, moves →
replace / add as new, no Enter); delete from the table with a question and Undo
(Ctrl+Z, 6 s, waits under the mouse); UTF-8 copy for legacy-encoded files with
the restored letters; online and ChessBase stay read-only. Writes are explicit:
append, or an atomic rewrite through a temporary file and a rename (through a
symlink, keeping the mode, syncing the folder), refused when the file changed on
the disk. chess_core::pgn::store: append/replace/remove/restore/write_utf8_copy,
find_same_game, pgn_date; Game::remove_tag and order_roster. Settings: your
name (annotator), the folder for new databases, the last target. Nine languages.
Also: library warnings (wgpu, winit) go to chesspenguin.log, CP_LOG_FRAMES=1
traces egui_wgpu frames (the GNOME hang hunt); dev hooks CP_OWN, CP_PASTE,
CP_COMMENT, CP_KEYS with Ctrl+, CP_SETTINGS=interface.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 00:46:47 +03:00
|
|
|
pub mod store;
|
2026-10-18 01:54:06 +03:00
|
|
|
pub mod write;
|
|
|
|
|
|
|
|
|
|
pub use parse::{
|
|
|
|
|
ParseOptions, ParsedGame, parse_game, parse_game_range, parse_game_range_with, parse_str,
|
|
|
|
|
};
|
|
|
|
|
pub use scan::{Cancelled, EntryFlags, GameEntry, ScanProgress, scan_games};
|
|
|
|
|
pub use write::{WriteOptions, write_game};
|
|
|
|
|
|
|
|
|
|
use crate::encoding::TextEncoding;
|
|
|
|
|
use std::sync::atomic::AtomicBool;
|
|
|
|
|
|
|
|
|
|
/// Scans and parses every record (convenience for tests and small inputs).
|
|
|
|
|
pub fn parse_all(bytes: &[u8], encoding: TextEncoding) -> Vec<(GameEntry, ParsedGame)> {
|
|
|
|
|
let entries =
|
|
|
|
|
scan_games(bytes, encoding, &mut |_| {}, &AtomicBool::new(false)).unwrap_or_default();
|
|
|
|
|
entries
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(|e| {
|
|
|
|
|
let parsed = parse_game_range(bytes, e.byte_range.clone(), e.first_line, encoding);
|
|
|
|
|
(e, parsed)
|
|
|
|
|
})
|
|
|
|
|
.collect()
|
|
|
|
|
}
|