forked from se-edu/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from KokJianYu/Intellisense
Auto complete functionality for commands
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/seedu/address/logic/commands/AutoCompleteCommandHelper.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package seedu.address.logic.commands; | ||
|
||
/** | ||
* Helper class to auto complete commands typed into command box | ||
*/ | ||
public class AutoCompleteCommandHelper { | ||
private static String[] commandWordList = { | ||
AddCommand.COMMAND_WORD, | ||
ClearCommand.COMMAND_WORD, | ||
DeleteCommand.COMMAND_WORD, | ||
EditCommand.COMMAND_WORD, | ||
ExitCommand.COMMAND_WORD, | ||
FindCommand.COMMAND_WORD, | ||
HelpCommand.COMMAND_WORD, | ||
HistoryCommand.COMMAND_WORD, | ||
ListCommand.COMMAND_WORD, | ||
RedoCommand.COMMAND_WORD, | ||
SelectCommand.COMMAND_WORD, | ||
UndoCommand.COMMAND_WORD | ||
}; | ||
|
||
/** | ||
* This method predicts the command the user is entering. | ||
* @param partialWord The current characters available in command box. | ||
* @return The predicted command. | ||
*/ | ||
public static String autoCompleteWord(String partialWord) { | ||
for (String s : commandWordList) { | ||
if (s.startsWith(partialWord)) { | ||
return s; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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