📄 edit.c
字号:
for (i = 0; i < BOOLCOUNT; i++) { v = (i == xon_index) ? xon_shadow : CUR Booleans[i]; if (original_term.Booleans[i] != v) { return TRUE; } } for (i = 0; i < NUMCOUNT; i++) { if (original_term.Numbers[i] != CUR Numbers[i]) { return TRUE; } } for (i = 0; i < STRCOUNT; i++) { a = original_term.Strings[i] ? original_term.Strings[i] : ""; b = CUR Strings[i] ? CUR Strings[i] : ""; if (strcmp(a, b)) { return TRUE; } } return FALSE;}/***************************************************************************** * * Maintain the list of capabilities that can be tested * *****************************************************************************//*** mark_cap(name, flag)**** Mark the cap data base with the flag provided.*/static voidmark_cap( char *name, int flag){ struct name_table_entry const *nt; if ((nt = _nc_find_entry(name, _nc_info_hash_table))) { switch (nt->nte_type) { case BOOLEAN: flag_boolean[nt->nte_index] |= flag; break; case STRING: flag_strings[nt->nte_index] |= flag; break; case NUMBER: flag_numerics[nt->nte_index] |= flag; break; default: sprintf(temp, "unknown cap type (%s)", name); ptextln(temp); break; } } else { sprintf(temp, "Cap not found: %s", name); ptextln(temp); (void) wait_here(); }}/*** can_test(name-list, flags)**** Scan the name list and get the names.** Enter each name into the can-test data base.** <space> ( and ) may be used as separators.*/voidcan_test( const char *s, int flags){ int ch, j; char name[32]; if (s) { for (j = 0; (name[j] = ch = *s); s++) { if (ch == ' ' || ch == ')' || ch == '(') { if (j) { name[j] = '\0'; mark_cap(name, flags); } j = 0; } else { j++; } } if (j) { mark_cap(name, flags); } }}/*** cap_index(name-list, index-list)**** Scan the name list and return a list of indexes.** <space> ( and ) may be used as separators.** This list is terminated with -1.*/voidcap_index( const char *s, int *inx){ struct name_table_entry const *nt; int ch, j; char name[32]; if (s) { for (j = 0; ; s++) { name[j] = ch = *s; if (ch == ' ' || ch == ')' || ch == '(' || ch == 0) { if (j) { name[j] = '\0'; if ((nt = _nc_find_entry(name, _nc_info_hash_table)) && (nt->nte_type == STRING)) { *inx++ = nt->nte_index; } } if (ch == 0) { break; } j = 0; } else { j++; } } } *inx = -1;}/*** cap_match(name-list, cap)**** Scan the name list and see if the cap is in the list.** Return TRUE if we find an exact match.** <space> ( and ) may be used as separators.*/intcap_match( const char *names, const char *cap){ char *s; int c, l, t; if (names) { l = strlen(cap); while ((s = strstr(names, cap))) { c = (names == s) ? 0 : *(s - 1); t = s[l]; if ((c == 0 || c == ' ' || c == '(') && (t == 0 || t == ' ' || t == ')')) { return TRUE; } if (t == 0) { break; } names = s + l; } } return FALSE;}/*** show_report(test_list, status, ch)**** Display a list of caps that can be tested*/voidshow_report( struct test_list *t, int *state GCC_UNUSED, int *ch){ int i, j, nc, flag; const char *s; const char *nx[BOOLCOUNT + NUMCOUNT + STRCOUNT]; flag = t->flags & 255; nc = 0; for (i = 0; i < BOOLCOUNT; i++) { if (flag_boolean[i] & flag) { nx[nc++] = boolnames[i]; } } for (i = 0; i < NUMCOUNT; i++) { if (flag_numerics[i] & flag) { nx[nc++] = numnames[i]; } } for (i = 0; i < STRCOUNT; i++) { if (flag_strings[i] & flag) { nx[nc++] = strnames[i]; } } /* sort */ for (i = 0; i < nc - 1; i++) { for (j = i + 1; j < nc; j++) { if (strcmp(nx[i], nx[j]) > 0) { s = nx[i]; nx[i] = nx[j]; nx[j] = s; } } } if (flag & FLAG_FUNCTION_KEY) { ptextln("The following function keys can be tested:"); } else if (flag & FLAG_CAN_TEST) { ptextln("The following capabilities can be tested:"); } else if (flag & FLAG_TESTED) { ptextln("The following capabilities have been tested:"); } put_crlf(); for (i = 0; i < nc; i++) { sprintf(temp, "%s ", nx[i]); ptext(temp); } put_newlines(1); *ch = REQUEST_PROMPT;}/*** show_untested(test_list, status, ch)**** Display a list of caps that are defined but cannot be tested.** Don't bother to sort this list.*/static voidshow_untested( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch){ int i; ptextln("Caps that are defined but cannot be tested:"); for (i = 0; i < BOOLCOUNT; i++) { if (flag_boolean[i] == 0 && CUR Booleans[i]) { sprintf(temp, "%s ", boolnames[i]); ptext(temp); } } for (i = 0; i < NUMCOUNT; i++) { if (flag_numerics[i] == 0 && CUR Numbers[i] >= 0) { sprintf(temp, "%s ", numnames[i]); ptext(temp); } } for (i = 0; i < STRCOUNT; i++) { if (flag_strings[i] == 0 && CUR Strings[i]) { sprintf(temp, "%s ", strnames[i]); ptext(temp); } } put_newlines(1); *ch = REQUEST_PROMPT;}/*** edit_init()**** Initialize the function key data base*/voidedit_init(void){ int i, j, lc; char *lab; struct name_table_entry const *nt; int label_strings[STRCOUNT]; _nc_copy_termtype(&original_term, &cur_term->type); for (i = 0; i < BOOLCOUNT; i++) { original_term.Booleans[i] = CUR Booleans[i]; } for (i = 0; i < NUMCOUNT; i++) { original_term.Numbers[i] = CUR Numbers[i]; } /* scan for labels */ for (i = lc = 0; i < STRCOUNT; i++) { original_term.Strings[i] = CUR Strings[i]; if (strncmp(strnames[i], "lf", 2) == 0) { flag_strings[i] |= FLAG_LABEL; if (CUR Strings[i]) { label_strings[lc++] = i; } } } /* scan for function keys */ for (i = 0; i < STRCOUNT; i++) { if ((strnames[i][0] == 'k') && strcmp(strnames[i], "kmous")) { flag_strings[i] |= FLAG_FUNCTION_KEY; lab = (char *) 0; for (j = 0; j < lc; j++) { if (!strcmp(&strnames[i][1], &strnames[label_strings[j]][1])) { lab = CUR Strings[label_strings[j]]; break; } } enter_key(strnames[i], CUR Strings[i], lab); } } /* Lookup the translated strings */ for (i = 0; i < TM_last; i++) { if ((nt = _nc_find_entry(TM_string[i].name, _nc_info_hash_table)) && (nt->nte_type == STRING)) { TM_string[i].index = nt->nte_index; } else { sprintf(temp, "TM_string lookup failed for: %s", TM_string[i].name); ptextln(temp); } } if ((nt = _nc_find_entry("xon", _nc_info_hash_table)) != 0) { xon_index = nt->nte_index; } xon_shadow = xon_xoff;}/*** change_one_entry(test_list, status, ch)**** Change the padding on the selected cap*/static voidchange_one_entry( struct test_list *test, int *state, int *chp){ struct name_table_entry const *nt; int i, j, x, star, slash, v, dot, ch; const char *s; char *t, *p; const char *current_string; char buf[1024]; char pad[1024]; i = test->flags & 255; if (i == 255) { /* read the cap name from the user */ ptext("enter name: "); read_string(pad, 32); if (pad[0] == '\0' || pad[1] == '\0') { *chp = pad[0]; return; } if ((nt = _nc_find_entry(pad, _nc_info_hash_table)) && (nt->nte_type == STRING)) { x = nt->nte_index; current_string = CUR Strings[x]; } else { sprintf(temp, "%s is not a string capability", pad); ptext(temp); generic_done_message(test, state, chp); return; } } else { x = tx_index[i]; current_string = tx_cap[i]; strcpy(pad, strnames[x]); } if (!current_string) { ptextln("That string is not currently defined. Please enter a new value, including the padding delay:"); read_string(buf, sizeof(buf)); _nc_reset_input((FILE *) 0, buf); _nc_trans_string(pad, pad + sizeof(pad)); t = (char *)malloc(strlen(pad) + 1); strcpy(t, pad); CUR Strings[x] = t; sprintf(temp, "new string value %s", strnames[x]); ptextln(temp); ptextln(expand(t)); return; } sprintf(buf, "Current value: (%s) %s", pad, _nc_tic_expand(current_string, TRUE, TRUE)); putln(buf); ptextln("Enter new pad. 0 for no pad. CR for no change."); read_string(buf, 32); if (buf[0] == '\0' || (buf[1] == '\0' && isalpha(UChar(buf[0])))) { *chp = buf[0]; return; } star = slash = FALSE; for (j = v = dot = 0; (ch = buf[j]); j++) { if (ch >= '0' && ch <= '9') { v = ch - '0' + v * 10; if (dot) { dot++; } } else if (ch == '*') { star = TRUE; } else if (ch == '/') { slash = TRUE; } else if (ch == '.') { dot = 1; } else { sprintf(temp, "Illegal character: %c", ch); ptextln(temp); ptext("General format: 99.9*/ "); generic_done_message(test, state, chp); return; } } while (dot > 2) { v /= 10; dot--; } if (dot == 2) { sprintf(pad, "%d.%d%s%s", v / 10, v % 10, star ? "*" : "", slash ? "/" : ""); } else { sprintf(pad, "%d%s%s", v, star ? "*" : "", slash ? "/" : ""); } s = current_string; t = buf; for (v = 0; (ch = *t = *s++); t++) { if (v == '$' && ch == '<') { while ((ch = *s++) && (ch != '>')); for (p = pad; (*++t = *p++); ); *t++ = '>'; while ((*t++ = *s++)); pad[0] = '\0'; break; } v = ch; } if (pad[0]) { sprintf(t, "$<%s>", pad); } if ((t = (char *)malloc(strlen(buf) + 1))) { strcpy(t, buf); CUR Strings[x] = t; if (i != 255) { tx_cap[i] = t; } } generic_done_message(test, state, chp);}/*** build_change_menu(menu_list)**** Build the change pad menu list*/static voidbuild_change_menu( struct test_menu *m){ int i, j, k; char *s; for (i = j = 0; i < txp; i++) { if ((k = tx_index[i]) >= 0) { s = _nc_tic_expand(tx_cap[i], TRUE, TRUE); s[40] = '\0'; sprintf(change_pad_text[j], "%c) (%s) %s", 'a' + j, strnames[k], s); change_pad_list[j].flags = i; change_pad_list[j].lines_needed = 4; change_pad_list[j].menu_entry = change_pad_text[j]; change_pad_list[j].test_procedure = change_one_entry; j++; } } strcpy(change_pad_text[j], "z) enter name"); change_pad_list[j].flags = 255; change_pad_list[j].lines_needed = 4; change_pad_list[j].menu_entry = change_pad_text[j]; change_pad_list[j].test_procedure = change_one_entry; j++; change_pad_list[j].flags = MENU_LAST; if (m->menu_title) { put_crlf(); ptextln(m->menu_title); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -