| 706 | } |
| 707 | |
| 708 | bool nickcomplete(char *s, bool reversedirection) |
| 709 | { |
| 710 | static int nickcompleteidx; |
| 711 | |
| 712 | char *cp = strrchr(s, ' '); // find last space |
| 713 | cp = cp ? cp + 1 : s; |
| 714 | |
| 715 | if(nickcompletesize < 0) |
| 716 | { |
| 717 | nickcompletesize = (int)strlen(cp); |
| 718 | nickcompleteidx = reversedirection ? 0 : -1; |
| 719 | } |
| 720 | |
| 721 | vector<int> matchingnames; |
| 722 | vector<const char *> matchingigs; |
| 723 | loopv(players) if(players[i] && !strncasecmp(players[i]->name, cp, nickcompletesize)) matchingnames.add(i); // find all matching player names first |
| 724 | if(nickcompletesize > 0 && *cp == ':') enumigraphs(matchingigs, cp + 1, nickcompletesize - 1); // find all matching igraphs |
| 725 | int totalmatches = matchingnames.length() + matchingigs.length(); |
| 726 | if(totalmatches) |
| 727 | { |
| 728 | nickcompleteidx += reversedirection ? totalmatches - 1 : 1; |
| 729 | nickcompleteidx %= totalmatches; |
| 730 | bool isig = nickcompleteidx >= matchingnames.length(); |
| 731 | const char *fillin = isig ? matchingigs[nickcompleteidx - matchingnames.length()] : players[matchingnames[nickcompleteidx]]->name; |
| 732 | if(*fillin == '/' && cp == s) *cp++ = ' '; |
| 733 | if(isig) cp++; |
| 734 | *cp = '\0'; |
| 735 | concatstring(s, fillin); |
| 736 | return true; |
| 737 | } |
| 738 | return false; |
| 739 | } |
| 740 | |
| 741 | enum { COMPLETE_FILE = 0, COMPLETE_LIST, COMPLETE_NICK }; |
| 742 |
no test coverage detected