| 1145 | } |
| 1146 | |
| 1147 | static void selected_conf(struct menu *menu, struct menu *active_menu) |
| 1148 | { |
| 1149 | struct menu *submenu = NULL; |
| 1150 | struct symbol *sym; |
| 1151 | int i, res; |
| 1152 | int current_index = 0; |
| 1153 | int last_top_row = 0; |
| 1154 | struct match_state match_state = { |
| 1155 | .in_search = 0, |
| 1156 | .match_direction = MATCH_TINKER_PATTERN_DOWN, |
| 1157 | .pattern = "", |
| 1158 | }; |
| 1159 | |
| 1160 | while (!global_exit) { |
| 1161 | reset_menu(); |
| 1162 | current_menu = menu; |
| 1163 | build_conf(menu); |
| 1164 | if (!child_count) |
| 1165 | break; |
| 1166 | |
| 1167 | if (active_menu != NULL) { |
| 1168 | for (i = 0; i < items_num; i++) { |
| 1169 | struct mitem *mcur; |
| 1170 | |
| 1171 | mcur = (struct mitem *) item_userptr(curses_menu_items[i]); |
| 1172 | if ((struct menu *) mcur->usrptr == active_menu) { |
| 1173 | current_index = i; |
| 1174 | break; |
| 1175 | } |
| 1176 | } |
| 1177 | active_menu = NULL; |
| 1178 | } |
| 1179 | |
| 1180 | show_menu(menu_get_prompt(menu), menu_instructions, |
| 1181 | current_index, &last_top_row); |
| 1182 | keypad((menu_win(curses_menu)), TRUE); |
| 1183 | while (!global_exit) { |
| 1184 | if (match_state.in_search) { |
| 1185 | mvprintw(0, 0, |
| 1186 | "searching: %s", match_state.pattern); |
| 1187 | clrtoeol(); |
| 1188 | } |
| 1189 | refresh_all_windows(main_window); |
| 1190 | res = wgetch(menu_win(curses_menu)); |
| 1191 | if (!res) |
| 1192 | break; |
| 1193 | if (do_match(res, &match_state, ¤t_index) == 0) { |
| 1194 | if (current_index != -1) |
| 1195 | center_item(current_index, |
| 1196 | &last_top_row); |
| 1197 | continue; |
| 1198 | } |
| 1199 | if (process_special_keys(&res, |
| 1200 | (struct menu *) item_data())) |
| 1201 | break; |
| 1202 | switch (res) { |
| 1203 | case KEY_DOWN: |
| 1204 | case 'j': |
no test coverage detected