Exemplo n.º 1
0
int main()
{
	int key;
	putkey(DOWN);
	while (1)//主循环
	{
		move_counter2 = -1;
		key = _getch();/*用于去掉第一个字节*/
		system("CLS");
		if (key == 27) break; /*如果是ESC退出*/
		if (key>31 && key<127) /*如果不是特殊键*/
		{
			if (key == 119) { //按下W键
				putkey(TOP);

				continue;
			}
		if ( key == 115){   //按下S键
				putkey(DOWN);
				continue;
			}
		if ( key == 97){    //按下A键
				putkey(LEFT);

				continue;
			}
		if ( key == 100){   //按下D键
				putkey(RIGHT);
				
				continue;
			}
		}
		key = _getch();
		if (key == 72) putkey(TOP);
		if (key == 80) putkey(DOWN);
		if (key == 75) putkey(LEFT);
		if (key == 77) putkey(RIGHT);
	}
	return 0;
}
Exemplo n.º 2
0
void
doref(char *line1)
{
	char buff[QLEN], dbuff[3*QLEN];
	char answer[ANSLEN], temp[TLEN], line[BUFSIZ];
	char *p, **sr, *flds[NFLD], *r;
	int nf, nr, query = 0, alph, digs;

   again:
	buff[0] = dbuff[0] = 0;
	if (biblio && Iline == 1 && line1[0] == '%')
		n_strcat(dbuff, line1, sizeof(dbuff));
	while (input(line, sizeof(line))) {		/* get query */
		Iline++;
		if (prefix(line, ".]"))
			break;
		if (biblio && line[0] == '\n')
			break;
		if (biblio && line[0] == '%' && line[1] == *convert)
			break;
		if (control(line[0]))
			query = 1;
		n_strcat(query ? dbuff : buff, line, query ?
		    sizeof(dbuff) : sizeof(buff));
		if (strlen(buff) > QLEN)
			err("query too long (%d)", strlen(buff));
		if (strlen(dbuff) > 3 * QLEN)
			err("record at line %d too long", Iline-1);
	}
	if (biblio && line[0] == '\n' && feof(in))
		return;
	if (strcmp(buff, "$LIST$\n")==0) {
		assert (dbuff[0] == 0);
		dumpold();
		return;
	}
	answer[0] = 0;
	for (p = buff; *p; p++) {
		if (isupper((int)*p))
			*p |= 040;
	}
	alph = digs = 0;
	for (p = buff; *p; p++) {
		if (isalpha((int)*p))
			alph++;
		else
			if (isdigit((int)*p))
				digs++;
			else {
				*p = 0;
				if ((alph+digs < 3) || common(p-alph)) {
					r = p-alph;
					while (r < p)
						*r++ = ' ';
				}
				if (alph == 0 && digs > 0) {
					r = p-digs;
					if (digs != 4 || atoi(r)/100 != 19) { 
						while (r < p)
							*r++ = ' ';
					}
				}
				*p = ' ';
				alph = digs = 0;
			}
	}
	one[0] = 0;
	if (buff[0]) {	/* do not search if no query */
		for (sr = rdata; sr < search; sr++) {
			temp[0] = 0;
			corout(buff, temp, "hunt", *sr, TLEN);
			assert(strlen(temp) < TLEN);
			if (strlen(temp)+strlen(answer) > BUFSIZ)
				err("Accumulated answers too large",0);
			n_strcat(answer, temp, sizeof(answer));
			if (strlen(answer)>BUFSIZ)
				err("answer too long (%d)", strlen(answer));
			if (newline(answer) > 0)
				break;
		}
	}
	assert(strlen(one) < ANSLEN);
	assert(strlen(answer) < ANSLEN);
	if (buff[0])
		switch (newline(answer)) {
		case 0:
			fprintf(stderr, "No such paper: %s\n", buff);
			return;
		default:
			fprintf(stderr, "Too many hits: %s\n", trimnl(buff));
			choices(answer);
			p = buff;
			while (*p != '\n')
				p++;
			*++p = 0;
		case 1:
			if (endpush)
				if ((nr = chkdup(answer))) {
					if (bare < 2) {
						nf = tabs(flds, one);
						nf += tabs(flds+nf, dbuff);
						assert(nf < NFLD);
						putsig(nf,flds,nr,line1,line,0);
					}
					return;
				}
			if (one[0] == 0)
				corout(answer, one, "deliv", dr, QLEN);
			break;
		}
	assert(strlen(buff) < QLEN);
	assert(strlen(one) < ANSLEN);
	nf = tabs(flds, one);
	nf += tabs(flds+nf, dbuff);
	assert(nf < NFLD);
	refnum++;
	if (sort)
		putkey(nf, flds, refnum, keystr);
	if (bare < 2)
		putsig(nf, flds, refnum, line1, line, 1);
	else
		flout();
	putref(nf, flds);
	if (biblio && line[0] == '\n')
		goto again;
	if (biblio && line[0] == '%' && line[1] == *convert)
		fprintf(fo, "%s%c%s", convert+1, sep, line+3);
}
Exemplo n.º 3
0
void __task refresh_task(void * data)
{
    long count = 0;
    char buf[64];
    int flag = 0;

    data = data;

    for (;;) {
        sprintf(buf, "[%d%%] %ld $ %ld", CPU_USED, count, 50000-count*3);
        count++;
        if (count >= 5000)
            count = 1;
        gui_label_set_text(label, buf);

        #if 0
        gui_form_set_caption(form, buf);
        #endif

        sprintf(buf, "[%d%%] %ld 将那个Label盖住", CPU_USED, count*3);
        gui_button_set_caption(button, buf);

        if (0) {
            static int f = 0, i = 0;
            static KEYCODE key, test_keys[] = {'d', ENTER, ESC, 'f', ENTER, 'h', ENTER, ESC};

            if (--f <= 0) {
                f = 1;
                /* key = test_keys[i++]; */
                key = (random(128) * random(128)) % 128;
                if (key < 0x10 && key != ESC) {
                    key += 0x10;
                }
                putkey(key);
                if (i >= sizeof(test_keys))
                    i = 0;
            }
        }

        if (1) {
            static int f = 0, x = 0, y = 0;

            if (--f <= 0) {
                f = 20;
                x = random(900);
                y = random(700);
                gui_window_moveto(window3, x, y);
            }
        }        
	
        if (1) {
            static int f = 0, x = 0;
            char buf[32];

            if (--f <= 0) {
                f = 10;
                x = random(20000);
                sprintf(buf, "random() = %d", x);
                gui_edit_set_text(edit, buf);
            }
        }

        if (moveto_now) {
            moveto_now = 0;
            gui_window_moveto(window3, moveto_x, moveto_y);
        }

        TaskSleep(20);
    }
}