pub struct EditorBuffer { /* private fields */ }Implementations§
Source§impl EditorBuffer
impl EditorBuffer
pub fn new(text: String) -> Self
pub fn text(&self) -> &str
pub fn line_index(&self) -> &LineIndex
Sourcepub fn detect_indent(&self, sample_lines: usize) -> IndentStyle
pub fn detect_indent(&self, sample_lines: usize) -> IndentStyle
Detects the predominant indentation style by analyzing the first sample_lines lines.
Returns Spaces(4) as default when detection is inconclusive.
Sourcepub fn apply_patches(
&mut self,
patches: &[TextPatch],
) -> Result<Vec<RangeChange>, TextPatchError>
pub fn apply_patches( &mut self, patches: &[TextPatch], ) -> Result<Vec<RangeChange>, TextPatchError>
Apply patches, update text and LineIndex, return RangeChanges for downstream consumers.
Sourcepub fn apply_patches_with(
&mut self,
patches: &[TextPatch],
decorations: &mut DecorationSet,
wrap_map: Option<&mut WrapMap>,
wrap_policy: Option<&WrapPolicy>,
history: Option<&mut EditHistory>,
label: Option<&str>,
) -> Result<(), TextPatchError>
pub fn apply_patches_with( &mut self, patches: &[TextPatch], decorations: &mut DecorationSet, wrap_map: Option<&mut WrapMap>, wrap_policy: Option<&WrapPolicy>, history: Option<&mut EditHistory>, label: Option<&str>, ) -> Result<(), TextPatchError>
Apply patches and propagate to all subsystems in order:
- Record to history (before text change, needs original text for inverse patch computation)
- Apply patches to text and rebuild LineIndex
- Map decorations through changes
- Update wrap map (only when both wrap_map and wrap_policy are Some)
Auto Trait Implementations§
impl Freeze for EditorBuffer
impl RefUnwindSafe for EditorBuffer
impl Send for EditorBuffer
impl Sync for EditorBuffer
impl Unpin for EditorBuffer
impl UnsafeUnpin for EditorBuffer
impl UnwindSafe for EditorBuffer
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
Mutably borrows from an owned value. Read more