mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-19 07:37:41 +03:00
Compare commits
8 Commits
83e20fb568
...
2614d1da28
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2614d1da28 | ||
|
|
a29ff93f9c | ||
|
|
c591c2e033 | ||
|
|
d34122177c | ||
|
|
ad7e9bd267 | ||
|
|
91a0677503 | ||
|
|
b2985f87d3 | ||
|
|
b042e3c790 |
@ -414,6 +414,7 @@ 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
|
||||||
|
|||||||
@ -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) 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++) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +82,9 @@ 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;
|
||||||
|
|||||||
@ -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 = 8;
|
footnoteCapacity = 16;
|
||||||
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';
|
||||||
|
|||||||
@ -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 >= 32) return;
|
if (currentPageFootnoteCount >= 16) 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);
|
||||||
|
|
||||||
|
|||||||
@ -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[32];
|
FootnoteEntry currentPageFootnotes[16];
|
||||||
int currentPageFootnoteCount = 0;
|
int currentPageFootnoteCount = 0;
|
||||||
|
|
||||||
// Inline footnotes (aside) tracking
|
// Inline footnotes (aside) tracking
|
||||||
|
|||||||
@ -52,7 +52,7 @@ void EpubReaderActivity::onEnter() {
|
|||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|
||||||
xTaskCreate(&EpubReaderActivity::taskTrampoline, "EpubReaderActivityTask",
|
xTaskCreate(&EpubReaderActivity::taskTrampoline, "EpubReaderActivityTask",
|
||||||
8192, // Stack size
|
24576, // Stack size
|
||||||
this, // Parameters
|
this, // Parameters
|
||||||
1, // Priority
|
1, // Priority
|
||||||
&displayTaskHandle // Task handle
|
&displayTaskHandle // Task handle
|
||||||
@ -321,11 +321,15 @@ 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();
|
||||||
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);
|
FootnoteEntry* footnote = p->getFootnote(i);
|
||||||
if (footnote) {
|
if (footnote && footnote->href[0] != '\0') {
|
||||||
currentPageFootnotes.addFootnote(footnote->number, footnote->href);
|
currentPageFootnotes.addFootnote(footnote->number, footnote->href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,14 +8,19 @@
|
|||||||
|
|
||||||
class FootnotesData {
|
class FootnotesData {
|
||||||
private:
|
private:
|
||||||
FootnoteEntry entries[32];
|
FootnoteEntry entries[16];
|
||||||
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 < 32) {
|
if (count < 16 && number && href) {
|
||||||
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);
|
||||||
@ -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; }
|
int getCount() const { return count; }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user