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 (1for a single-line prompt). The first editable line isline_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: u32Number of trailing lines forming the editable region. Ignored when
first_editable_line is Some.
first_line_min_byte: u32Minimum 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
impl EditableTail
Sourcepub fn permits(&self, start_line: u32, start_byte: u32, line_count: u32) -> bool
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
impl Clone for EditableTail
Source§fn clone(&self) -> EditableTail
fn clone(&self) -> EditableTail
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EditableTail
Source§impl Debug for EditableTail
impl Debug for EditableTail
Source§impl Default for EditableTail
impl Default for EditableTail
Source§fn default() -> EditableTail
fn default() -> EditableTail
impl Eq for EditableTail
Source§impl PartialEq for EditableTail
impl PartialEq for EditableTail
impl StructuralPartialEq for EditableTail
Auto Trait Implementations§
impl Freeze for EditableTail
impl RefUnwindSafe for EditableTail
impl Send for EditableTail
impl Sync for EditableTail
impl Unpin for EditableTail
impl UnsafeUnpin for EditableTail
impl UnwindSafe for EditableTail
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.