[][src]Crate term_basics_linux

Structs

InputHistory

A struct that holds information about a history of typed input's but the user.

Enums

FGBG

To specify if you set the foreground or background colour.

PromptChar

What kind of character the prompt will print. Copy will just print what the user types in. Substitude(char) will print that character. None will not print anything at all.

TextStyle

All styles that do not alter fg or bg colours.

UserColour

Colours available. The user has defined the exact values of these colours for there TTY or emulator.

Functions

discard_newline_on_prompt_nexttime

Call this before input_field or it's variations if you want to NOT print a newline(\n) after the user presses enter. This will work for the next time you call any version of input_field. To cancel it you can call use_newline_on_prompt.

flush

Flushes stdout. When you do print! or term-basics-linux equivalent, it will not print immediately. For example if you print! and then input_field(), it will print after you typed in the input. flush() will make sure everything is printed first.

getch

Returns the character as u8 typed by the user. It will return immediately after being typed, without the user pressing 'enter'.

input_field

Lets the user type text. It returns the string after the user presses 'enter'. It supports moving the cursor with the arrow keys, going to the begin and end of the line using 'home' and 'end' and deleting characters with backspace and the delete key.

input_field_custom

Lets the user type text. It returns the string after the user presses 'enter'. It supports all functions input_field() supports. You can specify your own InputHistory and PromptChar.

input_field_scrollable

Lets the user type text. It returns the string after the user presses 'enter'. It supports all functions input_field() supports. It also supports scrolling through the history of earlier typed strings with the 'up' and 'down' arrow keys.

print

Print to stdout, it is just print!("{}", msg); Here to stay consistent

print_col

Print to stdout with a text colour.

print_cols

Print to stdout with text and background colours.

print_cols_style

Print to stdout with text and background colours and style.

print_style

Print to stdout with text style.

println

Print to stdout, it is just println!("{}", msg); Here to stay consistent

println_col

Print to stdout with a text colour.

println_cols

Print to stdout with text and background colours.

println_cols_style

Print to stdout with text and background colours and style.

println_style

Print to stdout with text style.

prompt

Prints a message to the user. The user can type its input next to the message on the same line. It will return the user input after the user pressed enter. It uses term_basics_linux::input_field and supports the same operations.

prompt_custom

Prints a message to the user. The user can type its input next to the message on the same line. It will return the user input after the user pressed enter. It uses term_basics_linux::input_field_custom and supports the same operations. So you can provide your own InputHistory and PromptChar.

prompt_masked

Prints a message to the user. The user can type its input next to the message on the same line. It will return the user input after the user pressed enter. It uses term_basics_linux::input_field_scrollable and supports the same operations.

prompt_scrollable

Prints a message to the user. The user can type its input next to the message on the same line. It will return the user input after the user pressed enter. It uses term_basics_linux::input_field_scrollable and supports the same operations.

reset_all

Resets foreground colour, background colour and text style.

reset_colours

Resets all the colours. It set the foreground and background colours to the standard colours, whatever they may be. This depends on your terminal emulator and or settings like bashrc or zshrc.

reset_style

Resets the style. It sets the style to the default style.

restore_colour

Restores the colour from the state. set_colour will set the state and use colour will not.

restore_colours

Restores all colours from state. It is used after a call like use_colour to get back to the old colours.

restore_style

Restores the style from the state. The state is set after calls like set_style Usually you restore it after a call like use_style.

set_colour

Sets the colour of the text printed after this call. It will print linux colour escape characters to std out. It will set the state, so you can use restore_colour to get it back.

set_colours

Sets both foreground and background colours. It will print linux colour escape characters to std out. It will set the state.

set_style

Sets the style of the text printed after this call. It will print linux colour escape characters to std out. It will also set the state.

string_to_bool
string_to_value

Small helper to parse string to a value

test_chars

Prints the result of getch as u8, infinite loop. Can be used for testing.

use_colour

Sets the colour of the text printed after this call. It will print linux colour escape characters to std out. It will not set the state, so you can not use restore_colour to get this state back.

use_colours

Sets both foreground and background colours. It will print linux colour escape characters to std out. It will not set the state.

use_newline_on_prompt

Call this to let any variation of input_field print a newline after the user presses enter. This is not needed, they will print a newline by default. This is used to cancel discard_newline_on_prompt_nexttime.

use_style

Sets the style of the text printed after this call. It will print linux colour escape characters to std out. It will not set the state so you can not restore it.