pub struct DatePicker(/* private fields */);Expand description
Pick a day from a month grid. Returns the Date.
use rich_interact::datetime::Date;
use rich_interact::headless::{self, Script};
use rich_interact::{DatePicker, Outcome};
let picker = DatePicker::new("Due").value(Date::new(2026, 10, 17));
let script = Script::new().keys("right down enter");
let (outcome, record) = headless::run(picker, script, 40, 14);
assert_eq!(outcome.unwrap(), Outcome::Done(Date::new(2026, 10, 25)));
assert_eq!(record.last_frame(), "? Due › 2026-10-25");Implementations§
Source§impl DatePicker
impl DatePicker
pub fn new(prompt: impl Into<String>) -> DatePicker
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 today(self, today: Date) -> Self
pub fn today(self, today: Date) -> Self
The day marked as today and t goes to (default: today in
UTC).
Sourcepub fn default(self, date: Date) -> Self
pub fn default(self, date: Date) -> Self
Answer this day without a terminal and to an empty line, and start
on it unless value says where to start.
Trait Implementations§
Source§impl Component for DatePicker
impl Component for DatePicker
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<Date>
fn default_value(&self) -> Option<Date>
The default, unless the picker would refuse it: outside the range, or refused by the validator.
type Output = Date
Source§fn start(&mut self, _context: &Context<'_>) -> Flow<Date>
fn start(&mut self, _context: &Context<'_>) -> Flow<Date>
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 handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<Date>
fn handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<Date>
Handle one event. Ctrl+C never arrives here: the event loop ends the
component with
Outcome::Interrupted.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 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 prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<Date>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<Date>, 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
Auto Trait Implementations§
impl !Freeze for DatePicker
impl !RefUnwindSafe for DatePicker
impl !Sync for DatePicker
impl !UnwindSafe for DatePicker
impl Send for DatePicker
impl Unpin for DatePicker
impl UnsafeUnpin for DatePicker
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.