pub struct StyledText {
pub buffer: Vec<(Style, String)>,
}Expand description
A representation of a buffer with styling, used for doing syntax highlighting
Fields§
§buffer: Vec<(Style, String)>The component, styled parts of the text
Implementations§
Source§impl StyledText
impl StyledText
Sourcepub fn render_around_insertion_point(
&self,
insertion_point: usize,
prompt: &dyn Prompt,
use_ansi_coloring: bool,
) -> (String, String)
pub fn render_around_insertion_point( &self, insertion_point: usize, prompt: &dyn Prompt, use_ansi_coloring: bool, ) -> (String, String)
Render the styled string. We use the insertion point to render around so that we can properly write out the styled string to the screen and find the correct place to put the cursor. This assumes a logic that prints the first part of the string, saves the cursor position, prints the second half, and then restores the cursor position
Also inserts the multiline continuation prompt
Sourcepub fn render_simple(&self) -> String
pub fn render_simple(&self) -> String
Apply the ANSI style formatting to the full string.
Sourcepub fn raw_string(&self) -> String
pub fn raw_string(&self) -> String
Get the unformatted text as a single continuous string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StyledText
impl RefUnwindSafe for StyledText
impl Send for StyledText
impl Sync for StyledText
impl Unpin for StyledText
impl UnwindSafe for StyledText
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> 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