pub struct TimePicker(/* private fields */);Expand description
Pick a time of day, field by field. Returns the Time.
use rich_interact::datetime::Time;
use rich_interact::headless::{self, Script};
use rich_interact::{Outcome, TimePicker};
let picker = TimePicker::new("Start").value(Time::new(9, 0, 0));
let script = Script::new().text("1415").keys("enter");
let (outcome, _) = headless::run(picker, script, 40, 6);
assert_eq!(outcome.unwrap(), Outcome::Done(Time::new(14, 15, 0)));Implementations§
Source§impl TimePicker
impl TimePicker
pub fn new(prompt: impl Into<String>) -> TimePicker
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 (#476): a click selects a day (a second click on it picks it) or focuses a time field, and the wheel turns the month or the focused field.
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 (see date_keymap) on this picker
only; no keys unbinds it.
Sourcepub fn seconds(self, on: bool) -> Self
pub fn seconds(self, on: bool) -> Self
Pick the seconds too. Without them (the default) the picker works to the minute, whatever order the builders come in: the start, the default and a typed answer drop their seconds, the earliest rounds up to a minute and the latest down.
Sourcepub fn twelve_hour(self, on: bool) -> Self
pub fn twelve_hour(self, on: bool) -> Self
Show a 12-hour clock with AM and PM (a and p set them).
Sourcepub fn default(self, time: Time) -> Self
pub fn default(self, time: Time) -> Self
Answer this time without a terminal and to an empty line, and start
at it unless value says where to start.
Trait Implementations§
Source§impl Component for TimePicker
impl Component for TimePicker
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
Tab inside: the next part, if there is one.
Source§fn focus_enter(&mut self, forward: bool) -> bool
fn focus_enter(&mut self, forward: bool) -> bool
Tab from outside: the first part, or the last going back.
Source§fn default_value(&self) -> Option<Time>
fn default_value(&self) -> Option<Time>
The default, unless the picker would refuse it: outside the range, or refused by the validator.
type Output = Time
Source§fn start(&mut self, _context: &Context<'_>) -> Flow<Time>
fn start(&mut self, _context: &Context<'_>) -> Flow<Time>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<Time>
fn handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<Time>
Outcome::Interrupted.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<Time>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<Time>, NotInteractive>
Auto Trait Implementations§
impl !Freeze for TimePicker
impl !RefUnwindSafe for TimePicker
impl !Sync for TimePicker
impl !UnwindSafe for TimePicker
impl Send for TimePicker
impl Unpin for TimePicker
impl UnsafeUnpin for TimePicker
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<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,
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.