class CCompositionProcessorEngine {
CStringRange _keystrokeBuffer;
void CCompositionProcessorEngine::GetCandidateList(_Inout_ CSampleImeArray<CCandidateListItem> *pCandidateList, BOOL isIncrementalWordSearch, BOOL isWildcardSearch)
{
if (isIncrementalWordSearch)
{
// ¥ 更新候选字列表
CollectWord(&_keystrokeBuffer, pCandidateList);
}
else if (isWildcardSearch)
{
CollectWord(&_keystrokeBuffer, pCandidateList);
}
else
{
CollectWord(&_keystrokeBuffer, pCandidateList);
}
}
void CCompositionProcessorEngine::GetReadingStrings(_Inout_ CSampleImeArray<CStringRange> *pReadingStrings, _Out_ BOOL *pIsWildcardIncluded)
{
CStringRange oneKeystroke;
_hasWildcardIncludedInKeystrokeBuffer = FALSE;
if (pReadingStrings->Count() == 0 && _keystrokeBuffer.GetLength())
{
CStringRange* pNewString = nullptr;
pNewString = pReadingStrings->Append();
if (pNewString)
{
// ¥ 在此处,如果拼写文本为空,则把拼写文本和按键序列关联了起来,按键序列同步更新拼写文本
*pNewString = _keystrokeBuffer;
}
for (DWORD index = 0; index < _keystrokeBuffer.GetLength(); index++)
{
oneKeystroke.Set(_keystrokeBuffer.Get() + index, 1);
if (IsWildcard() && IsWildcardChar(*oneKeystroke.Get()))
{
_hasWildcardIncludedInKeystrokeBuffer = TRUE;
}
}
}
*pIsWildcardIncluded = _hasWildcardIncludedInKeystrokeBuffer;
}
void CollectWord(_In_ CStringRange *pKeyCode, _Inout_ CSampleImeArray<CCandidateListItem> *pItemList) {
// evaluate str1,2,...
CStringRange Strs[] = { str1,str2,str3,str4,str5,str6,str7,str8,str9,str0 };
for (UINT iIndex = 0; iIndex < 10; iIndex++)
{
CCandidateListItem* pLI = nullptr;
pLI = pItemList->Append();
if (pLI)
{
pLI->_ItemString.Set(Strs[iIndex]);
//pLI->_FindKeyCode.Set(pdret->_FindKeyCode.Get(), pdret->_FindKeyCode.GetLength());
}
}
}
}
TSF 如何更新候选字和拼写文本
最新推荐文章于 2024-07-19 19:11:47 发布