示例#1
0
文件: fileopen.c 项目: justid/Zoolu
int PrintfRev(const char *cpFormat, ...)
{
	char cpBuffer[STRING_BUFFER_SIZE];
	va_list pArgList;

	va_start(pArgList, cpFormat);
	vsprintf(cpBuffer, cpFormat, pArgList);
	va_end(pArgList);
	PrintRev((unsigned char*)cpBuffer);
	return 0;
}
示例#2
0
int dGetLine (char * s,int max)	// This function is depended on dConsole
								// And this function is not allowed to abolish
{
	int		pos = strlen(s);
	int		refresh = 1;
	int		x,y,l,width;
	uint	key;
	char	c;
	int		downcase = 0;

	l = strlen (line_buf[line_index]);
	
	if (l>=LINE_COL_MAX)
	{
		dConsolePut("\n");
		l = 0;
	}
	else
		dConsoleRedraw();

	x = l + 1;
	y = line_count;
	width = LINE_COL_MAX - 2;

	while (1)
	{
		if (refresh)
		{
			int i;
			locate(x,y);PrintRev((uchar*)(downcase ? "\xE6\x9D" : "\xE6\x9C"));
			for (i=x+1;i<=LINE_COL_MAX;++i)
			{
				locate(i,y);Print((uchar*)" ");
			}
			if (pos<width-1)
			{
				locate(x+1,y);		Print((uchar*)s);
				locate(x+pos+1,y);	Print((uchar*)"_");
			}
			else
			{
				locate(x+1,y);			Print((uchar*)s+pos-width+1);
				locate(x+width,y);	Print((uchar*)"_");
			}
			refresh = 0;
		}
		GetKey(&key);
		if ((c=dGetKeyChar(key,downcase))!=0)
		{
			if (pos>=max) continue;
			s[pos++] = c;s[pos] = '\0';
			refresh = 1;
		}
		else
		{
			if (key==KEY_CTRL_DEL)
			{
				if (pos<=0) continue;
				s[--pos] = '\0';
				refresh  = 1;
			}
			else if (key==KEY_CTRL_AC)
			{
				*s		= 0;
				pos		= 0;
				refresh	= 1;
			}
			else if (key==KEY_CTRL_OPTN)
			{
				downcase = !downcase;
				refresh = 1;
			}
			else if (key==KEY_CTRL_EXE) return 1;
			
		}
	}
	return 0;
}