Skip to main content

StatusModel

Struct StatusModel 

Source
pub struct StatusModel<'a> {
    pub mode: Mode,
    pub line: usize,
    pub column: usize,
    pub prompt: PromptKind,
    pub prompt_text: &'a str,
    pub prompt_caret: usize,
    pub count: MatchCount,
    pub message: Option<&'a str>,
}
Expand description

Everything a status line needs, borrowed from the editor state.

Borrowed rather than owned so building it costs nothing per frame — a face may call this every redraw.

Fields§

§mode: Mode§line: usize

1-based, display-ready.

§column: usize

1-based, display-ready.

§prompt: PromptKind§prompt_text: &'a str

What has been typed into the prompt, without the sigil.

§prompt_caret: usize

Where the caret sits inside prompt_text, in CHARS.

Chars, not bytes, because a face positions a cursor by column and a byte index is the wrong number the moment the pattern contains é. A face draws its cursor at sigil_width + prompt_caret.

§count: MatchCount

[3/17]. MatchCount::Idle when there is nothing to say.

§message: Option<&'a str>

The newest message — vim’s E486 and friends. These were written to EditorState::messages from the start and had no reader outside the eval CLI’s println!, so a failed search was indistinguishable from a dropped keystroke on both interactive faces.

Implementations§

Source§

impl StatusModel<'_>

Source

pub fn mode_label(self) -> &'static str

What the mode indicator should SAY — which is not always the mode.

vim’s / reuses the command line, so escriba’s search runs in Mode::Command. Reporting the raw mode therefore labelled a search COMMAND and drew it with the : glyph: pressing / produced a status line indistinguishable from having pressed :. The mode was right and the report was wrong — an implementation detail (which mode hosts the prompt) leaking into what the operator is told.

Derived from the same typed PromptKind the sigil comes from, so the label and the sigil cannot disagree.

Source

pub const fn pill_sigil(self) -> Option<char>

The character the mode indicator leads with, when a prompt is open.

None means “no prompt — use your own mode glyph”. A face that draws a pill takes this over its mode glyph so / and ? read as themselves instead of as the : of an ex-command.

Source

pub fn render_prompt_into(self, out: &mut String)

Render the prompt segment (/foo) into out. Empty when no prompt is open.

Source

pub fn render(self) -> String

Render the whole line the way a plain-text face wants it: -- NORMAL -- 3:1 [2/7] /foo with the message last.

A face with real layout (the GPU one) reads the fields instead; this is for the text/TUI paths and for tests, which want one string to assert against.

Trait Implementations§

Source§

impl<'a> Clone for StatusModel<'a>

Source§

fn clone(&self) -> StatusModel<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for StatusModel<'a>

Source§

impl<'a> Debug for StatusModel<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for StatusModel<'a>

§

impl<'a> RefUnwindSafe for StatusModel<'a>

§

impl<'a> Send for StatusModel<'a>

§

impl<'a> Sync for StatusModel<'a>

§

impl<'a> Unpin for StatusModel<'a>

§

impl<'a> UnsafeUnpin for StatusModel<'a>

§

impl<'a> UnwindSafe for StatusModel<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more