Skip to main content

TextBuffer

Struct TextBuffer 

Source
pub struct TextBuffer { /* private fields */ }
Expand description

A text buffer that manages document content using a piece table with integrated line tracking

Implementations§

Source§

impl TextBuffer

Source

pub fn new( _large_file_threshold: usize, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Self

Create a new text buffer with the given filesystem implementation. Note: large_file_threshold is ignored in the new implementation

Source

pub fn new_with_path( large_file_threshold: usize, fs: Arc<dyn FileSystem + Send + Sync>, path: PathBuf, ) -> Self

Create an empty buffer associated with a file path. Used for files that don’t exist yet — the path is set so saving will create the file.

Source

pub fn version(&self) -> u64

Current buffer version (monotonic, wraps on overflow)

Source

pub fn filesystem(&self) -> &Arc<dyn FileSystem + Send + Sync>

Get a reference to the filesystem implementation used by this buffer.

Source

pub fn set_filesystem(&mut self, fs: Arc<dyn FileSystem + Send + Sync>)

Set the filesystem implementation for this buffer.

Source

pub fn from_bytes( content: Vec<u8>, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Self

Create a text buffer from initial content with the given filesystem.

Source

pub fn from_bytes_with_encoding( content: Vec<u8>, encoding: Encoding, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Self

Create a text buffer from bytes with a specific encoding (no auto-detection).

Source

pub fn from_str( s: &str, _large_file_threshold: usize, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Self

Create a text buffer from a string with the given filesystem.

Source

pub fn empty(fs: Arc<dyn FileSystem + Send + Sync>) -> Self

Create an empty text buffer with the given filesystem.

Source

pub fn load_from_file<P: AsRef<Path>>( path: P, large_file_threshold: usize, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Result<Self>

Load a text buffer from a file using the given filesystem.

Source

pub fn load_from_file_with_encoding<P: AsRef<Path>>( path: P, encoding: Encoding, fs: Arc<dyn FileSystem + Send + Sync>, config: BufferConfig, ) -> Result<Self>

Load a text buffer from a file with a specific encoding (no auto-detection).

Source

pub fn check_large_file_encoding( path: impl AsRef<Path>, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Result<Option<LargeFileEncodingConfirmation>>

Check if loading a large file requires user confirmation due to encoding.

Some encodings (like Shift-JIS, GB18030, GBK, EUC-KR) cannot be “resynchronized” - meaning you cannot determine character boundaries when jumping into the middle of a file. These encodings require loading the entire file into memory.

Returns Some(confirmation) if user confirmation is needed, None if the file can be loaded with lazy/streaming loading.

Source

pub fn load_large_file_confirmed( path: impl AsRef<Path>, fs: Arc<dyn FileSystem + Send + Sync>, ) -> Result<Self>

Load a large file, optionally forcing full load for non-resynchronizable encodings.

Called with force_full_load=true after user confirms the warning about non-resynchronizable encodings requiring full file loading.

Source

pub fn save(&mut self) -> Result<()>

Save the buffer to its associated file

Source

pub fn save_to_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Save the buffer to a specific file

Uses the write recipe approach for both local and remote filesystems:

  • Copy ops reference unchanged regions in the source file
  • Insert ops contain new/modified data

For remote filesystems, the recipe is sent to the agent which reconstructs the file server-side, avoiding transfer of unchanged content.

For local filesystems with ownership concerns (file owned by another user), uses in-place writing to preserve ownership. Otherwise uses atomic writes.

If the line ending format has been changed (via set_line_ending), all content will be converted to the new format during save.

Source

pub fn finalize_external_save(&mut self, dest_path: PathBuf) -> Result<()>

Finalize buffer state after an external save operation (e.g., via sudo).

This updates the saved snapshot and file size to match the new state on disk.

Source

pub fn total_bytes(&self) -> usize

Get the total number of bytes in the document

Source

pub fn line_count(&self) -> Option<usize>

Get the total number of lines in the document Uses the piece tree’s integrated line tracking Returns None if line count is unknown (e.g., for large files without line indexing)

Source

pub fn mark_saved_snapshot(&mut self)

Snapshot the current tree as the saved baseline

Source

pub fn refresh_saved_root_if_unmodified(&mut self)

Refresh the saved root to match the current tree structure without clearing the modified flag. Call this after structural-only changes (e.g. chunk_split_and_load during search scan) so that diff_since_saved() can take the fast Arc::ptr_eq path.

Source

pub fn diff_since_saved(&self) -> PieceTreeDiff

Diff the current piece tree against the last saved snapshot.

This compares actual byte content, not just tree structure. This means that if you delete text and then paste it back, the diff will correctly show no changes (even though the tree structure differs).

Uses a two-phase algorithm for efficiency:

  • Phase 1: Fast structure-based diff to find changed byte ranges (O(num_leaves))
  • Phase 2: Only compare actual content within changed ranges (O(edit_size))

This is O(edit_size) instead of O(file_size) for small edits in large files.

Source

pub fn offset_to_position(&self, offset: usize) -> Option<Position>

Convert a byte offset to a line/column position

Source

pub fn position_to_offset(&self, position: Position) -> usize

Convert a line/column position to a byte offset

Source

pub fn insert_bytes(&mut self, offset: usize, text: Vec<u8>) -> Cursor

Insert text at the given byte offset

Source

pub fn insert(&mut self, offset: usize, text: &str)

Insert text (from &str) at the given byte offset

Source

pub fn insert_at_position( &mut self, position: Position, text: Vec<u8>, ) -> Cursor

Insert text at a line/column position This now uses the optimized piece_tree.insert_at_position() for a single traversal

Source

pub fn delete_bytes(&mut self, offset: usize, bytes: usize)

Delete text starting at the given byte offset

Source

pub fn delete(&mut self, range: Range<usize>)

Delete text in a range

Source

pub fn delete_range(&mut self, start: Position, end: Position)

Delete text in a line/column range This now uses the optimized piece_tree.delete_position_range() for a single traversal

Source

pub fn replace_content(&mut self, new_content: &str)

Replace the entire buffer content with new content This is an O(n) operation that rebuilds the piece tree in a single pass, avoiding the O(n²) complexity of applying individual edits.

This is used for bulk operations like “replace all” where applying individual edits would be prohibitively slow.

Source

pub fn restore_buffer_state(&mut self, snapshot: &BufferSnapshot)

Restore a previously saved buffer state (for undo/redo of BulkEdit).

This restores the piece tree AND the buffers list, which is critical because consolidate_after_save() replaces self.buffers. Without restoring buffers, the piece tree would reference buffer IDs that no longer exist.

Source

pub fn snapshot_buffer_state(&self) -> Arc<BufferSnapshot>

Snapshot the current buffer state (piece tree + buffers) for BulkEdit undo/redo.

The snapshot includes buffers because consolidate_after_save() can replace self.buffers between the snapshot and restore, which would otherwise cause the restored piece tree to reference nonexistent buffer IDs.

Source

pub fn apply_bulk_edits(&mut self, edits: &[(usize, usize, &str)]) -> isize

Apply bulk edits efficiently in a single pass Returns the net change in bytes

Source

pub fn get_text_range_mut( &mut self, offset: usize, bytes: usize, ) -> Result<Vec<u8>>

Get text from a byte offset range with lazy loading This will load unloaded chunks on-demand and always returns complete data

Returns an error if loading fails or if data cannot be read for any reason.

NOTE: Currently loads entire buffers on-demand. Future optimization would split large pieces and load only LOAD_CHUNK_SIZE chunks at a time.

Source

pub fn prepare_viewport( &mut self, start_offset: usize, line_count: usize, ) -> Result<()>

Prepare a viewport for rendering

This is called before rendering with &mut access to pre-load all data that will be needed for the viewport. It estimates the number of bytes needed based on the line count and pre-loads them.

§Arguments
  • start_offset - The byte offset where the viewport starts
  • line_count - The number of lines to prepare (estimate)
§Returns

Ok(()) if preparation succeeded, Err if loading failed

Source

pub fn to_string(&self) -> Option<String>

Get all text as a String Returns None if any buffers are unloaded (lazy loading)

Source

pub fn len(&self) -> usize

Get the total number of bytes

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty

Source

pub fn file_path(&self) -> Option<&Path>

Get the file path associated with this buffer

Source

pub fn rename_file_path(&mut self, path: PathBuf)

Update the file path after a rename operation on disk.

Source

pub fn clear_file_path(&mut self)

Clear the file path (make buffer unnamed) Note: This does NOT affect Unloaded chunk file_paths used for lazy loading. Those still point to the original source file for chunk loading.

Source

pub fn extend_streaming(&mut self, source_path: &Path, new_size: usize)

Extend buffer to include more bytes from a streaming source file. Used for stdin streaming where the temp file grows over time. Appends a new Unloaded chunk for the new bytes.

Source

pub fn is_modified(&self) -> bool

Check if the buffer has been modified since last save

Source

pub fn clear_modified(&mut self)

Clear the modified flag (after save)

Source

pub fn set_modified(&mut self, modified: bool)

Set the modified flag explicitly Used by undo/redo to restore the correct modified state

Source

pub fn is_recovery_pending(&self) -> bool

Check if buffer has pending changes for recovery auto-save

Source

pub fn set_recovery_pending(&mut self, pending: bool)

Mark buffer as needing recovery auto-save (call after edits)

Source

pub fn is_large_file(&self) -> bool

Check if this is a large file with lazy loading enabled

Source

pub fn has_line_feed_scan(&self) -> bool

Check if line feeds have been scanned for this large file. When true, line_count() returns exact values.

Source

pub fn piece_tree_leaves(&self) -> Vec<LeafData>

Get the raw piece tree leaves (for storing alongside scan chunks).

Source

pub fn prepare_line_scan(&mut self) -> (Vec<LineScanChunk>, usize)

Prepare work items for an incremental line scan.

First splits any oversized leaves in the piece tree so every leaf is at most LOAD_CHUNK_SIZE bytes. Then returns one work item per leaf. After scanning, get_text_range_mut will never need to split a scanned leaf (it’s already chunk-sized), so line-feed counts are preserved.

Returns (chunks, total_bytes).

Source

pub fn search_scan_init( &mut self, regex: Regex, max_matches: usize, query_len: usize, ) -> ChunkedSearchState

Initialize a chunked search scan over this buffer’s piece tree.

Used for in-editor Ctrl+F (incremental, yields to the event loop between chunks) and for searching dirty buffers during project grep. For searching files on disk, use FileSystem::search_file instead.

Source

pub fn search_scan_next_chunk( &mut self, state: &mut ChunkedSearchState, ) -> Result<bool>

Process one chunk of a chunked search scan.

Loads the next chunk via get_text_range_mut, prepends overlap from the previous chunk, runs the regex, and appends matches to state with line/column/context computed on the fly from the loaded bytes.

Line numbers are tracked incrementally via running_line — each chunk counts newlines in its non-overlap portion to advance the counter for the next chunk, and matches use an incremental cursor so total line-counting work is O(chunk_size), not O(chunk × matches).

Returns Ok(true) if there are more chunks to process, Ok(false) when the scan is complete.

TODO: For concurrent/parallel search (searching multiple files at once), chunks would need to return chunk-relative line numbers and have them fixed up with each file’s starting line offset after all chunks complete.

Source

pub fn search_scan_all( &mut self, regex: Regex, max_matches: usize, query_len: usize, ) -> Result<ChunkedSearchState>

Run a complete chunked search over the piece tree (all chunks).

Synchronous variant — used for dirty buffer snapshots in project grep and in tests. For on-disk files, use FileSystem::search_file.

Source

pub fn search_hybrid_plan(&mut self) -> Option<HybridSearchPlan>

Build a hybrid search plan from the piece tree.

Extracts regions (unloaded file ranges + loaded in-memory data) that can be searched independently. The plan is Send so it can be executed on a background thread via HybridSearchPlan::execute.

Returns None if the buffer has no file path (caller should fall back to search_scan_all).

Source

pub fn search_hybrid( &mut self, pattern: &str, opts: &FileSearchOptions, regex: Regex, max_matches: usize, query_len: usize, ) -> Result<Vec<SearchMatch>>

Hybrid search: uses fs.search_file for unloaded piece-tree regions (searches where the data lives, no network transfer) and in-memory regex for loaded/edited regions. Handles overlap at region boundaries.

For a huge remote file with a small local edit, this avoids transferring the entire file — only match metadata crosses the network.

Falls back to search_scan_all when the buffer has no file path or is fully loaded.

Source

pub fn scan_leaf(&self, leaf: &LeafData) -> Result<usize>

Count \n bytes in a single leaf.

Uses count_line_feeds_in_range for unloaded buffers, which remote filesystem implementations can override to count server-side.

Source

pub fn leaf_io_params(&self, leaf: &LeafData) -> Option<(PathBuf, u64, usize)>

Return the I/O parameters for an unloaded leaf, or None if loaded.

Used by the incremental scan to distinguish leaves that can be counted in-memory (via scan_leaf) from those that need filesystem I/O.

Source

pub fn buffer_slice(&self) -> &[StringBuffer]

Get a reference to the string buffers (for parallel scanning).

Source

pub fn apply_scan_updates(&mut self, updates: &[(usize, usize)])

Apply the results of an incremental line scan.

Source

pub fn rebuild_with_pristine_saved_root( &mut self, scan_updates: &[(usize, usize)], )

After an incremental line-feed scan completes, rebuild the tree so that saved_root and the current tree share Arc pointers for unedited subtrees. This makes diff_since_saved() O(edited regions) instead of O(file size).

Source

pub fn resolve_line_byte_offset(&mut self, target_line: usize) -> Option<usize>

Resolve the exact byte offset for a given line number (0-indexed).

Uses the tree’s line feed counts to find the piece containing the target line, then loads/reads that piece’s data to find the exact newline position. This works even when buffers are unloaded (large file with scanned line index).

Source

pub fn original_file_size(&self) -> Option<usize>

Get the saved file size (size of the file on disk after last load/save) For large files, this is used during recovery to know the expected original file size. Returns None for new unsaved buffers.

Source

pub fn get_recovery_chunks(&self) -> Vec<(usize, Vec<u8>)>

Get recovery chunks for this buffer (only modified portions)

For large files, this returns only the pieces that come from Added buffers (i.e., the modifications), not the original file content. This allows efficient incremental recovery without reading/writing the entire file.

Returns: Vec of (original_file_offset, data) for each modified chunk The offset is the position in the ORIGINAL file where this chunk should be inserted.

Source

pub fn is_binary(&self) -> bool

Check if this buffer contains binary content

Source

pub fn line_ending(&self) -> LineEnding

Get the line ending format for this buffer

Source

pub fn set_line_ending(&mut self, line_ending: LineEnding)

Set the line ending format for this buffer

This marks the buffer as modified since the line ending format has changed. On save, the buffer content will be converted to the new format.

Source

pub fn set_default_line_ending(&mut self, line_ending: LineEnding)

Set the default line ending format for a new/empty buffer

Unlike set_line_ending, this does NOT mark the buffer as modified. This should be used when initializing a new buffer with a configured default.

Source

pub fn encoding(&self) -> Encoding

Get the encoding format for this buffer

Source

pub fn set_encoding(&mut self, encoding: Encoding)

Set the encoding format for this buffer

This marks the buffer as modified since the encoding format has changed. On save, the buffer content will be converted to the new encoding.

Source

pub fn set_default_encoding(&mut self, encoding: Encoding)

Set the default encoding format for a new/empty buffer

Unlike set_encoding, this does NOT mark the buffer as modified. This should be used when initializing a new buffer with a configured default.

Source

pub fn detect_line_ending(bytes: &[u8]) -> LineEnding

Detect the line ending format from a sample of bytes

Uses majority voting: counts CRLF, LF-only, and CR-only occurrences and returns the most common format.

Source

pub fn detect_encoding(bytes: &[u8]) -> Encoding

Detect the text encoding from a sample of bytes

Delegates to the encoding module. Use detect_encoding_or_binary when you need to know if the content should be treated as binary.

Source

pub fn detect_encoding_or_binary( bytes: &[u8], truncated: bool, ) -> (Encoding, bool)

Detect the text encoding and whether content is binary.

Returns (Encoding, is_binary) where:

  • Encoding is the detected encoding (or default if binary)
  • is_binary is true if the content should be treated as raw binary

Delegates to the encoding module for detection logic.

Source

pub fn detect_and_convert_encoding(bytes: &[u8]) -> (Encoding, Vec<u8>)

Detect encoding and convert bytes to UTF-8

Returns the detected encoding and the UTF-8 converted content. This is the core function for normalizing file content to UTF-8 on load.

Source

pub fn convert_to_encoding( utf8_bytes: &[u8], target_encoding: Encoding, ) -> Vec<u8>

Convert UTF-8 content to the specified encoding for saving

Used when saving files to convert internal UTF-8 representation back to the original (or user-selected) encoding. Note: This does NOT add BOM - the BOM is handled separately in build_write_recipe.

Source

pub fn normalize_line_endings(bytes: Vec<u8>) -> Vec<u8>

Normalize line endings in the given bytes to LF only

Converts CRLF (\r\n) and CR (\r) to LF (\n) for internal representation. This makes editing and cursor movement simpler while preserving the original format for saving.

Source

pub fn get_line(&self, line: usize) -> Option<Vec<u8>>

Get text for a specific line

Source

pub fn line_start_offset(&self, line: usize) -> Option<usize>

Get the byte offset where a line starts

Source

pub fn piece_info_at_offset(&self, offset: usize) -> Option<PieceInfo>

Get piece information at a byte offset

Source

pub fn stats(&self) -> TreeStats

Get tree statistics for debugging

Source

pub fn find_next(&self, pattern: &str, start_pos: usize) -> Option<usize>

Find the next occurrence of a pattern, with wrap-around

Source

pub fn find_next_in_range( &self, pattern: &str, start_pos: usize, range: Option<Range<usize>>, ) -> Option<usize>

Find the next occurrence of a pattern within an optional range If range is None, searches the entire buffer with wrap-around (same as find_next) If range is Some, searches only within that range without wrap-around

Source

pub fn find_next_regex(&self, regex: &Regex, start_pos: usize) -> Option<usize>

Find the next occurrence of a regex pattern, with wrap-around

Source

pub fn find_next_regex_in_range( &self, regex: &Regex, start_pos: usize, range: Option<Range<usize>>, ) -> Option<usize>

Find the next occurrence of a regex pattern within an optional range

Source

pub fn replace_range(&mut self, range: Range<usize>, replacement: &str) -> bool

Replace a range with replacement text

Source

pub fn replace_next( &mut self, pattern: &str, replacement: &str, start_pos: usize, range: Option<Range<usize>>, ) -> Option<usize>

Find and replace the next occurrence of a pattern

Source

pub fn replace_all(&mut self, pattern: &str, replacement: &str) -> usize

Replace all occurrences of a pattern with replacement text

Source

pub fn replace_all_regex( &mut self, regex: &Regex, replacement: &str, ) -> Result<usize>

Replace all occurrences of a regex pattern with replacement text

Source

pub fn position_to_line_col(&self, byte_pos: usize) -> (usize, usize)

Convert byte position to (line, column) in bytes

Source

pub fn line_col_to_position(&self, line: usize, character: usize) -> usize

Convert (line, character) to byte position - 0-indexed character is in BYTES, not UTF-16 code units Optimized to use single line_range() call instead of two

Source

pub fn position_to_lsp_position(&self, byte_pos: usize) -> (usize, usize)

Convert byte position to LSP position (line, UTF-16 code units) LSP protocol uses UTF-16 code units for character offsets

Source

pub fn lsp_position_to_byte(&self, line: usize, utf16_offset: usize) -> usize

Convert LSP position (line, UTF-16 code units) to byte position LSP uses UTF-16 code units for character offsets, not bytes Optimized to use single line_range() call instead of two

Source

pub fn prev_char_boundary(&self, pos: usize) -> usize

Find the previous character boundary (UTF-8 aware)

Source

pub fn next_char_boundary(&self, pos: usize) -> usize

Find the next character boundary (UTF-8 aware)

Source

pub fn snap_to_char_boundary(&self, pos: usize) -> usize

Snap position to a valid UTF-8 character boundary If already at a boundary, returns the same position. Otherwise, moves to the previous valid boundary.

Source

pub fn prev_grapheme_boundary(&self, pos: usize) -> usize

Find the previous grapheme cluster boundary (for proper cursor movement with combining characters)

This handles complex scripts like Thai where multiple Unicode code points form a single visual character (grapheme cluster). For example, Thai “ที่” is 3 code points but 1 grapheme cluster.

Source

pub fn next_grapheme_boundary(&self, pos: usize) -> usize

Find the next grapheme cluster boundary (for proper cursor movement with combining characters)

This handles complex scripts like Thai where multiple Unicode code points form a single visual character (grapheme cluster). For example, Thai “ที่” is 3 code points but 1 grapheme cluster.

Source

pub fn prev_word_boundary(&self, pos: usize) -> usize

Find the previous word boundary

Source

pub fn next_word_boundary(&self, pos: usize) -> usize

Find the next word boundary

Source

pub fn line_iterator( &mut self, byte_pos: usize, estimated_line_length: usize, ) -> LineIterator<'_>

Create a line iterator starting at the given byte position

This iterator lazily loads chunks as needed, never scanning the entire file. For large files with unloaded buffers, chunks are loaded on-demand (1MB at a time).

Source

pub fn iter_lines_from( &mut self, byte_pos: usize, max_lines: usize, ) -> Result<TextBufferLineIterator>

Iterate over lines starting from a given byte offset, with line numbers

This is a more efficient alternative to using line_iterator() + offset_to_position() because it calculates line numbers incrementally during iteration by accumulating line_feed_cnt from pieces (which is already tracked in the piece tree).

Returns: Iterator yielding (byte_offset, content, line_number: Option)

  • line_number is Some(n) for small files with line metadata
  • line_number is None for large files without line metadata
§Performance
  • O(1) per line for line number calculation (vs O(log n) per line with offset_to_position)
  • Uses single source of truth: piece tree’s existing line_feed_cnt metadata
Source

pub fn get_line_number(&self, byte_offset: usize) -> usize

Get the line number for a given byte offset

Returns exact line number if metadata available, otherwise estimates based on bytes.

§Behavior by File Size:
  • Small files (< 1MB): Returns exact line number from piece tree’s line_starts metadata
  • Large files (≥ 1MB): Returns estimated line number using byte_offset / estimated_line_length

Large files don’t maintain line metadata for performance reasons. The estimation uses the configured estimated_line_length (default 80 bytes).

Source

pub fn estimated_line_length(&self) -> usize

Get the configured estimated line length for approximate line number calculations.

Source

pub fn populate_line_cache( &mut self, start_byte: usize, _line_count: usize, ) -> usize

Get the starting line number at a byte offset (used for viewport rendering)

§Line Cache Architecture (Post-Refactoring):

The concept of a separate “line cache” is now obsolete. After the refactoring, line tracking is integrated directly into the piece tree via:

BufferData::Loaded {
    data: Vec<u8>,
    line_starts: Option<Vec<usize>>  // None = large file mode (no line metadata)
}
§Why This Method Still Exists:

The rendering code needs to know what line number to display in the margin at the top of the viewport. This method returns that line number, handling both small and large file modes transparently.

§Small vs Large File Modes:
  • Small files: line_starts = Some(vec) → returns exact line number from metadata
  • Large files: line_starts = None → returns estimated line number (byte_offset / estimated_line_length)
§Legacy Line Cache Methods:

These methods are now no-ops and can be removed in a future cleanup:

  • invalidate_line_cache_from() - No-op (piece tree updates automatically)
  • handle_line_cache_insertion() - No-op (piece tree updates automatically)
  • handle_line_cache_deletion() - No-op (piece tree updates automatically)
  • clear_line_cache() - No-op (can’t clear piece tree metadata)
§Bug Fix (2025-11):

Previously this method always returned 0, causing line numbers in the margin to always show 1, 2, 3… regardless of scroll position. Now it correctly returns the actual line number at start_byte.

Source

pub fn get_cached_byte_offset_for_line( &self, line_number: usize, ) -> Option<usize>

Get cached byte offset for line (compatibility method)

Source

pub fn invalidate_line_cache_from(&mut self, _byte_offset: usize)

Invalidate line cache from offset (no-op in new implementation)

Source

pub fn handle_line_cache_insertion( &mut self, _byte_offset: usize, _bytes_inserted: usize, )

Handle line cache insertion (no-op in new implementation)

Source

pub fn handle_line_cache_deletion( &mut self, _byte_offset: usize, _bytes_deleted: usize, )

Handle line cache deletion (no-op in new implementation)

Source

pub fn clear_line_cache(&mut self)

Clear line cache (no-op in new implementation)

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> 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> 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
Source§

impl<T> ParallelSend for T