pub trait Backend {
fn finish(&mut self);
fn refresh(&mut self);
fn has_colors(&self) -> bool;
fn screen_size(&self) -> Vec2;
fn print_at(&self, pos: Vec2, text: &str);
fn clear(&self, color: Color);
fn set_color(&self, colors: ColorPair) -> ColorPair;
fn set_effect(&self, effect: Effect);
fn unset_effect(&self, effect: Effect);
fn start_input_thread(
&mut self,
event_sink: Sender<Option<Event>>,
input_request: Receiver<InputRequest>
) { ... }
fn prepare_input(&mut self, input_request: InputRequest) { ... }
}
Expand description
Trait defining the required methods to be a backend.
Required Methods
sourcefn finish(&mut self)
fn finish(&mut self)
Prepares to close the backend.
This should clear any state in the terminal.
sourcefn has_colors(&self) -> bool
fn has_colors(&self) -> bool
Should return true
if this backend supports colors.
sourcefn screen_size(&self) -> Vec2
fn screen_size(&self) -> Vec2
Returns the screen size.
sourcefn set_color(&self, colors: ColorPair) -> ColorPair
fn set_color(&self, colors: ColorPair) -> ColorPair
Starts using a new color.
This should return the previously active color.
sourcefn set_effect(&self, effect: Effect)
fn set_effect(&self, effect: Effect)
Enables the given effect.
sourcefn unset_effect(&self, effect: Effect)
fn unset_effect(&self, effect: Effect)
Disables the given effect.
Provided Methods
sourcefn start_input_thread(
&mut self,
event_sink: Sender<Option<Event>>,
input_request: Receiver<InputRequest>
)
fn start_input_thread(
&mut self,
event_sink: Sender<Option<Event>>,
input_request: Receiver<InputRequest>
)
Starts a thread to collect input and send it to the given channel.
event_trigger
will receive a value before any event is needed.
sourcefn prepare_input(&mut self, input_request: InputRequest)
fn prepare_input(&mut self, input_request: InputRequest)
Prepares the backend to collect input.
This is only required for non-thread-safe backends like BearLibTerminal where we cannot collect input in a separate thread.