Trait surf_n_term::image::ImageHandler

source ·
pub trait ImageHandler: Send + Sync {
    // Required methods
    fn kind(&self) -> ImageHandlerKind;
    fn draw(
        &mut self,
        out: &mut dyn Write,
        img: &Image,
        pos: Position
    ) -> Result<(), Error>;
    fn erase(
        &mut self,
        out: &mut dyn Write,
        img: &Image,
        pos: Option<Position>
    ) -> Result<(), Error>;
    fn handle(
        &mut self,
        out: &mut dyn Write,
        event: &TerminalEvent
    ) -> Result<bool, Error>;
}
Expand description

Image rendering/handling interface

Required Methods§

source

fn kind(&self) -> ImageHandlerKind

Name

source

fn draw( &mut self, out: &mut dyn Write, img: &Image, pos: Position ) -> Result<(), Error>

Draw image

Send an appropriate terminal escape sequence so the image would be rendered.

source

fn erase( &mut self, out: &mut dyn Write, img: &Image, pos: Option<Position> ) -> Result<(), Error>

Erase image at specified position

This is needed when erasing characters is not actually removing image from the terminal. For example kitty needs to send separate escape sequence to actually erase image. If position is not specified all matching images are deleted.

source

fn handle( &mut self, out: &mut dyn Write, event: &TerminalEvent ) -> Result<bool, Error>

Handle events from the terminal

True means event has been handled and should not be propagated to a user

Trait Implementations§

source§

impl ImageHandler for Box<dyn ImageHandler>

source§

fn kind(&self) -> ImageHandlerKind

Name
source§

fn draw( &mut self, out: &mut dyn Write, img: &Image, pos: Position ) -> Result<(), Error>

Draw image Read more
source§

fn erase( &mut self, out: &mut dyn Write, img: &Image, pos: Option<Position> ) -> Result<(), Error>

Erase image at specified position Read more
source§

fn handle( &mut self, out: &mut dyn Write, event: &TerminalEvent ) -> Result<bool, Error>

Handle events from the terminal Read more

Implementations on Foreign Types§

source§

impl ImageHandler for Box<dyn ImageHandler>

source§

fn kind(&self) -> ImageHandlerKind

source§

fn draw( &mut self, out: &mut dyn Write, img: &Image, pos: Position ) -> Result<(), Error>

source§

fn erase( &mut self, out: &mut dyn Write, img: &Image, pos: Option<Position> ) -> Result<(), Error>

source§

fn handle( &mut self, out: &mut dyn Write, event: &TerminalEvent ) -> Result<bool, Error>

Implementors§