Crate term_basics_linux
source ·Expand description
Examples
use term_basics_linux as tbl;
for sty in tbl::TextStyle::iterator(){
for bg in tbl::UC::iterator(){
for fg in tbl::UC::iterator(){
tbl::println_cols_style("cool and good", *fg, *bg, *sty);
}
}
}
use term_basics_linux as tbl;
let name = tbl::prompt("type your name: ");
tbl::print("Your name: ");
tbl::println(name);
Structs
A struct that holds information about a history of typed input’s but the user.
Enums
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.All styles that do not alter fg or bg colours.
User Colours(UC) available. The user has defined the exact values of
these colours for there TTY or emulator.
To specify if you set the foreground or background colour.
Functions
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
.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.
Returns the character as u8 typed by the user.
It will return immediately after being typed, without the user pressing ‘enter’.
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.
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
.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 to stdout, it is just print!(“{}”, msg);
Here to stay consistent
Print to stdout with a text colour.
Print to stdout with text and background colours.
Print to stdout with text and background colours and style.
Print to stdout with text style.
Print to stdout, it is just println!(“{}”, msg);
Here to stay consistent
Print to stdout with a text colour.
Print to stdout with text and background colours.
Print to stdout with text and background colours and style.
Print to stdout with text style.
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.
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.
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.
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.
Resets foreground colour, background colour and text style.
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.
Resets the style.
It sets the style to the default style.
Restores the colour from the state.
set_colour
will set the state and use colour will not.Restores all colours from state.
It is used after a call like
use_colour
to get back to the old colours.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
.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.Sets both foreground and background colours.
It will print linux colour escape characters to std out.
It will set the state.
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.
Small helper to parse string to a value
Prints the result of getch as u8, infinite loop. Can be used for testing.
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.Sets both foreground and background colours.
It will print linux colour escape characters to std out.
It will not set the state.
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
.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.