pub struct Buffer {
pub id: BufferId,
pub path: Option<PathBuf>,
pub rope: Rope,
pub modified: bool,
pub encoding: Encoding,
pub line_ending: LineEnding,
pub undo: UndoTree,
}Expand description
A single open text buffer.
Fields§
§id: BufferId§path: Option<PathBuf>§rope: Rope§modified: bool§encoding: Encoding§line_ending: LineEnding§undo: UndoTreeImplementations§
Source§impl Buffer
impl Buffer
pub fn empty(id: BufferId) -> Self
pub fn from_str(id: BufferId, src: &str) -> Self
pub fn open(id: BufferId, path: impl AsRef<Path>) -> Result<Self, BufferError>
pub fn save(&mut self) -> Result<(), BufferError>
pub fn save_as(&mut self, path: impl AsRef<Path>) -> Result<(), BufferError>
pub fn line_count(&self) -> u32
pub fn byte_count(&self) -> usize
pub fn char_count(&self) -> usize
pub fn line(&self, n: u32) -> Option<String>
pub fn line_len_chars(&self, n: u32) -> u32
Sourcepub fn clamp(&self, pos: Position) -> Position
pub fn clamp(&self, pos: Position) -> Position
Clamp a position to valid coordinates inside this buffer.
pub fn position_to_char(&self, pos: Position) -> Result<usize, BufferError>
pub fn char_to_position(&self, ch: usize) -> Position
pub fn slice(&self, range: Range) -> Result<String, BufferError>
pub fn apply(&mut self, edit: &Edit) -> Result<UndoEntry, BufferError>
pub fn undo(&mut self) -> Result<UndoEntry, BufferError>
pub fn redo(&mut self) -> Result<UndoEntry, BufferError>
pub fn to_string(&self) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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