pub struct TextWrapper;Expand description
Text wrapping engine that handles word boundaries while preserving spacing
Implementations§
Source§impl TextWrapper
impl TextWrapper
Sourcepub fn wrap_text(text: &str, config: &WrapConfig) -> String
pub fn wrap_text(text: &str, config: &WrapConfig) -> String
Wrap text at word boundaries while preserving all original spacing.
Sourcepub fn count_wrapped_lines(text: &str, config: &WrapConfig) -> usize
pub fn count_wrapped_lines(text: &str, config: &WrapConfig) -> usize
Count the number of lines that text would wrap to
Sourcepub fn calculate_cursor_line(
text: &str,
cursor_position: usize,
config: &WrapConfig,
) -> usize
pub fn calculate_cursor_line( text: &str, cursor_position: usize, config: &WrapConfig, ) -> usize
Calculate which line a cursor position would be on after wrapping
Sourcepub fn cursor_position_map(
text: &str,
config: &WrapConfig,
) -> Vec<(usize, usize)>
pub fn cursor_position_map( text: &str, config: &WrapConfig, ) -> Vec<(usize, usize)>
Build a mapping of cursor positions to wrapped line/column coordinates
Sourcepub fn cursor_layout(text: &str, config: &WrapConfig) -> WrappedCursorLayout
pub fn cursor_layout(text: &str, config: &WrapConfig) -> WrappedCursorLayout
Compute the cursor layout for wrapped text, including the position map and total lines.
Sourcepub fn calculate_cursor_position_in_wrapped_text(
text: &str,
cursor_position: usize,
config: &WrapConfig,
) -> (usize, usize)
pub fn calculate_cursor_position_in_wrapped_text( text: &str, cursor_position: usize, config: &WrapConfig, ) -> (usize, usize)
Calculate cursor position within wrapped text using a character-by-character mapping
Auto Trait Implementations§
impl Freeze for TextWrapper
impl RefUnwindSafe for TextWrapper
impl Send for TextWrapper
impl Sync for TextWrapper
impl Unpin for TextWrapper
impl UnsafeUnpin for TextWrapper
impl UnwindSafe for TextWrapper
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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