⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uiime_wb.c

📁 嵌入工linux开发的源码
💻 C
字号:
/*********************************************************************/
//	文 件 名:	uiIme_WB.cpp
//	程序说明:	五笔输入法
//	程序设计:	张学平
//				2001.11.05		设计完成		说明文档:R004-S216-0001
//	程序审查:	宋军霞
//				2002.01.25		审查完成		说明文档:R004-S216-0001
//	项目编号:	R004-S216
//	版	  本:	V1.0
//	版    权:	Reality Plus Technology (ShenZhen) Co.,Ltd.
/*********************************************************************/
#include "uiIme_wb.h"
#include "uiWB_TBL.res"
#include "uiWB_WORD.res"

/***********************************************
* wbStr:  code of wb                           *
* offset: offset of candidate word             *
* return: total count of candidate word        *
************************************************/
int guiIme_wb(char *wbStr, DWORD *offset)
{
	unsigned short iMid, iLeft, iRight;
	unsigned short startOffset, endOffset, index;
	char *pTemp;
	int iRet, len, wordNum;

	iLeft = 0;  iRight = WB_TABLE_COUNT-1;

	len = strlen(wbStr);
	if(!len)
		return 0;
	strlwr(wbStr);
	
	while(1)
	{
		iMid = (iRight+iLeft)/2;

		pTemp = (char *)WB_TABLE[iMid].codeStr;
		iRet = strncmp(wbStr, pTemp, len);
		
		if(!iRet)
		{
			startOffset = iMid;
			while(startOffset)
			{
				startOffset--;
				pTemp = (char *)WB_TABLE[startOffset].codeStr;
				iRet = strncmp(wbStr, pTemp, len);
				if(iRet)
				{
					startOffset++;
					break;
				}				
			}

			endOffset = iMid;
			while(endOffset<WB_TABLE_COUNT)
			{				
				pTemp = (char *)WB_TABLE[endOffset].codeStr;
				iRet = strncmp(wbStr, pTemp, len);
				if(iRet)
					break;
				endOffset++;
			}

			if(endOffset==WB_TABLE_COUNT)
				endOffset--;
			
			index = WB_TABLE[startOffset].offset;
			*offset = (DWORD)&(WB_GB_WORD[index]);

			wordNum = WB_TABLE[endOffset].offset-index;
			if(!iRet)
				wordNum = WB_TABLE[endOffset].offset-index+1; // count of last item is 1

			return (wordNum);
		}

		if(iRet<0)
			iRight = iMid-1;
		else
			iLeft = iMid+1;

		if(iLeft>iRight)
			break;
	}
	*offset = 0;
	return 0;
}

/******************************************************************
* offset: offset of candidate word, get from guiIme_py()          *
* totalCount: total count of candidate word, get form guiIme_py() *
* startPos: start position of word to read                        *
* toReadCount: number of word to read                             *
* pWordText: buffer of word                                       *
* return: actual number of word read                              *
*******************************************************************/
int guiGetCandidate_wb(DWORD offset, unsigned short totalCount, unsigned short startPos, unsigned short toReadCount, unsigned short *pWordText)
{
	unsigned short *pWord;
	int readCount, i;
	
	if(!offset)
		return 0;

	if(startPos>totalCount)
		return 0;

	pWord = (unsigned short *)(offset+2*startPos);

	readCount = (totalCount>startPos+toReadCount)?toReadCount:(totalCount-startPos);

	for(i=0; i<readCount; i++)
		pWordText[i] = pWord[i];
	
	pWordText[readCount] = 0x0000; 
	
	return readCount;
}

#if _DEBUG_IME_WB && _DEBUG
unsigned short guiGetWb_Table(int index, char *pStr)
{
	if(index >= WB_TABLE_COUNT)
		return 0;

	strcpy(pStr,WB_TABLE[index].codeStr);
	return WB_TABLE[index].offset;
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -