pub struct CommandPalette<Msg> { /* private fields */ }Expand description
A layer with a filter field over a list of commands, for running anything from the keyboard.
Typing filters the commands with fuzzy matching, best matches first, matched characters in
the match colour. ↑/↓ (or Ctrl+P/Ctrl+N), PgUp/PgDn move the highlight, Enter runs the
highlighted command. The mouse does the same: moving the pointer over a row moves the one
highlight (a pointer resting where the palette opened waits until it moves), a click runs
the clicked command and the wheel scrolls. It is dismissable by default: Esc, the close
mark × at the top right and a click on the dimmed screen close it;
dismissable(false) turns all three off. Running sends the
close message first, then the command’s message. Only visible rows are drawn, so thousands of
commands stay fast. Add it to the view while it should be shown; it opens as a modal layer
in the upper part of the screen. Applications usually open it from the global palette
action, bound to Ctrl+P.
With no options it lists the given commands. keymap adds the keymap’s actions with
their keys; recent lists the given command ids first under “Recent” while nothing is
typed; on_run reports which command ran, e.g. to remember recent ones.
Style keys: modal (with its pillar down the left edge), close-mark, layer-backdrop,
layer-filter, layer-filter-mark, layer-filter-placeholder, layer-filter-cursor,
layer-match, palette-item with hover (bg, fg, pillar), palette-chord,
palette-header, layer-hint-key, layer-hint-label. Text: quvyta.palette.*,
quvyta.layer.*.
Implementations§
Source§impl<Msg: Clone + 'static> CommandPalette<Msg>
impl<Msg: Clone + 'static> CommandPalette<Msg>
Sourcepub fn new(
commands: impl IntoIterator<Item = PaletteCommand<Msg>>,
on_close: Msg,
) -> Self
pub fn new( commands: impl IntoIterator<Item = PaletteCommand<Msg>>, on_close: Msg, ) -> Self
A palette of commands; dismissing it (Esc, the close mark, a click outside) and running a
command send on_close.
Sourcepub fn keymap(self, include: bool) -> Self
pub fn keymap(self, include: bool) -> Self
Also lists the keymap’s actions (except moving focus and the palette itself), labelled
from the language files and showing their first key. Running one runs the action as if
its key had been pressed. Their ids are action:<name>.
Sourcepub fn recent(self, ids: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn recent(self, ids: impl IntoIterator<Item = impl Into<String>>) -> Self
Ids of recently run commands, most recent first, listed on top while nothing is typed.
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
The faint text of the empty filter; quvyta.palette.placeholder by default.
Sourcepub fn width(self, cells: u16) -> Self
pub fn width(self, cells: u16) -> Self
Width in cells, padding included; 72 by default. Narrow screens shrink it.
Sourcepub fn dismissable(self, dismissable: bool) -> Self
pub fn dismissable(self, dismissable: bool) -> Self
Whether Esc, the close mark and a click on the dimmed screen close the palette; true by
default. With false none of them works and the mark is not drawn; running a command
still sends the close message.
Trait Implementations§
Source§impl<Msg: Clone + 'static> Widget<Msg> for CommandPalette<Msg>
impl<Msg: Clone + 'static> Widget<Msg> for CommandPalette<Msg>
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, _available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, _available: Size) -> Size
available.Source§fn paint_overlay(&self, cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for CommandPalette<Msg>
impl<Msg> !Send for CommandPalette<Msg>
impl<Msg> !Sync for CommandPalette<Msg>
impl<Msg> !UnwindSafe for CommandPalette<Msg>
impl<Msg> Freeze for CommandPalette<Msg>
impl<Msg> Unpin for CommandPalette<Msg>
impl<Msg> UnsafeUnpin for CommandPalette<Msg>where
Vec<PaletteCommand<Msg>>: UnsafeUnpin,
Msg: UnsafeUnpin,
Option<Box<dyn Fn(&str) -> Msg>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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