SalsaAppContext

Struct SalsaAppContext 

Source
pub struct SalsaAppContext<Event, Error>
where Event: 'static, Error: 'static,
{ /* private fields */ }
Expand description

Application context for event handling.

Add this to your global state and implement SalsaContext to access the facilities of rat-salsa. You can Default::default() initialize this field with some dummy values. It will be set correctly when calling run_tui.

Trait Implementations§

Source§

impl<Event, Error> Debug for SalsaAppContext<Event, Error>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Event, Error> Default for SalsaAppContext<Event, Error>
where Event: 'static, Error: 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Event, Error> SalsaContext<Event, Error> for SalsaAppContext<Event, Error>
where Event: 'static, Error: 'static,

Source§

fn set_salsa_ctx(&mut self, app_ctx: SalsaAppContext<Event, Error>)

The AppContext struct holds all the data for the rat-salsa functionality. run_tui calls this to set the initialized struct.
Source§

fn salsa_ctx(&self) -> &SalsaAppContext<Event, Error>

Access the AppContext previously set.
Source§

fn count(&self) -> usize

Get the current frame/render-count.
Source§

fn last_render(&self) -> Duration

Get the last render timing.
Source§

fn last_event(&self) -> Duration

Get the last event-handling timing.
Source§

fn set_window_title(&self, title: String)

Set a window title.
Source§

fn set_screen_cursor(&self, cursor: Option<(u16, u16)>)

Set the cursor, if the given value is something, hides it otherwise. Read more
Source§

fn add_timer(&self, t: TimerDef) -> TimerHandle

Add a timer. Read more
Source§

fn remove_timer(&self, tag: TimerHandle)

Remove a timer. Read more
Source§

fn replace_timer(&self, h: Option<TimerHandle>, t: TimerDef) -> TimerHandle

Replace a timer. Remove the old timer and create a new one. If the old timer no longer exists it just creates the new one. Read more
Source§

fn spawn_ext( &self, task: impl FnOnce(Cancel, &Sender<Result<Control<Event>, Error>>) -> Result<Control<Event>, Error> + Send + 'static, ) -> Result<(Cancel, Liveness), SendError<()>>
where Event: 'static + Send, Error: 'static + Send,

Add a background worker task. Read more
Source§

fn spawn( &self, task: impl FnOnce() -> Result<Control<Event>, Error> + Send + 'static, ) -> Result<(), SendError<()>>
where Event: 'static + Send, Error: 'static + Send,

Add a background worker task. Read more
Source§

fn queue_event(&self, event: Event)

Queue an application event.
Source§

fn queue(&self, ctrl: impl Into<Control<Event>>)

Queue additional results.
Source§

fn queue_err(&self, err: Error)

Queue an error.
Source§

fn set_focus(&self, focus: Focus)

Set the Focus.
Source§

fn take_focus(&self) -> Option<Focus>

Take the Focus back from the Context.
Source§

fn clear_focus(&self)

Clear the Focus.
Source§

fn focus<'a>(&'a self) -> Ref<'a, Focus>

Access the Focus. Read more
Source§

fn focus_mut<'a>(&'a mut self) -> RefMut<'a, Focus>

Mutably access the focus-field. Read more
Source§

fn handle_focus<E>(&mut self, event: &E) -> Outcome

Handle the focus-event and automatically queue the result. Read more
Source§

fn terminal(&mut self) -> Rc<RefCell<Terminal<CrosstermBackend<Stdout>>>>

Access the terminal.
Source§

fn clear_terminal(&mut self)

Clear the terminal and do a full redraw before the next draw.
Source§

fn insert_before( &mut self, height: u16, draw_fn: impl FnOnce(&mut Buffer) + 'static, )

Call insert_before() before the next draw.

Auto Trait Implementations§

§

impl<Event, Error> !Freeze for SalsaAppContext<Event, Error>

§

impl<Event, Error> !RefUnwindSafe for SalsaAppContext<Event, Error>

§

impl<Event, Error> !Send for SalsaAppContext<Event, Error>

§

impl<Event, Error> !Sync for SalsaAppContext<Event, Error>

§

impl<Event, Error> Unpin for SalsaAppContext<Event, Error>
where Error: Unpin, Event: Unpin,

§

impl<Event, Error> !UnwindSafe for SalsaAppContext<Event, Error>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.