pub struct SyntaxHighlightedBuilder { /* private fields */ }Expand description
Easily build syntax-highlighted text.
Implementations§
Source§impl SyntaxHighlightedBuilder
Easily build syntax-highlighted LayoutJobs.
impl SyntaxHighlightedBuilder
Easily build syntax-highlighted LayoutJobs.
Try to use one of the append_* or with_* methods that semantically matches
what you are trying to highlight. Check the docs of the append_* methods for examples
of what they should be used with.
The with_* methods are builder-style, taking self and returning Self.
The append_* methods take &mut self and return &mut Self.
Use the with_* methods when building something inline.
pub const QUOTE_CHAR: char = '"'
pub fn new() -> SyntaxHighlightedBuilder
Sourcepub fn from(job: impl Into<LayoutJob>) -> SyntaxHighlightedBuilder
pub fn from(job: impl Into<LayoutJob>) -> SyntaxHighlightedBuilder
Sourcepub fn with(self, portion: &dyn SyntaxHighlighting) -> SyntaxHighlightedBuilder
pub fn with(self, portion: &dyn SyntaxHighlighting) -> SyntaxHighlightedBuilder
Append anything that implements SyntaxHighlighting.
Sourcepub fn append(
&mut self,
portion: &dyn SyntaxHighlighting,
) -> &mut SyntaxHighlightedBuilder
pub fn append( &mut self, portion: &dyn SyntaxHighlighting, ) -> &mut SyntaxHighlightedBuilder
Append anything that implements SyntaxHighlighting.
Source§impl SyntaxHighlightedBuilder
impl SyntaxHighlightedBuilder
Sourcepub fn with_null(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_null(self, portion: &str) -> SyntaxHighlightedBuilder
null
Sourcepub fn append_null(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
pub fn append_null(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
null
Sourcepub fn null(portion: &str) -> SyntaxHighlightedBuilder
pub fn null(portion: &str) -> SyntaxHighlightedBuilder
null
Sourcepub fn with_primitive(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_primitive(self, portion: &str) -> SyntaxHighlightedBuilder
Some primitive value, e.g. a number or bool.
Sourcepub fn append_primitive(
&mut self,
portion: &str,
) -> &mut SyntaxHighlightedBuilder
pub fn append_primitive( &mut self, portion: &str, ) -> &mut SyntaxHighlightedBuilder
Some primitive value, e.g. a number or bool.
Sourcepub fn primitive(portion: &str) -> SyntaxHighlightedBuilder
pub fn primitive(portion: &str) -> SyntaxHighlightedBuilder
Some primitive value, e.g. a number or bool.
Sourcepub fn with_identifier(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_identifier(self, portion: &str) -> SyntaxHighlightedBuilder
A string identifier.
E.g. a variable name, field name, etc. Won’t be quoted.
Sourcepub fn append_identifier(
&mut self,
portion: &str,
) -> &mut SyntaxHighlightedBuilder
pub fn append_identifier( &mut self, portion: &str, ) -> &mut SyntaxHighlightedBuilder
A string identifier.
E.g. a variable name, field name, etc. Won’t be quoted.
Sourcepub fn identifier(portion: &str) -> SyntaxHighlightedBuilder
pub fn identifier(portion: &str) -> SyntaxHighlightedBuilder
A string identifier.
E.g. a variable name, field name, etc. Won’t be quoted.
Sourcepub fn with_string_value(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_string_value(self, portion: &str) -> SyntaxHighlightedBuilder
Some string data. Will be quoted.
Sourcepub fn append_string_value(
&mut self,
portion: &str,
) -> &mut SyntaxHighlightedBuilder
pub fn append_string_value( &mut self, portion: &str, ) -> &mut SyntaxHighlightedBuilder
Some string data. Will be quoted.
Sourcepub fn string_value(portion: &str) -> SyntaxHighlightedBuilder
pub fn string_value(portion: &str) -> SyntaxHighlightedBuilder
Some string data. Will be quoted.
Sourcepub fn append_string_value_truncated(
&mut self,
portion: &str,
max_chars: usize,
) -> &mut SyntaxHighlightedBuilder
pub fn append_string_value_truncated( &mut self, portion: &str, max_chars: usize, ) -> &mut SyntaxHighlightedBuilder
Like Self::append_string_value, but truncates to max_chars characters
and appends … (in syntax style) when truncated.
Sourcepub fn with_keyword(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_keyword(self, portion: &str) -> SyntaxHighlightedBuilder
A keyword, e.g. a filter operator, like and or all
Sourcepub fn append_keyword(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
pub fn append_keyword(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
A keyword, e.g. a filter operator, like and or all
Sourcepub fn keyword(portion: &str) -> SyntaxHighlightedBuilder
pub fn keyword(portion: &str) -> SyntaxHighlightedBuilder
A keyword, e.g. a filter operator, like and or all
Sourcepub fn with_index(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_index(self, portion: &str) -> SyntaxHighlightedBuilder
An index number, e.g. an array index.
Sourcepub fn append_index(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
pub fn append_index(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
An index number, e.g. an array index.
Sourcepub fn index(portion: &str) -> SyntaxHighlightedBuilder
pub fn index(portion: &str) -> SyntaxHighlightedBuilder
An index number, e.g. an array index.
Sourcepub fn with_syntax(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_syntax(self, portion: &str) -> SyntaxHighlightedBuilder
Some syntax, e.g. brackets, commas, colons, etc.
Sourcepub fn append_syntax(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
pub fn append_syntax(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
Some syntax, e.g. brackets, commas, colons, etc.
Sourcepub fn syntax(portion: &str) -> SyntaxHighlightedBuilder
pub fn syntax(portion: &str) -> SyntaxHighlightedBuilder
Some syntax, e.g. brackets, commas, colons, etc.
Sourcepub fn with_body(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_body(self, portion: &str) -> SyntaxHighlightedBuilder
Body text, subdued (default label color).
Sourcepub fn append_body(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
pub fn append_body(&mut self, portion: &str) -> &mut SyntaxHighlightedBuilder
Body text, subdued (default label color).
Sourcepub fn body(portion: &str) -> SyntaxHighlightedBuilder
pub fn body(portion: &str) -> SyntaxHighlightedBuilder
Body text, subdued (default label color).
Sourcepub fn with_body_default(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_body_default(self, portion: &str) -> SyntaxHighlightedBuilder
Body text with default color (color of inactive buttons).
Sourcepub fn append_body_default(
&mut self,
portion: &str,
) -> &mut SyntaxHighlightedBuilder
pub fn append_body_default( &mut self, portion: &str, ) -> &mut SyntaxHighlightedBuilder
Body text with default color (color of inactive buttons).
Sourcepub fn body_default(portion: &str) -> SyntaxHighlightedBuilder
pub fn body_default(portion: &str) -> SyntaxHighlightedBuilder
Body text with default color (color of inactive buttons).
Sourcepub fn with_body_italics(self, portion: &str) -> SyntaxHighlightedBuilder
pub fn with_body_italics(self, portion: &str) -> SyntaxHighlightedBuilder
Body text in italics, e.g. for emphasis.
Sourcepub fn append_body_italics(
&mut self,
portion: &str,
) -> &mut SyntaxHighlightedBuilder
pub fn append_body_italics( &mut self, portion: &str, ) -> &mut SyntaxHighlightedBuilder
Body text in italics, e.g. for emphasis.
Sourcepub fn body_italics(portion: &str) -> SyntaxHighlightedBuilder
pub fn body_italics(portion: &str) -> SyntaxHighlightedBuilder
Body text in italics, e.g. for emphasis.
Sourcepub fn append_with_format(
&mut self,
text: &str,
format: TextFormat,
) -> &mut SyntaxHighlightedBuilder
pub fn append_with_format( &mut self, text: &str, format: TextFormat, ) -> &mut SyntaxHighlightedBuilder
Append text with a custom format.
Sourcepub fn append_with_format_closure<F>(
&mut self,
text: &str,
f: F,
) -> &mut SyntaxHighlightedBuilder
pub fn append_with_format_closure<F>( &mut self, text: &str, f: F, ) -> &mut SyntaxHighlightedBuilder
Append text with a custom format closure.
Sourcepub fn with_format(
self,
text: &str,
format: TextFormat,
) -> SyntaxHighlightedBuilder
pub fn with_format( self, text: &str, format: TextFormat, ) -> SyntaxHighlightedBuilder
With a custom format.
Sourcepub fn with_format_closure<F>(
self,
text: &str,
f: F,
) -> SyntaxHighlightedBuilder
pub fn with_format_closure<F>( self, text: &str, f: F, ) -> SyntaxHighlightedBuilder
With a custom format closure.
Trait Implementations§
Source§impl Debug for SyntaxHighlightedBuilder
impl Debug for SyntaxHighlightedBuilder
Source§impl Default for SyntaxHighlightedBuilder
impl Default for SyntaxHighlightedBuilder
Source§fn default() -> SyntaxHighlightedBuilder
fn default() -> SyntaxHighlightedBuilder
Source§impl<T> From<T> for SyntaxHighlightedBuilderwhere
T: SyntaxHighlighting,
impl<T> From<T> for SyntaxHighlightedBuilderwhere
T: SyntaxHighlighting,
Source§fn from(portion: T) -> SyntaxHighlightedBuilder
fn from(portion: T) -> SyntaxHighlightedBuilder
Auto Trait Implementations§
impl Freeze for SyntaxHighlightedBuilder
impl !RefUnwindSafe for SyntaxHighlightedBuilder
impl !Send for SyntaxHighlightedBuilder
impl !Sync for SyntaxHighlightedBuilder
impl Unpin for SyntaxHighlightedBuilder
impl UnsafeUnpin for SyntaxHighlightedBuilder
impl !UnwindSafe for SyntaxHighlightedBuilder
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.