Esempio n. 1
0
/*
**	enter_key(name, value, label)
**
**	Enter a function key into the data base
*/
void
enter_key(
	     const char *name,
	     char *value,
	     char *lab)
{

    alloc_strings();
    if (value) {
	int found = 0;
	if (key_count != 0) {
	    size_t j = strlen(value);
	    fkmax = (fkmax > j) ? fkmax : j;
	    /* do not permit duplicates */
	    for (j = 0; j < (size_t) key_count; j++) {
		if (fk_name[j] == 0) {
		    break;
		} else if (!strcmp(fk_name[j], name)) {
		    found = 1;
		    break;
		}
	    }
	}
	if (!found) {
	    fkval[key_count] = value;
	    fk_tested[key_count] = 0;
	    fk_label[key_count] = lab;
	    fk_name[key_count++] = name;
	    if (lab) {
		got_labels = TRUE;
	    }
	}
    }
}
Esempio n. 2
0
/*
**	enter_key(name, value, label)
**
**	Enter a function key into the data base
*/
void
enter_key(
	const char *name,
	char *value,
	char *lab)
{
	unsigned j;

	alloc_strings();
	if (value) {
		j = strlen(value);
		fkmax = fkmax > j ? fkmax : j;
		/* do not permit duplicates */
		for (j = 0; (int) j < key_count; j++) {
			if (!strcmp(fk_name[j], name)) {
				return;
			}
		}
		fkval[key_count] = value;
		fk_tested[key_count] = 0;
		fk_label[key_count] = lab;
		fk_name[key_count++] = name;
		if (lab) {
			got_labels = TRUE;
		}
	}
}
Esempio n. 3
0
/*
**	keys_tested(first-time, show-help, hex-output)
**
**	Display a list of the keys not tested.
*/
static void
keys_tested(
	       int first_time,
	       int show_help,
	       int hex_output)
{
    int i, l;
    char outbuf[256];

    alloc_strings();
    put_clear();
    tty_set();
    flush_input();
    if (got_labels) {
	putln("Function key labels:");
	for (i = 0; i < key_count; ++i) {
	    if (fk_label[i]) {
		sprintf(outbuf, "%s %s",
			fk_name[i] ? fk_name[i] : "??", fk_label[i]);
		put_columns(outbuf, (int) strlen(outbuf), 16);
	    }
	}
	put_newlines(2);
    }
    if (funk) {
	putln("The following keys are not defined:");
	for (i = 0; i < funk; ++i) {
	    put_columns(fk_unknown[i], fk_length[i], 16);
	}
	put_mode(exit_attribute_mode);
	put_newlines(2);
    }
    if (first_time) {
	putln("The following keys are defined:");
    } else {
	putln("The following keys have not been tested:");
    }
    if (scan_mode) {
	for (i = 0; scan_down[i]; i++) {
	    if (!scan_tested[i]) {
		if (hex_output) {
		    strcpy(outbuf, hex_expand_to(scan_down[i], 3));
		} else {
		    strcpy(outbuf, expand(scan_down[i]));
		}
		l = expand_chars;
		if (hex_output) {
		    strcat(outbuf, hex_expand_to(scan_up[i], 3));
		} else {
		    strcat(outbuf, expand(scan_up[i]));
		}
		expand_chars += l;
		l = (int) strlen(scan_name[i]);
		if (((char_count + 16) & ~15) +
		    ((expand_chars + 7) & ~7) + l >= columns) {
		    put_crlf();
		} else if (char_count + 24 > columns) {
		    put_crlf();
		} else if (char_count) {
		    putchp(' ');
		}
		put_columns(outbuf, expand_chars, 16);
		put_columns(scan_name[i], l, 8);
	    }
	}
    } else {
	for (i = 0; i < key_count; i++) {
	    if (!fk_tested[i] && fk_name[i] != 0) {
		if (hex_output) {
		    strcpy(outbuf, hex_expand_to(fkval[i], 3));
		} else {
		    strcpy(outbuf, expand(fkval[i]));
		}
		l = (int) strlen(fk_name[i]);
		if (((char_count + 16) & ~15) +
		    ((expand_chars + 7) & ~7) + l >= columns) {
		    put_crlf();
		} else if (char_count + 24 > columns) {
		    put_crlf();
		} else if (char_count) {
		    putchp(' ');
		}
		put_columns(outbuf, expand_chars, 16);
		put_columns(fk_name[i], l, 8);
	    }
	}
    }
    put_newlines(2);
    if (show_help) {
	ptextln("Hit any function key.  Type 'end' to quit.  Type ? to update the display.");
	put_crlf();
    }
}
Esempio n. 4
0
static int
found_match(char *s, int hx, int cc)
{				/* return true if this string is a match */
    int j, f;

    alloc_strings();
    if (!*s) {
	return 0;
    }
    if (scan_mode) {
	for (j = f = 0; scan_down[j]; j++) {
	    if (scan_length[j] == 0) {
		continue;
	    }
	    if (!strncmp(s, scan_down[j], scan_length[j])) {
		if (!f) {	/* first match */
		    put_cr();
		    if (hx) {
			put_str(hex_expand_to(s, 10));
		    } else {
			put_str(expand_to(s, 10));
		    }
		    f = 1;
		}
		(void) end_funky(scan_name[j][0]);
		put_str(" ");
		put_str(scan_name[j]);
		scan_tested[j] = 1;
		s += scan_length[j];
		if (strncmp(s, scan_up[j], scan_length[j])) {
		    put_str(" scan down");
		} else {
		    s += scan_length[j];
		}
		if (!*s) {
		    break;
		}
		j = -1;
	    }
	    if (!strncmp(s, scan_up[j], scan_length[j])) {
		if (!f) {	/* first match */
		    put_cr();
		    if (hx) {
			put_str(hex_expand_to(s, 10));
		    } else {
			put_str(expand_to(s, 10));
		    }
		    f = 1;
		}
		put_str(" ");
		put_str(scan_name[j]);
		put_str(" scan up");
		s += scan_length[j];
		if (!*s) {
		    break;
		}
		j = -1;
	    }
	}
    } else {
	for (j = f = 0; j < key_count; j++) {
	    if (fkval[j] && !strcmp(s, fkval[j])) {
		char outbuf[256];

		if (!f) {	/* first match */
		    put_cr();
		    if (hx) {
			put_str(hex_expand_to(s, 10));
		    } else {
			put_str(expand_to(s, 10));
		    }
		    f = 1;
		}
		sprintf(outbuf, " (%s)", fk_name[j]);
		put_str(outbuf);
		if (fk_label[j]) {
		    sprintf(outbuf, " <%s>", fk_label[j]);
		    put_str(outbuf);
		}
		fk_tested[j] = 1;
	    }
	}
    }
    if (end_state == '?') {
	keys_tested(0, 1, hx);
	tty_raw(cc, char_mask);
	end_state = 0;
    }
    return f;
}