pub struct Span<'a> {
pub text: &'a str,
pub color: Option<Color>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub underline_color: Option<Color>,
pub underline_style: UnderlineStyle,
pub strikethrough: bool,
pub bg: Option<Color>,
pub bg_radius: f32,
}Expand description
One styled run inside a rich-text paragraph. Spans are shaped and wrapped together as a single flow; plain data, so every frontend can build them.
Fields§
§text: &'a str§color: Option<Color>§bold: bool§italic: bool§underline: boolA line under the span, where the face puts its underline.
underline_color: Option<Color>The underline’s own colour; None is the span’s.
underline_style: UnderlineStyleThe underline’s shape.
strikethrough: boolA line through the span, where the face puts its strikeout.
bg: Option<Color>A background behind the span’s glyphs, one rect per line it spans, so it follows the span across a wrap the way a box cannot.
bg_radius: f32The background’s corner radius, logical px. Above zero, every background of the same colour and radius that meets another edge to edge on the line above or below — in this text or another — is one shape with it: its corners convex where a line reaches past its neighbour, concave where it falls short, round where nothing meets it. What a selection over lines looks like.
Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
pub fn new(text: &'a str) -> Span<'a>
pub fn color(self, c: Color) -> Span<'a>
pub fn bold(self) -> Span<'a>
pub fn italic(self) -> Span<'a>
pub fn underline(self) -> Span<'a>
Sourcepub fn underline_color(self, c: Color) -> Span<'a>
pub fn underline_color(self, c: Color) -> Span<'a>
An underline in its own colour; turns it on.
Sourcepub fn underline_style(self, s: UnderlineStyle) -> Span<'a>
pub fn underline_style(self, s: UnderlineStyle) -> Span<'a>
An underline of this shape; turns it on.
pub fn strikethrough(self) -> Span<'a>
pub fn bg(self, c: Color) -> Span<'a>
Sourcepub fn bg_radius(self, r: f32) -> Span<'a>
pub fn bg_radius(self, r: f32) -> Span<'a>
Rounds the background, joined with the ones it meets (see
Span::bg_radius).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Span<'a>
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> Send for Span<'a>
impl<'a> Sync for Span<'a>
impl<'a> Unpin for Span<'a>
impl<'a> UnsafeUnpin for Span<'a>
impl<'a> UnwindSafe for Span<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.