/* dict.h Copyright (C) 2026 Pierre Sarrazin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _H_dict #define _H_dict #include "defs.h" // See iterateDictionary(). // typedef byte (*ProcessDictBlockFuncPtr)(word numWordsInBlock, void *userData); // See iterateDictionary(). // Must not assume that the 'currentWord' pointer will be valid // after the call to this function has returned. // typedef BOOL (*ProcessDictWordFuncPtr)(const char *currentWord, byte currentWordLength, void *userData); // Loads the data file into memory, including font data and the dictionary. // driveNo: Drive where that file is. // textScrnWritePos: Pointer to the cursor pointer. Assigning to that pointer // must reposition the cursor used by printf(). // Returns true upon success. // BOOL loadDataFile(byte driveNo, byte **textScrnWritePos); // See iterateDictionary(). // enum { DICT_ITER_STOP, // stop the iteration DICT_ITER_NEXT_BLOCK, // jump to the next block (do not call ProcessDictWordFuncPtr) DICT_ITER_LIST_WORDS // call ProcessDictWordFuncPtr on each word in the current block }; // Sets the callback that is invoked periodically during a call to // isWordInDictionary(). Allowed to be null. // void dict_setSearchProgressCallback(void (*functor)(void)); // processDictBlock: If not null, invoked for each MMU block that contains dictionary data. // Must return one of the DICT_ITER_* enum names above. // processDictWord: Invoked for each word in the current MMU block, after processDictBlock // has been invoked, and only if the latter returned DICT_ITER_LIST_WORDS. // If null, then processDictBlock must NOT return DICT_ITER_LIST_WORDS. // wordLength: If not zero, restrict the search to words of this length. // userData: Pointer passed to the callbacks. // Returns TRUE if the iteration reached the end, FALSE otherwise, i.e., // one of the two callbacks returned a value that requested stopping the iteration. // // A callback is allowed to start a sub-iteration by making its own call // to iterateDictionary(). // BOOL iterateDictionary(ProcessDictBlockFuncPtr processDictBlock, ProcessDictWordFuncPtr processDictWord, byte wordLength, void *userData); // See also dict_setSearchProgressCallback(). // BOOL isWordInDictionary(const char *candidateWord); void getDictionaryStats(word *totalNumWords); #endif /* _H_dict */