Files
crosspoint-reader-mod/src/util/BookmarkStore.h
cottongin 21a75c624d feat: Implement bookmark functionality for epub reader
Replace bookmark stubs with full add/remove/navigate implementation:

- BookmarkStore: per-book binary persistence on SD card with v2 format
  supporting text snippets (backward-compatible with v1)
- Visual bookmark ribbon indicator drawn on bookmarked pages via fillPolygon
- Reader menu dynamically shows Add/Remove Bookmark based on current page state
- Bookmark selection activity with chapter name, first sentence snippet, and
  page number display; long-press to delete with confirmation
- Go to Bookmark falls back to Table of Contents when no bookmarks exist
- Smart snippet extraction: skips partial sentences (lowercase first word)
  to capture the first full sentence on the page
- Label truncation reserves space for page suffix so it's never cut off
- Half refresh forced on menu exit to clear popup/menu artifacts

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 20:40:07 -05:00

25 lines
848 B
C++

#pragma once
#include <cstdint>
#include <string>
#include <vector>
struct Bookmark {
int16_t spineIndex;
int16_t pageNumber;
std::string snippet; // First sentence or text excerpt from the page
};
class BookmarkStore {
public:
static std::vector<Bookmark> load(const std::string& cachePath);
static bool save(const std::string& cachePath, const std::vector<Bookmark>& bookmarks);
static bool addBookmark(const std::string& cachePath, int spineIndex, int page, const std::string& snippet = "");
static bool removeBookmark(const std::string& cachePath, int spineIndex, int page);
static bool hasBookmark(const std::string& cachePath, int spineIndex, int page);
private:
static std::string filePath(const std::string& cachePath);
static constexpr int MAX_BOOKMARKS = 200;
static constexpr int MAX_SNIPPET_LENGTH = 120;
};