コード例 #1
0
ファイル: iskanji.c プロジェクト: erukiti/ne
int 	kanji_tkprev(const char *s,int a,bool f)
{
	int 	pa;

	if (a<=0)
		return 0;
	if (a>strlen(s))
		return strlen(s);

	--a;

	pa=char_getctype(s[a]);
	if (f&& !IsThisKanjiPosition(a-1,s)&& pa==CT_skip)
		{
		 --a;
		 while(a>0&& !IsThisKanjiPosition(a,s)
		 		&& pa==char_getctype(s[a]))
		 	--a;
		 pa=char_getctype(s[a]);
		}

	if (a<=0)
		return 0;

	if (IsThisKanjiPosition(a-1,s))
		{
		 --a;
		 pa=kanji_getctype(s[a],s[a+1]);
		 do	{
		 	 a-=2;
		 	} while(a>=0&& IsThisKanjiPosition(a,s)&&
		 			(pa&kanji_getctype(s[a],s[a+1]))!=0);
		 ++a;
		} else
		{
		 do	{
		 	 --a;
		 	} while(a>=0&& (a==0|| !IsThisKanjiPosition(a-1,s))
		 			&& pa== char_getctype(s[a]));
		}
	++a;
	return a;
}
コード例 #2
0
ファイル: lineedit.c プロジェクト: smorimura/ne
void	le_edit(le_t *lep,int ch,int cm)
{
	int 	i;
	int 	strlength;
	void	*p;

	strlength=strlen(lep->buf);
	if (!sysinfo.freecursorf)
		{
		 if (lep->lx >strlength)
		 	lep->lx=strlength;
		} else
		{
		 if (strlength< lep->lx)
		 	{
		 	 for (i=strlength;i< lep->lx;++i)
		 	 	lep->buf[i] = ' ';
		 	 lep->buf[i] = '\0';
		 	 strlength = i;
		 	}
		}

	switch(cm)
		{
	 case BACKSPACE:
	 	 if (lep->lx <=0)
	 	 	break;
	 	 le_csrleft(lep);
	 case DELETE:
	 	 if (lep->lx < strlength)
	 	 	{
			 p=lep->buf+lep->lx;
	 	 	 if (IsThisKanjiPosition(lep->lx,lep->buf))
	 	 	 	memmove(p,p+2, strlength- lep->lx-1); else
	 	 	 	memmove(p,p+1, strlength- lep->lx);
	 	 	}
	 	 break;
	 default:
		 if (strlength< lep->size)
		 	{
			 p=lep->buf+lep->lx;
	 	 	 if (ch>=0x8e00)
	 	 	 	{
	 	 	 	 memmove(p+1,p, strlength- lep->lx+1);
	 	 	 	 *(char *)p =ch>>8;
	 	 	 	 ++p;
	 	 	 	}
	 	 	 memmove(p+1,p, strlength- lep->lx+1);
	 	 	 *(char *)p =ch&0xff;

	 	 	 le_csrright(lep);
		 	}
コード例 #3
0
ファイル: lineedit.c プロジェクト: smorimura/ne
void	le_csrright(le_t *lep)
{
	if (lep->lx<strlen(lep->buf))
		le_setlx(lep, lep->lx+1+ (IsThisKanjiPosition(lep->lx,lep->buf)?1:0));
}