Struct reedline::StyledText
source · 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 style_range(&mut self, from: usize, to: usize, new_style: Style)
pub fn style_range(&mut self, from: usize, to: usize, new_style: Style)
Style range with the provided style
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§
source§impl Clone for StyledText
impl Clone for StyledText
source§fn clone(&self) -> StyledText
fn clone(&self) -> StyledText
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
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