Compare commits

..

No commits in common. "2614d1da28662927a3de210e5f997acba240fbf4" and "83e20fb568fc153218a0000c3cb2dc8b904dfbe3" have entirely different histories.

8 changed files with 13 additions and 34 deletions

View File

@ -414,7 +414,6 @@ int Epub::findVirtualSpineIndex(const std::string& filename) const {
} }
return -1; return -1;
} }
size_t Epub::getBookSize() const { return getCumulativeSpineItemSize(getSpineItemsCount() - 1); } size_t Epub::getBookSize() const { return getCumulativeSpineItemSize(getSpineItemsCount() - 1); }
// Calculate progress in book // Calculate progress in book
@ -424,4 +423,4 @@ uint8_t Epub::calculateProgress(const int currentSpineIndex, const float current
size_t bookSize = getBookSize(); size_t bookSize = getBookSize();
size_t sectionProgSize = currentSpineRead * curChapterSize; size_t sectionProgSize = currentSpineRead * curChapterSize;
return round(static_cast<float>(prevChapterSize + sectionProgSize) / bookSize * 100.0); return round(static_cast<float>(prevChapterSize + sectionProgSize) / bookSize * 100.0);
} }

View File

@ -70,5 +70,5 @@ class Epub {
int findVirtualSpineIndex(const std::string& filename) const; int findVirtualSpineIndex(const std::string& filename) const;
size_t getBookSize() const; size_t getBookSize() const;
uint8_t calculateProgress(const int currentSpineIndex, const float currentSpineRead); uint8_t calculateProgress(const int currentSpineIndex, const float currentSpineRead) const;
}; };

View File

@ -44,8 +44,6 @@ void Page::serialize(std::ostream& os) const {
for (int i = 0; i < footnoteCount; i++) { for (int i = 0; i < footnoteCount; i++) {
os.write(footnotes[i].number, 3); os.write(footnotes[i].number, 3);
os.write(footnotes[i].href, 64); os.write(footnotes[i].href, 64);
uint8_t isInlineFlag = footnotes[i].isInline ? 1 : 0;
os.write(reinterpret_cast<const char*>(&isInlineFlag), 1);
} }
} }
@ -82,9 +80,6 @@ std::unique_ptr<Page> Page::deserialize(std::istream& is) {
for (int i = 0; i < page->footnoteCount; i++) { for (int i = 0; i < page->footnoteCount; i++) {
is.read(page->footnotes[i].number, 3); is.read(page->footnotes[i].number, 3);
is.read(page->footnotes[i].href, 64); 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; return page;

View File

@ -48,7 +48,7 @@ class Page {
elementCapacity = 24; elementCapacity = 24;
elements = new std::shared_ptr<PageElement>[elementCapacity]; elements = new std::shared_ptr<PageElement>[elementCapacity];
footnoteCapacity = 16; footnoteCapacity = 8;
footnotes = new FootnoteEntry[footnoteCapacity]; footnotes = new FootnoteEntry[footnoteCapacity];
for (int i = 0; i < footnoteCapacity; i++) { for (int i = 0; i < footnoteCapacity; i++) {
footnotes[i].number[0] = '\0'; footnotes[i].number[0] = '\0';

View File

@ -60,7 +60,7 @@ void ChapterHtmlSlimParser::startNewTextBlock(const TextBlock::BLOCK_STYLE style
} }
void ChapterHtmlSlimParser::addFootnoteToCurrentPage(const char* number, const char* href) { void ChapterHtmlSlimParser::addFootnoteToCurrentPage(const char* number, const char* href) {
if (currentPageFootnoteCount >= 16) return; if (currentPageFootnoteCount >= 32) return;
Serial.printf("[%lu] [ADDFT] Adding footnote: num=%s, href=%s\n", millis(), number, href); Serial.printf("[%lu] [ADDFT] Adding footnote: num=%s, href=%s\n", millis(), number, href);

View File

@ -77,7 +77,7 @@ class ChapterHtmlSlimParser {
std::function<void(Noteref&)> noterefCallback = nullptr; std::function<void(Noteref&)> noterefCallback = nullptr;
// Footnote tracking for current page // Footnote tracking for current page
FootnoteEntry currentPageFootnotes[16]; FootnoteEntry currentPageFootnotes[32];
int currentPageFootnoteCount = 0; int currentPageFootnoteCount = 0;
// Inline footnotes (aside) tracking // Inline footnotes (aside) tracking

View File

@ -52,7 +52,7 @@ void EpubReaderActivity::onEnter() {
updateRequired = true; updateRequired = true;
xTaskCreate(&EpubReaderActivity::taskTrampoline, "EpubReaderActivityTask", xTaskCreate(&EpubReaderActivity::taskTrampoline, "EpubReaderActivityTask",
24576, // Stack size 8192, // Stack size
this, // Parameters this, // Parameters
1, // Priority 1, // Priority
&displayTaskHandle // Task handle &displayTaskHandle // Task handle
@ -321,15 +321,11 @@ void EpubReaderActivity::renderScreen() {
return 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 // Copy footnotes from page to currentPageFootnotes
currentPageFootnotes.clear(); currentPageFootnotes.clear();
int maxFootnotes = (p->footnoteCount < 8) ? p->footnoteCount : 8; for (int i = 0; i < p->footnoteCount && i < 16; i++) {
for (int i = 0; i < maxFootnotes; i++) {
FootnoteEntry* footnote = p->getFootnote(i); FootnoteEntry* footnote = p->getFootnote(i);
if (footnote && footnote->href[0] != '\0') { if (footnote) {
currentPageFootnotes.addFootnote(footnote->number, footnote->href); currentPageFootnotes.addFootnote(footnote->number, footnote->href);
} }
} }

View File

@ -8,19 +8,14 @@
class FootnotesData { class FootnotesData {
private: private:
FootnoteEntry entries[16]; FootnoteEntry entries[32];
int count; int count;
public: 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) { void addFootnote(const char* number, const char* href) {
if (count < 16 && number && href) { if (count < 32) {
strncpy(entries[count].number, number, 2); strncpy(entries[count].number, number, 2);
entries[count].number[2] = '\0'; entries[count].number[2] = '\0';
strncpy(entries[count].href, href, 63); strncpy(entries[count].href, href, 63);
@ -29,13 +24,7 @@ class FootnotesData {
} }
} }
void clear() { void clear() { count = 0; }
count = 0;
for (int i = 0; i < 16; i++) {
entries[i].number[0] = '\0';
entries[i].href[0] = '\0';
}
}
int getCount() const { return count; } int getCount() const { return count; }
@ -69,4 +58,4 @@ class EpubReaderFootnotesActivity final : public Activity {
private: private:
void render(); void render();
}; };