pub struct TextSpan {
pub start: u32,
pub length: u32,
pub type_role: Option<TypeRole>,
pub color: Option<Paint>,
pub background: Option<Paint>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub strikethrough: bool,
pub on_click: Option<u64>,
}Expand description
One run, given in bytes into the string rather than characters.
Bytes because that is what the string is measured in on both sides, and a character count would have to be recomputed against a UTF-8 buffer at every use.
Fields§
§start: u32§length: u32§type_role: Option<TypeRole>§color: Option<Paint>§background: Option<Paint>What is painted behind this run’s letters, and only behind them.
The word that actually changed inside a changed line is what this is for: the line is the node’s own background, and this marks the part of it that differs. A run that wraps is painted on each line it reaches. There is no shape and no inset, because nothing yet needs one, and when something does it is the design system’s to say.
bold: bool§italic: bool§underline: bool§strikethrough: bool§on_click: Option<u64>The handler a press on this run reports to, if it is a link.
Implementations§
Source§impl TextSpan
impl TextSpan
Sourcepub const fn new(start: u32, length: u32) -> Self
pub const fn new(start: u32, length: u32) -> Self
A run of the given bytes with nothing said about it yet.
pub const fn bold(self) -> Self
pub const fn italic(self) -> Self
pub const fn underline(self) -> Self
pub const fn strikethrough(self) -> Self
pub const fn with_role(self, role: TypeRole) -> Self
pub const fn with_color(self, color: Paint) -> Self
Sourcepub const fn with_background(self, background: Paint) -> Self
pub const fn with_background(self, background: Paint) -> Self
Paints behind this run. A role first, as everywhere else a colour is taken: the diff’s word backgrounds are roles, so they follow the scheme and the system.