| 1173 | } |
| 1174 | |
| 1175 | static char |
| 1176 | topl_resp_key(char ch) |
| 1177 | { |
| 1178 | if (strlen(topl_resp) > 0) { |
| 1179 | char *loc = strchr(topl_resp, ch); |
| 1180 | |
| 1181 | if (!loc) { |
| 1182 | if (ch == '\x9' /* tab */) { |
| 1183 | topl_set_def(topl_def_idx <= 0 ? strlen(topl_resp) - 1 |
| 1184 | : topl_def_idx - 1); |
| 1185 | ch = '\0'; |
| 1186 | } else if (ch == CHAR_ESC) { |
| 1187 | loc = strchr(topl_resp, 'q'); |
| 1188 | if (!loc) { |
| 1189 | loc = strchr(topl_resp, 'n'); |
| 1190 | if (!loc && topl_def_idx >= 0) |
| 1191 | loc = topl_resp + topl_def_idx; |
| 1192 | } |
| 1193 | } else if (ch == (0x1f & 'P')) { |
| 1194 | mac_doprev_message(); |
| 1195 | ch = '\0'; |
| 1196 | } else if (topl_def_idx >= 0) { |
| 1197 | if (ch == CHAR_ENTER || ch == CHAR_CR || ch == CHAR_LF |
| 1198 | || ch == CHAR_BLANK |
| 1199 | || topl_resp[topl_def_idx] == CHAR_ANY) |
| 1200 | loc = topl_resp + topl_def_idx; |
| 1201 | |
| 1202 | else if (strchr(topl_resp, '#')) { |
| 1203 | if (digit(ch)) { |
| 1204 | topl_set_def(strchr(topl_resp, '#') - topl_resp); |
| 1205 | TEKey(ch, top_line); |
| 1206 | ch = '\0'; |
| 1207 | |
| 1208 | } else if (topl_resp[topl_def_idx] == '#') { |
| 1209 | if (ch == '\x1e' /* up arrow */) { |
| 1210 | topl_set_select(topl_query_len, topl_query_len); |
| 1211 | ch = '\0'; |
| 1212 | } else if (ch == '\x1d' /* right arrow */ |
| 1213 | || ch == '\x1f' /* down arrow */ |
| 1214 | || ch == CHAR_BS |
| 1215 | || ch == '\x1c' /* left arrow */ |
| 1216 | && (*top_line)->selEnd |
| 1217 | > topl_query_len) { |
| 1218 | TEKey(ch, top_line); |
| 1219 | ch = '\0'; |
| 1220 | } |
| 1221 | } |
| 1222 | } |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | if (loc) { |
| 1227 | topl_flash_resp(loc - topl_resp); |
| 1228 | if (*loc != CHAR_ANY) |
| 1229 | ch = *loc; |
| 1230 | TEKey(ch, top_line); |
| 1231 | } |
| 1232 | } |
no test coverage detected