pub trait Backend {
// Required methods
fn present(&mut self, grid: &Grid, out: &mut dyn Write) -> Result<()>;
fn invalidate(&mut self);
// Provided methods
fn scroll(
&mut self,
_from: &Grid,
_to: &Grid,
_area: Rect,
_rows: i32,
_out: &mut dyn Write,
) -> Result<()> { ... }
fn gliding(&self) -> Option<Duration> { ... }
fn glide(&mut self, _now: Instant, _out: &mut dyn Write) -> Result<()> { ... }
fn settle(&mut self) { ... }
fn set_lines(&mut self, _lines: u16) { ... }
fn foot_drops(&self, _rows: u16, _foot: u16) -> Vec<usize> { ... }
}Expand description
Presents a grid. Implementations send only what changed since the last call.
Required Methods§
fn present(&mut self, grid: &Grid, out: &mut dyn Write) -> Result<()>
Sourcefn invalidate(&mut self)
fn invalidate(&mut self)
Forgets what the terminal shows, so the next present redraws everything.
Provided Methods§
Sourcefn scroll(
&mut self,
_from: &Grid,
_to: &Grid,
_area: Rect,
_rows: i32,
_out: &mut dyn Write,
) -> Result<()>
fn scroll( &mut self, _from: &Grid, _to: &Grid, _area: Rect, _rows: i32, _out: &mut dyn Write, ) -> Result<()>
Starts moving area from one grid to the other, rows lines further down the content,
or up if negative, and carries on from where it is if it’s already moving. The moving
happens in glide. Tiers that can’t move
anything by less than a cell do nothing, and the page just jumps.
Sourcefn gliding(&self) -> Option<Duration>
fn gliding(&self) -> Option<Duration>
How often a scroll under way wants to move, if there is one.
Sourcefn glide(&mut self, _now: Instant, _out: &mut dyn Write) -> Result<()>
fn glide(&mut self, _now: Instant, _out: &mut dyn Write) -> Result<()>
Moves a scroll under way one step on.
Sourcefn set_lines(&mut self, _lines: u16)
fn set_lines(&mut self, _lines: u16)
How many lines the terminal has. Only a backend whose rows aren’t the terminal’s lines needs telling: it fills what’s left under its last row.
Sourcefn foot_drops(&self, _rows: u16, _foot: u16) -> Vec<usize>
fn foot_drops(&self, _rows: u16, _foot: u16) -> Vec<usize>
How far below its own place each of the last foot rows of rows is drawn, in
pixels, the last of them last. Only a backend that stands its foot’s rows apart in
what’s under the sheets says anything: a press there is then on the row drawn where
it lands, which isn’t the row that begins there.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".