pub struct BlinkState {
pub is_visible: bool,
pub last_input_time: Option<Instant>,
pub blink_timer_active: bool,
pub blink_interval: Duration,
}Expand description
Cursor blink animation state.
Extracted from the old CursorManager so it can live independently
on TextEditManager without coupling to cursor position.
Fields§
§is_visible: boolWhether the cursor is currently visible (toggled by blink timer)
last_input_time: Option<Instant>Timestamp of the last user input event (keyboard, mouse click in text). Used to determine whether to blink or stay solid while typing.
blink_timer_active: boolWhether the cursor blink timer is currently active
blink_interval: DurationHow long the caret stays solid after input before blinking resumes, and the interval the blink timer is armed with.
Defaults to CURSOR_BLINK_INTERVAL; caret-animation-duration on the
focused node overrides it, in whichever unit the stylesheet used.
Implementations§
Source§impl BlinkState
impl BlinkState
pub fn new() -> Self
Sourcepub const fn set_blink_interval(&mut self, interval: Duration)
pub const fn set_blink_interval(&mut self, interval: Duration)
Override the blink interval (from caret-animation-duration).
Takes a Duration rather than milliseconds so a t-unit stylesheet
value stays a frame count: a 5t caret flips on the 5th frame exactly,
on any machine, at any load.
Sourcepub fn reset_blink_on_input(&mut self, now: Instant)
pub fn reset_blink_on_input(&mut self, now: Instant)
Reset blink on user input — cursor stays solid until blink interval elapses.
Sourcepub const fn toggle_visibility(&mut self) -> bool
pub const fn toggle_visibility(&mut self) -> bool
Toggle cursor visibility (called by blink timer callback).
pub const fn set_visibility(&mut self, visible: bool)
pub const fn set_blink_timer_active(&mut self, active: bool)
pub const fn is_blink_timer_active(&self) -> bool
Sourcepub fn should_blink(&self, now: &Instant) -> bool
pub fn should_blink(&self, now: &Instant) -> bool
Check if enough time has passed since last input to start blinking.
The interval is Self::blink_interval, compared unit-aware: a tick
interval against wall-clock elapsed time (or the reverse) both answer
truthfully. This used to build a Duration::System constant inline, which
meant a tick-driven clock produced a Duration::Tick elapsed value that
could never be “greater than” it — the caret stopped blinking, silently
and permanently, on every clockless build.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear all blink state (when editing ends).
The interval goes back to the default too: it was read off the node that
just lost focus, and leaving it behind would apply that node’s
caret-animation-duration to the next element focused — including one
that never set the property.
Trait Implementations§
Source§impl Clone for BlinkState
impl Clone for BlinkState
Source§fn clone(&self) -> BlinkState
fn clone(&self) -> BlinkState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlinkState
impl Debug for BlinkState
Auto Trait Implementations§
impl Freeze for BlinkState
impl RefUnwindSafe for BlinkState
impl Send for BlinkState
impl Sync for BlinkState
impl Unpin for BlinkState
impl UnsafeUnpin for BlinkState
impl UnwindSafe for BlinkState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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