mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
chore(clang-format-fix): fixing format
This commit is contained in:
parent
98f14da65a
commit
2072741a59
@ -3,7 +3,8 @@
|
|||||||
#include <FsHelpers.h>
|
#include <FsHelpers.h>
|
||||||
#include <JpegToBmpConverter.h>
|
#include <JpegToBmpConverter.h>
|
||||||
|
|
||||||
Txt::Txt(std::string path, std::string cacheBasePath) : filepath(std::move(path)), cacheBasePath(std::move(cacheBasePath)) {
|
Txt::Txt(std::string path, std::string cacheBasePath)
|
||||||
|
: filepath(std::move(path)), cacheBasePath(std::move(cacheBasePath)) {
|
||||||
// Generate cache path from file path hash
|
// Generate cache path from file path hash
|
||||||
const size_t hash = std::hash<std::string>{}(filepath);
|
const size_t hash = std::hash<std::string>{}(filepath);
|
||||||
cachePath = this->cacheBasePath + "/txt_" + std::to_string(hash);
|
cachePath = this->cacheBasePath + "/txt_" + std::to_string(hash);
|
||||||
@ -112,8 +113,9 @@ bool Txt::generateCoverBmp() const {
|
|||||||
|
|
||||||
// Get file extension
|
// Get file extension
|
||||||
const size_t len = coverImagePath.length();
|
const size_t len = coverImagePath.length();
|
||||||
const bool isJpg = (len >= 4 && (coverImagePath.substr(len - 4) == ".jpg" || coverImagePath.substr(len - 4) == ".JPG")) ||
|
const bool isJpg =
|
||||||
(len >= 5 && (coverImagePath.substr(len - 5) == ".jpeg" || coverImagePath.substr(len - 5) == ".JPEG"));
|
(len >= 4 && (coverImagePath.substr(len - 4) == ".jpg" || coverImagePath.substr(len - 4) == ".JPG")) ||
|
||||||
|
(len >= 5 && (coverImagePath.substr(len - 5) == ".jpeg" || coverImagePath.substr(len - 5) == ".JPEG"));
|
||||||
const bool isBmp = len >= 4 && (coverImagePath.substr(len - 4) == ".bmp" || coverImagePath.substr(len - 4) == ".BMP");
|
const bool isBmp = len >= 4 && (coverImagePath.substr(len - 4) == ".bmp" || coverImagePath.substr(len - 4) == ".BMP");
|
||||||
|
|
||||||
if (isBmp) {
|
if (isBmp) {
|
||||||
|
|||||||
@ -141,7 +141,8 @@ void TxtReaderActivity::initializeReader() {
|
|||||||
|
|
||||||
// Calculate viewport dimensions
|
// Calculate viewport dimensions
|
||||||
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
||||||
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom, &orientedMarginLeft);
|
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
||||||
|
&orientedMarginLeft);
|
||||||
orientedMarginTop += topPadding;
|
orientedMarginTop += topPadding;
|
||||||
orientedMarginLeft += horizontalPadding;
|
orientedMarginLeft += horizontalPadding;
|
||||||
orientedMarginRight += horizontalPadding;
|
orientedMarginRight += horizontalPadding;
|
||||||
@ -154,7 +155,8 @@ void TxtReaderActivity::initializeReader() {
|
|||||||
linesPerPage = viewportHeight / lineHeight;
|
linesPerPage = viewportHeight / lineHeight;
|
||||||
if (linesPerPage < 1) linesPerPage = 1;
|
if (linesPerPage < 1) linesPerPage = 1;
|
||||||
|
|
||||||
Serial.printf("[%lu] [TRS] Viewport: %dx%d, lines per page: %d\n", millis(), viewportWidth, viewportHeight, linesPerPage);
|
Serial.printf("[%lu] [TRS] Viewport: %dx%d, lines per page: %d\n", millis(), viewportWidth, viewportHeight,
|
||||||
|
linesPerPage);
|
||||||
|
|
||||||
// Try to load cached page index first
|
// Try to load cached page index first
|
||||||
if (!loadPageIndexCache()) {
|
if (!loadPageIndexCache()) {
|
||||||
@ -298,7 +300,8 @@ bool TxtReaderActivity::loadPageAtOffset(size_t offset, std::vector<std::string>
|
|||||||
|
|
||||||
// Find break point
|
// Find break point
|
||||||
size_t breakPos = line.length();
|
size_t breakPos = line.length();
|
||||||
while (breakPos > 0 && renderer.getTextWidth(SETTINGS.getReaderFontId(), line.substr(0, breakPos).c_str()) > viewportWidth) {
|
while (breakPos > 0 &&
|
||||||
|
renderer.getTextWidth(SETTINGS.getReaderFontId(), line.substr(0, breakPos).c_str()) > viewportWidth) {
|
||||||
// Try to break at space
|
// Try to break at space
|
||||||
size_t spacePos = line.rfind(' ', breakPos - 1);
|
size_t spacePos = line.rfind(' ', breakPos - 1);
|
||||||
if (spacePos != std::string::npos && spacePos > 0) {
|
if (spacePos != std::string::npos && spacePos > 0) {
|
||||||
@ -388,7 +391,8 @@ void TxtReaderActivity::renderScreen() {
|
|||||||
|
|
||||||
void TxtReaderActivity::renderPage() {
|
void TxtReaderActivity::renderPage() {
|
||||||
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
||||||
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom, &orientedMarginLeft);
|
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
||||||
|
&orientedMarginLeft);
|
||||||
orientedMarginTop += topPadding;
|
orientedMarginTop += topPadding;
|
||||||
orientedMarginLeft += horizontalPadding;
|
orientedMarginLeft += horizontalPadding;
|
||||||
orientedMarginRight += horizontalPadding;
|
orientedMarginRight += horizontalPadding;
|
||||||
@ -416,7 +420,7 @@ void TxtReaderActivity::renderPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
||||||
const int orientedMarginLeft) const {
|
const int orientedMarginLeft) const {
|
||||||
const bool showProgress = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
const bool showProgress = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
||||||
const bool showBattery = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::NO_PROGRESS ||
|
const bool showBattery = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::NO_PROGRESS ||
|
||||||
SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user