import "io/console"; // not needed for print/progress/beep and the simple variant of prompt
These functions provide basic access to the console. The functions are designed in a way
to be both programmer and user friendly. They are synchronized so multiple tasks (threads)
won't print over in a middle of the line and the output is locked during an active prompt.
The built-in log
function is augmented with this behavior as well.
The state is tracked so for example the progress
function (which replaces
the current line if called repeatedly) will be correctly cleared when the other functions
are called or when the process exits.
The functions don't allow to use control characters (these are converted to '?'
).
The only supported control characters are a tab ('\t'
) and a newline ('\n'
)
characters. The progress
function disallows newlines as they can't work with it.
If you need to output arbitrary characters use the ProcessStream
class.
Use the Console class to use the console in an advanced way.
function print(value)
log
function to print to the standard error stream instead.
function prompt(msg: String): String
function prompt(msg: String, handler: PromptHandler): String
function progress(msg: String)
function beep()
function set_log_function(func)
to_string
built-in
function. The function can use the log
function to produce an output
(it will use the default implementation when called from the custom log handler). To
revert back to the default logging function just pass null
as a function.
function prompt_int(msg: String): Integer
function prompt_long(msg: String): Long
function prompt_float(msg: String): Float
function prompt_double(msg: String): Double
is_int
and is_float
) or checking for null
for the Long
and Double variants.
function prompt_password(msg: String): String
function prompt_password(msg: String, replacement_char: Integer): String
function prompt_password(msg: String, replacement_char: Integer, max_length: Integer): String
'*'
character is used as
a replacement character. You can also specify 0
to disable showing the length of
the password.