Console Engine
This library provides simple features for handling user's input and display for terminal applications.
Besides the user input and display, this library also provides some tools to build standalone "screens" that can be used just for printing.
It uses Crossterm as main tool for handling the screen and inputs. You don't have to worry about initalizing anything because the lib will handle this for you.
Summary
Features
- Build custom terminal display using shapes or text
- Terminal handling with a target frame per seconds
- Keyboard and mouse support
- Terminal resizing support
- You are not interested by keyboard/mouse handling, even terminal handling ? You can still build "screens" that will just print its content.
- Embedding screens to one another
- with feature
event
:- Manage inputs as they arrive
- with feature
form
:- Build self-managed forms with a set of inputs (text, checkboxes ...)
- Validate each input with a set of validation constraints
Platforms
Since it uses crossterm
, it should work on Windows, Linux and Mac (see Tested Terminals on Crossterm's page).
Example usage
ConsoleEngine (managing input & output)
use pixel;
use Color;
use KeyCode;
Screens (generating output)
use Screen;
use pixel;
Events (with feature event
)
(see examples for complete source code implementation)
loop
Forms (with feature form
)
(see examples for complete source code implementation)
// Define a theme for the form
let theme = FormStyle ;
// Create a new Form
let mut form = new;
form.;
form.;
/* ... */
while !form.is_finished
Documentation
Take a look at the generated documentation.
Examples
See examples :
- drag-and-drop : Move a rectangle with your mouse
- emojis : Display an emoji on the terminal
- events : Example usage of the event polling method.
- form-choices : Example usage of a
Checkbox
andRadio
FormFields - form-simple : Example creation and usage of a
Form
containing two inputs - form-text : Example usage of a
Text
FormField - form-validation : Example usage of Form Validation
- graph : Display a graph being generated with some values.
- lines : Draw random lines of random colors on the screen.
- lines-fps : Same example as lines, but with a FPS counter.
- mouse : Simple mouse clicking test
- screen-embed : Example usage of Screen's
print_screen
function to embed one screen into another - screen-extract : Example usage of Screen's
extract
function to extract part of a screen - screen-simple : Example usage of Screen struct instead of ConsoleEngine
- screen-swap : Swap between several Screen structures
- scroll : Example for the
scroll
function - scroll-smooth : Example for smooth scrolling (windows only as of crossterm 0.26.1)
- shapes : Shape's functions testing tool
- snake : A simple game of snake.
- styled-rect : Example of the
rect_border
function - tetris : A game of Tetris
Media
Trustworthiness
It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.