TSF 如何更新候选字和拼写文本

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());
			}
		}
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值