#pragma once #include #include #include #include #include #include #include #include #include "../Activity.h" /** * DictionaryResultActivity displays a word definition with pagination. * Supports multi-page definitions with navigation and rich text formatting. */ class DictionaryResultActivity final : public Activity { TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; bool updateRequired = false; const std::string lookupWord; // Named to avoid Arduino's 'word' macro const std::string rawDefinition; const std::function onBack; const std::function onSearchAnother; // Pagination - each page contains TextBlocks with styled text std::vector>> pages; int currentPage = 0; bool notFound = false; static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void render() const; void paginateDefinition(); public: /** * Constructor * @param renderer Graphics renderer * @param mappedInput Input manager * @param wordToLookup The word that was looked up * @param definition The definition text (HTML will be stripped). Empty = not found. * @param onBack Callback when user wants to go back to book * @param onSearchAnother Callback when user wants to search another word */ explicit DictionaryResultActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& wordToLookup, const std::string& definition, const std::function& onBack, const std::function& onSearchAnother) : Activity("DictionaryResult", renderer, mappedInput), lookupWord(wordToLookup), rawDefinition(definition), onBack(onBack), onSearchAnother(onSearchAnother), notFound(definition.empty()) {} void onEnter() override; void onExit() override; void loop() override; };