Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tab completion of user names
This commit implements a feature commonly found in IRC clients and often referred to as "tab complete". This allows a user to type part of a user's name in the chat box and then press tab, which causes the program to complete the user's name in the chat box. The user can then press tab additional times in order to cycle through the list of possible matches. Tab complete has been implemented for the main chat, for battles, and for private messages. The algorithm implemented is that when you press tab, the program looks backward to the last space (or start of the line) and considers the substring between the last space and the position of the cursor to be the prefix of a name. It then builds a list of all names that it could be, which is then sorted. The sort is done first based on activity (i.e. users who have spoken more recently are sorted higher), and if users are tied as to activity, then by alphabetical order. After a name has been tab-completed, you can then press tab subsequent times in order to cycle through the remainder of the list. The idea behind this algorithm is that a user will usually want to refer to somebody who has spoken recently in the chat. This is especially helpful for Pokemon Showdown because with 1500+ users, it would be difficult to complete the correct name if it were based purely on alphabetical order. Matching of names is based on userids, which are strictly alphanumeric. Therefore, when intending to use tab complete, a user should type only the letters and numbers from a user's name, not any spaces or symbols. After pressing tab, the spaces and symbols will appear in the chatbox, however.
- Loading branch information
Showing
1 changed file
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters