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

📄 ringkey.c

📁 PSP YDICT ver0.3 改进的功能 1。在《牛津现代英汉双解词典》中
💻 C
📖 第 1 页 / 共 2 页
字号:
					idx=wordlist[curword].index;
				i=1;
				tag=0;
				while(i<wordcount){
					tag = *(tagfilep+(idx+wordcount-i)%wordcount);
					if (tag&0x03)
						break;
					i++;
				}
				if (i==wordcount) {
					// no find any marked word, do nothing
					break;
				}
				idx=(idx+wordcount-i)%wordcount;
				if ((idx>=wordlist[0].index) &&(idx<=wordlist[WORDLIST_SIZE-1].index)) {
					curword=idx-wordlist[0].index;
				}
				else
					if (idx <WORDLIST_SIZE) {
					updatelist(0);
					curword=idx;
				}
				else if (idx > (wordcount - WORDLIST_SIZE)) {
					updatelist(wordcount - WORDLIST_SIZE);
					curword = WORDLIST_SIZE -(wordcount - idx);
				}
				else { 
					updatelist(idx);
					curword = 0;
				}
				curpage = 0;
			}
			break;
		case PSP_CTRL_RTRIGGER:
			if (tagfilep!=NULL)
			{
				int idx, i;
				unsigned char tag;
				// view the next marked word
				if (curword ==-1)
					idx=wordlist[0].index;
				else
					idx=wordlist[curword].index;
				i=1;
				tag=0;
				while(i<wordcount){
					tag = *(tagfilep+(idx+i)%wordcount);
					if (tag&0x03)
						break;
					i++;
				}
				if (i==wordcount) {
					// no find any marked word, do nothing
					break;
				}
				idx=(idx+i)%wordcount;
				if ((idx>=wordlist[0].index) &&(idx<=wordlist[WORDLIST_SIZE-1].index)) {
					curword=idx-wordlist[0].index;
				}
				else if (idx <WORDLIST_SIZE) {
					updatelist(0);
					curword=idx;
				}
				else if (idx > (wordcount - WORDLIST_SIZE)) {
					updatelist(wordcount - WORDLIST_SIZE);
					curword = WORDLIST_SIZE -(wordcount - idx);
				}
				else { 
					updatelist(idx);
					curword = 0;
				}
				curpage = 0;
			}
			break;
		default:
			break;
		}
	}
}

void disp_ringkey_page(void)
{
	int i, len;
	static int cursor;

	pgWaitV();
	pgFillvram(BG_COLOR);

	// draw the input string
	chDrawString(0, 0, FG_COLOR, BG_COLOR, myinput.string, 1, 1);
	// draw a nice flashing cursor
	{
		cursor++;
		if ((cursor/15)%2)
			chDrawString(myinput.cursor * 8, 0, FG_COLOR, BG_COLOR, "_", 1, 1);
	}

	// draw the dict chinese name
	chDrawString(SCREEN_WIDTH-strlen(ydictconf.dictcname)*8, 0,
		FG_COLOR, BG_COLOR, ydictconf.dictcname, 1, 1);
	// draw the color hint line
	chDrawRec(0, 17, SCREEN_WIDTH, 3, FG_COLOR, 1);
	chDrawRec(SCREEN_WIDTH * wordlist[0].index /wordcount, 17, 2, 3, RED_COLOR, 1);


	if (curword ==-1) {
		if (currkeyindex==-1) {
			// draw ring keyboard in GRAY_COLOR
			for (i=0;i<KEYNUMBER;i++)
				chPutChar(kb[i].x, kb[i].y-8, GRAY_COLOR, BG_COLOR, *(currkb+i), 1, 1, 1);
			// draw wordlist all in FG_COLOR
			for (i=0;i<WORDLIST_SIZE;i++) {
				char tag;
				if (tagfilep !=NULL) {
					tag=*(tagfilep+wordlist[i].index);
					if ((tag&0x03)==0x01)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG1_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
					else if ((tag&0x03)==0x02)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG2_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
					else
						chDrawString(0, 16+4 +i*16, FG_COLOR, TAG0_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
				}
				else
					chDrawString(0, 16+4 +i*16, FG_COLOR, BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
			}
		}
		else {
			// draw wordlist all in FG_COLOR
			for (i=0;i<WORDLIST_SIZE;i++) {
				char tag;
				if (tagfilep !=NULL) {
					tag=*(tagfilep+wordlist[i].index);
					if ((tag&0x03)==0x01)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG1_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
					else if ((tag&0x03)==0x02)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG2_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
					else
						chDrawString(0, 16+4 +i*16, FG_COLOR, TAG0_BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
				}
				else
					chDrawString(0, 16+4 +i*16, FG_COLOR, BG_COLOR, *(wordarray+wordlist[i].index), 1, 1);
				// draw wordlist tail in GRAY_COLOR
				if (strlen(*(wordarray+wordlist[i].index))>18)
					chDrawString(18*8, 16+4 +i*16, GRAY_COLOR, BG_COLOR, *(wordarray+wordlist[i].index)+18, 1, 1);
			}
			// draw ring keyboard in FG_COLOR
			for (i=0;i<KEYNUMBER;i++) {
				if (i==currkeyindex)
					chPutChar(kb[i].x, kb[i].y-8, CURRKEY_COLOR, BG_COLOR, *(currkb+currkeyindex), 1, 1, 1);
				else
					chPutChar(kb[i].x, kb[i].y-8, KEYS_COLOR, BG_COLOR, *(currkb+i), 1, 1, 1);
			}
			// draw the current key in center point
			//chPutChar(KBCENTRE_X, KBCENTRE_Y-8, CURRKEY_COLOR, BG_COLOR, currkey, 1, 1, 1);
		}
	}
	else {
		// draw tag after the wordlist
		for (i=0;i<WORDLIST_SIZE;i++) {
			char curtag;
			int delta=0;
			if (curword != i) {
				if (tagfilep!=NULL) {
					curtag = *(tagfilep+wordlist[i].index);
					if ((curtag&0x03) ==0x01)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG1_BG_COLOR, wordlist[i].word, 1, 1);
					else if ((curtag&0x03) ==0x02)
						chDrawString(0, 16+4 +i*16, WHITE_COLOR, TAG2_BG_COLOR, wordlist[i].word, 1, 1);
					else
						chDrawString(0, 16+4 +i*16, FG_COLOR, TAG0_BG_COLOR, wordlist[i].word, 1, 1);
				}
				else
					chDrawString(0, 16+4 +i*16, FG_COLOR, BG_COLOR, wordlist[i].word, 1, 1);
			}
			else {
				if (tagfilep!=NULL) {
					curtag = *(tagfilep+wordlist[i].index);
					if ((curtag&0x03) ==0x01)
						chDrawString(0, 16+4 +i*16, CURWORD_COLOR, TAG1_BG_COLOR, wordlist[i].word, 1, 1);
					else if ((curtag&0x03) ==0x02)
						chDrawString(0, 16+4 +i*16, CURWORD_COLOR, TAG2_BG_COLOR, wordlist[i].word, 1, 1);
					else
						chDrawString(0, 16+4 +i*16, CURWORD_COLOR, TAG0_BG_COLOR, wordlist[i].word, 1, 1);
				}
				else
					chDrawString(0, 16+4 +i*16, CURWORD_COLOR, BG_COLOR, wordlist[i].word, 1, 1);
			}
			len = strlen(wordlist[i].word);
			if (len > WORDLIST_WIDTH) {
				// hide the word tail in dict area
				chDrawString(8*WORDLIST_WIDTH, 16+4+i*16, BG_COLOR, BG_COLOR, wordlist[i].word+WORDLIST_WIDTH, 1, 1);
			}
			if (tagfilep!=NULL) {
				// draw the difficult tag
				curtag=*(tagfilep + wordlist[i].index);
				if (curtag&0x10) {
					delta+=5;
					chDrawRec(8*WORDLIST_WIDTH -4-delta, 16+4 +i*16, 5, 16, GRE_COLOR, 1);
				}
				if (curtag&0x20) {
					delta+=5;
					chDrawRec(8*WORDLIST_WIDTH -4-delta, 16+4 +i*16, 5, 16, TOEFL_COLOR, 1);
				}
				if (curtag&0x40) {
					delta+=5;
					chDrawRec(8*WORDLIST_WIDTH -4-delta, 16+4 +i*16, 5, 16, CET6_COLOR, 1);
				}
				if (curtag&0x80) {
					delta+=5;
					chDrawRec(8*WORDLIST_WIDTH -4-delta, 16+4 +i*16, 5, 16, CET4_COLOR, 1);
				}
			}
		}
		// draw the vertical line
		chDrawRec(8*WORDLIST_WIDTH -4, 16+4, 2, WORDLIST_SIZE *16, FG_COLOR, 1);
		chDrawRec(SCREEN_WIDTH-2, 16+4, 2, WORDLIST_SIZE *16, FG_COLOR, 1);
		// hide the char behind the vertical line
		chDrawRec(8*WORDLIST_WIDTH -2, 16+4, 2, WORDLIST_SIZE *16, BG_COLOR, 1);
	}

	// draw dict area
	if (curword!=-1) {
		int i, wordlen, currow;
		unsigned char temp[SCREEN_WIDTH/8];
		unsigned char *rowstr;
		int rowlen;

		// draw ring keyboard in GRAY_COLOR
		for (i=0;i<KEYNUMBER;i++)
			chPutChar(kb[i].x, kb[i].y-8, GRAY_COLOR, BG_COLOR, *(currkb+i), 1, 1, 1);

		if (curpage==0) {
			// first page, draw curword in RED_COLOR
			memset(temp, 0, SCREEN_WIDTH/8);
			wordlen =strlen(*(wordarray+wordlist[curword].index));
			memcpy(temp, *(wordarray+wordlist[curword].index), (wordlen<(SCREEN_WIDTH/8))?wordlen:(SCREEN_WIDTH/8 -1));
			if (curwordrows == 2) {
				chDrawString(8*WORDLIST_WIDTH -2, 16+4+16, RED_COLOR, BG_COLOR, &temp[C_LEN], 1, 1);
				temp[C_LEN]=0x0;
				chDrawString(8*WORDLIST_WIDTH -2, 16+4, RED_COLOR, BG_COLOR, &temp, 1, 1);
			}
			else {
				chDrawString(8*WORDLIST_WIDTH -2, 16+4, RED_COLOR, BG_COLOR, &temp, 1, 1);
			}

			for (i=0; i<(WORDLIST_SIZE-curwordrows);i++) {
				rowstr = dictfilep+ wordlist[curword].dictoffset + dictrow[i];
				memcpy(temp, rowstr, SCREEN_WIDTH/8);
				if (i<(dictrows-1)) {
					// throw the next row data
					rowlen=dictrow[i+1]-dictrow[i];
					temp[rowlen]= 0x0;
					chDrawString(8*WORDLIST_WIDTH-2, 16+4+(curwordrows*16)+ i*16, FG_COLOR, BG_COLOR, temp, 1, 1);
				}
				else if (i==(dictrows-1)) {
					// fix the last row, avoid garbage of next word
					rowlen=wordlist[curword].dictlen - dictrow[i];
					temp[rowlen] = 0x0;
					chDrawString(8*WORDLIST_WIDTH-2, 16+4+(curwordrows*16)+ i*16, FG_COLOR, BG_COLOR, temp, 1, 1);
				}
				else
					break;
				// draw the phonetic symbol in the current row
				if (!strcmp(ydictconf.dictename, "oxford-ec"))
				{
					struct symidx cursymidx;
					int k;

					cursymidx.offset = ((struct symidx *)(symidxarray+wordlist[curword].index))->offset;
					cursymidx.count = ((struct symidx *)(symidxarray+wordlist[curword].index))->count;
					for (k=0; k<cursymidx.count;k++) {
						unsigned char *symoffset;
						int symlen;
						symoffset = ((struct symbol*)(cursymidx.offset+k))->symoffset;
						symlen = ((struct symbol*)(cursymidx.offset+k))->symlen;
						//DBG_PRINT("w %d soff 0x%x slen %d rstr %x rlen %d", wordlist[curword].index,
						//	symoffset, symlen, rowstr, rowlen);
						if ((symoffset<=rowstr)&&(rowstr<(symoffset+symlen))) {
							int curlen=((symoffset+symlen-rowstr)<rowlen)?(symoffset+symlen-rowstr):(rowlen);
							chDrawSymbolString(8*WORDLIST_WIDTH-2, 16+4+(curwordrows*16)+ i*16,
								SYM_FG_COLOR, SYM_BG_COLOR, rowstr, curlen, 1, 1);
						}
						else if ((symoffset>rowstr)&&(symoffset<(rowstr+rowlen))) {
							int curlen=((symoffset+symlen)<(rowstr+rowlen))?(symlen):(rowstr+rowlen-symoffset);
							chDrawSymbolString(8*WORDLIST_WIDTH-2+8*(symoffset-rowstr), 16+4+(curwordrows*16)+ i*16,
								SYM_FG_COLOR, SYM_BG_COLOR, symoffset, curlen, 1, 1);
						}
					}
				}
			}
			
		}
		else {
			currow = (curpage*R_LEN-curwordrows);
			for (i=0; i<WORDLIST_SIZE;i++) {
				rowstr = dictfilep+ wordlist[curword].dictoffset + dictrow[currow+i];
				memcpy(temp, rowstr, SCREEN_WIDTH/8);
				if ((currow+i)<(dictrows-1)) {
					// throw the next row data
					rowlen=dictrow[currow+i+1]-dictrow[currow+i];
					temp[rowlen]=0x0;
					chDrawString(8*WORDLIST_WIDTH-2, 16+4+i*16, FG_COLOR, BG_COLOR, temp, 1, 1);
				}
				else if ((currow+i)==(dictrows-1)) {
					// fix the last row, avoid garbage of next word
					rowlen=wordlist[curword].dictlen - dictrow[currow+i];
					temp[rowlen] = 0x0;
					chDrawString(8*WORDLIST_WIDTH-2, 16+4+i*16, FG_COLOR, BG_COLOR, temp, 1, 1);
				}
				else 
					break;
				// draw the phonetic symbol in the current row
				if (!strcmp(ydictconf.dictename, "oxford-ec"))
				{
					struct symidx cursymidx;
					int k;

					cursymidx.offset = ((struct symidx *)(symidxarray+wordlist[curword].index))->offset;
					cursymidx.count = ((struct symidx *)(symidxarray+wordlist[curword].index))->count;
					for (k=0; k<cursymidx.count;k++) {
						unsigned char *symoffset;
						int symlen;
						symoffset = ((struct symbol*)(cursymidx.offset+k))->symoffset;
						symlen = ((struct symbol*)(cursymidx.offset+k))->symlen;
						if ((symoffset<=rowstr)&&(rowstr<(symoffset+symlen))) {
							int curlen=((symoffset+symlen-rowstr)<rowlen)?(symoffset+symlen-rowstr):(rowlen);
							chDrawSymbolString(8*WORDLIST_WIDTH-2, 16+4+ i*16,
								RED_COLOR, SYM_BG_COLOR, rowstr, curlen, 1, 1);
						}
						else if ((symoffset>rowstr)&&(symoffset<(rowstr+rowlen))) {
							int curlen=((symoffset+symlen)<(rowstr+rowlen))?(symlen):(rowstr+rowlen-symoffset);
							chDrawSymbolString(8*WORDLIST_WIDTH-2+8*(symoffset-rowstr), 16+4+i*16,
								RED_COLOR, SYM_BG_COLOR, symoffset, curlen, 1, 1);
						}
					}
				}
			}
		}
		// draw the vertical scroll bar
		if (dictpages>1) {
			int barlen;
			// if dictpages is big, barlen will have error in precision, maybe should use float type
			barlen = (R_LEN*16)/dictpages;
			chDrawRec(SCREEN_WIDTH-2, 16+4+barlen*curpage, 2, barlen, BLUE_COLOR, 1);
		}
	}
	// draw bottom horizon line
	chDrawRec(0, 16+4+WORDLIST_SIZE*16, SCREEN_WIDTH, 2, FG_COLOR, 1);
	// draw version, current word index/wordcount
	pgPrint(0, CMAX_Y-1, FG_COLOR, VERSION);
	// draw dict english name
	pgPrint(strlen(VERSION)+3, CMAX_Y-1, FG_COLOR, "<");
	pgPrint(strlen(VERSION)+4, CMAX_Y-1, FG_COLOR, ydictconf.dictename);
	pgPrint(strlen(VERSION)+4+strlen(ydictconf.dictename),
				CMAX_Y-1, FG_COLOR, ">");

	{
		// draw wordcount
		char temp[20];
		int index;

		if (curword != -1)
			index = wordlist[curword].index;
		else
			index = wordlist[0].index;
		sprintf(temp, "%d/%d",index+1,wordcount);
		pgPrint(CMAX_X-strlen(temp), CMAX_Y-1, FG_COLOR, temp);
	}

	pgScreenFlipV();
}

⌨️ 快捷键说明

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