|
|
@ -52,14 +52,14 @@ use unicode_segmentation::UnicodeSegmentation;
|
|
|
|
use unicode_width::UnicodeWidthStr;
|
|
|
|
use unicode_width::UnicodeWidthStr;
|
|
|
|
|
|
|
|
|
|
|
|
/// A grapheme associated to a style.
|
|
|
|
/// A grapheme associated to a style.
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub struct StyledGrapheme<'a> {
|
|
|
|
pub struct StyledGrapheme<'a> {
|
|
|
|
pub symbol: &'a str,
|
|
|
|
pub symbol: &'a str,
|
|
|
|
pub style: Style,
|
|
|
|
pub style: Style,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A string where all graphemes have the same style.
|
|
|
|
/// A string where all graphemes have the same style.
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub struct Span<'a> {
|
|
|
|
pub struct Span<'a> {
|
|
|
|
pub content: Cow<'a, str>,
|
|
|
|
pub content: Cow<'a, str>,
|
|
|
|
pub style: Style,
|
|
|
|
pub style: Style,
|
|
|
@ -194,7 +194,7 @@ impl<'a> From<&'a str> for Span<'a> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A string composed of clusters of graphemes, each with their own style.
|
|
|
|
/// A string composed of clusters of graphemes, each with their own style.
|
|
|
|
#[derive(Debug, Clone, PartialEq, Default)]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Default, Eq)]
|
|
|
|
pub struct Spans<'a>(pub Vec<Span<'a>>);
|
|
|
|
pub struct Spans<'a>(pub Vec<Span<'a>>);
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a> Spans<'a> {
|
|
|
|
impl<'a> Spans<'a> {
|
|
|
@ -273,7 +273,7 @@ impl<'a> From<Spans<'a>> for String {
|
|
|
|
/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
|
|
|
|
/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
|
|
|
|
/// assert_eq!(6, text.height());
|
|
|
|
/// assert_eq!(6, text.height());
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[derive(Debug, Clone, PartialEq, Default)]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Default, Eq)]
|
|
|
|
pub struct Text<'a> {
|
|
|
|
pub struct Text<'a> {
|
|
|
|
pub lines: Vec<Spans<'a>>,
|
|
|
|
pub lines: Vec<Spans<'a>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|