- matches = 0;
- uniquematch = NULL;
- for (i = 0; i < credits.num_items; i++) {
- if (strncmp(nickname, credits.credits[i].nickname, strlen(nickname)) !=
- 0) {
- continue;
- }
- matches++;
- if (matches > 1) {
- break;
- }
- uniquematch = credits.credits[i].nickname;
- }
- if (matches == 1) {
- /* Display the rest of the nickname */
- textcolor(TC_LIGHT_GREEN);
- cprintf("%s", uniquematch + strlen(nickname));
- textcolor(TC_LIGHT_GRAY);
- strcat(nickname, uniquematch + strlen(nickname));
- } else {
- /* Multiple nicknames match what was entered so far. Abort and
- * display all matches, then prompt the user again. */
- char completion[NICKNAME_MAX_LEN + 1];
- BYTE len = strlen(nickname);
- x = wherex();
- y = wherey();
- cprintf("\r\nCompletion:\r\n");
- matches = 0;
- for (i = 0; i < credits.num_items; i++) {
- if (strncmp(nickname, credits.credits[i].nickname, len) != 0) {
- continue;
- }
- if (++matches == 5) {
- cprintf("...\r\n");
- break;
- }
- strcpy(completion, credits.credits[i].nickname);
- *(completion + len) = '\0';
- cprintf("%s", completion);
- textcolor(TC_LIGHT_GREEN);
- cprintf("%c", *(credits.credits[i].nickname + len));
- textcolor(TC_LIGHT_GRAY);
- cprintf("%s\r\n", completion + len + 1);
- }
- gotoxy(x, y);
- }
- }
- }
-
- if (*nickname != '\0' && *nickname != 32) {
- nickname_len = strlen(nickname);