@@ -8,6 +8,7 @@
|
||||
#include <Utf8.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
#include "CrossPointSettings.h"
|
||||
@@ -657,15 +658,13 @@ void MdReaderActivity::render(RenderLock&&) {
|
||||
void MdReaderActivity::renderPage() {
|
||||
const int lineHeight = renderer.getLineHeight(cachedFontId);
|
||||
|
||||
auto renderLines =
|
||||
[&]() {
|
||||
std::function<void()> renderLines = [&]() {
|
||||
int y = cachedOrientedMarginTop;
|
||||
for (const auto& line : currentPageLines) {
|
||||
if (line.isHR) {
|
||||
// Draw horizontal rule as a thin line
|
||||
int hrY = y + lineHeight / 2;
|
||||
renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth,
|
||||
hrY);
|
||||
renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth, hrY);
|
||||
} else {
|
||||
if (line.isCodeBlock) {
|
||||
const int barX = cachedOrientedMarginLeft + std::max(line.indent - 6, 0);
|
||||
@@ -701,6 +700,7 @@ void MdReaderActivity::renderPage() {
|
||||
}
|
||||
y += lineHeight;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Font prewarm: scan pass accumulates text, then prewarm, then real render
|
||||
@@ -716,21 +716,20 @@ void MdReaderActivity::renderPage() {
|
||||
ReaderUtils::displayWithRefreshCycle(renderer, pagesUntilFullRefresh);
|
||||
|
||||
if (SETTINGS.textAntiAliasing) {
|
||||
ReaderUtils::renderAntiAliased(renderer, [&renderLines]() { renderLines(); });
|
||||
}
|
||||
ReaderUtils::renderAntiAliased(renderer, [&]() { renderLines(); });
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MdReaderActivity::renderStatusBar() const {
|
||||
void MdReaderActivity::renderStatusBar() const {
|
||||
const float progress = totalPages > 0 ? (currentPage + 1) * 100.0f / totalPages : 0;
|
||||
std::string title;
|
||||
if (SETTINGS.statusBarTitle != CrossPointSettings::STATUS_BAR_TITLE::HIDE_TITLE) {
|
||||
title = txt->getTitle();
|
||||
}
|
||||
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title);
|
||||
}
|
||||
}
|
||||
|
||||
void MdReaderActivity::saveProgress() const {
|
||||
void MdReaderActivity::saveProgress() const {
|
||||
FsFile f;
|
||||
if (Storage.openFileForWrite("MDR", txt->getCachePath() + "/progress.bin", f)) {
|
||||
uint8_t data[4];
|
||||
@@ -740,9 +739,9 @@ void MdReaderActivity::renderPage() {
|
||||
data[3] = 0;
|
||||
f.write(data, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MdReaderActivity::loadProgress() {
|
||||
void MdReaderActivity::loadProgress() {
|
||||
FsFile f;
|
||||
if (Storage.openFileForRead("MDR", txt->getCachePath() + "/progress.bin", f)) {
|
||||
uint8_t data[4];
|
||||
@@ -757,9 +756,9 @@ void MdReaderActivity::renderPage() {
|
||||
LOG_DBG("MDR", "Loaded progress: page %d/%d", currentPage, totalPages);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MdReaderActivity::loadPageIndexCache() {
|
||||
bool MdReaderActivity::loadPageIndexCache() {
|
||||
std::string cachePath = txt->getCachePath() + "/index.bin";
|
||||
FsFile f;
|
||||
if (!Storage.openFileForRead("MDR", cachePath, f)) {
|
||||
@@ -849,9 +848,9 @@ void MdReaderActivity::renderPage() {
|
||||
totalPages = pageOffsets.size();
|
||||
LOG_DBG("MDR", "Loaded page index cache: %d pages", totalPages);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void MdReaderActivity::savePageIndexCache() const {
|
||||
void MdReaderActivity::savePageIndexCache() const {
|
||||
std::string cachePath = txt->getCachePath() + "/index.bin";
|
||||
FsFile f;
|
||||
if (!Storage.openFileForWrite("MDR", cachePath, f)) {
|
||||
@@ -875,4 +874,4 @@ void MdReaderActivity::renderPage() {
|
||||
}
|
||||
|
||||
LOG_DBG("MDR", "Saved page index cache: %d pages", totalPages);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user