Input Setup - Sam36502/SimpleTUI GitHub Wiki

Input Scanner

In order to prompt the user for any input, you must first open the global scanner. This can be done with the Input.openScanner() method.

Make sure to also close the scanner again, once you are done reading input. This is done with Input.closeScanner().

If you aren't sure whether the scanner is currently open or not, you can use the Input.isOpened() method. This will return true if the scanner is open, and false if the scanner is closed.

Prompt String

By default, whenever the user is prompted for input, the console displays --> . If you would like a different input prompt, this can be changed with the Input.setPrompt() method. Simply pass a String with the desired prompt.

Example:

Input.getInt();
// How the prompt looks by default
--> 25

Input.setPrompt(">>");
Input.getInt();

// How the prompt looks after being changed. Note, no space is added,
// so if you want to distance the prompt from the input value, make
// sure to add one in the string.
>>25