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 如何更新候选字和拼写文本
最新推荐文章于 2023-04-02 10:20:00 发布
本文介绍了一个输入法中候选字生成及处理的实现过程。具体包括如何根据不同的搜索模式获取候选字列表,并通过按键缓冲区收集可能的候选词汇。此外,还详细描述了如何从按键缓冲区中提取读音字符串并判断是否包含通配符。
6346

被折叠的 条评论
为什么被折叠?



