Skip to main content

Crate terminal_graphics_interactive

Crate terminal_graphics_interactive 

Source
Expand description

Keyboard and mouse input for terminal_graphics.

Modules§

game
Terminal Games: a scene-based game loop with keys, mouse, drawing and random numbers. Everything except run is plain Rust with no terminal access, so games can be tested and played headless.
graphics
Everything that is drawn on a Display is a graphic.
prelude
Everything in one import: use terminal_graphics_interactive::prelude::*;

Structs§

Cell
What a formula is told about the cell it is colouring.
Container
A bordered, filled box that can hold one other Graphic.
Display
The terminal buffer: a grid of Pixels that you draw into, then print.
Graphics
A collection of named graphics, drawn in the order they were added (later graphics are drawn on top of earlier ones).
Key
A key press: which key, and which modifiers were held.
Modifiers
Modifier keys held down during an event.
Mouse
A mouse event at a position on the terminal screen.
Palette
A ramp of colours from dark to bright. A number from 0.0 to 1.0 picks a point along the ramp.
ParseColourError
The error returned when parsing a colour name that matches no variant.
Parser
An incremental parser for terminal input.
Pixel
One cell of the terminal grid: a character, a foreground colour and a background colour.
Pointer
Where the mouse is and what it is doing, in cells.
RawMode
Puts the terminal into raw mode until it is dropped.
Renderer
Writes frames to any Write, sending only the cells that changed since the last frame. The first frame clears the screen and draws everything; after that a frame costs only the cells that differ, and an unchanged frame costs nothing.
Simulation
The world’s state and rules, with no terminal in sight so it can be tested.
Terminal
An interactive terminal session: keyboard and mouse input for a program that draws with Display.
Text
A single line of text.
World
A world of bouncing balls, described with a few chained settings and started with World::run.

Enums§

Colour
One of the 16 ANSI terminal colours.
Event
One input event.
KeyCode
Which key was pressed.
MouseButton
A mouse button.
MouseKind
What the mouse did.

Constants§

MOUSE_OFF
Escape sequence that turns mouse reporting back off.
MOUSE_ON
Escape sequence that asks the terminal to report mouse buttons, dragging and scrolling in SGR format (1002 is button and drag tracking, 1006 is the SGR encoding, which works for terminals wider than 223 columns).

Traits§

Graphic
Anything that can be drawn onto a Display.

Functions§

sketch
Fills the window every frame from a formula, until the user presses q.
sketch_frame
Draws one frame of a sketch into display, with no terminal: every cell is coloured from formula, which returns a number from -1.0 to 1.0.
sketch_with
Like sketch, with a choice of Palette.