Skip to main content

EditableTail

Struct EditableTail 

Source
pub struct EditableTail {
    pub trailing_lines: u32,
    pub first_line_min_byte: u32,
    pub first_editable_line: Option<u32>,
}
Expand description

An editable region at the tail of an otherwise read-only, owner-written buffer — the comint pattern (AU‑3) (the agent-conversation prompt, future *scratch* / REPL input lines). A mode declares it via Mode::editable_tail; the host’s read-only edit gate consults it so user keystrokes may edit only the tail while the owner’s projection writes (which bypass the gate by going through the runtime document handle directly) keep the rest owner-controlled.

The region is expressed structurally, relative to the buffer end, not as an absolute position — so it stays valid as the owner appends content above the tail without any per-edit bookkeeping:

  • trailing_lines — the number of trailing lines that form the region (1 for a single-line prompt). The first editable line is line_count - trailing_lines.
  • first_line_min_byte — the minimum byte column on that first editable line, protecting a prompt marker rendered as buffer text (e.g. the "> " prefix ⇒ 2). Lines strictly after the first are editable from column 0.

Default is the empty tail (trailing_lines = 0), i.e. nothing editable.

§Bottom-relative vs. anchored

The bottom-relative trailing_lines encoding is correct for a fixed-height tail: it stays valid as the owner appends content ABOVE the tail, but breaks the moment the user grows the tail itself (a multi-line prompt), because the added lines push the marker line out of the region. For a prompt whose height changes with user newlines AND whose top drifts as a transcript streams above it, set first_editable_line to the ABSOLUTE line where the editable region begins (the transcript-end line); the owning mode updates it as the transcript grows. When set it overrides trailing_lines.

§Examples

use lattice_mode::EditableTail;

// A one-line `> ` prompt at the bottom of a 5-line transcript.
let prompt = EditableTail { trailing_lines: 1, first_line_min_byte: 2, first_editable_line: None };
assert!(prompt.permits(4, 2, 5)); // after the marker, on the prompt line
assert!(!prompt.permits(4, 0, 5)); // inside the `> ` marker
assert!(!prompt.permits(3, 0, 5)); // history above the prompt
assert!(prompt.permits(9, 2, 10)); // still the last line after the owner appends

// The default tail permits nothing.
assert!(!EditableTail::default().permits(0, 0, 1));

Fields§

§trailing_lines: u32

Number of trailing lines forming the editable region. Ignored when first_editable_line is Some.

§first_line_min_byte: u32

Minimum editable byte column on the first editable line (guards a text-rendered prompt marker). Ignored for lines after the first.

§first_editable_line: Option<u32>

When Some(anchor), the editable region is anchor..EOF (absolute), overriding the bottom-relative trailing_lines. Lets a mode with a multi-line, growing prompt anchor the region to the transcript end and keep it correct as the user adds newlines. Clamped to the last line so a stale-high anchor never freezes the whole buffer.

Implementations§

Source§

impl EditableTail

Source

pub fn permits(&self, start_line: u32, start_byte: u32, line_count: u32) -> bool

Is a keystroke edit whose earliest affected position is (start_line, start_byte) permitted, given the buffer currently has line_count lines? Pure + unit-testable: the host gate computes the live line_count from the document snapshot and delegates here.

Trait Implementations§

Source§

impl Clone for EditableTail

Source§

fn clone(&self) -> EditableTail

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 Copy for EditableTail

Source§

impl Debug for EditableTail

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EditableTail

Source§

fn default() -> EditableTail

Returns the “default value” for a type. Read more
Source§

impl Eq for EditableTail

Source§

impl PartialEq for EditableTail

Source§

fn eq(&self, other: &EditableTail) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EditableTail

Auto Trait Implementations§

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<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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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