Skip to main content

Command

Struct Command 

Source
pub struct Command<Msg> { /* private fields */ }
Expand description

Work for the runtime, returned from App::update.

Implementations§

Source§

impl<Msg: Send + 'static> Command<Msg>

Source

pub fn none() -> Self

Nothing to do.

Source

pub fn batch(commands: impl IntoIterator<Item = Self>) -> Self

Several commands, run in order.

Source

pub fn quit() -> Self

Leaves the application after this update.

Source

pub fn focus(name: impl Into<String>) -> Self

Moves keyboard focus to the widget named name with NodeMut::id. When no such widget is on screen yet, focus moves to it after the next frame if it appears there, so an update can show a widget and focus it at once.

Source

pub fn set_theme(id: impl Into<String>) -> Self

Switches to theme id. An unusable theme falls back to the default and is reported in the environment’s diagnostics.

Source

pub fn set_locale(code: impl Into<String>) -> Self

Switches the language to locale code.

Source

pub fn set_icon_mode(mode: IconMode) -> Self

Switches between Nerd Font, Unicode, ASCII or detected glyphs.

Source

pub fn set_reduced_motion(reduced: bool) -> Self

Turns reduced motion on or off: layers appear at once and nothing breathes or spins. Has no effect while the QUVYTA_REDUCED_MOTION environment variable decides.

Source

pub fn set_pillar(style: PillarStyle) -> Self

Draws every pillar in style over the theme’s choice.

Source

pub fn set_slide(slide: bool) -> Self

Turns the one-cell slide of hovered and selected entries in list structures (lists, menus, trees, tables, tab rails, setting rows, dropdown options and tabs) on or off over the theme’s motion.slide. Buttons and other controls never slide.

Source

pub fn copy(text: impl Into<String>) -> Self

Copies text to the system clipboard (OSC 52, which also works over SSH) and to the application’s in-process clipboard, which keeps pasting inside the application working on terminals without OSC 52.

Source

pub fn read_clipboard( message: impl FnOnce(Option<String>) -> Msg + 'static, ) -> Self

Reads the clipboard and delivers its text, or None when there is none. Like the paste key and Paste menu entries it tries, in order: the system clipboard through its tool (wl-paste, xclip or xsel, pbpaste; run without a shell, briefly, off the drawing thread), the terminal’s clipboard through an OSC 52 query (many terminals do not answer, so the wait is short), and the text copied last inside this application (by a widget, a selection or Command::copy). The message arrives in a later update once the text is known; drawing never waits for it. Text pasted with the terminal’s own paste arrives as Event::Paste instead.

Source

pub fn perform(work: impl FnOnce() -> Msg + Send + 'static) -> Self

Runs work on a background thread and delivers its message when done. Drawing never waits for it.

Source

pub fn confirm(confirm: Confirm<Msg>) -> Self

Asks the user a question in a dialog the runtime shows over the application, and delivers the message of their answer: the confirm message, or the cancel message (if any) for Cancel, Esc and the close mark. Cancel, the safe answer, has focus when the dialog opens. Several requests stack; the newest is answered first.

use qframe::prelude::*;

enum Msg {
    AskRemove,
    Remove,
}

fn update(msg: Msg) -> Command<Msg> {
    match msg {
        Msg::AskRemove => Command::confirm(
            Confirm::new("Remove container?", Msg::Remove).message("Its volumes are deleted too.").danger(),
        ),
        Msg::Remove => Command::none(),
    }
}
Source

pub fn toast(toast: Toast<Msg>) -> Self

Shows toast in the toast corner, above everything else. It slides in, stays for its duration (paused while the pointer is on it) and slides out; a click on its close mark dismisses it.

Source

pub fn dismiss_toast(key: impl Into<String>) -> Self

Removes the toast shown with Toast::key key.

Source

pub fn toast_corner(corner: Corner) -> Self

Stacks toasts in corner from now on; bottom right by default.

Source

pub fn task(task: Task<Msg>) -> Self

Starts task on a background thread. Its Started event is applied before this update returns; progress, messages and the outcome arrive as the work goes on.

Source

pub fn cancel_task(id: TaskId) -> Self

Asks task id to stop: its sleeps wake at once, TaskCx::is_cancelled turns true and it ends as TaskOutcome::Cancelled. Asking a finished task does nothing.

Auto Trait Implementations§

§

impl<Msg> !RefUnwindSafe for Command<Msg>

§

impl<Msg> !Send for Command<Msg>

§

impl<Msg> !Sync for Command<Msg>

§

impl<Msg> !UnwindSafe for Command<Msg>

§

impl<Msg> Freeze for Command<Msg>
where Vec<Action<Msg>>: Freeze,

§

impl<Msg> Unpin for Command<Msg>
where Vec<Action<Msg>>: Unpin,

§

impl<Msg> UnsafeUnpin for Command<Msg>
where Vec<Action<Msg>>: UnsafeUnpin,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.