Stupid fix

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