MCPcopy Create free account
hub / github.com/Entware/Entware / do_match

Function do_match

scripts/config/nconf.c:1095–1140  ·  view source on GitHub ↗

Return 0 means I have handled the key. In such a case, ans should hold the * item to center, or -1 otherwise. * Else return -1 . */

Source from the content-addressed store, hash-verified

1093 * Else return -1 .
1094 */
1095static int do_match(int key, struct match_state *state, int *ans)
1096{
1097 char c = (char) key;
1098 int terminate_search = 0;
1099 *ans = -1;
1100 if (key == '/' || (state->in_search && key == 27)) {
1101 move(0, 0);
1102 refresh();
1103 clrtoeol();
1104 state->in_search = 1-state->in_search;
1105 bzero(state->pattern, sizeof(state->pattern));
1106 state->match_direction = MATCH_TINKER_PATTERN_DOWN;
1107 return 0;
1108 } else if (!state->in_search)
1109 return 1;
1110
1111 if (isalnum(c) || isgraph(c) || c == ' ') {
1112 state->pattern[strlen(state->pattern)] = c;
1113 state->pattern[strlen(state->pattern)] = '\0';
1114 adj_match_dir(&state->match_direction);
1115 *ans = get_mext_match(state->pattern,
1116 state->match_direction);
1117 } else if (key == KEY_DOWN) {
1118 state->match_direction = FIND_NEXT_MATCH_DOWN;
1119 *ans = get_mext_match(state->pattern,
1120 state->match_direction);
1121 } else if (key == KEY_UP) {
1122 state->match_direction = FIND_NEXT_MATCH_UP;
1123 *ans = get_mext_match(state->pattern,
1124 state->match_direction);
1125 } else if (key == KEY_BACKSPACE || key == 8 || key == 127) {
1126 state->pattern[strlen(state->pattern)-1] = '\0';
1127 adj_match_dir(&state->match_direction);
1128 } else
1129 terminate_search = 1;
1130
1131 if (terminate_search) {
1132 state->in_search = 0;
1133 bzero(state->pattern, sizeof(state->pattern));
1134 move(0, 0);
1135 refresh();
1136 clrtoeol();
1137 return -1;
1138 }
1139 return 0;
1140}
1141
1142static void conf(struct menu *menu)
1143{

Callers 2

selected_confFunction · 0.85
conf_choiceFunction · 0.85

Calls 2

adj_match_dirFunction · 0.85
get_mext_matchFunction · 0.85

Tested by

no test coverage detected