2026-02-12 19:36:14 -05:00
|
|
|
#pragma once
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "../ActivityWithSubactivity.h"
|
|
|
|
|
#include "util/ButtonNavigator.h"
|
|
|
|
|
|
|
|
|
|
class LookedUpWordsActivity final : public ActivityWithSubactivity {
|
|
|
|
|
public:
|
|
|
|
|
explicit LookedUpWordsActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& cachePath,
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
int readerFontId, uint8_t orientation, const std::function<void()>& onBack,
|
|
|
|
|
const std::function<void()>& onDone)
|
2026-02-12 19:36:14 -05:00
|
|
|
: ActivityWithSubactivity("LookedUpWords", renderer, mappedInput),
|
|
|
|
|
cachePath(cachePath),
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
readerFontId(readerFontId),
|
|
|
|
|
orientation(orientation),
|
2026-02-12 19:36:14 -05:00
|
|
|
onBack(onBack),
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
onDone(onDone) {}
|
2026-02-12 19:36:14 -05:00
|
|
|
|
|
|
|
|
void onEnter() override;
|
|
|
|
|
void onExit() override;
|
|
|
|
|
void loop() override;
|
2026-02-16 13:22:40 -05:00
|
|
|
void render(Activity::RenderLock&&) override;
|
2026-02-12 19:36:14 -05:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::string cachePath;
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
int readerFontId;
|
|
|
|
|
uint8_t orientation;
|
2026-02-12 19:36:14 -05:00
|
|
|
const std::function<void()> onBack;
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
const std::function<void()> onDone;
|
2026-02-12 19:36:14 -05:00
|
|
|
|
|
|
|
|
std::vector<std::string> words;
|
|
|
|
|
int selectedIndex = 0;
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
bool pendingBackFromDef = false;
|
|
|
|
|
bool pendingExitToReader = false;
|
2026-02-12 19:36:14 -05:00
|
|
|
ButtonNavigator buttonNavigator;
|
|
|
|
|
|
|
|
|
|
// Delete confirmation state
|
|
|
|
|
bool deleteConfirmMode = false;
|
|
|
|
|
bool ignoreNextConfirmRelease = false;
|
|
|
|
|
int pendingDeleteIndex = 0;
|
|
|
|
|
|
feat: Integrate PR #857 dictionary intelligence and sub-activity refactor
Pull in the full feature update from PR #857 while preserving fork
advantages (HTML parsing, custom drawHints, PageForward/PageBack,
cache management, stardictCmp, /.dictionary/ paths).
- Add morphological stemming (getStemVariants), Levenshtein edit
distance, and fuzzy matching (findSimilar) to Dictionary
- Create DictionarySuggestionsActivity for "Did you mean?" flow
- Add onDone callback to DictionaryDefinitionActivity for direct
exit-to-reader via "Done" button
- Refactor DictionaryWordSelectActivity to ActivityWithSubactivity
with cascading lookup (exact → stems → suggestions → not found),
en-dash/em-dash splitting, and cross-page hyphenation
- Refactor LookedUpWordsActivity with reverse-chronological order,
inline cascading lookup, UITheme-aware rendering, and sub-activities
- Simplify EpubReaderActivity LOOKUP/LOOKED_UP_WORDS handlers
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 20:50:03 -05:00
|
|
|
int getPageItems() const;
|
2026-02-12 19:36:14 -05:00
|
|
|
};
|