/* ** funkey_label(test_list, status, ch) ** ** Test labels (nlab) (smln) (pln) (rmln) (lw) (lh) */ static void funkey_label( struct test_list *t, int *state, int *ch) { int i; char outbuf[256]; if (num_labels == -1) { ptextln("Your terminal has no labels. (nlab)"); } else { sprintf(temp, "Your terminal has %d labels (nlab) that are %d characters wide (lw) and %d lines high (lh)", num_labels, label_width, label_height); ptext(temp); ptextln(" Testing (smln) (pln) (rmln)"); if (label_on) { tc_putp(label_on); } if (label_width <= 0) { label_width = sizeof(outbuf) - 1; } for (i = 1; i <= num_labels; i++) { sprintf(outbuf, "L%d..............................", i); outbuf[label_width] = '\0'; tc_putp(TPARM_2(plab_norm, i, outbuf)); } if (label_off) { ptext("Hit any key to remove the labels: "); (void) wait_here(); tc_putp(label_off); } } generic_done_message(t, state, ch); }
/* ** funkey_local(test_list, status, ch) ** ** Test program local function keys (pfloc) */ static void funkey_local( TestList * t, int *state, int *ch) { if (pkey_local) { int fk = 1; /* test local function key */ sprintf(temp, "(pfloc) Set function key %d to execute a clear and print \"Done!\"", fk); ptextln(temp); sprintf(temp, "%sDone!", liberated(clear_screen)); tc_putp(TPARM_2(pkey_local, fk, temp)); sprintf(temp, "Hit function key %d. Then hit return.", fk); ptextln(temp); (void) wait_here(); flush_input(); if (key_f1 && pkey_xmit) { tc_putp(TPARM_2(pkey_xmit, fk, key_f1)); } } else { ptextln("Function key execute local (pfloc), not present."); } generic_done_message(t, state, ch); }
/* ** funkey_meta(test_list, status, ch) ** ** Test meta key (km) (smm) (rmm) */ static void funkey_meta( TestList * t, int *state, int *ch) { if (has_meta_key) { int i, j, k, len; char outbuf[256]; put_crlf(); if (char_mask != ALLOW_PARITY) { if (tty_meta_prep()) { ptext("\nHit any key to continue > "); (void) wait_here(); put_crlf(); } } ptext("Begin meta key test. (km) (smm) (rmm) Hit any key"); ptext(" with the meta key. The character will be"); ptext(" displayed in hex. If the meta key is working"); ptext(" then the most significant bit will be set. Type"); ptextln(" 'end' to exit."); tty_raw(1, ALLOW_PARITY); tc_putp(meta_on); for (i = j = k = len = 0; i != 'e' || j != 'n' || k != 'd';) { i = j; j = k; k = getchp(ALLOW_PARITY); if (k == EOF) { break; } if ((len += 3) >= columns) { put_crlf(); len = 3; } sprintf(outbuf, "%02X ", k); put_str(outbuf); k &= STRIP_PARITY; } tc_putp(meta_off); put_crlf(); tty_set(); put_crlf(); } else { ptext("(km) Has-meta-key is not set. "); } generic_done_message(t, state, ch); }
/* ** pad_done_message(test_list) ** ** Print the Done message and request input. */ void pad_done_message( struct test_list *test, int *state, int *ch) { int default_action = 0; char done_message[128]; char rep_text[16]; while (1) { if ((test->flags & MENU_LC_MASK)) { sprintf(rep_text, "*%d", augment); } else { rep_text[0] = '\0'; } if (test->caps_done) { sprintf(done_message, "(%s)%s Done ", test->caps_done, rep_text); ptext(done_message); } else { if (rep_text[0]) { ptext(rep_text); ptext(" "); } ptext("Done "); } if (debug_level & 2) { dump_test_stats(test, state, ch); } else { *ch = wait_here(); } if (*ch == '\r' || *ch == '\n') { *ch = default_action; return; } if (*ch == 's' || *ch == 'n') { *ch = 0; return; } if (strchr(pad_repeat_test, *ch)) { /* default action is now repeat */ default_action = 'r'; } if (subtest_menu(pad_test_list, state, ch)) { continue; } return; } }
/* ** send_info_string(str) ** ** Return the terminfo string prefixed by the correct separator */ static void send_info_string( const char *str, int *ch) { int len; if (display_lines == -1) { return; } len = strlen(str); if (len + char_count + 3 >= columns) { if (start_display == 0) { put_str(","); } put_crlf(); if (++display_lines > lines) { ptext("-- more -- "); *ch = wait_here(); if (*ch == 'q') { display_lines = -1; return; } display_lines = 0; } if (len >= columns) { /* if the terminal does not (am) then this loses */ if (columns) { display_lines += ((strlen(str) + 3) / columns) + 1; } put_str(" "); put_str(str); start_display = 0; return; } ptext(" "); } else if (start_display == 0) { ptext(", "); } else { ptext(" "); } ptext(str); start_display = 0; }
/* ** skip_pad_test(test-list-entry, state, ch, text) ** ** Print the start test line. Handle start up commands. ** Return TRUE if a return is requested. */ int skip_pad_test( struct test_list *test, int *state, int *ch, const char *text) { char rep_text[16]; while(1) { if (text) { ptext(text); } if ((test->flags & MENU_LC_MASK)) { sprintf(rep_text, " *%d", augment); ptext(rep_text); } ptext(" [n] > "); *ch = wait_here(); if (*ch == 's') { /* Skip is converted to next */ *ch = 'n'; return TRUE; } if (*ch == 'q') { /* Quit is converted to help */ *ch = '?'; return TRUE; } if (*ch == '\r' || *ch == '\n' || *ch == 'n' || *ch == 'r') { /* this is the only response that allows the test to run */ *ch = 0; } if (subtest_menu(pad_test_list, state, ch)) { continue; } return (*ch != 0); } }
static int found_exit(char *keybuf, int hx, int cc) { /* return true if the user wants to exit */ int j; char *s; if (scan_mode) { if (*keybuf == '\0') { return TRUE; } } else { int k; /* break is a special case */ if (*keybuf == '\0') { fresh_line(); tty_set(); ptext("Hit X to exit: "); if (wait_here() == 'X') { return TRUE; } keys_tested(0, 1, hx); tty_raw(cc, char_mask); return FALSE; } /* is this the end? */ for (k = 0; (j = (keybuf[k] & STRIP_PARITY)); k++) { if (end_funky(j)) { return TRUE; } } j = TRUE; /* does he need an updated list? */ for (k = 0; keybuf[k]; k++) { j &= (keybuf[k] & STRIP_PARITY) == '?'; } if (j || end_state == '?') { keys_tested(0, 1, hx); tty_raw(cc, char_mask); end_state = 0; return FALSE; } } put_cr(); if (hx) { s = hex_expand_to(keybuf, 10); } else { s = expand_to(keybuf, 10); } sprintf(temp, "%s Unknown", s); put_str(temp); for (j = 0; j < MAX_FK_UNK; j++) { if (j == funk) { fk_length[funk] = expand_chars; if ((fk_unknown[funk] = (char *) malloc(strlen(s) + 1))) { strcpy(fk_unknown[funk++], s); } break; } if (fk_length[j] == expand_chars) { if (!strcmp(fk_unknown[j], s)) { break; } } } return FALSE; }
/* ** crum_move(test_list, status, ch) ** ** (*) test all cursor move commands */ static void crum_move( struct test_list *t, int *state, int *ch) { char buf[80]; int n; switch (n = (t->flags & 15)) { case 0: sprintf(buf, " (cr) (nel) (cub1)%s", cursor_home ? " (home)" : (cursor_up ? " (cuu1)" : "")); break; case 1: sprintf(buf, "%s%s%s%s", cursor_left ? " (cub1)" : "", cursor_down ? " (cud1)" : "", cursor_right ? " (cuf1)" : "", cursor_up ? " (cuu1)" : ""); if (buf[0] == '\0') { ptext(" (cub1) (cud1) (cuf1) (cuu1) not defined."); } break; case 2: sprintf(buf, "%s%s%s%s", parm_left_cursor ? " (cub)" : "", parm_down_cursor ? " (cud)" : "", parm_right_cursor ? " (cuf)" : "", parm_up_cursor ? " (cuu)" : ""); if (buf[0] == '\0') { ptext(" (cub) (cud) (cuf) (cuu) not defined."); } break; case 3: sprintf(buf, "%s%s", row_address ? " (vpa)" : "", column_address ? " (hpa)" : ""); if (buf[0] == '\0') { ptext(" (vpa) (hpa) not defined."); } break; case 4: if (!cursor_address) { ptext(" (cup) not defined. "); generic_done_message(t, state, ch); return; } strcpy(buf, " (cup)"); break; } if (buf[0] == '\0') { put_str(" Done. "); } else { can_test(buf, FLAG_TESTED); strcpy(crum_text[n], &buf[2]); crum_text[n][strlen(buf) - 3] = '\0'; display_it(1 << n, buf); } *ch = wait_here(); if (*ch != 'r') { put_clear(); } }
void scan_init(char *fn) { /* read the scan mode key definitions */ char *s, *sl; FILE *fp; int ch, i, j; unsigned len; char home[512]; if ((str = getenv("HOME"))) strcpy(home, str); else home[0] = '\0'; fp = NULL; if ((str = getenv("KEYBOARD"))) { if (!(fp = fopen(str, "r")) && home[0]) { sprintf(temp, "%s/.scan.%s", home, str); fp = fopen(temp, "r"); } } if (!fp) { sprintf(temp, ".scan.%s", fn); fp = fopen(temp, "r"); } if (!fp && home[0]) { sprintf(temp, "%s/.scan.%s", home, fn); fp = fopen(temp, "r"); } if (!fp) { ptext("Unable to open scanfile: "); ptextln(temp); bye_kids(EXIT_FAILURE); return; } /* scan file format: <down value> <up value> <name> values are in hex. <name> may be any string of characters */ scan_up = (char **) malloc(sizeof(char *) * MAX_SCAN); scan_down = (char **) malloc(sizeof(char *) * MAX_SCAN); scan_name = (char **) malloc(sizeof(char *) * MAX_SCAN); scan_tested = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN); scan_length = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN); scan_value = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN); scan_up[0] = scan_down[0] = scan_name[0] = (char *) 0; str = (char *) malloc(4096); /* buffer space */ sl = str + 4000; /* an upper limit */ scan_max = 1; for (i = 0;;) { for (s = str; (ch = getc(fp)) != EOF;) { if (ch == '\n' || ch == '\r') break; *s++ = (char) ch; } *s++ = '\0'; if (ch == EOF) break; if (*str == '#' || *str == '\0') continue; scan_down[i] = smash(); scan_blanks(); scan_up[i] = smash(); scan_blanks(); scan_name[i] = str; scan_length[i] = strlen(scan_down[i]); len = strlen(scan_up[i]) + scan_length[i]; if (len > scan_max) scan_max = len; scan_value[i] = UChar(scan_name[i][0]); if (scan_name[i][1]) /* multi-character name */ for (j = 0; scan_special[j].name; j++) { if (!strcmp(scan_name[i], scan_special[j].name)) { scan_value[i] = scan_special[j].type; break; } } i++; if (str > sl) { str = (char *) malloc(4096); sl = str + 4000; } else str = s; } fclose(fp); #ifdef notdef for (i = 0; scan_down[i]; i++) { put_str(hex_expand_to(scan_down[i], 3)); put_str(hex_expand_to(scan_up[i], 3)); put_str(" "); put_str(scan_name[i]); put_crlf(); } (void) wait_here(); #endif }