33 lines
2.1 KiB
Markdown
33 lines
2.1 KiB
Markdown
|
|
# Implement Dictionary Word Lookup Feature (PR #857)
|
||
|
|
|
||
|
|
## Task
|
||
|
|
|
||
|
|
Ported upstream PR #857 (dictionary word lookup feature) into the local codebase on `mod/add-dictionary` branch. Two adaptations were made:
|
||
|
|
|
||
|
|
1. **Vector compatibility**: PR #857 was written against upstream `master` which used `std::list` for word storage. Our codebase already has PR #802 applied (list-to-vector). The `TextBlock.h` getters added by PR #857 were changed to return `const std::vector<...>&` instead of `const std::list<...>&`.
|
||
|
|
|
||
|
|
2. **Dictionary path tweak**: Changed dictionary file lookup from SD card root (`/dictionary.idx`, `/dictionary.dict`) to a `/.dictionary/` subfolder (`/.dictionary/dictionary.idx`, `/.dictionary/dictionary.dict`).
|
||
|
|
|
||
|
|
## Changes Made
|
||
|
|
|
||
|
|
### New files (10)
|
||
|
|
|
||
|
|
- `src/util/Dictionary.h` / `.cpp` -- StarDict 3 format dictionary lookup (sparse index + binary search)
|
||
|
|
- `src/util/LookupHistory.h` / `.cpp` -- Per-book lookup history stored in book cache dir
|
||
|
|
- `src/activities/reader/DictionaryDefinitionActivity.h` / `.cpp` -- Definition display with pagination
|
||
|
|
- `src/activities/reader/DictionaryWordSelectActivity.h` / `.cpp` -- Word selection from current page with orientation-aware navigation
|
||
|
|
- `src/activities/reader/LookedUpWordsActivity.h` / `.cpp` -- Lookup history browser with long-press delete
|
||
|
|
|
||
|
|
### Modified files (5)
|
||
|
|
|
||
|
|
- `lib/Epub/Epub/blocks/TextBlock.h` -- Added `getWords()`, `getWordXpos()`, `getWordStyles()` accessors (returning `std::vector`)
|
||
|
|
- `lib/Epub/Epub/Page.h` -- Added `getBlock()` accessor to `PageLine`
|
||
|
|
- `src/activities/reader/EpubReaderMenuActivity.h` -- Added `LOOKUP`/`LOOKED_UP_WORDS` enum values, `hasDictionary` constructor param, dynamic `buildMenuItems()`
|
||
|
|
- `src/activities/reader/EpubReaderActivity.h` -- Added includes for new activity headers
|
||
|
|
- `src/activities/reader/EpubReaderActivity.cpp` -- Added includes, `Dictionary::exists()` check, `LOOKUP` and `LOOKED_UP_WORDS` case handling
|
||
|
|
|
||
|
|
## Follow-up Items
|
||
|
|
|
||
|
|
- Dictionary files (`dictionary.idx`, `dictionary.dict`, `dictionary.ifo`) must be placed in `/.dictionary/` folder on the SD card root
|
||
|
|
- Menu items "Lookup" and "Lookup History" only appear when dictionary files are detected
|