Android stage 0: the core opens databases without paths; the mobile-api bridge
chess-import opens a database from its content (PGN, zip, 7z, cbv) and a ChessBase database from the contents of its files: Android hands over file descriptors, not paths. The text of comments as shown moves to chess-core (comment_display_text), so the phone and the desktop show the same. crates/mobile-api: a thin UniFFI bridge — open a database from a descriptor, a ChessBase folder's files, or a path (tests); game rows a page at a time; a game as a tree of moves with positions, last-move squares, NAGs and comments. It builds for arm64-v8a and x86_64 with cargo-ndk (NDK r30, API 31) and its Kotlin bindings generate with `cargo run -p mobile-api --features bindgen --bin uniffi-bindgen`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
985b877063
commit
0c912ac669
10 changed files with 1020 additions and 31 deletions
|
|
@ -7,7 +7,7 @@ use crate::i18n::tr;
|
|||
use crate::review::{Mark, judgement_color, judgement_name, judgement_symbol};
|
||||
use crate::translate_ui::Mark as Translated;
|
||||
use chess_core::shakmaty::{Color, Position};
|
||||
use chess_core::{CommentPart, Game, Nag, NodeId, parse_comment};
|
||||
use chess_core::{Game, Nag, NodeId};
|
||||
use egui::{Align2, Color32, FontId, RichText, Sense, Stroke, Ui, vec2};
|
||||
|
||||
pub struct Notation<'a> {
|
||||
|
|
@ -362,34 +362,9 @@ fn move_glyph(nags: &[Nag]) -> (String, Option<Color32>) {
|
|||
(s, color)
|
||||
}
|
||||
|
||||
/// The text of comments as shown (see [`chess_core::comment_display_text`]).
|
||||
pub fn comment_text(comments: &[String]) -> String {
|
||||
let mut out = String::new();
|
||||
for c in comments {
|
||||
for part in parse_comment(c) {
|
||||
if let CommentPart::Text(t) = part {
|
||||
// Single line breaks are formatting, not content: reflow to the panel width.
|
||||
// A blank line starts a new paragraph (book chapters imported from ChessBase).
|
||||
let mut blank = false;
|
||||
for line in t.lines() {
|
||||
if line.trim().is_empty() {
|
||||
blank = true;
|
||||
continue;
|
||||
}
|
||||
if blank && !out.is_empty() {
|
||||
out.push_str("\n\n");
|
||||
}
|
||||
blank = false;
|
||||
for word in line.split_whitespace() {
|
||||
if !out.is_empty() && !out.ends_with('\n') {
|
||||
out.push(' ');
|
||||
}
|
||||
out.push_str(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
chess_core::comment_display_text(comments)
|
||||
}
|
||||
|
||||
fn block_frame(ui: &Ui) -> egui::Frame {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue