pub struct EditPopupState {
pub setting: &'static EditableSetting,
pub kind: EditPopupKind,
pub buffer: String,
pub caret: usize,
pub original: String,
pub opened_mtime: Option<SystemTime>,
pub stale_overwrite_armed: bool,
}Expand description
State for the harmonized edit popup.
Fields§
§setting: &'static EditableSettingSchema entry being edited. Carries key, file, kind, sensitivity.
kind: EditPopupKindType-specific control state.
buffer: StringText buffer used by Int/Text/Secret variants. For Bool/Enum it is
kept as the canonical string of the current selection so that
Ctrl+S always has a single value to write.
caret: usizeCaret position (byte index) inside buffer for Int/Text/Secret.
original: StringCanonical value the popup opened with; Ctrl+Z resets back to it.
opened_mtime: Option<SystemTime>Target file’s modification time when the popup opened. Used to warn when the file changed on disk while the popup was editing.
stale_overwrite_armed: boolSet after the first save attempt hit an mtime mismatch; the next
save proceeds anyway (explicit user confirmation via repeat Ctrl+S).
Implementations§
Source§impl EditPopupState
impl EditPopupState
Sourcepub fn from_current(setting: &'static EditableSetting, current: &str) -> Self
pub fn from_current(setting: &'static EditableSetting, current: &str) -> Self
What: Build a popup for setting initialized from current on-disk
(or in-memory) value.
Inputs:
setting: Schema row to edit.current: Current canonical string value, or the effective default if the file did not have the key.
Output:
- Popup state ready for the renderer/handler.
Details:
- For
Bool, parsestrue/yes/on/1astrue(everything else asfalse). - For
Enum, snaps tochoices[0]ifcurrentis not in the list. - For
IntRange, clamps the parsed integer into the schema range. - For
Secret, starts unrevealed;currentis loaded into the buffer so saving without typing keeps the existing value, but the renderer masks it.
Sourcepub fn canonical_value(&self) -> String
pub fn canonical_value(&self) -> String
What: Compute the canonical string the editor should write for this
popup if the user invoked Ctrl+S right now.
Inputs: None.
Output:
- The on-disk representation; for Bool/Enum this is the selected choice; otherwise it is the trimmed buffer.
Details:
- The handler is responsible for additional validation (Int range,
OptionalUnsignedOrAllparsing). This method only normalizes.
Trait Implementations§
Source§impl Clone for EditPopupState
impl Clone for EditPopupState
Source§fn clone(&self) -> EditPopupState
fn clone(&self) -> EditPopupState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for EditPopupState
impl RefUnwindSafe for EditPopupState
impl Send for EditPopupState
impl Sync for EditPopupState
impl Unpin for EditPopupState
impl UnsafeUnpin for EditPopupState
impl UnwindSafe for EditPopupState
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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