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

Function do_match

util/kconfig/nconf.c:1041–1086  ·  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

1039 * Else return -1 .
1040 */
1041static int do_match(int key, struct match_state *state, int *ans)
1042{
1043 char c = (char) key;
1044 int terminate_search = 0;
1045 *ans = -1;
1046 if (key == '/' || (state->in_search && key == 27)) {
1047 move(0, 0);
1048 refresh();
1049 clrtoeol();
1050 state->in_search = 1-state->in_search;
1051 bzero(state->pattern, sizeof(state->pattern));
1052 state->match_direction = MATCH_TINKER_PATTERN_DOWN;
1053 return 0;
1054 } else if (!state->in_search)
1055 return 1;
1056
1057 if (isalnum(c) || isgraph(c) || c == ' ') {
1058 state->pattern[strlen(state->pattern)] = c;
1059 state->pattern[strlen(state->pattern)] = '\0';
1060 adj_match_dir(&state->match_direction);
1061 *ans = get_mext_match(state->pattern,
1062 state->match_direction);
1063 } else if (key == KEY_DOWN) {
1064 state->match_direction = FIND_NEXT_MATCH_DOWN;
1065 *ans = get_mext_match(state->pattern,
1066 state->match_direction);
1067 } else if (key == KEY_UP) {
1068 state->match_direction = FIND_NEXT_MATCH_UP;
1069 *ans = get_mext_match(state->pattern,
1070 state->match_direction);
1071 } else if (key == KEY_BACKSPACE || key == 8 || key == 127) {
1072 state->pattern[strlen(state->pattern)-1] = '\0';
1073 adj_match_dir(&state->match_direction);
1074 } else
1075 terminate_search = 1;
1076
1077 if (terminate_search) {
1078 state->in_search = 0;
1079 bzero(state->pattern, sizeof(state->pattern));
1080 move(0, 0);
1081 refresh();
1082 clrtoeol();
1083 return -1;
1084 }
1085 return 0;
1086}
1087
1088static void conf(struct menu *menu)
1089{

Callers 2

selected_confFunction · 0.85
conf_choiceFunction · 0.85

Calls 8

moveFunction · 0.85
refreshFunction · 0.85
clrtoeolFunction · 0.85
isalnumFunction · 0.85
isgraphFunction · 0.85
strlenFunction · 0.85
adj_match_dirFunction · 0.85
get_mext_matchFunction · 0.85

Tested by

no test coverage detected