diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp index bedf987..4202538 100644 --- a/src/stardict_lib.cpp +++ b/src/stardict_lib.cpp @@ -1037,133 +1037,6 @@ void Libs::load(const std::list &dicts_dirs, }); } -const gchar *Libs::poGetCurrentWord(glong *iCurrent) -{ - const gchar *poCurrentWord = nullptr; - const gchar *word; - for (std::vector::size_type iLib = 0; iLib < oLib.size(); iLib++) { - if (iCurrent[iLib] == INVALID_INDEX) - continue; - if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0) - continue; - if (poCurrentWord == nullptr) { - poCurrentWord = poGetWord(iCurrent[iLib], iLib); - } else { - word = poGetWord(iCurrent[iLib], iLib); - - if (stardict_strcmp(poCurrentWord, word) > 0) - poCurrentWord = word; - } - } - return poCurrentWord; -} - -const gchar *Libs::poGetNextWord(const gchar *sWord, glong *iCurrent) -{ - // the input can be: - // (word,iCurrent),read word,write iNext to iCurrent,and return next word. used by TopWin::NextCallback(); - // (nullptr,iCurrent),read iCurrent,write iNext to iCurrent,and return next word. used by AppCore::ListWords(); - const gchar *poCurrentWord = nullptr; - size_t iCurrentLib = 0; - const gchar *word; - - glong nextWordIdx = 0; - std::set wordIndices; - - for (size_t iLib = 0; iLib < oLib.size(); ++iLib) { - wordIndices.clear(); - if (sWord) { - if (oLib[iLib]->Lookup(sWord, wordIndices, nextWordIdx)) { - // In order to progress over words which have multiple entries, - // pick the smallest index larger than iCurrent. - for (auto &wordIdx : wordIndices) { - if (wordIdx > iCurrent[iLib]) { - iCurrent[iLib] = wordIdx; - break; - } - } - } else { - iCurrent[iLib] = nextWordIdx; - } - } - if (iCurrent[iLib] == INVALID_INDEX) - continue; - if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0) - continue; - if (poCurrentWord == nullptr) { - poCurrentWord = poGetWord(iCurrent[iLib], iLib); - iCurrentLib = iLib; - } else { - word = poGetWord(iCurrent[iLib], iLib); - - if (stardict_strcmp(poCurrentWord, word) > 0) { - poCurrentWord = word; - iCurrentLib = iLib; - } - } - } - if (poCurrentWord) { - iCurrent[iCurrentLib]++; - for (std::vector::size_type iLib = 0; iLib < oLib.size(); iLib++) { - if (iLib == iCurrentLib) - continue; - if (iCurrent[iLib] == INVALID_INDEX) - continue; - if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0) - continue; - if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib], iLib)) == 0) - iCurrent[iLib]++; - } - poCurrentWord = poGetCurrentWord(iCurrent); - } - return poCurrentWord; -} - -const gchar * -Libs::poGetPreWord(glong *iCurrent) -{ - // used by TopWin::PreviousCallback(); the iCurrent is cached by AppCore::TopWinWordChange(); - const gchar *poCurrentWord = nullptr; - std::vector::size_type iCurrentLib = 0; - const gchar *word; - - for (std::vector::size_type iLib = 0; iLib < oLib.size(); iLib++) { - if (iCurrent[iLib] == INVALID_INDEX) - iCurrent[iLib] = narticles(iLib); - else { - if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0) - continue; - } - if (poCurrentWord == nullptr) { - poCurrentWord = poGetWord(iCurrent[iLib] - 1, iLib); - iCurrentLib = iLib; - } else { - word = poGetWord(iCurrent[iLib] - 1, iLib); - if (stardict_strcmp(poCurrentWord, word) < 0) { - poCurrentWord = word; - iCurrentLib = iLib; - } - } - } - - if (poCurrentWord) { - iCurrent[iCurrentLib]--; - for (std::vector::size_type iLib = 0; iLib < oLib.size(); iLib++) { - if (iLib == iCurrentLib) - continue; - if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0) - continue; - if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib] - 1, iLib)) == 0) { - iCurrent[iLib]--; - } else { - if (iCurrent[iLib] == narticles(iLib)) - iCurrent[iLib] = INVALID_INDEX; - } - } - } - return poCurrentWord; -} - bool Libs::LookupSimilarWord(const gchar *sWord, std::set &iWordIndices, int iLib) { bool bFound = false; diff --git a/src/stardict_lib.hpp b/src/stardict_lib.hpp index f864604..4161c4f 100644 --- a/src/stardict_lib.hpp +++ b/src/stardict_lib.hpp @@ -195,9 +195,6 @@ public: return nullptr; return oLib[iLib]->get_data(iIndex); } - const gchar *poGetCurrentWord(glong *iCurrent); - const gchar *poGetNextWord(const gchar *word, glong *iCurrent); - const gchar *poGetPreWord(glong *iCurrent); bool LookupWord(const gchar *sWord, std::set &iWordIndices, int iLib) { return oLib[iLib]->Lookup(sWord, iWordIndices);