pub struct ColorPicker { /* private fields */ }Expand description
Pick a colour. Returns it as a string in the ColorFormat chosen.
Implementations§
Source§impl ColorPicker
impl ColorPicker
pub fn new(prompt: impl Into<String>) -> ColorPicker
pub fn format(self, format: ColorFormat) -> Self
Sourcepub fn value(self, value: impl Into<String>) -> Self
pub fn value(self, value: impl Into<String>) -> Self
Start with this typed: a name to filter by, or a colour.
Sourcepub fn default(self, color: impl Into<String>) -> Self
pub fn default(self, color: impl Into<String>) -> Self
The colour returned without a terminal, and for an empty line at a
line prompt. One that is not a colour (ColorPicker::is_color)
is reported when the line prompt starts, and is no default.
Sourcepub fn is_color(text: &str) -> bool
pub fn is_color(text: &str) -> bool
Whether text is a colour the picker takes: a rich name, #rrggbb,
rgb(r,g,b) or color(N). Check a default with it up front.
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do action (in context color; see
keymap) on this picker only; no keys unbinds
it.
pub fn theme(self, theme: Theme) -> Self
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
Report the mouse: a click focuses a colour, a second click picks it.
Trait Implementations§
Source§impl Component for ColorPicker
impl Component for ColorPicker
type Output = String
Source§fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<String>
fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<String>
Handle one event. Ctrl+C never arrives here: the event loop ends the
component with
Outcome::Interrupted.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
The bindings this component has right now, for a help overlay, a
shortcut list or status-bar hints to read (see
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
Whether the component wants mouse events (#476): clicks, drags and
the wheel. Off by default, since reporting the mouse takes text
selection away from the terminal; a component turns it on when its
caller opts in, and
run then enables mouse reporting
for the session.Source§fn default_value(&self) -> Option<String>
fn default_value(&self) -> Option<String>
The value to return when the terminal is not interactive and the
policy asks for defaults.
None: there is none.Source§fn prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<String>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<String>, NotInteractive>
Ask for the value line by line, for when the terminal is not
interactive and the policy asks for a prompt. The default says the
component has no line-based form. Read more
Source§fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
Called once, before the component is first painted, with the
terminal’s size: for work that needs it, such as rendering content
at the width. Returning
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
How often the component wants
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Whether the component takes focus in a container: Tab stops on it
and keys go to it. The default: yes. A label, or a component that
has finished, says no.
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
Move focus to the next (
forward) or previous focus stop inside
this component, for Tab and Shift+Tab. false when there is none
after the current one, so the container moves on to its next
child. The default, for a component that is one stop: false.Auto Trait Implementations§
impl !Freeze for ColorPicker
impl !RefUnwindSafe for ColorPicker
impl !Sync for ColorPicker
impl Send for ColorPicker
impl Unpin for ColorPicker
impl UnsafeUnpin for ColorPicker
impl UnwindSafe for ColorPicker
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
Mutably borrows from an owned value. Read more
Source§impl<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
Turn this component’s answer into
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.