To use this package, first call init function
optional argument to change the prompt to anything you want, default is " :"
Returns .OK or .INVALID_HANDLE
Queries for a number input. Number can be positive or negative 64 bit integer Optional min and max values, forces entry of numbers between min and max
Returns value, .OK or .CANCEL or a .MIN_MAX error (if min is greater than max)
Queries for a response from a list of items. The ^[]option($T) is an array of option structs, having key, value pairs.
option :: struct($T:typeid) {
key :string,
value :T,
}
Eg: to set up options that return a u32:
my_options := []prompt.option(u32) {
{"option 1", 100},
{"option 2", 200},
}
Arrow keys are used to select an item and enter finalizes the choice. Current selection is highlited in green.
Returns the value, and an index which can be used to retrieve the key.
Lists options for the user to select from an array of multi-option structs.
multi_option :: struct {
option :string,
is_selected :bool,
}
Arrow keys are used to move cursor up and down, space bar is used to select options. Selected options appear as "X"
On return, all the selected options are set to true
get_password :: proc(message:string, min_len:int=0, max_len:int=0, show:bool=false) ->(value:string, ok:err)
Queries for a password. Accepts all alphanumeric characters and valid symbols Optional min_len and max_len forces the user to enter a string in those bounds. If show is true, prints '*' characters as user types password, otherwise the cursor doesn't move.
Returns a string that the caller must free. .OK, .CANCEL or a .MIN_MAX error (if min_len is greater than max_len).
Returns an immediate character rune, without waiting for enter to be pressed. Returns .OK, .KEY_UP
Returns an immediate scan code (enum), without waiting for enter to be pressed. Returns .OK, .KEY_UP
console_info ::struct { hStdin :w.HANDLE, hStdout :w.HANDLE, scr_buf :w.CONSOLE_SCREEN_BUFFER_INFO, }
Sets up the console input and output handles
Flushes the input or output handle passed as argument.
returns cursor position in column, row format.
Returns a key event filled with the relavant information.
console_key_event :: struct { char :rune, scan_code :u16, repeat_count:u16, is_key_down :bool, }
The scan_code can be cast to a Scancode enum type if you wish to use the incomplete Scancodes contained in the console package.
Scrolls the display. Note, cursor position will change.
Scrolls the display. Note, cursor position will change.
Delets from cursor column position to beginning of line.
Delets from cursor column position to end of line.
Delets the entire line regardless of cursor position.
Clears the screen. Does no move cursor to home position.
Move the cursor to desired column, row.
Moves the cursor to home position (column = row = 1)
Clears the screen and moves cursor to home position.
Set a graphics attribute not covered by any other procedure.
Set the text color to one of the FG_XXX or BG_XXX color enums from the ansi package.
Resets all graphics attributes
Returns the size of the console window in columns, rows
Write text to console at specified column, row. fg_col and bg_col are optional parameters to set the text color using 256 color format.