Skip to content

Add chapter select support to XTC files#145

Merged
daveallie merged 1 commit intocrosspoint-reader:masterfrom
treetrum:master
Dec 30, 2025
Merged

Add chapter select support to XTC files#145
daveallie merged 1 commit intocrosspoint-reader:masterfrom
treetrum:master

Conversation

@treetrum
Copy link
Copy Markdown
Contributor

Summary

  • What is the goal of this PR? Add chapter selection support to the XTC reader activity, including parsing chapter metadata from XTC files.
  • What changes are included? Implemented XTC chapter parsing and exposure in the XTC library, added a chapter selection activity for XTC, integrated it into XtcReaderActivity, and normalized chapter page indices by shifting them to 0-based.

Additional Context

  • The reader uses 0-based page indexing (first page = 0), but the XTC chapter table appears to be 1-based (first page = 1), so chapter start/end pages are shifted down by 1 during parsing.

@treetrum treetrum marked this pull request as ready for review December 29, 2025 08:19
Copy link
Copy Markdown
Member

@daveallie daveallie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, @eunchurn did you have any thoughts on this one?

Copy link
Copy Markdown
Contributor

@eunchurn eunchurn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation! The approach of normalizing page indices during parsing (converting 1-based to 0-based) is clean.

A couple of suggestions:

  1. Unused include: #include <SD.h> in XtcReaderChapterSelectionActivity.cpp appears unused and can be removed.

  2. Long chapter names: Consider truncating chapter names that exceed screen width with "..." suffix, similar to EpubReaderChapterSelectionActivity::renderScreen().

Currently long names could overflow the display.

Otherwise LGTM!

I've also been working on similar features in my branch https://github.com/eunchurn/crosspoint-reader-ko/tree/feature/xtc-chapter-support

  • Chapter overlay: Displays current chapter name at bottom center while reading
  • V2 metadata parsing: Full XtcHeaderV2, XtcMetadata structures for coverPage, author, title (future use)
  • Centralized chapter lookup: getChapterIndexForPage() in XtcParser instead of Activity
  • Cover page support: Uses coverPage from metadata for cover image generation

And I've created PR to your repo treetrum#1

Comment on lines +48 to +50
if (!xtc) {
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!xtc) {
return;
}
if (!xtc || !xtc->hasChapters()) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids creating a FreeRTOS task unnecessarily if chapters are somehow empty when entering the activity.

@treetrum
Copy link
Copy Markdown
Contributor Author

Thanks for the review @eunchurn! Appreciate the feedback 🙂

Given you've already addressed those points you've left in your fork, should we merge this as is and have you open a new PR with those fixes?

@daveallie
Copy link
Copy Markdown
Member

Going to merge this in and we can have the remaining improvements to the XTC parser come later

@daveallie daveallie merged commit 278b056 into crosspoint-reader:master Dec 30, 2025
1 check passed
@eunchurn
Copy link
Copy Markdown
Contributor

Good work!. I don't think it's a good idea to merge my improvement commit yet. There's some interference with the chapter display. I think we'll need to make this optional later. I'll reorganize the parser and types and submit a PR.

jonasdiemer pushed a commit to jonasdiemer/crosspoint-reader that referenced this pull request Dec 30, 2025
## Summary

- **What is the goal of this PR?** Add chapter selection support to the
XTC reader activity, including parsing chapter metadata from XTC files.
- **What changes are included?** Implemented XTC chapter parsing and
exposure in the XTC library, added a chapter selection activity for XTC,
integrated it into XtcReaderActivity, and normalized chapter page
indices by shifting them to 0-based.

  ## Additional Context

- The reader uses 0-based page indexing (first page = 0), but the XTC
chapter table appears to be 1-based (first page = 1), so chapter
start/end pages are shifted down by 1 during parsing.
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
## Summary

- **What is the goal of this PR?** Add chapter selection support to the
XTC reader activity, including parsing chapter metadata from XTC files.
- **What changes are included?** Implemented XTC chapter parsing and
exposure in the XTC library, added a chapter selection activity for XTC,
integrated it into XtcReaderActivity, and normalized chapter page
indices by shifting them to 0-based.

  ## Additional Context

- The reader uses 0-based page indexing (first page = 0), but the XTC
chapter table appears to be 1-based (first page = 1), so chapter
start/end pages are shifted down by 1 during parsing.
whale-n pushed a commit to whale-n/njwiv-xt that referenced this pull request Mar 17, 2026
## Summary

- **What is the goal of this PR?** Add chapter selection support to the
XTC reader activity, including parsing chapter metadata from XTC files.
- **What changes are included?** Implemented XTC chapter parsing and
exposure in the XTC library, added a chapter selection activity for XTC,
integrated it into XtcReaderActivity, and normalized chapter page
indices by shifting them to 0-based.

  ## Additional Context

- The reader uses 0-based page indexing (first page = 0), but the XTC
chapter table appears to be 1-based (first page = 1), so chapter
start/end pages are shifted down by 1 during parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants