Crate surf_n_term[−][src]
This crate is used to interract 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 - implementes Terminal trait // - event - is a TerminalEvent // - view - is a Suface that can be used to render on, see render module for defails 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 color::Blend; | |
pub use color::Color; | |
pub use color::ColorLinear; | |
pub use color::RGBA; | |
pub use error::Error; | |
pub use face::Face; | |
pub use face::FaceAttrs; | |
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::KeyMap; | |
pub use keys::KeyMod; | |
pub use keys::KeyName; | |
pub use render::Cell; | |
pub use render::TerminalSurface; | |
pub use render::TerminalSurfaceExt; | |
pub use render::TerminalWritable; | |
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::TerminalColor; | |
pub use terminal::TerminalCommand; | |
pub use terminal::TerminalEvent; | |
pub use terminal::TerminalSize; | |
pub use terminal::TerminalWaker; |
Modules
automata | NFA and DFA |
color | Color definition |
common | Common utility funcitons 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 |
widgets |
Enums
FillRule | The algorithm to use to determine the inside part of a shape, when filling it. |
Type Definitions
SystemTerminal | System specific terminal |