Expand description
This crate is used to interact with Posix terminal. It can be used to
- Read events from the terminal
- Send commands to the terminal
- Render on a surface which will be reconciled with current content of the terminal
- Issue direct commends to the terminal
- Supports kitty/sixel image protocol
§Simple example
use surf_n_term::{Terminal, TerminalEvent, TerminalAction, SystemTerminal, Error};
fn main() -> Result<(), Error> {
let ctrl_c = TerminalEvent::Key("ctrl+c".parse()?);
let mut term = SystemTerminal::new()?;
term.run_render(|term, event, mut view| -> Result<_, Error> {
// This function will be executed on each event from terminal
// - term - implements Terminal trait
// - event - is a TerminalEvent
// - view - is a Surface that can be used to render on, see render module for details
match event {
Some(event) if &event == &ctrl_c => {
// exit if 'ctrl+c' is pressed
Ok(TerminalAction::Quit(()))
}
_ => {
// do some rendering by updating the view
Ok(TerminalAction::Wait)
},
}
})?;
Ok(())
}Re-exports§
pub use error::Error;pub use face::Face;pub use face::FaceAttrs;pub use face::FaceDeserializer;pub use face::FaceModify;pub use face::UnderlineStyle;pub use glyph::Glyph;pub use image::ColorPalette;pub use image::Image;pub use image::ImageHandler;pub use image::KittyImageHandler;pub use image::SixelImageHandler;pub use keys::Key;pub use keys::KeyChord;pub use keys::KeyMap;pub use keys::KeyMapHandler;pub use keys::KeyMod;pub use keys::KeyName;pub use render::Cell;pub use render::CellWrite;pub use render::TerminalSurface;pub use render::TerminalSurfaceExt;pub use render::TerminalWriter;pub use surface::Shape;pub use surface::Surface;pub use surface::SurfaceIter;pub use surface::SurfaceMut;pub use surface::SurfaceMutIter;pub use surface::SurfaceMutView;pub use surface::SurfaceOwned;pub use surface::SurfaceOwnedView;pub use surface::SurfaceView;pub use terminal::DecMode;pub use terminal::DecModeStatus;pub use terminal::Position;pub use terminal::Size;pub use terminal::Terminal;pub use terminal::TerminalAction;pub use terminal::TerminalCaps;pub use terminal::TerminalColor;pub use terminal::TerminalCommand;pub use terminal::TerminalEvent;pub use terminal::TerminalSize;pub use terminal::TerminalWaker;pub use rasterize;
Modules§
- automata
- NFA and DFA
- common
- Common utility functions used across different modules
- decoder
- Decoders
- encoder
- Encoders
- error
- Error type
- face
- Type describing foreground/background/style-attrs of the terminal cell
- glyph
- image
- Handling everything to do with images.
- keys
- render
- Terminal rendering logic
- surface
- Surface object
- terminal
- Main interface to interact with terminal
- view
- Defines View that represents anything that can be rendered into a terminal. As well as some useful implementations such as Text, Flex, Container, …
Structs§
- BBox
- Bounding box with sides directed along the axes
- LinColor
- Alpha premultiplied RGBA color in the linear color space (no gamma correction)
- Path
- Collection of the SubPath treated as a single unit. Represents the same concept as an SVG path
- RGBA
- sRGBA color packed as [u8; 4]
Enums§
- Fill
Rule - The algorithm to use to determine the inside part of a shape, when filling it.
Traits§
- Color
- Common interface to all color representations
Type Aliases§
- System
Terminal - System specific terminal