示例#1
0
文件: pipe.c 项目: dkastner/sc
void
dogetkey()
{
    int c, len;

    goraw();
    c = nmgetch();
    deraw(0);

    if (c < 256) {
	sprintf(line, "%c", c);
	len = 1;
    } else if (c >= KEY_MIN && c <= KEY_MAX) {
	int i, j;
	line[0] = '\0';
	sprintf(line + 1, "%s\n", keyname(c));
	for (i = 1, j = 5; line[j-1]; ) {
	    if (line[j] == '(' || line[j] == ')')
		j++;
	    else
		line[i++] = line[j++];
	}
	len = strlen(line + 1) + 1;
    } else {
	line[0] = '0';
	sprintf(line + 1, "UNKNOWN KEY");
	len = strlen(line + 1) + 1;
    }


    write(macrofd, line, len);
}
示例#2
0
static int pscreen (const char* l)
{
    clear();
    for (short lineno = 1; *l; ++lineno, l += strlen(l)+1) {
	move (lineno, 4);
	addstr (l);
    }
    move (0,0);
    addstr ("Which Screen? [a-p, q]");
    refresh();
    return (nmgetch());
}
示例#3
0
文件: help.c 项目: jintonic/sc
static int
pscreen(char *screen[])
{
    int lineno;
    int dbline;

    (void) move(1,0);
    (void) clrtobot();
    dbline = 1;
    for (lineno = 0; screen[lineno]; lineno++) {
	(void) move(dbline++, 4);
	(void) addstr (screen[lineno]);
	(void) clrtoeol();
    }
    (void) move(0,0);
    (void) printw("Which Screen? [a-o, q]");
    (void) clrtoeol();
    (void) refresh();
    return(nmgetch());
}
示例#4
0
文件: lex.c 项目: recalcc/sc
int
nmgetch() 
{
    register int c;
    register struct key_map *kp;
    register struct key_map *biggest;
    register int i;
    int almost;
    int maybe;

    static char dumpbuf[10];
    static char *dumpindex;

#ifdef SIGVOID
    void time_out();
#else
    int time_out();
#endif

    if (dumpindex && *dumpindex)
	return (*dumpindex++);

    c = getchar();
    biggest = 0;
    almost = 0;

    for (kp = &km[0]; kp < &km[N_KEY]; kp++) {
	if (!kp->k_str)
	    continue;
	if (c == kp->k_str[kp->k_index]) {
	    almost = 1;
	    kp->k_index++;
	    if (kp->k_str[kp->k_index] == 0) {
		c = kp->k_val;
		for (kp = &km[0]; kp < &km[N_KEY]; kp++)
		    kp->k_index = 0;
		return (c);
	    }
	}
	if (!biggest && kp->k_index)
	    biggest = kp;
        else if (kp->k_index && biggest->k_index < kp->k_index)
	    biggest = kp;
    }

    if (almost) { 
        (void) signal(SIGALRM, time_out);
        (void) alarm(1);

	if (setjmp(wakeup) == 0) { 
	    maybe = nmgetch();
	    (void) alarm(0);
	    return (maybe);
	}
    }
    
    if (biggest) {
	for (i = 0; i<biggest->k_index; i++) 
	    dumpbuf[i] = biggest->k_str[i];
	if (!almost)
	    dumpbuf[i++] = c;
	dumpbuf[i] = '\0';
	dumpindex = &dumpbuf[1];
	for (kp = &km[0]; kp < &km[N_KEY]; kp++)
	    kp->k_index = 0;
	return (dumpbuf[0]);
    }

    return(c);
}