[−][src]Crate crossterm
Have you ever been disappointed when a terminal library for rust was only written for UNIX systems? Crossterm provides clearing, input handling, styling, cursor movement, and terminal actions for both Windows and UNIX systems.
Crossterm aims to be simple and easy to call in code. Through the simplicity of Crossterm, you do not have to worry about the platform you are working with.
This crate supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested see Tested Terminals for more info).
This crate consists of five modules that are provided behind feature flags so that you can define which features you'd like to have; by default, all features are enabled.
Macros
execute | Execute one or more command(s) |
queue | Queue one or more command(s) for execution in the near future. |
Structs
AlternateScreen | With this type you will be able to switch to the alternate screen and then back to the main screen. Check also the Screen type for switching to alternate mode. |
AsyncReader | This type allows you to read the input asynchronously which means that input events are gathered on the background and will be queued for you to read. |
BlinkOff | When executed, this command will disable cursor blinking. |
BlinkOn | When executed, this command will enable cursor blinking. |
Clear | When executed, this command will clear the terminal buffer based on the type provided. |
Crossterm | This type offers an easy way to use functionalities like |
Down | When executed, this command will move the current cursor position |
Goto | When executed, this command will move the cursor position to the given |
Hide | When executed, this command will hide de cursor in the console. |
Left | When executed, this command will move the current cursor position |
ObjectStyle | Struct that contains the style properties that can be applied to a displayable object. |
Output | When executed, this command will output the given string to the terminal. |
PrintStyledFont | When executed, this command will print the styled font to the terminal. |
RawScreen | A wrapper for the raw terminal state, which can be used to write to. |
ResetPos | When executed, this command will return the cursor position to the saved cursor position |
Right | When executed, this command will move the current cursor position |
SavePos | When executed, this command will save the cursor position for recall later. |
ScrollDown | When executed, this command will scroll down the terminal buffer by the given number of times. |
ScrollUp | When executed, this command will scroll up the terminal buffer by the given number of times. |
SetAttr | When executed, this command will set the given attribute to the terminal. |
SetBg | When executed, this command will set the background color of the terminal to the given color. |
SetFg | When executed, this command will set the foreground color of the terminal to the given color. |
SetSize | When executed, this command will set the terminal sie to the given ( |
Show | When executed, this command will show de cursor in the console. |
StyledObject | Contains both the style and the content which can be styled. |
SyncReader | This type allows you to read input synchronously, which means that reading calls will block. |
Terminal | Allows you to preform actions on the terminal. |
TerminalColor | Allows you to style the terminal. |
TerminalCursor | Allows you to preform actions with the terminal cursor. |
TerminalInput | Allows you to read user input. |
Up | When executed, this command will move the current cursor position |
Enums
Attribute | Enum with the different attributes to style your test. |
ClearType | Enum with the different values to clear the terminal. |
Color | Enum with the different colors to color your test and terminal. |
Colored | Could be used to color the foreground or background color. |
ErrorKind | Wrapper for all errors that can occur in |
InputEvent | Enum to specify which input event has occurred. |
KeyEvent | Enum with different key or key combinations. |
MouseButton | Enum to define mouse buttons. |
MouseEvent | Enum to specify which mouse event has occurred. |
Traits
Colorize | Provides a set of methods to color any type implementing |
Command | A command is an action that can be performed on the terminal. |
ExecutableCommand | A trait that defines behaviour for a command that will be executed immediately. |
IntoRawMode | Types which can be converted into "raw mode". |
QueueableCommand | A trait that defines behaviour for a command that can be used to be executed at a later time point. This can be used in order to get more performance. |
Styler | Provides a set of methods to style any type implementing |
Functions
color | Get a |
cursor | Get a |
input | Get a |
style | This could be used to style a type that implements |
terminal | Get a |
Type Definitions
Result | The |