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
runis plain Rust with no terminal access, so games can be tested and played headless. - graphics
- Everything that is drawn on a
Displayis 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.
- Parse
Colour Error - 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.
- Mouse
Button - A mouse button.
- Mouse
Kind - 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 (
1002is button and drag tracking,1006is the SGR encoding, which works for terminals wider than 223 columns).
Traits§
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 fromformula, which returns a number from -1.0 to 1.0. - sketch_
with - Like
sketch, with a choice ofPalette.