mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 15:17:42 +03:00
Compare commits
9 Commits
f536424011
...
94a87470b7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94a87470b7 | ||
|
|
2614d1da28 | ||
|
|
a29ff93f9c | ||
|
|
c591c2e033 | ||
|
|
d34122177c | ||
|
|
ad7e9bd267 | ||
|
|
91a0677503 | ||
|
|
b2985f87d3 | ||
|
|
b042e3c790 |
@ -414,6 +414,7 @@ int Epub::findVirtualSpineIndex(const std::string& filename) const {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t Epub::getBookSize() const { return getCumulativeSpineItemSize(getSpineItemsCount() - 1); }
|
||||
|
||||
// Calculate progress in book
|
||||
@ -423,4 +424,4 @@ uint8_t Epub::calculateProgress(const int currentSpineIndex, const float current
|
||||
size_t bookSize = getBookSize();
|
||||
size_t sectionProgSize = currentSpineRead * curChapterSize;
|
||||
return round(static_cast<float>(prevChapterSize + sectionProgSize) / bookSize * 100.0);
|
||||
}
|
||||
}
|
||||
@ -70,5 +70,5 @@ class Epub {
|
||||
int findVirtualSpineIndex(const std::string& filename) const;
|
||||
|
||||
size_t getBookSize() const;
|
||||
uint8_t calculateProgress(const int currentSpineIndex, const float currentSpineRead) const;
|
||||
uint8_t calculateProgress(const int currentSpineIndex, const float currentSpineRead);
|
||||
};
|
||||
|
||||
@ -44,6 +44,8 @@ void Page::serialize(std::ostream& os) const {
|
||||
for (int i = 0; i < footnoteCount; i++) {
|
||||
os.write(footnotes[i].number, 3);
|
||||
os.write(footnotes[i].href, 64);
|
||||
uint8_t isInlineFlag = footnotes[i].isInline ? 1 : 0;
|
||||
os.write(reinterpret_cast<const char*>(&isInlineFlag), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +82,9 @@ std::unique_ptr<Page> Page::deserialize(std::istream& is) {
|
||||
for (int i = 0; i < page->footnoteCount; i++) {
|
||||
is.read(page->footnotes[i].number, 3);
|
||||
is.read(page->footnotes[i].href, 64);
|
||||
uint8_t isInlineFlag = 0;
|
||||
is.read(reinterpret_cast<char*>(&isInlineFlag), 1);
|
||||
page->footnotes[i].isInline = (isInlineFlag != 0);
|
||||
}
|
||||
|
||||
return page;
|
||||
|
||||
@ -48,7 +48,7 @@ class Page {
|
||||
elementCapacity = 24;
|
||||
elements = new std::shared_ptr<PageElement>[elementCapacity];
|
||||
|
||||
footnoteCapacity = 8;
|
||||
footnoteCapacity = 16;
|
||||
footnotes = new FootnoteEntry[footnoteCapacity];
|
||||
for (int i = 0; i < footnoteCapacity; i++) {
|
||||
footnotes[i].number[0] = '\0';
|
||||
|
||||
@ -60,7 +60,7 @@ void ChapterHtmlSlimParser::startNewTextBlock(const TextBlock::BLOCK_STYLE style
|
||||
}
|
||||
|
||||
void ChapterHtmlSlimParser::addFootnoteToCurrentPage(const char* number, const char* href) {
|
||||
if (currentPageFootnoteCount >= 32) return;
|
||||
if (currentPageFootnoteCount >= 16) return;
|
||||
|
||||
Serial.printf("[%lu] [ADDFT] Adding footnote: num=%s, href=%s\n", millis(), number, href);
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ class ChapterHtmlSlimParser {
|
||||
std::function<void(Noteref&)> noterefCallback = nullptr;
|
||||
|
||||
// Footnote tracking for current page
|
||||
FootnoteEntry currentPageFootnotes[32];
|
||||
FootnoteEntry currentPageFootnotes[16];
|
||||
int currentPageFootnoteCount = 0;
|
||||
|
||||
// Inline footnotes (aside) tracking
|
||||
|
||||
@ -52,7 +52,7 @@ void EpubReaderActivity::onEnter() {
|
||||
updateRequired = true;
|
||||
|
||||
xTaskCreate(&EpubReaderActivity::taskTrampoline, "EpubReaderActivityTask",
|
||||
8192, // Stack size
|
||||
24576, // Stack size
|
||||
this, // Parameters
|
||||
1, // Priority
|
||||
&displayTaskHandle // Task handle
|
||||
@ -321,11 +321,15 @@ void EpubReaderActivity::renderScreen() {
|
||||
return renderScreen();
|
||||
}
|
||||
|
||||
Serial.printf("[%lu] [ERS] Page loaded: %d elements, %d footnotes\n", millis(), p->elementCount, p->footnoteCount);
|
||||
|
||||
// Copy footnotes from page to currentPageFootnotes
|
||||
currentPageFootnotes.clear();
|
||||
for (int i = 0; i < p->footnoteCount && i < 16; i++) {
|
||||
int maxFootnotes = (p->footnoteCount < 8) ? p->footnoteCount : 8;
|
||||
|
||||
for (int i = 0; i < maxFootnotes; i++) {
|
||||
FootnoteEntry* footnote = p->getFootnote(i);
|
||||
if (footnote) {
|
||||
if (footnote && footnote->href[0] != '\0') {
|
||||
currentPageFootnotes.addFootnote(footnote->number, footnote->href);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,14 +8,19 @@
|
||||
|
||||
class FootnotesData {
|
||||
private:
|
||||
FootnoteEntry entries[32];
|
||||
FootnoteEntry entries[16];
|
||||
int count;
|
||||
|
||||
public:
|
||||
FootnotesData() : count(0) {}
|
||||
FootnotesData() : count(0) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
entries[i].number[0] = '\0';
|
||||
entries[i].href[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void addFootnote(const char* number, const char* href) {
|
||||
if (count < 32) {
|
||||
if (count < 16 && number && href) {
|
||||
strncpy(entries[count].number, number, 2);
|
||||
entries[count].number[2] = '\0';
|
||||
strncpy(entries[count].href, href, 63);
|
||||
@ -24,7 +29,13 @@ class FootnotesData {
|
||||
}
|
||||
}
|
||||
|
||||
void clear() { count = 0; }
|
||||
void clear() {
|
||||
count = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
entries[i].number[0] = '\0';
|
||||
entries[i].href[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
int getCount() const { return count; }
|
||||
|
||||
@ -58,4 +69,4 @@ class EpubReaderFootnotesActivity final : public Activity {
|
||||
|
||||
private:
|
||||
void render();
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user